parent
85f0f3f34a
commit
e569c7a39e
|
@ -27,6 +27,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||||
|
import org.springframework.mock.web.MockFilterChain;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
import org.springframework.mock.web.MockHttpServletResponse;
|
import org.springframework.mock.web.MockHttpServletResponse;
|
||||||
import org.springframework.mock.web.MockServletContext;
|
import org.springframework.mock.web.MockServletContext;
|
||||||
|
@ -74,6 +75,8 @@ class WebAuthnRegistrationFilterTests {
|
||||||
@Mock
|
@Mock
|
||||||
private FilterChain chain;
|
private FilterChain chain;
|
||||||
|
|
||||||
|
private MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
|
||||||
private MockHttpServletResponse response = new MockHttpServletResponse();
|
private MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
|
|
||||||
private static final String REGISTRATION_REQUEST_BODY = """
|
private static final String REGISTRATION_REQUEST_BODY = """
|
||||||
|
@ -101,32 +104,26 @@ class WebAuthnRegistrationFilterTests {
|
||||||
|
|
||||||
private WebAuthnRegistrationFilter filter;
|
private WebAuthnRegistrationFilter filter;
|
||||||
|
|
||||||
private MockHttpServletRequest request;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup() {
|
||||||
this.filter = new WebAuthnRegistrationFilter(this.userCredentials, this.operations);
|
this.filter = new WebAuthnRegistrationFilter(this.userCredentials, this.operations);
|
||||||
this.request = new MockHttpServletRequest();
|
|
||||||
this.response = new MockHttpServletResponse();
|
|
||||||
this.chain = mock(FilterChain.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doFilterWhenCustomRequestRegisterCredentialMatcherThenUses() throws Exception {
|
void doFilterWhenCustomRequestRegisterCredentialMatcherThenUses() throws Exception {
|
||||||
RequestMatcher requestMatcher = mock(RequestMatcher.class);
|
RequestMatcher requestMatcher = mock(RequestMatcher.class);
|
||||||
this.filter.setRegisterCredentialMatcher(requestMatcher);
|
this.filter.setRegisterCredentialMatcher(requestMatcher);
|
||||||
FilterChain mock = mock(FilterChain.class);
|
this.filter.doFilter(this.request, this.response, new MockFilterChain());
|
||||||
this.filter.doFilter(this.request, this.response, mock);
|
|
||||||
verify(requestMatcher).matches(any());
|
verify(requestMatcher).matches(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doFilterWhenCustomRequestRemoveCredentialMatcherThenUses() throws Exception {
|
void doFilterWhenCustomRequestRemoveCredentialMatcherThenUses() throws Exception {
|
||||||
RequestMatcher requestMatcher = mock(RequestMatcher.class);
|
RequestMatcher requestMatcher = mock(RequestMatcher.class);
|
||||||
|
given(requestMatcher.matcher(any())).willReturn(RequestMatcher.MatchResult.notMatch());
|
||||||
this.filter.setRemoveCredentialMatcher(requestMatcher);
|
this.filter.setRemoveCredentialMatcher(requestMatcher);
|
||||||
FilterChain mock = mock(FilterChain.class);
|
this.filter.doFilter(this.request, this.response, new MockFilterChain());
|
||||||
this.filter.doFilter(this.request, this.response, mock);
|
verify(requestMatcher).matcher(any());
|
||||||
verify(requestMatcher).matches(any());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue