use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.
the class DefaultSavedRequestMixinTests method deserializeDefaultSavedRequest.
@Test
public void deserializeDefaultSavedRequest() throws IOException {
DefaultSavedRequest request = (DefaultSavedRequest) mapper.readValue(REQUEST_JSON, Object.class);
assertThat(request).isNotNull();
assertThat(request.getCookies()).hasSize(1);
assertThat(request.getLocales()).hasSize(1).contains(new Locale("en"));
assertThat(request.getHeaderNames()).hasSize(1).contains("x-auth-token");
assertThat(request.getHeaderValues("x-auth-token")).hasSize(1).contains("12");
}
use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.
the class DefaultSavedRequestMixinTests method matchRequestBuildWithConstructorAndBuilder.
// @formatter:on
@Test
public void matchRequestBuildWithConstructorAndBuilder() {
DefaultSavedRequest request = new DefaultSavedRequest.Builder().setCookies(Collections.singletonList(new SavedCookie(new Cookie("SESSION", "123456789")))).setHeaders(Collections.singletonMap("x-auth-token", Collections.singletonList("12"))).setScheme("http").setRequestURL("http://localhost").setServerName("localhost").setRequestURI("").setLocales(Collections.singletonList(new Locale("en"))).setContextPath("").setMethod("").setServletPath("").build();
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setCookies(new Cookie("SESSION", "123456789"));
mockRequest.addHeader("x-auth-token", "12");
assert request.doesRequestMatch(mockRequest, new PortResolverImpl());
}
use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.
the class DefaultSavedRequestTests method discardsIfNoneMatchHeader.
// SEC-1412
@Test
public void discardsIfNoneMatchHeader() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("If-None-Match", "somehashvalue");
DefaultSavedRequest saved = new DefaultSavedRequest(request, new MockPortResolver(8080, 8443));
assertThat(saved.getHeaderValues("if-none-match").isEmpty()).isTrue();
}
use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.
the class DefaultSavedRequestTests method headersAreCaseInsensitive.
// SEC-308, SEC-315
@Test
public void headersAreCaseInsensitive() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("USER-aGenT", "Mozilla");
DefaultSavedRequest saved = new DefaultSavedRequest(request, new MockPortResolver(8080, 8443));
assertThat(saved.getHeaderValues("user-agent").get(0)).isEqualTo("Mozilla");
}
use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.
the class DefaultSavedRequestTests method parametersAreCaseSensitive.
// SEC-3082
@Test
public void parametersAreCaseSensitive() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("AnotHerTest", "Hi dad");
request.addParameter("thisisatest", "Hi mom");
DefaultSavedRequest saved = new DefaultSavedRequest(request, new MockPortResolver(8080, 8443));
assertThat(saved.getParameterValues("thisisatest")[0]).isEqualTo("Hi mom");
assertThat(saved.getParameterValues("anothertest")).isNull();
}
Aggregations