|
@@ -25,7 +25,7 @@ public class OpenIDAuthenticationFilterTests {
|
|
private static final String REDIRECT_URL = "http://www.example.com/redirect";
|
|
private static final String REDIRECT_URL = "http://www.example.com/redirect";
|
|
private static final String CLAIMED_IDENTITY_URL = "http://www.example.com/identity";
|
|
private static final String CLAIMED_IDENTITY_URL = "http://www.example.com/identity";
|
|
private static final String REQUEST_PATH = "/j_spring_openid_security_check";
|
|
private static final String REQUEST_PATH = "/j_spring_openid_security_check";
|
|
- private static final String FILTER_PROCESS_URL = "http://localhost:80" + REQUEST_PATH;
|
|
|
|
|
|
+ private static final String FILTER_PROCESS_URL = "http://localhost:8080" + REQUEST_PATH;
|
|
private static final String DEFAULT_TARGET_URL = FILTER_PROCESS_URL;
|
|
private static final String DEFAULT_TARGET_URL = FILTER_PROCESS_URL;
|
|
|
|
|
|
@Before
|
|
@Before
|
|
@@ -46,6 +46,7 @@ public class OpenIDAuthenticationFilterTests {
|
|
@Test
|
|
@Test
|
|
public void testFilterOperation() throws Exception {
|
|
public void testFilterOperation() throws Exception {
|
|
MockHttpServletRequest req = new MockHttpServletRequest("GET", REQUEST_PATH);
|
|
MockHttpServletRequest req = new MockHttpServletRequest("GET", REQUEST_PATH);
|
|
|
|
+ req.setServerPort(8080);
|
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
|
|
|
|
|
req.setParameter("openid_identifier", " " + CLAIMED_IDENTITY_URL);
|
|
req.setParameter("openid_identifier", " " + CLAIMED_IDENTITY_URL);
|
|
@@ -55,7 +56,7 @@ public class OpenIDAuthenticationFilterTests {
|
|
public String beginConsumption(HttpServletRequest req, String claimedIdentity, String returnToUrl, String realm) throws OpenIDConsumerException {
|
|
public String beginConsumption(HttpServletRequest req, String claimedIdentity, String returnToUrl, String realm) throws OpenIDConsumerException {
|
|
assertEquals(CLAIMED_IDENTITY_URL, claimedIdentity);
|
|
assertEquals(CLAIMED_IDENTITY_URL, claimedIdentity);
|
|
assertEquals(DEFAULT_TARGET_URL, returnToUrl);
|
|
assertEquals(DEFAULT_TARGET_URL, returnToUrl);
|
|
- assertEquals("http://localhost:80/", realm);
|
|
|
|
|
|
+ assertEquals("http://localhost:8080/", realm);
|
|
return REDIRECT_URL;
|
|
return REDIRECT_URL;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -66,7 +67,7 @@ public class OpenIDAuthenticationFilterTests {
|
|
// Filter chain shouldn't proceed
|
|
// Filter chain shouldn't proceed
|
|
verify(fc, never()).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
verify(fc, never()).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Tests that the filter encodes any query parameters on the return_to URL.
|
|
* Tests that the filter encodes any query parameters on the return_to URL.
|
|
*/
|
|
*/
|
|
@@ -78,13 +79,13 @@ public class OpenIDAuthenticationFilterTests {
|
|
MockHttpServletRequest req = new MockHttpServletRequest("GET", REQUEST_PATH);
|
|
MockHttpServletRequest req = new MockHttpServletRequest("GET", REQUEST_PATH);
|
|
req.addParameter(paramName, paramValue);
|
|
req.addParameter(paramName, paramValue);
|
|
filter.setReturnToUrlParameters(Collections.singleton(paramName));
|
|
filter.setReturnToUrlParameters(Collections.singleton(paramName));
|
|
-
|
|
|
|
|
|
+
|
|
URI returnTo = new URI(filter.buildReturnToUrl(req));
|
|
URI returnTo = new URI(filter.buildReturnToUrl(req));
|
|
String query = returnTo.getRawQuery();
|
|
String query = returnTo.getRawQuery();
|
|
assertEquals(1, count(query, '='));
|
|
assertEquals(1, count(query, '='));
|
|
assertEquals(0, count(query, '&'));
|
|
assertEquals(0, count(query, '&'));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Counts the number of occurrences of {@code c} in {@code s}.
|
|
* Counts the number of occurrences of {@code c} in {@code s}.
|
|
*/
|
|
*/
|