use of org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter 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.security.oauth2.client.filter.OAuth2ClientContextFilter in project spring-security-oauth by spring-projects.
the class ClientConfigurationTests method testAuthCodeRedirect.
@Test
public void testAuthCodeRedirect() throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(ClientContext.class);
context.refresh();
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).addFilters(new OAuth2ClientContextFilter()).build();
mvc.perform(MockMvcRequestBuilders.get("/photos")).andExpect(MockMvcResultMatchers.status().isFound()).andExpect(MockMvcResultMatchers.header().string("Location", CoreMatchers.startsWith("http://example.com/authorize")));
context.close();
}
Aggregations