use of org.springframework.security.web.savedrequest.SavedRequestAwareWrapper in project spring-security by spring-projects.
the class SavedRequestAwareWrapperTests method getParameterValuesReturnsCombinedSavedAndWrappedRequestValues.
@Test
public void getParameterValuesReturnsCombinedSavedAndWrappedRequestValues() {
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
savedRequest.setParameter("action", "foo");
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
assertThat(wrapper.getParameterValues("action")).isEqualTo(new Object[] { "foo" });
wrappedRequest.setParameter("action", "bar");
assertThat(wrapper.getParameterValues("action")).isEqualTo(new Object[] { "bar", "foo" });
// Check map is consistent
String[] valuesFromMap = (String[]) wrapper.getParameterMap().get("action");
assertThat(valuesFromMap.length).isEqualTo(2);
assertThat(valuesFromMap[0]).isEqualTo("bar");
}
use of org.springframework.security.web.savedrequest.SavedRequestAwareWrapper in project spring-security by spring-projects.
the class SavedRequestAwareWrapperTests method correctHttpMethodIsReturned.
@Test
public void correctHttpMethodIsReturned() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/notused");
SavedRequestAwareWrapper wrapper = createWrapper(request, new MockHttpServletRequest("GET", "/notused"));
assertThat(wrapper.getMethod()).isEqualTo("PUT");
}
use of org.springframework.security.web.savedrequest.SavedRequestAwareWrapper in project spring-security by spring-projects.
the class SavedRequestAwareWrapperTests method savedRequestCookiesAreIgnored.
// SEC-2569
@Test
public void savedRequestCookiesAreIgnored() throws Exception {
MockHttpServletRequest newRequest = new MockHttpServletRequest();
newRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromnew") });
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
savedRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromsaved") });
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, newRequest);
assertThat(wrapper.getCookies().length).isEqualTo(1);
assertThat(wrapper.getCookies()[0].getValue()).isEqualTo("fromnew");
}
use of org.springframework.security.web.savedrequest.SavedRequestAwareWrapper in project spring-security by spring-projects.
the class SavedRequestAwareWrapperTests method savedRequestHeadersTakePrecedence.
@Test
public void savedRequestHeadersTakePrecedence() {
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
savedRequest.addHeader("Authorization", "foo");
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
wrappedRequest.addHeader("Authorization", "bar");
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
assertThat(wrapper.getHeader("Authorization")).isEqualTo("foo");
}
use of org.springframework.security.web.savedrequest.SavedRequestAwareWrapper in project spring-security by spring-projects.
the class SavedRequestAwareWrapperTests method savedRequestDoesntCreateDuplicateParams.
@Test
public void savedRequestDoesntCreateDuplicateParams() {
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
savedRequest.setParameter("action", "foo");
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
wrappedRequest.setParameter("action", "foo");
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
assertThat(wrapper.getParameterValues("action").length).isEqualTo(1);
assertThat(wrapper.getParameterMap()).hasSize(1);
assertThat(((String[]) wrapper.getParameterMap().get("action")).length).isEqualTo(1);
}
Aggregations