Search in sources :

Example 1 with AssertionOptionsProvider

use of com.webauthn4j.springframework.security.options.AssertionOptionsProvider in project webauthn4j-spring-security by webauthn4j.

the class AssertionOptionsEndpointFilterTest method doFilter_with_error_test.

@Test
public void doFilter_with_error_test() throws IOException, ServletException {
    AssertionOptionsProvider optionsProvider = mock(AssertionOptionsProvider.class);
    doThrow(new RuntimeException()).when(optionsProvider).getAssertionOptions(any(), any());
    AssertionOptionsEndpointFilter optionsEndpointFilter = new AssertionOptionsEndpointFilter(optionsProvider, objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI(AssertionOptionsEndpointFilter.FILTER_URL);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain filterChain = new MockFilterChain();
    optionsEndpointFilter.doFilter(request, response, filterChain);
    assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value());
}
Also used : AuthenticationTrustResolverImpl(org.springframework.security.authentication.AuthenticationTrustResolverImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AssertionOptionsProvider(com.webauthn4j.springframework.security.options.AssertionOptionsProvider) AuthenticationTrustResolver(org.springframework.security.authentication.AuthenticationTrustResolver) MockFilterChain(org.springframework.mock.web.MockFilterChain) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 2 with AssertionOptionsProvider

use of com.webauthn4j.springframework.security.options.AssertionOptionsProvider in project webauthn4j-spring-security by webauthn4j.

the class AssertionOptionsEndpointFilterTest method doFilter_test.

@Test
public void doFilter_test() throws IOException, ServletException {
    AssertionOptionsProvider optionsProvider = mock(AssertionOptionsProvider.class);
    AssertionOptions assertionOptions = new AssertionOptions(null, null, null, null, null, null);
    when(optionsProvider.getAssertionOptions(any(), any())).thenReturn(assertionOptions);
    AssertionOptionsEndpointFilter optionsEndpointFilter = new AssertionOptionsEndpointFilter(optionsProvider, objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI(AssertionOptionsEndpointFilter.FILTER_URL);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain filterChain = new MockFilterChain();
    optionsEndpointFilter.doFilter(request, response, filterChain);
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
}
Also used : AuthenticationTrustResolverImpl(org.springframework.security.authentication.AuthenticationTrustResolverImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AssertionOptions(com.webauthn4j.springframework.security.options.AssertionOptions) AssertionOptionsProvider(com.webauthn4j.springframework.security.options.AssertionOptionsProvider) AuthenticationTrustResolver(org.springframework.security.authentication.AuthenticationTrustResolver) MockFilterChain(org.springframework.mock.web.MockFilterChain) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 3 with AssertionOptionsProvider

use of com.webauthn4j.springframework.security.options.AssertionOptionsProvider in project webauthn4j-spring-security by webauthn4j.

the class AssertionOptionsEndpointFilterTest method doFilter_with_unmatched_url_test.

@Test
public void doFilter_with_unmatched_url_test() throws IOException, ServletException {
    AssertionOptionsProvider optionsProvider = mock(AssertionOptionsProvider.class);
    AssertionOptionsEndpointFilter optionsEndpointFilter = new AssertionOptionsEndpointFilter(optionsProvider, objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/unmatched_url");
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain filterChain = new MockFilterChain();
    optionsEndpointFilter.doFilter(request, response, filterChain);
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
}
Also used : AuthenticationTrustResolverImpl(org.springframework.security.authentication.AuthenticationTrustResolverImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AssertionOptionsProvider(com.webauthn4j.springframework.security.options.AssertionOptionsProvider) AuthenticationTrustResolver(org.springframework.security.authentication.AuthenticationTrustResolver) MockFilterChain(org.springframework.mock.web.MockFilterChain) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

AssertionOptionsProvider (com.webauthn4j.springframework.security.options.AssertionOptionsProvider)3 Test (org.junit.Test)3 MockFilterChain (org.springframework.mock.web.MockFilterChain)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 AuthenticationTrustResolver (org.springframework.security.authentication.AuthenticationTrustResolver)3 AuthenticationTrustResolverImpl (org.springframework.security.authentication.AuthenticationTrustResolverImpl)3 AssertionOptions (com.webauthn4j.springframework.security.options.AssertionOptions)1