use of org.springframework.security.web.PortResolverImpl 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.PortResolverImpl in project spring-security by spring-projects.
the class HttpSessionRequestCacheTests method getRequestCustomNoClassCastException.
// SEC-2246
@Test
public void getRequestCustomNoClassCastException() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/destination");
MockHttpServletResponse response = new MockHttpServletResponse();
HttpSessionRequestCache cache = new HttpSessionRequestCache() {
@Override
public void saveRequest(HttpServletRequest request, HttpServletResponse response) {
request.getSession().setAttribute(SAVED_REQUEST, new CustomSavedRequest(new DefaultSavedRequest(request, new PortResolverImpl())));
}
};
cache.saveRequest(request, response);
cache.saveRequest(request, response);
assertThat(cache.getRequest(request, response)).isInstanceOf(CustomSavedRequest.class);
}
use of org.springframework.security.web.PortResolverImpl in project spring-security by spring-projects.
the class DefaultSavedRequestMixinTests method serializeDefaultRequestBuildWithConstructorTest.
@Test
public void serializeDefaultRequestBuildWithConstructorTest() throws IOException, JSONException {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setCookies(new Cookie("SESSION", "123456789"));
request.addHeader("x-auth-token", "12");
String actualString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(new DefaultSavedRequest(request, new PortResolverImpl()));
JSONAssert.assertEquals(REQUEST_JSON, actualString, true);
}
Aggregations