Author: rombert
Date: Tue Sep 30 08:37:07 2014
New Revision: 1628372
URL: http://svn.apache.org/r1628372
Log:
SLING-3972 - Remove openid from launchpad
Also move affected integration tests from launchpad/testing to
contrib/launchpad/testing
Added:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/SelectorAuthenticationResponseCodeTest.java
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java
- copied, changed from r1628370,
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/SelectorRedirectOnLoginErrorTest.java
- copied, changed from r1628370,
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
Removed:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java
Modified:
sling/trunk/contrib/launchpad/testing/pom.xml
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/auth/AuthenticationResponseCodeTest.java
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
Modified: sling/trunk/contrib/launchpad/testing/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/pom.xml?rev=1628372&r1=1628371&r2=1628372&view=diff
==============================================================================
--- sling/trunk/contrib/launchpad/testing/pom.xml (original)
+++ sling/trunk/contrib/launchpad/testing/pom.xml Tue Sep 30 08:37:07 2014
@@ -412,7 +412,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.0.6</version>
+ <version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
Added:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/SelectorAuthenticationResponseCodeTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/SelectorAuthenticationResponseCodeTest.java?rev=1628372&view=auto
==============================================================================
---
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/SelectorAuthenticationResponseCodeTest.java
(added)
+++
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/auth/SelectorAuthenticationResponseCodeTest.java
Tue Sep 30 08:37:07 2014
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest.auth;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.sling.commons.testing.integration.HttpTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test of the response code from an authentication request depending on
various
+ * request parameters and headers including j_validate, Ajax detection, and
+ * non-browser client detection.
+ */
+public class SelectorAuthenticationResponseCodeTest {
+
+ private final HttpTest H = new HttpTest();
+
+ @Before
+ public void setup() throws Exception {
+ H.setUp();
+ }
+
+ @After
+ public void cleanup() throws Exception {
+ H.tearDown();
+ }
+
+ // this method assumes the use of the selector auth bundle
+ @Test
+ public void testWithAcceptHeaderIncorrectCredentials() throws Exception {
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
+ params.add(new NameValuePair("j_username", "garbage"));
+ params.add(new NameValuePair("j_password", "garbage"));
+
+ // simulate a browser request
+ List<Header> headers = new ArrayList<Header>();
+ headers.add(new Header("User-Agent", "Mozilla/5.0 Sling Integration
Test"));
+
+ HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
+ HttpServletResponse.SC_MOVED_TEMPORARILY, params, headers,
null);
+
+ final String location = post.getResponseHeader("Location").getValue();
+ assertNotNull(location);
+ assertTrue(location.startsWith(HttpTest.HTTP_BASE_URL +
"/system/sling/selector/login?"));
+ assertTrue(location.contains("resource=%2F"));
+ assertTrue(location.contains("j_reason=INVALID_CREDENTIALS"));
+ }
+
+
+ // TODO - move this method into commons.testing
+ protected HttpMethod assertPostStatus(String url, int expectedStatusCode,
List<NameValuePair> postParams,
+ List<Header> headers, String assertMessage) throws IOException {
+ final PostMethod post = new PostMethod(url);
+ post.setFollowRedirects(false);
+
+ if (headers != null) {
+ for (Header header : headers) {
+ post.addRequestHeader(header);
+ }
+ }
+
+ if (postParams != null) {
+ final NameValuePair[] nvp = {};
+ post.setRequestBody(postParams.toArray(nvp));
+ }
+
+ final int status = H.getHttpClient().executeMethod(post);
+ if (assertMessage == null) {
+ assertEquals(expectedStatusCode, status);
+ } else {
+ assertEquals(assertMessage, expectedStatusCode, status);
+ }
+ return post;
+ }
+}
Copied:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java
(from r1628370,
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java)
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java?p2=sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/FormGenerationTest.java&r1=1628370&r2=1628372&rev=1628372&view=diff
==============================================================================
(empty)
Copied:
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/SelectorRedirectOnLoginErrorTest.java
(from r1628370,
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java)
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/SelectorRedirectOnLoginErrorTest.java?p2=sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/SelectorRedirectOnLoginErrorTest.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java&r1=1628370&r2=1628372&rev=1628372&view=diff
==============================================================================
---
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
(original)
+++
sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/login/SelectorRedirectOnLoginErrorTest.java
Tue Sep 30 08:37:07 2014
@@ -29,13 +29,14 @@ import org.apache.commons.httpclient.met
import org.apache.sling.commons.testing.integration.HttpTestBase;
/** Test SLING-2165 Verify that redirect to the referring login form after
login error works */
-public class RedirectOnLoginErrorTest extends HttpTestBase {
+public class SelectorRedirectOnLoginErrorTest extends HttpTestBase {
/** Execute a POST request and check status
* @return the HttpMethod executed
* @throws IOException */
private HttpMethod assertPostStatus(String url, int expectedStatusCode,
List<NameValuePair> postParams,
String assertMessage, String referer)
throws IOException {
+ // TODO - method copied from
org.apache.sling.launchpad.webapp.integrationtest.login.RedirectOnLoginErrorTest
final PostMethod post = new PostMethod(url);
post.setFollowRedirects(false);
post.setDoAuthentication(false);
@@ -117,42 +118,4 @@ public class RedirectOnLoginErrorTest ex
}
assertEquals("Expected to remain on the openid/login page",
loginPageUrl, location);
}
-
- /**
- * Test SLING-2165. Login Error should redirect back to the referrer
- * login page.
- *
- * @throws Exception
- */
- public void testRedirectToLoginFormAfterLoginError() throws Exception {
- //login failure
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new NameValuePair("j_username", "___bogus___"));
- params.add(new NameValuePair("j_password", "not_a_real_user"));
- final String loginPageUrl =
String.format("%s/system/sling/form/login", HTTP_BASE_URL);
- PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL +
"/j_security_check",
- HttpServletResponse.SC_MOVED_TEMPORARILY,
- params,
- null,
- loginPageUrl);
-
- final Header locationHeader = post.getResponseHeader("Location");
- String location = locationHeader.getValue();
- int queryStrStart = location.indexOf('?');
- if (queryStrStart != -1) {
- location = location.substring(0, queryStrStart);
- }
- assertEquals("Expected to remain on the form/login page",
loginPageUrl, location);
- }
-
- /**
- * Test SLING-2165. Verify that a GET request to the default login page
does not
- * result in an error condition.
- *
- * @throws Exception
- */
- public void testGetDefaultLoginPage() throws Exception {
- final String loginPageUrl = String.format("%s/system/sling/login",
HTTP_BASE_URL);
- assertHttpStatus(loginPageUrl, HttpServletResponse.SC_OK);
- }
}
Modified:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/auth/AuthenticationResponseCodeTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/auth/AuthenticationResponseCodeTest.java?rev=1628372&r1=1628371&r2=1628372&view=diff
==============================================================================
---
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/auth/AuthenticationResponseCodeTest.java
(original)
+++
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/auth/AuthenticationResponseCodeTest.java
Tue Sep 30 08:37:07 2014
@@ -60,45 +60,50 @@ public class AuthenticationResponseCodeT
public void cleanup() throws Exception {
H.tearDown();
}
-
- @Test
- @Category(JackrabbitOnly.class) // TODO: fails on Oak
+
+ @Test
+ @Category(JackrabbitOnly.class)
+ // TODO: fails on Oak
public void testValidatingCorrectFormCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "admin"));
params.add(new NameValuePair("j_password", "admin"));
params.add(new NameValuePair("j_validate", "true"));
- HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK, params, null);
+ HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK,
+ params, null);
assertTrue(post.getResponseBodyAsString().length() == 0);
List<NameValuePair> params2 = new ArrayList<NameValuePair>();
params2.add(new NameValuePair("j_validate", "true"));
- HttpMethod post2 = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK, params2, null);
+ HttpMethod post2 = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK,
+ params2, null);
assertTrue(post2.getResponseBodyAsString().length() == 0);
}
- @Test
+ @Test
public void testValidatingCorrectHttpBasicCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_validate", "true"));
- HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK, params, null);
+ HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_OK,
+ params, null);
assertTrue(post.getResponseBodyAsString().length() == 0);
HttpMethod get = H.assertHttpStatus(HttpTest.HTTP_BASE_URL +
"/?j_validate=true", HttpServletResponse.SC_OK);
assertTrue(get.getResponseBodyAsString().length() == 0);
}
- @Test
+ @Test
public void testValidatingIncorrectCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
params.add(new NameValuePair("j_password", "garbage"));
params.add(new NameValuePair("j_validate", "true"));
- HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, null);
+ HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
+ HttpServletResponse.SC_FORBIDDEN, params, null);
assertNotNull(post.getResponseHeader("X-Reason"));
}
- @Test
+ @Test
public void testValidatingIncorrectCookie() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_validate", "true"));
@@ -106,34 +111,39 @@ public class AuthenticationResponseCodeT
List<Header> headers = new ArrayList<Header>();
headers.add(new Header("Cookie", "sling.formauth=garbage"));
- HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, headers, null);
+ HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
+ HttpServletResponse.SC_FORBIDDEN, params, headers, null);
assertXReason(post);
}
- @Test
+ @Test
public void testValidatingIncorrectHttpBasicCredentials() throws Exception
{
// assume http and webdav are on the same host + port
URL url = new URL(HttpTest.HTTP_BASE_URL);
Credentials defaultcreds = new UsernamePasswordCredentials("garbage",
"garbage");
- H.getHttpClient().getState().setCredentials(new
AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);
+ H.getHttpClient().getState()
+ .setCredentials(new AuthScope(url.getHost(), url.getPort(),
AuthScope.ANY_REALM), defaultcreds);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_validate", "true"));
- HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, null);
+ HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
+ HttpServletResponse.SC_FORBIDDEN, params, null);
assertXReason(post);
- HttpMethod get = H.assertHttpStatus(HttpTest.HTTP_BASE_URL +
"/?j_validate=true", HttpServletResponse.SC_FORBIDDEN);
+ HttpMethod get = H.assertHttpStatus(HttpTest.HTTP_BASE_URL +
"/?j_validate=true",
+ HttpServletResponse.SC_FORBIDDEN);
assertXReason(get);
}
- @Test
+ @Test
public void testPreventLoopIncorrectHttpBasicCredentials() throws
Exception {
// assume http and webdav are on the same host + port
URL url = new URL(HttpTest.HTTP_BASE_URL);
Credentials defaultcreds = new UsernamePasswordCredentials("garbage",
"garbage");
- H.getHttpClient().getState().setCredentials(new
AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);
+ H.getHttpClient().getState()
+ .setCredentials(new AuthScope(url.getHost(), url.getPort(),
AuthScope.ANY_REALM), defaultcreds);
final String requestUrl = HttpTest.HTTP_BASE_URL + "/junk?param1=1";
HttpMethod get = new GetMethod(requestUrl);
@@ -143,7 +153,7 @@ public class AuthenticationResponseCodeT
assertEquals(HttpServletResponse.SC_UNAUTHORIZED, status);
}
- @Test
+ @Test
public void testPreventLoopIncorrectFormCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
@@ -159,7 +169,7 @@ public class AuthenticationResponseCodeT
assertEquals("Username and Password do not match",
post.getResponseHeader("X-Reason").getValue());
}
- @Test
+ @Test
public void testXRequestedWithIncorrectCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
@@ -169,43 +179,23 @@ public class AuthenticationResponseCodeT
headers.add(new Header("X-Requested-With", "XMLHttpRequest"));
headers.add(new Header("User-Agent", "Mozilla/5.0 Sling Integration
Test"));
- HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check", HttpServletResponse.SC_FORBIDDEN,
- params, headers, null);
+ HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
+ HttpServletResponse.SC_FORBIDDEN, params, headers, null);
assertNotNull(post.getResponseHeader("X-Reason"));
assertEquals("Username and Password do not match",
post.getResponseHeader("X-Reason").getValue());
}
- // this method assumes the use of the selector auth bundle
- @Test
- public void testWithAcceptHeaderIncorrectCredentials() throws Exception {
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new NameValuePair("j_username", "garbage"));
- params.add(new NameValuePair("j_password", "garbage"));
-
- // simulate a browser request
- List<Header> headers = new ArrayList<Header>();
- headers.add(new Header("User-Agent", "Mozilla/5.0 Sling Integration
Test"));
-
- HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL +
"/j_security_check",
- HttpServletResponse.SC_MOVED_TEMPORARILY, params, headers,
null);
-
- final String location = post.getResponseHeader("Location").getValue();
- assertNotNull(location);
- assertTrue(location.startsWith(HttpTest.HTTP_BASE_URL +
"/system/sling/selector/login?"));
- assertTrue(location.contains("resource=%2F"));
- assertTrue(location.contains("j_reason=INVALID_CREDENTIALS"));
- }
-
- @Test
+ @Test
public void testWithoutAcceptHeaderIncorrectCredentials() throws Exception
{
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
params.add(new NameValuePair("j_password", "garbage"));
- H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
HttpServletResponse.SC_UNAUTHORIZED, params, null);
+ H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
HttpServletResponse.SC_UNAUTHORIZED, params,
+ null);
}
- @Test
+ @Test
public void testWithNonHtmlAcceptHeaderIncorrectCredentials() throws
Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
@@ -214,7 +204,8 @@ public class AuthenticationResponseCodeT
List<Header> headers = new ArrayList<Header>();
headers.add(new Header("User-Agent", "Mozilla/5.0 Sling Integration
Test"));
- H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
HttpServletResponse.SC_UNAUTHORIZED, params, null);
+ H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
HttpServletResponse.SC_UNAUTHORIZED, params,
+ null);
}
// TODO - move this method into commons.testing
Modified:
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java?rev=1628372&r1=1628371&r2=1628372&view=diff
==============================================================================
---
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
(original)
+++
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/login/RedirectOnLoginErrorTest.java
Tue Sep 30 08:37:07 2014
@@ -71,59 +71,6 @@ public class RedirectOnLoginErrorTest ex
*
* @throws Exception
*/
- public void testRedirectToSelectorLoginFormAfterLoginError() throws
Exception {
- //login failure
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new NameValuePair("j_username", "___bogus___"));
- params.add(new NameValuePair("j_password", "not_a_real_user"));
- final String loginPageUrl =
String.format("%s/system/sling/selector/login", HTTP_BASE_URL);
- PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL +
"/j_security_check",
- HttpServletResponse.SC_MOVED_TEMPORARILY,
- params,
- null,
- loginPageUrl);
-
- final Header locationHeader = post.getResponseHeader("Location");
- String location = locationHeader.getValue();
- int queryStrStart = location.indexOf('?');
- if (queryStrStart != -1) {
- location = location.substring(0, queryStrStart);
- }
- assertEquals("Expected to remain on the selector/login page",
loginPageUrl, location);
- }
-
- /**
- * Test SLING-2165. Login Error should redirect back to the referrer
- * login page.
- *
- * @throws Exception
- */
- public void testRedirectToOpenIDLoginFormAfterLoginError() throws
Exception {
- //login failure
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new NameValuePair("openid_identifier", "___bogus___"));
- final String loginPageUrl =
String.format("%s/system/sling/openid/login", HTTP_BASE_URL);
- PostMethod post = (PostMethod)assertPostStatus(HTTP_BASE_URL +
"/j_security_check",
- HttpServletResponse.SC_MOVED_TEMPORARILY,
- params,
- null,
- loginPageUrl);
-
- final Header locationHeader = post.getResponseHeader("Location");
- String location = locationHeader.getValue();
- int queryStrStart = location.indexOf('?');
- if (queryStrStart != -1) {
- location = location.substring(0, queryStrStart);
- }
- assertEquals("Expected to remain on the openid/login page",
loginPageUrl, location);
- }
-
- /**
- * Test SLING-2165. Login Error should redirect back to the referrer
- * login page.
- *
- * @throws Exception
- */
public void testRedirectToLoginFormAfterLoginError() throws Exception {
//login failure
List<NameValuePair> params = new ArrayList<NameValuePair>();