use of org.springframework.mock.web.MockHttpServletRequest in project spring-security-oauth by spring-projects.
the class OAuth2ClientContextFilterTests method testVanillaCurrentUri.
@Test
public void testVanillaCurrentUri() throws Exception {
OAuth2ClientContextFilter filter = new OAuth2ClientContextFilter();
MockHttpServletRequest request = new MockHttpServletRequest();
request.setQueryString("foo=bar");
assertEquals("http://localhost?foo=bar", filter.calculateCurrentUri(request));
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security-oauth by spring-projects.
the class OAuth2ClientContextFilterTests method testRedirectUri.
public void testRedirectUri(String redirect, Map<String, String> params, String result) throws Exception {
OAuth2ClientContextFilter filter = new OAuth2ClientContextFilter();
RedirectStrategy redirectStrategy = Mockito.mock(RedirectStrategy.class);
filter.setRedirectStrategy(redirectStrategy);
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
UserRedirectRequiredException exception = new UserRedirectRequiredException(redirect, params);
filter.redirectUser(exception, request, response);
Mockito.verify(redirectStrategy).sendRedirect(request, response, result);
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security-oauth by spring-projects.
the class OAuth2ClientContextFilterTests method testCurrentUriRemovingCode.
@Test
public void testCurrentUriRemovingCode() throws Exception {
OAuth2ClientContextFilter filter = new OAuth2ClientContextFilter();
MockHttpServletRequest request = new MockHttpServletRequest();
request.setQueryString("code=XXXX&foo=bar");
assertEquals("http://localhost?foo=bar", filter.calculateCurrentUri(request));
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class SessionManagementConfigServlet31Tests method changeSessionIdDefaultsInServlet31Plus.
@Test
public void changeSessionIdDefaultsInServlet31Plus() throws Exception {
spy(ReflectionUtils.class);
Method method = mock(Method.class);
MockHttpServletRequest request = new MockHttpServletRequest();
request.getSession();
request.setServletPath("/login");
request.setMethod("POST");
request.setParameter("username", "user");
request.setParameter("password", "password");
when(ReflectionUtils.findMethod(HttpServletRequest.class, "changeSessionId")).thenReturn(method);
loadContext("<http>\n" + " <form-login/>\n" + " <session-management/>\n" + " <csrf disabled='true'/>\n" + " </http>" + XML_AUTHENTICATION_MANAGER);
springSecurityFilterChain.doFilter(request, response, chain);
verifyStatic();
ReflectionUtils.invokeMethod(same(method), any(HttpServletRequest.class));
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class OpenID4JavaConsumerTests method discoveryExceptionRaisesOpenIDException.
@Test(expected = OpenIDConsumerException.class)
public void discoveryExceptionRaisesOpenIDException() throws Exception {
ConsumerManager mgr = mock(ConsumerManager.class);
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
when(mgr.discover(anyString())).thenThrow(new DiscoveryException("msg"));
consumer.beginConsumption(new MockHttpServletRequest(), "", "", "");
}
Aggregations