SEC-1648: Implemented Rob's suggestion to use a null value for the targetUrlParameter rather than a boolean property. It should thus only be used if this value is set.
This commit is contained in:
@@ -42,20 +42,34 @@ public class SimpleUrlAuthenticationSuccessHandlerTests {
|
||||
* SEC-213
|
||||
*/
|
||||
@Test
|
||||
public void targetUrlParameterIsUsedIfPresent() throws Exception {
|
||||
public void targetUrlParameterIsUsedIfPresentAndParameterNameIsSet() throws Exception {
|
||||
SimpleUrlAuthenticationSuccessHandler ash = new SimpleUrlAuthenticationSuccessHandler("/defaultTarget");
|
||||
ash.setUseTargetUrlparameter(true);
|
||||
ash.setTargetUrlParameter("targetUrl");
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
request.setParameter("targetUrl", "/target");
|
||||
|
||||
ash.onAuthenticationSuccess(request, response, mock(Authentication.class));
|
||||
assertEquals("/defaultTarget", response.getRedirectedUrl());
|
||||
|
||||
// Try with parameter set
|
||||
ash.setTargetUrlParameter("targetUrl");
|
||||
response = new MockHttpServletResponse();
|
||||
ash.onAuthenticationSuccess(request, response, mock(Authentication.class));
|
||||
assertEquals("/target", response.getRedirectedUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refererIsUsedIfUseRefererIsSet() throws Exception {
|
||||
SimpleUrlAuthenticationSuccessHandler ash = new SimpleUrlAuthenticationSuccessHandler("/defaultTarget");
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
ash.setUseReferer(true);
|
||||
request.addHeader("Referer", "http://www.springsource.com/");
|
||||
|
||||
ash.onAuthenticationSuccess(request, response, mock(Authentication.class));
|
||||
assertEquals("http://www.springsource.com/", response.getRedirectedUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* SEC-297 fix.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user