use of org.springframework.security.oauth.provider.filter.UserAuthorizationSuccessfulAuthenticationHandler in project spring-security-oauth by spring-projects.
the class UserAuthorizationSuccessfulAuthenticationHandlerTests method testAuthenticationSuccess.
/**
* test determineTargetUrl
*/
@Test
public void testAuthenticationSuccess() throws Exception {
UserAuthorizationSuccessfulAuthenticationHandler handler = new UserAuthorizationSuccessfulAuthenticationHandler();
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
RedirectStrategy redirectStrategy = mock(RedirectStrategy.class);
handler.setRedirectStrategy(redirectStrategy);
when(request.getAttribute(UserAuthorizationProcessingFilter.CALLBACK_ATTRIBUTE)).thenReturn("http://my.host.com/my/context");
when(request.getAttribute(UserAuthorizationProcessingFilter.VERIFIER_ATTRIBUTE)).thenReturn("myver");
when(request.getParameter("requestToken")).thenReturn("mytok");
handler.onAuthenticationSuccess(request, response, null);
verify(redirectStrategy).sendRedirect(request, response, "http://my.host.com/my/context?oauth_token=mytok&oauth_verifier=myver");
handler = new UserAuthorizationSuccessfulAuthenticationHandler();
handler.setRedirectStrategy(redirectStrategy);
when(request.getAttribute(UserAuthorizationProcessingFilter.CALLBACK_ATTRIBUTE)).thenReturn("http://my.hosting.com/my/context?with=some&query=parameter");
when(request.getAttribute(UserAuthorizationProcessingFilter.VERIFIER_ATTRIBUTE)).thenReturn("myvera");
when(request.getParameter("requestToken")).thenReturn("mytoka");
handler.onAuthenticationSuccess(request, response, null);
verify(redirectStrategy).sendRedirect(request, response, "http://my.hosting.com/my/context?with=some&query=parameter&oauth_token=mytoka&oauth_verifier=myvera");
}
Aggregations