Search in sources :

Example 6 with DefaultSavedRequest

use of org.springframework.security.web.savedrequest.DefaultSavedRequest in project spring-security by spring-projects.

the class DefaultSavedRequestMixinTests method serializeDefaultRequestBuildWithBuilderTest.

@Test
public void serializeDefaultRequestBuildWithBuilderTest() throws IOException, JSONException {
    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();
    String actualString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request);
    JSONAssert.assertEquals(REQUEST_JSON, actualString, true);
}
Also used : SavedCookie(org.springframework.security.web.savedrequest.SavedCookie) Cookie(javax.servlet.http.Cookie) Locale(java.util.Locale) SavedCookie(org.springframework.security.web.savedrequest.SavedCookie) DefaultSavedRequest(org.springframework.security.web.savedrequest.DefaultSavedRequest) Test(org.junit.Test)

Example 7 with DefaultSavedRequest

use of org.springframework.security.web.savedrequest.DefaultSavedRequest 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);
}
Also used : SavedCookie(org.springframework.security.web.savedrequest.SavedCookie) Cookie(javax.servlet.http.Cookie) PortResolverImpl(org.springframework.security.web.PortResolverImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultSavedRequest(org.springframework.security.web.savedrequest.DefaultSavedRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 DefaultSavedRequest (org.springframework.security.web.savedrequest.DefaultSavedRequest)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 Locale (java.util.Locale)3 Cookie (javax.servlet.http.Cookie)3 MockPortResolver (org.springframework.security.MockPortResolver)3 SavedCookie (org.springframework.security.web.savedrequest.SavedCookie)3 PortResolverImpl (org.springframework.security.web.PortResolverImpl)2