Search in sources :

Example 1 with AuthenticationRequestRepository

use of oidc.repository.AuthenticationRequestRepository in project OpenConext-oidcng by OpenConext.

the class ConcurrentSavedRequestAwareAuthenticationSuccessHandlerTest method onAuthenticationSuccess.

@Test
public void onAuthenticationSuccess() throws IOException {
    AuthenticationRequestRepository authenticationRequestRepository = mock(AuthenticationRequestRepository.class);
    ConcurrentSavedRequestAwareAuthenticationSuccessHandler subject = new ConcurrentSavedRequestAwareAuthenticationSuccessHandler(authenticationRequestRepository);
    when(authenticationRequestRepository.findById(isNull())).thenReturn(Optional.of(new AuthenticationRequest("ID", new Date(), "client_id", "http://localhost")));
    MockHttpServletResponse response = new MockHttpServletResponse();
    subject.onAuthenticationSuccess(new MockHttpServletRequest(), response, new OidcSamlAuthentication());
    assertEquals("http://localhost", response.getHeader("Location"));
    assertEquals(HttpServletResponse.SC_MOVED_TEMPORARILY, response.getStatus());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AuthenticationRequestRepository(oidc.repository.AuthenticationRequestRepository) AuthenticationRequest(oidc.model.AuthenticationRequest) Date(java.util.Date) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) OidcSamlAuthentication(oidc.user.OidcSamlAuthentication) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 AuthenticationRequest (oidc.model.AuthenticationRequest)1 AuthenticationRequestRepository (oidc.repository.AuthenticationRequestRepository)1 OidcSamlAuthentication (oidc.user.OidcSamlAuthentication)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1