Change Default for (Server)AuthenticationEntryPointFailureHandler

Closes gh-9429
This commit is contained in:
Josh Cummings
2022-10-13 20:03:03 -06:00
parent 5afc7cb04f
commit f4cc27c375
6 changed files with 14 additions and 17 deletions

View File

@@ -30,17 +30,17 @@ import static org.mockito.Mockito.mock;
public class AuthenticationEntryPointFailureHandlerTests {
@Test
void onAuthenticationFailureWhenDefaultsThenAuthenticationServiceExceptionSwallowed() throws Exception {
void onAuthenticationFailureWhenRethrowingThenAuthenticationServiceExceptionSwallowed() throws Exception {
AuthenticationEntryPoint entryPoint = mock(AuthenticationEntryPoint.class);
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(entryPoint);
handler.setRethrowAuthenticationServiceException(false);
handler.onAuthenticationFailure(null, null, new AuthenticationServiceException("fail"));
}
@Test
void handleWhenRethrowingThenAuthenticationServiceExceptionRethrown() {
void handleWhenDefaultsThenAuthenticationServiceExceptionRethrown() {
AuthenticationEntryPoint entryPoint = mock(AuthenticationEntryPoint.class);
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(entryPoint);
handler.setRethrowAuthenticationServiceException(true);
assertThatExceptionOfType(AuthenticationServiceException.class).isThrownBy(
() -> handler.onAuthenticationFailure(null, null, new AuthenticationServiceException("fail")));
}

View File

@@ -71,16 +71,16 @@ public class ServerAuthenticationEntryPointFailureHandlerTests {
}
@Test
void onAuthenticationFailureWhenDefaultsThenAuthenticationServiceExceptionSwallowed() {
void onAuthenticationFailureWhenRethrownFalseThenAuthenticationServiceExceptionSwallowed() {
AuthenticationServiceException e = new AuthenticationServiceException("fail");
this.handler.setRethrowAuthenticationServiceException(false);
given(this.authenticationEntryPoint.commence(this.exchange, e)).willReturn(Mono.empty());
this.handler.onAuthenticationFailure(this.filterExchange, e).block();
}
@Test
void handleWhenRethrowingThenAuthenticationServiceExceptionRethrown() {
void handleWhenDefaultsThenAuthenticationServiceExceptionRethrown() {
AuthenticationServiceException e = new AuthenticationServiceException("fail");
this.handler.setRethrowAuthenticationServiceException(true);
assertThatExceptionOfType(AuthenticationServiceException.class)
.isThrownBy(() -> this.handler.onAuthenticationFailure(this.filterExchange, e).block());
}