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());
}
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());
}
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());
}
Aggregations