Merge branch 'mockito-update-5.8.x' into 5.8.x

Closes gh-11748
This commit is contained in:
Rob Winch 2022-08-23 16:02:19 -05:00
commit 26f8f2ce2d
46 changed files with 175 additions and 177 deletions

View File

@ -34,7 +34,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Luke Taylor * @author Luke Taylor
@ -68,7 +68,7 @@ public class AclPermissionCacheOptimizerTests {
pco.setObjectIdentityRetrievalStrategy(oids); pco.setObjectIdentityRetrievalStrategy(oids);
pco.setSidRetrievalStrategy(sids); pco.setSidRetrievalStrategy(sids);
pco.cachePermissionsFor(mock(Authentication.class), Collections.emptyList()); pco.cachePermissionsFor(mock(Authentication.class), Collections.emptyList());
verifyZeroInteractions(service, sids, oids); verifyNoMoreInteractions(service, sids, oids);
} }
} }

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Luke Taylor * @author Luke Taylor
@ -89,7 +89,7 @@ public class SecurityNamespaceHandlerTests {
ReflectionTestUtils.setField(handler, "logger", logger); ReflectionTestUtils.setField(handler, "logger", logger);
expectClassUtilsForNameThrowsNoClassDefFoundError(className); expectClassUtilsForNameThrowsNoClassDefFoundError(className);
handler.init(); handler.init();
verifyZeroInteractions(logger); verifyNoMoreInteractions(logger);
} }
@Test @Test

View File

@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@ -102,7 +102,7 @@ public class OAuth2ClientConfigurationTests {
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().string("resolved")); .andExpect(content().string("resolved"));
// @formatter:on // @formatter:on
verifyZeroInteractions(accessTokenResponseClient); verifyNoMoreInteractions(accessTokenResponseClient);
} }
@Test @Test

View File

@ -57,7 +57,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@ -129,7 +129,7 @@ public class NamespaceRememberMeTests {
AuthSuccessConfig.SUCCESS_HANDLER = mock(AuthenticationSuccessHandler.class); AuthSuccessConfig.SUCCESS_HANDLER = mock(AuthenticationSuccessHandler.class);
this.spring.register(AuthSuccessConfig.class).autowire(); this.spring.register(AuthSuccessConfig.class).autowire();
MvcResult result = this.mvc.perform(post("/login").with(rememberMeLogin())).andReturn(); MvcResult result = this.mvc.perform(post("/login").with(rememberMeLogin())).andReturn();
verifyZeroInteractions(AuthSuccessConfig.SUCCESS_HANDLER); verifyNoMoreInteractions(AuthSuccessConfig.SUCCESS_HANDLER);
Cookie rememberMe = result.getResponse().getCookie("remember-me"); Cookie rememberMe = result.getResponse().getCookie("remember-me");
assertThat(rememberMe).isNotNull(); assertThat(rememberMe).isNotNull();
this.mvc.perform(get("/somewhere").cookie(rememberMe)); this.mvc.perform(get("/somewhere").cookie(rememberMe));

View File

@ -45,7 +45,6 @@ import org.springframework.security.web.util.matcher.AnyRequestMatcher;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atLeastOnce;
@ -104,7 +103,7 @@ public class DefaultFilterChainValidatorTests {
@Test @Test
public void validateCheckLoginPageIsntProtectedThrowsIllegalArgumentException() { public void validateCheckLoginPageIsntProtectedThrowsIllegalArgumentException() {
IllegalArgumentException toBeThrown = new IllegalArgumentException("failed to eval expression"); IllegalArgumentException toBeThrown = new IllegalArgumentException("failed to eval expression");
willThrow(toBeThrown).given(this.accessDecisionManager).decide(any(Authentication.class), anyObject(), willThrow(toBeThrown).given(this.accessDecisionManager).decide(any(Authentication.class), any(),
any(Collection.class)); any(Collection.class));
this.validator.validate(this.chain); this.validator.validate(this.chain);
verify(this.logger).info( verify(this.logger).info(

View File

@ -23,7 +23,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class WebConfigUtilsTests { public class WebConfigUtilsTests {
@ -38,7 +38,7 @@ public class WebConfigUtilsTests {
public void validateHttpRedirectSpELNoParserWarning() { public void validateHttpRedirectSpELNoParserWarning() {
WebConfigUtils.validateHttpRedirect("#{T(org.springframework.security.config.http.WebConfigUtilsTest).URL}", WebConfigUtils.validateHttpRedirect("#{T(org.springframework.security.config.http.WebConfigUtilsTest).URL}",
this.parserContext, "fakeSource"); this.parserContext, "fakeSource");
verifyZeroInteractions(this.parserContext); verifyNoMoreInteractions(this.parserContext);
} }
} }

View File

@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.springframework.security.config.Customizer.withDefaults; import static org.springframework.security.config.Customizer.withDefaults;
/** /**
@ -294,7 +294,7 @@ public class FormLoginTests {
.submit(HomePage.class); .submit(HomePage.class);
// @formatter:on // @formatter:on
homePage.assertAt(); homePage.assertAt();
verifyZeroInteractions(defaultAuthenticationManager); verifyNoMoreInteractions(defaultAuthenticationManager);
} }
@Test @Test

View File

@ -85,7 +85,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.springframework.security.config.Customizer.withDefaults; import static org.springframework.security.config.Customizer.withDefaults;
/** /**
@ -409,7 +409,7 @@ public class ServerHttpSecurityTests {
.expectStatus().isOk() .expectStatus().isOk()
.expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")); .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"));
// @formatter:on // @formatter:on
verifyZeroInteractions(this.authenticationManager); verifyNoMoreInteractions(this.authenticationManager);
} }
@Test @Test
@ -438,7 +438,7 @@ public class ServerHttpSecurityTests {
.expectStatus().isOk() .expectStatus().isOk()
.expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")); .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"));
// @formatter:on // @formatter:on
verifyZeroInteractions(this.authenticationManager); verifyNoMoreInteractions(this.authenticationManager);
verify(customAuthenticationManager).authenticate(any(Authentication.class)); verify(customAuthenticationManager).authenticate(any(Authentication.class));
} }

View File

@ -57,7 +57,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link MethodSecurityInterceptor}. * Tests {@link MethodSecurityInterceptor}.
@ -318,7 +318,7 @@ public class MethodSecurityInterceptorTests {
this.interceptor.setAfterInvocationManager(aim); this.interceptor.setAfterInvocationManager(aim);
given(mi.proceed()).willThrow(new Throwable()); given(mi.proceed()).willThrow(new Throwable());
assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.interceptor.invoke(mi)); assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.interceptor.invoke(mi));
verifyZeroInteractions(aim); verifyNoMoreInteractions(aim);
} }
void mdsReturnsNull() { void mdsReturnsNull() {

View File

@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link AspectJMethodSecurityInterceptor}. * Tests {@link AspectJMethodSecurityInterceptor}.
@ -154,7 +154,7 @@ public class AspectJMethodSecurityInterceptorTests {
given(this.aspectJCallback.proceedWithObject()).willThrow(new RuntimeException()); given(this.aspectJCallback.proceedWithObject()).willThrow(new RuntimeException());
assertThatExceptionOfType(RuntimeException.class) assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(() -> this.interceptor.invoke(this.joinPoint, this.aspectJCallback)); .isThrownBy(() -> this.interceptor.invoke(this.joinPoint, this.aspectJCallback));
verifyZeroInteractions(aim); verifyNoMoreInteractions(aim);
} }
// SEC-1967 // SEC-1967

View File

@ -44,7 +44,6 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* @author Luke Taylor * @author Luke Taylor
@ -132,7 +131,7 @@ public class DefaultAuthenticationEventPublisherTests {
this.publisher.setApplicationEventPublisher(appPublisher); this.publisher.setApplicationEventPublisher(appPublisher);
this.publisher.publishAuthenticationFailure(new AuthenticationException("") { this.publisher.publishAuthenticationFailure(new AuthenticationException("") {
}, mock(Authentication.class)); }, mock(Authentication.class));
verifyZeroInteractions(appPublisher); verifyNoMoreInteractions(appPublisher);
} }
@Test @Test

View File

@ -42,7 +42,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -128,7 +128,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests {
this.user.getPassword()); this.user.getPassword());
assertThatExceptionOfType(BadCredentialsException.class) assertThatExceptionOfType(BadCredentialsException.class)
.isThrownBy(() -> this.manager.authenticate(token).block()); .isThrownBy(() -> this.manager.authenticate(token).block());
verifyZeroInteractions(this.userDetailsPasswordService); verifyNoMoreInteractions(this.userDetailsPasswordService);
} }
@Test @Test
@ -141,7 +141,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests {
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user, UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user,
this.user.getPassword()); this.user.getPassword());
Authentication result = this.manager.authenticate(token).block(); Authentication result = this.manager.authenticate(token).block();
verifyZeroInteractions(this.userDetailsPasswordService); verifyNoMoreInteractions(this.userDetailsPasswordService);
} }
@Test @Test
@ -165,7 +165,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests {
UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user, UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user,
this.user.getPassword()); this.user.getPassword());
this.manager.authenticate(token).block(); this.manager.authenticate(token).block();
verifyZeroInteractions(this.postAuthenticationChecks); verifyNoMoreInteractions(this.postAuthenticationChecks);
} }
@Test @Test

View File

@ -60,7 +60,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link DaoAuthenticationProvider}. * Tests {@link DaoAuthenticationProvider}.
@ -301,7 +301,7 @@ public class DaoAuthenticationProviderTests {
given(encoder.matches(any(), any())).willReturn(false); given(encoder.matches(any(), any())).willReturn(false);
given(userDetailsService.loadUserByUsername(any())).willReturn(user); given(userDetailsService.loadUserByUsername(any())).willReturn(user);
assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> provider.authenticate(token)); assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> provider.authenticate(token));
verifyZeroInteractions(passwordManager); verifyNoMoreInteractions(passwordManager);
} }
@Test @Test
@ -320,7 +320,7 @@ public class DaoAuthenticationProviderTests {
given(encoder.upgradeEncoding(any())).willReturn(false); given(encoder.upgradeEncoding(any())).willReturn(false);
given(userDetailsService.loadUserByUsername(any())).willReturn(user); given(userDetailsService.loadUserByUsername(any())).willReturn(user);
Authentication result = provider.authenticate(token); Authentication result = provider.authenticate(token);
verifyZeroInteractions(passwordManager); verifyNoMoreInteractions(passwordManager);
} }
@Test @Test

View File

@ -38,7 +38,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Checks that the embedded version information is up to date. * Checks that the embedded version information is up to date.
@ -94,7 +94,7 @@ public class SpringSecurityCoreVersionTests {
expectSpringSecurityVersionThenReturn(version); expectSpringSecurityVersionThenReturn(version);
expectSpringVersionThenReturn(version); expectSpringVersionThenReturn(version);
performChecks(); performChecks();
verifyZeroInteractions(this.logger); verifyNoMoreInteractions(this.logger);
} }
@Test @Test
@ -103,7 +103,7 @@ public class SpringSecurityCoreVersionTests {
expectSpringSecurityVersionThenReturn(version); expectSpringSecurityVersionThenReturn(version);
expectSpringVersionThenReturn(null); expectSpringVersionThenReturn(null);
performChecks(); performChecks();
verifyZeroInteractions(this.logger); verifyNoMoreInteractions(this.logger);
} }
@Test @Test
@ -139,7 +139,7 @@ public class SpringSecurityCoreVersionTests {
expectSpringVersionThenReturn("2"); expectSpringVersionThenReturn("2");
System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString()); System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString());
performChecks(); performChecks();
verifyZeroInteractions(this.logger); verifyNoMoreInteractions(this.logger);
} }
private String getDisableChecksProperty() { private String getDisableChecksProperty() {

View File

@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -150,7 +150,7 @@ public class DelegatingPasswordEncoderTests {
this.passwordEncoder.setDefaultPasswordEncoderForMatches(this.invalidId); this.passwordEncoder.setDefaultPasswordEncoderForMatches(this.invalidId);
assertThat(this.passwordEncoder.matches(this.rawPassword, encodedPassword)).isFalse(); assertThat(this.passwordEncoder.matches(this.rawPassword, encodedPassword)).isFalse();
verify(this.invalidId).matches(this.rawPassword, encodedPassword); verify(this.invalidId).matches(this.rawPassword, encodedPassword);
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -170,7 +170,7 @@ public class DelegatingPasswordEncoderTests {
given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true); given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true);
assertThat(this.passwordEncoder.matches(this.rawPassword, this.bcryptEncodedPassword)).isTrue(); assertThat(this.passwordEncoder.matches(this.rawPassword, this.bcryptEncodedPassword)).isTrue();
verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword); verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword);
verifyZeroInteractions(this.noop); verifyNoMoreInteractions(this.noop);
} }
@Test @Test
@ -178,7 +178,7 @@ public class DelegatingPasswordEncoderTests {
given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true); given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true);
assertThat(this.onlySuffixPasswordEncoder.matches(this.rawPassword, "bcrypt$" + this.encodedPassword)).isTrue(); assertThat(this.onlySuffixPasswordEncoder.matches(this.rawPassword, "bcrypt$" + this.encodedPassword)).isTrue();
verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword); verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword);
verifyZeroInteractions(this.noop); verifyNoMoreInteractions(this.noop);
} }
@Test @Test
@ -186,7 +186,7 @@ public class DelegatingPasswordEncoderTests {
given(this.noop.matches(this.rawPassword, this.encodedPassword)).willReturn(true); given(this.noop.matches(this.rawPassword, this.encodedPassword)).willReturn(true);
assertThat(this.passwordEncoder.matches(this.rawPassword, this.noopEncodedPassword)).isTrue(); assertThat(this.passwordEncoder.matches(this.rawPassword, this.noopEncodedPassword)).isTrue();
verify(this.noop).matches(this.rawPassword, this.encodedPassword); verify(this.noop).matches(this.rawPassword, this.encodedPassword);
verifyZeroInteractions(this.bcrypt); verifyNoMoreInteractions(this.bcrypt);
} }
@Test @Test
@ -194,7 +194,7 @@ public class DelegatingPasswordEncoderTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{unmapped}" + this.rawPassword)) .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{unmapped}" + this.rawPassword))
.withMessage("There is no PasswordEncoder mapped for the id \"unmapped\""); .withMessage("There is no PasswordEncoder mapped for the id \"unmapped\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -202,7 +202,7 @@ public class DelegatingPasswordEncoderTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{bcrypt" + this.rawPassword)) .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{bcrypt" + this.rawPassword))
.withMessage("There is no PasswordEncoder mapped for the id \"null\""); .withMessage("There is no PasswordEncoder mapped for the id \"null\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -210,7 +210,7 @@ public class DelegatingPasswordEncoderTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "bcrypt}" + this.rawPassword)) .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "bcrypt}" + this.rawPassword))
.withMessage("There is no PasswordEncoder mapped for the id \"null\""); .withMessage("There is no PasswordEncoder mapped for the id \"null\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -218,7 +218,7 @@ public class DelegatingPasswordEncoderTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{}" + this.rawPassword)) .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{}" + this.rawPassword))
.withMessage("There is no PasswordEncoder mapped for the id \"\""); .withMessage("There is no PasswordEncoder mapped for the id \"\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -228,7 +228,7 @@ public class DelegatingPasswordEncoderTests {
() -> this.passwordEncoder.matches(this.rawPassword, "invalid" + this.bcryptEncodedPassword)) () -> this.passwordEncoder.matches(this.rawPassword, "invalid" + this.bcryptEncodedPassword))
.isInstanceOf(IllegalArgumentException.class) .isInstanceOf(IllegalArgumentException.class)
.withMessage("There is no PasswordEncoder mapped for the id \"null\""); .withMessage("There is no PasswordEncoder mapped for the id \"null\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -238,7 +238,7 @@ public class DelegatingPasswordEncoderTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> passwordEncoder.matches(this.rawPassword, this.rawPassword)) .isThrownBy(() -> passwordEncoder.matches(this.rawPassword, this.rawPassword))
.withMessage("There is no PasswordEncoder mapped for the id \"null\""); .withMessage("There is no PasswordEncoder mapped for the id \"null\"");
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -248,7 +248,7 @@ public class DelegatingPasswordEncoderTests {
given(this.invalidId.matches(this.rawPassword, this.encodedPassword)).willReturn(true); given(this.invalidId.matches(this.rawPassword, this.encodedPassword)).willReturn(true);
assertThat(this.passwordEncoder.matches(this.rawPassword, this.encodedPassword)).isTrue(); assertThat(this.passwordEncoder.matches(this.rawPassword, this.encodedPassword)).isTrue();
verify(this.invalidId).matches(this.rawPassword, this.encodedPassword); verify(this.invalidId).matches(this.rawPassword, this.encodedPassword);
verifyZeroInteractions(this.bcrypt, this.noop); verifyNoMoreInteractions(this.bcrypt, this.noop);
} }
@Test @Test
@ -287,7 +287,7 @@ public class DelegatingPasswordEncoderTests {
@Test @Test
public void upgradeEncodingWhenDifferentIdThenTrue() { public void upgradeEncodingWhenDifferentIdThenTrue() {
assertThat(this.passwordEncoder.upgradeEncoding(this.noopEncodedPassword)).isTrue(); assertThat(this.passwordEncoder.upgradeEncoding(this.noopEncodedPassword)).isTrue();
verifyZeroInteractions(this.bcrypt); verifyNoMoreInteractions(this.bcrypt);
} }
} }

View File

@ -11,6 +11,7 @@ dependencies {
api platform("io.projectreactor:reactor-bom:2020.0.21") api platform("io.projectreactor:reactor-bom:2020.0.21")
api platform("io.rsocket:rsocket-bom:1.1.2") api platform("io.rsocket:rsocket-bom:1.1.2")
api platform("org.junit:junit-bom:5.9.0-RC1") api platform("org.junit:junit-bom:5.9.0-RC1")
api platform("org.mockito:mockito-bom:4.7.0")
api platform("org.springframework.data:spring-data-bom:2021.2.2") api platform("org.springframework.data:spring-data-bom:2021.2.2")
api platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion") api platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")
api platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4") api platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")
@ -56,10 +57,13 @@ dependencies {
api "org.hibernate:hibernate-entitymanager:5.6.10.Final" api "org.hibernate:hibernate-entitymanager:5.6.10.Final"
api "org.hsqldb:hsqldb:2.6.1" api "org.hsqldb:hsqldb:2.6.1"
api "org.jasig.cas.client:cas-client-core:3.6.4" api "org.jasig.cas.client:cas-client-core:3.6.4"
<<<<<<< HEAD
api "org.mockito:mockito-core:3.12.4" api "org.mockito:mockito-core:3.12.4"
api "org.mockito:mockito-inline:3.12.4" api "org.mockito:mockito-inline:3.12.4"
api "org.mockito:mockito-junit-jupiter:3.12.4" api "org.mockito:mockito-junit-jupiter:3.12.4"
api "org.openid4java:openid4java-nodeps:0.9.6" api "org.openid4java:openid4java-nodeps:0.9.6"
=======
>>>>>>> 8e018fd921 (Update to mockito 4.7.0)
api "org.opensaml:opensaml-core:$openSamlVersion" api "org.opensaml:opensaml-core:$openSamlVersion"
api "org.opensaml:opensaml-saml-api:$openSamlVersion" api "org.opensaml:opensaml-saml-api:$openSamlVersion"
api "org.opensaml:opensaml-saml-impl:$openSamlVersion" api "org.opensaml:opensaml-saml-impl:$openSamlVersion"

View File

@ -56,7 +56,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests for {@link OAuth2AuthorizationRequestRedirectFilter}. * Tests for {@link OAuth2AuthorizationRequestRedirectFilter}.
@ -150,7 +150,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = mock(FilterChain.class); FilterChain filterChain = mock(FilterChain.class);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value());
assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
} }
@ -164,7 +164,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = mock(FilterChain.class); FilterChain filterChain = mock(FilterChain.class);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?"
+ "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&"
+ "redirect_uri=http://localhost/login/oauth2/code/registration-id"); + "redirect_uri=http://localhost/login/oauth2/code/registration-id");
@ -182,7 +182,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
AuthorizationRequestRepository.class); AuthorizationRequestRepository.class);
this.filter.setAuthorizationRequestRepository(authorizationRequestRepository); this.filter.setAuthorizationRequestRepository(authorizationRequestRepository);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
verify(authorizationRequestRepository).saveAuthorizationRequest(any(OAuth2AuthorizationRequest.class), verify(authorizationRequestRepository).saveAuthorizationRequest(any(OAuth2AuthorizationRequest.class),
any(HttpServletRequest.class), any(HttpServletResponse.class)); any(HttpServletRequest.class), any(HttpServletResponse.class));
} }
@ -230,7 +230,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain filterChain = mock(FilterChain.class); FilterChain filterChain = mock(FilterChain.class);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?"
+ "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&"
+ "redirect_uri=http://localhost/login/oauth2/code/registration-id"); + "redirect_uri=http://localhost/login/oauth2/code/registration-id");
@ -268,7 +268,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver);
filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain);
verify(filterChain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class)); verify(filterChain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value());
assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
} }
@ -294,7 +294,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
given(resolver.resolve(any())).willReturn(result); given(resolver.resolve(any())).willReturn(result);
OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver);
filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?"
+ "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&"
+ "redirect_uri=http://localhost/login/oauth2/code/registration-id&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id&"
@ -335,7 +335,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
given(resolver.resolve(any())).willReturn(result); given(resolver.resolve(any())).willReturn(result);
OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver);
filter.doFilter(request, response, filterChain); filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?"
+ "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&"
+ "redirect_uri=http://localhost/login/oauth2/code/registration-id&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id&"
@ -360,7 +360,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
}; };
this.filter.setAuthorizationRedirectStrategy(customRedirectStrategy); this.filter.setAuthorizationRedirectStrategy(customRedirectStrategy);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_PLAIN_VALUE); assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_PLAIN_VALUE);
assertThat(response.getContentAsString(StandardCharsets.UTF_8)) assertThat(response.getContentAsString(StandardCharsets.UTF_8))

View File

@ -69,7 +69,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests for {@link OAuth2LoginAuthenticationFilter}. * Tests for {@link OAuth2LoginAuthenticationFilter}.
@ -310,7 +310,7 @@ public class OAuth2LoginAuthenticationFilterTests {
this.setUpAuthorizationRequest(request, response, this.registration2, state); this.setUpAuthorizationRequest(request, response, this.registration2, state);
this.setUpAuthenticationResult(this.registration2); this.setUpAuthenticationResult(this.registration2);
this.filter.doFilter(request, response, filterChain); this.filter.doFilter(request, response, filterChain);
verifyZeroInteractions(filterChain); verifyNoMoreInteractions(filterChain);
verify(this.filter).attemptAuthentication(any(HttpServletRequest.class), any(HttpServletResponse.class)); verify(this.filter).attemptAuthentication(any(HttpServletRequest.class), any(HttpServletResponse.class));
} }

View File

@ -113,7 +113,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -846,7 +846,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
// @formatter:on // @formatter:on
List<ClientRequest> requests = this.exchange.getRequests(); List<ClientRequest> requests = this.exchange.getRequests();
assertThat(requests).hasSize(1); assertThat(requests).hasSize(1);
verifyZeroInteractions(this.clientRegistrationRepository, this.authorizedClientRepository); verifyNoMoreInteractions(this.clientRegistrationRepository, this.authorizedClientRepository);
} }
@Test @Test

View File

@ -66,7 +66,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -191,7 +191,7 @@ public class PayloadInterceptorRSocketTests {
.isThrownBy(() -> interceptor.requestResponse(this.payload).block()).isEqualTo(expected); .isThrownBy(() -> interceptor.requestResponse(this.payload).block()).isEqualTo(expected);
verify(this.interceptor).intercept(this.exchange.capture(), any()); verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload); assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verifyZeroInteractions(this.delegate); verifyNoMoreInteractions(this.delegate);
} }
@Test @Test
@ -442,7 +442,7 @@ public class PayloadInterceptorRSocketTests {
.isThrownBy(() -> interceptor.fireAndForget(this.payload).block()).isEqualTo(expected); .isThrownBy(() -> interceptor.fireAndForget(this.payload).block()).isEqualTo(expected);
verify(this.interceptor).intercept(this.exchange.capture(), any()); verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload); assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verifyZeroInteractions(this.interceptor2); verifyNoMoreInteractions(this.interceptor2);
this.voidResult.assertWasNotSubscribed(); this.voidResult.assertWasNotSubscribed();
} }

View File

@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Luke Taylor * @author Luke Taylor
@ -109,7 +109,7 @@ public class FilterChainProxyTests {
this.fcp.doFilter(this.request, this.response, this.chain); this.fcp.doFilter(this.request, this.response, this.chain);
assertThat(this.fcp.getFilterChains()).hasSize(1); assertThat(this.fcp.getFilterChains()).hasSize(1);
assertThat(this.fcp.getFilterChains().get(0).getFilters().get(0)).isSameAs(this.filter); assertThat(this.fcp.getFilterChains().get(0).getFilters().get(0)).isSameAs(this.filter);
verifyZeroInteractions(this.filter); verifyNoMoreInteractions(this.filter);
// The actual filter chain should be invoked though // The actual filter chain should be invoked though
verify(this.chain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class)); verify(this.chain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class));
} }
@ -147,7 +147,7 @@ public class FilterChainProxyTests {
given(this.matcher.matches(any(HttpServletRequest.class))).willReturn(false); given(this.matcher.matches(any(HttpServletRequest.class))).willReturn(false);
this.fcp.doFilter(this.request, this.response, this.chain); this.fcp.doFilter(this.request, this.response, this.chain);
verify(this.matcher).matches(any(FirewalledRequest.class)); verify(this.matcher).matches(any(FirewalledRequest.class));
verifyZeroInteractions(this.filter); verifyNoMoreInteractions(this.filter);
verify(this.chain).doFilter(any(FirewalledRequest.class), any(HttpServletResponse.class)); verify(this.chain).doFilter(any(FirewalledRequest.class), any(HttpServletResponse.class));
} }

View File

@ -36,7 +36,6 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
@ -76,14 +75,14 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests {
@Test @Test
public void permitsAccessIfNoMatchingAttributesAndPublicInvocationsAllowed() { public void permitsAccessIfNoMatchingAttributesAndPublicInvocationsAllowed() {
DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor);
given(this.ods.getAttributes(anyObject())).willReturn(null); given(this.ods.getAttributes(any())).willReturn(null);
assertThat(wipe.isAllowed("/context", "/foo/index.jsp", "GET", mock(Authentication.class))).isTrue(); assertThat(wipe.isAllowed("/context", "/foo/index.jsp", "GET", mock(Authentication.class))).isTrue();
} }
@Test @Test
public void deniesAccessIfNoMatchingAttributesAndPublicInvocationsNotAllowed() { public void deniesAccessIfNoMatchingAttributesAndPublicInvocationsNotAllowed() {
DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor);
given(this.ods.getAttributes(anyObject())).willReturn(null); given(this.ods.getAttributes(any())).willReturn(null);
this.interceptor.setRejectPublicInvocations(true); this.interceptor.setRejectPublicInvocations(true);
assertThat(wipe.isAllowed("/context", "/foo/index.jsp", "GET", mock(Authentication.class))).isFalse(); assertThat(wipe.isAllowed("/context", "/foo/index.jsp", "GET", mock(Authentication.class))).isFalse();
} }
@ -106,8 +105,7 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests {
public void deniesAccessIfAccessDecisionManagerDoes() { public void deniesAccessIfAccessDecisionManagerDoes() {
Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX"); Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX");
DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor);
willThrow(new AccessDeniedException("")).given(this.adm).decide(any(Authentication.class), anyObject(), willThrow(new AccessDeniedException("")).given(this.adm).decide(any(Authentication.class), any(), anyList());
anyList());
assertThat(wipe.isAllowed("/foo/index.jsp", token)).isFalse(); assertThat(wipe.isAllowed("/foo/index.jsp", token)).isFalse();
} }

View File

@ -55,7 +55,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.willThrow; import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link ExceptionTranslationFilter}. * Tests {@link ExceptionTranslationFilter}.
@ -284,7 +284,7 @@ public class ExceptionTranslationFilterTests {
ExceptionTranslationFilter filter = new ExceptionTranslationFilter(this.mockEntryPoint); ExceptionTranslationFilter filter = new ExceptionTranslationFilter(this.mockEntryPoint);
assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain)) assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain))
.withCauseInstanceOf(AccessDeniedException.class); .withCauseInstanceOf(AccessDeniedException.class);
verifyZeroInteractions(this.mockEntryPoint); verifyNoMoreInteractions(this.mockEntryPoint);
} }
@Test @Test

View File

@ -52,7 +52,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link FilterSecurityInterceptor}. * Tests {@link FilterSecurityInterceptor}.
@ -137,7 +137,7 @@ public class FilterSecurityInterceptorTests {
AfterInvocationManager aim = mock(AfterInvocationManager.class); AfterInvocationManager aim = mock(AfterInvocationManager.class);
this.interceptor.setAfterInvocationManager(aim); this.interceptor.setAfterInvocationManager(aim);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> this.interceptor.invoke(fi)); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> this.interceptor.invoke(fi));
verifyZeroInteractions(aim); verifyNoMoreInteractions(aim);
} }
// SEC-1967 // SEC-1967

View File

@ -53,7 +53,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Sergey Bespalov * @author Sergey Bespalov
@ -97,7 +97,7 @@ public class AuthenticationFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(this.authenticationManager); verifyNoMoreInteractions(this.authenticationManager);
verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class));
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
} }
@ -110,7 +110,7 @@ public class AuthenticationFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(this.authenticationManagerResolver); verifyNoMoreInteractions(this.authenticationManagerResolver);
verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class));
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
} }
@ -208,7 +208,7 @@ public class AuthenticationFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
filter.doFilter(request, new MockHttpServletResponse(), chain); filter.doFilter(request, new MockHttpServletResponse(), chain);
verifyZeroInteractions(this.authenticationManagerResolver); verifyNoMoreInteractions(this.authenticationManagerResolver);
verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class));
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
} }
@ -227,7 +227,7 @@ public class AuthenticationFilterTests {
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verify(this.successHandler).onAuthenticationSuccess(any(), any(), any(), eq(authentication)); verify(this.successHandler).onAuthenticationSuccess(any(), any(), any(), eq(authentication));
verifyZeroInteractions(this.failureHandler); verifyNoMoreInteractions(this.failureHandler);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull();
} }
@ -244,7 +244,7 @@ public class AuthenticationFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain)); assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain));
verifyZeroInteractions(this.successHandler); verifyNoMoreInteractions(this.successHandler);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
} }
@ -258,7 +258,7 @@ public class AuthenticationFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain chain = mock(FilterChain.class); FilterChain chain = mock(FilterChain.class);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(this.authenticationConverter, this.authenticationManagerResolver, this.successHandler); verifyNoMoreInteractions(this.authenticationConverter, this.authenticationManagerResolver, this.successHandler);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
} }

View File

@ -35,7 +35,7 @@ import org.springframework.security.core.AuthenticationException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Test class for * Test class for
@ -77,7 +77,7 @@ public class DelegatingAuthenticationFailureHandlerTests {
this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler);
AuthenticationException exception = new AccountExpiredException(""); AuthenticationException exception = new AccountExpiredException("");
this.handler.onAuthenticationFailure(this.request, this.response, exception); this.handler.onAuthenticationFailure(this.request, this.response, exception);
verifyZeroInteractions(this.handler1, this.handler2); verifyNoMoreInteractions(this.handler1, this.handler2);
verify(this.defaultHandler).onAuthenticationFailure(this.request, this.response, exception); verify(this.defaultHandler).onAuthenticationFailure(this.request, this.response, exception);
} }
@ -88,7 +88,7 @@ public class DelegatingAuthenticationFailureHandlerTests {
this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler);
AuthenticationException exception = new BadCredentialsException(""); AuthenticationException exception = new BadCredentialsException("");
this.handler.onAuthenticationFailure(this.request, this.response, exception); this.handler.onAuthenticationFailure(this.request, this.response, exception);
verifyZeroInteractions(this.handler2, this.defaultHandler); verifyNoMoreInteractions(this.handler2, this.defaultHandler);
verify(this.handler1).onAuthenticationFailure(this.request, this.response, exception); verify(this.handler1).onAuthenticationFailure(this.request, this.response, exception);
} }
@ -100,7 +100,7 @@ public class DelegatingAuthenticationFailureHandlerTests {
this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler);
AuthenticationException exception = new CredentialsExpiredException(""); AuthenticationException exception = new CredentialsExpiredException("");
this.handler.onAuthenticationFailure(this.request, this.response, exception); this.handler.onAuthenticationFailure(this.request, this.response, exception);
verifyZeroInteractions(this.handler1, this.defaultHandler); verifyNoMoreInteractions(this.handler1, this.defaultHandler);
verify(this.handler2).onAuthenticationFailure(this.request, this.response, exception); verify(this.handler2).onAuthenticationFailure(this.request, this.response, exception);
} }

View File

@ -32,7 +32,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* DelegatingLogoutSuccessHandlerTests Tests * DelegatingLogoutSuccessHandlerTests Tests
@ -83,7 +83,7 @@ public class DelegatingLogoutSuccessHandlerTests {
given(this.matcher.matches(this.request)).willReturn(true); given(this.matcher.matches(this.request)).willReturn(true);
this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication); this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication);
verify(this.handler).onLogoutSuccess(this.request, this.response, this.authentication); verify(this.handler).onLogoutSuccess(this.request, this.response, this.authentication);
verifyZeroInteractions(this.matcher2, this.handler2, this.defaultHandler); verifyNoMoreInteractions(this.matcher2, this.handler2, this.defaultHandler);
} }
@Test @Test
@ -92,7 +92,7 @@ public class DelegatingLogoutSuccessHandlerTests {
given(this.matcher2.matches(this.request)).willReturn(true); given(this.matcher2.matches(this.request)).willReturn(true);
this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication); this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication);
verify(this.handler2).onLogoutSuccess(this.request, this.response, this.authentication); verify(this.handler2).onLogoutSuccess(this.request, this.response, this.authentication);
verifyZeroInteractions(this.handler, this.defaultHandler); verifyNoMoreInteractions(this.handler, this.defaultHandler);
} }
@Test @Test
@ -100,13 +100,13 @@ public class DelegatingLogoutSuccessHandlerTests {
this.delegatingHandler.setDefaultLogoutSuccessHandler(this.defaultHandler); this.delegatingHandler.setDefaultLogoutSuccessHandler(this.defaultHandler);
this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication); this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication);
verify(this.defaultHandler).onLogoutSuccess(this.request, this.response, this.authentication); verify(this.defaultHandler).onLogoutSuccess(this.request, this.response, this.authentication);
verifyZeroInteractions(this.handler, this.handler2); verifyNoMoreInteractions(this.handler, this.handler2);
} }
@Test @Test
public void onLogoutSuccessNoMatchDefaultNull() throws Exception { public void onLogoutSuccessNoMatchDefaultNull() throws Exception {
this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication); this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication);
verifyZeroInteractions(this.handler, this.handler2, this.defaultHandler); verifyNoMoreInteractions(this.handler, this.handler2, this.defaultHandler);
} }
} }

View File

@ -52,7 +52,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -171,7 +171,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am); filter.setAuthenticationManager(am);
filter.afterPropertiesSet(); filter.afterPropertiesSet();
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(am); verifyNoMoreInteractions(am);
} }
@Test @Test
@ -274,7 +274,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am); filter.setAuthenticationManager(am);
filter.afterPropertiesSet(); filter.afterPropertiesSet();
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(am); verifyNoMoreInteractions(am);
} }
@Test @Test
@ -294,7 +294,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am); filter.setAuthenticationManager(am);
filter.afterPropertiesSet(); filter.afterPropertiesSet();
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(am); verifyNoMoreInteractions(am);
} }
@Test @Test
@ -359,7 +359,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am); filter.setAuthenticationManager(am);
filter.afterPropertiesSet(); filter.afterPropertiesSet();
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(am); verifyNoMoreInteractions(am);
} }
@Test @Test
@ -373,7 +373,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am); filter.setAuthenticationManager(am);
filter.afterPropertiesSet(); filter.afterPropertiesSet();
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(am); verifyNoMoreInteractions(am);
} }
@Test @Test

View File

@ -45,7 +45,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link RememberMeAuthenticationFilter}. * Tests {@link RememberMeAuthenticationFilter}.
@ -151,7 +151,7 @@ public class RememberMeAuthenticationFilterTests {
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
assertThat(response.getRedirectedUrl()).isEqualTo("/target"); assertThat(response.getRedirectedUrl()).isEqualTo("/target");
// Should return after success handler is invoked, so chain should not proceed // Should return after success handler is invoked, so chain should not proceed
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
} }
@Test @Test

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Sergey Bespalov * @author Sergey Bespalov
@ -80,7 +80,7 @@ public class BasicAuthenticationConverterTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("Authorization", "Bearer someOtherToken"); request.addHeader("Authorization", "Bearer someOtherToken");
UsernamePasswordAuthenticationToken authentication = this.converter.convert(request); UsernamePasswordAuthenticationToken authentication = this.converter.convert(request);
verifyZeroInteractions(this.authenticationDetailsSource); verifyNoMoreInteractions(this.authenticationDetailsSource);
assertThat(authentication).isNull(); assertThat(authentication).isNull();
} }

View File

@ -52,7 +52,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link ConcurrentSessionFilter}. * Tests {@link ConcurrentSessionFilter}.
@ -111,7 +111,7 @@ public class ConcurrentSessionFilterTests {
FilterChain fc = mock(FilterChain.class); FilterChain fc = mock(FilterChain.class);
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
// Expect that the filter chain will not be invoked, as we redirect to expiredUrl // Expect that the filter chain will not be invoked, as we redirect to expiredUrl
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
assertThat(response.getRedirectedUrl()).isEqualTo("/expired.jsp"); assertThat(response.getRedirectedUrl()).isEqualTo("/expired.jsp");
} }
@ -128,7 +128,7 @@ public class ConcurrentSessionFilterTests {
ConcurrentSessionFilter filter = new ConcurrentSessionFilter(registry); ConcurrentSessionFilter filter = new ConcurrentSessionFilter(registry);
FilterChain fc = mock(FilterChain.class); FilterChain fc = mock(FilterChain.class);
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
assertThat(response.getContentAsString()) assertThat(response.getContentAsString())
.isEqualTo("This session has been expired (possibly due to multiple concurrent logins being " .isEqualTo("This session has been expired (possibly due to multiple concurrent logins being "
+ "attempted as the same user)."); + "attempted as the same user).");

View File

@ -49,7 +49,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -129,7 +129,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class)); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
@Test @Test
@ -141,7 +141,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class)); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
@Test @Test
@ -153,7 +153,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class)); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
@Test @Test
@ -167,7 +167,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class)); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
@Test @Test
@ -178,7 +178,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
@Test @Test
@ -189,7 +189,7 @@ public class CsrfFilterTests {
assertToken(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertToken(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertToken(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertToken(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
@Test @Test
@ -201,7 +201,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
@Test @Test
@ -215,7 +215,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
@Test @Test
@ -227,7 +227,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
verify(this.tokenRepository, never()).saveToken(any(CsrfToken.class), any(HttpServletRequest.class), verify(this.tokenRepository, never()).saveToken(any(CsrfToken.class), any(HttpServletRequest.class),
any(HttpServletResponse.class)); any(HttpServletResponse.class));
} }
@ -244,7 +244,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(HttpServletResponse.class.getName())).isEqualTo(this.response); assertThat(this.request.getAttribute(HttpServletResponse.class.getName())).isEqualTo(this.response);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verify(this.tokenRepository).saveToken(this.token, this.request, this.response); verify(this.tokenRepository).saveToken(this.token, this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
@Test @Test
@ -257,7 +257,7 @@ public class CsrfFilterTests {
this.request.setMethod(method); this.request.setMethod(method);
this.filter.doFilter(this.request, this.response, this.filterChain); this.filter.doFilter(this.request, this.response, this.filterChain);
verify(this.filterChain).doFilter(this.request, this.response); verify(this.filterChain).doFilter(this.request, this.response);
verifyZeroInteractions(this.deniedHandler); verifyNoMoreInteractions(this.deniedHandler);
} }
} }
@ -278,7 +278,7 @@ public class CsrfFilterTests {
this.filter.doFilter(this.request, this.response, this.filterChain); this.filter.doFilter(this.request, this.response, this.filterChain);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), verify(this.deniedHandler).handle(eq(this.request), eq(this.response),
any(InvalidCsrfTokenException.class)); any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
} }
@ -293,7 +293,7 @@ public class CsrfFilterTests {
this.filter.doFilter(this.request, this.response, this.filterChain); this.filter.doFilter(this.request, this.response, this.filterChain);
verify(this.deniedHandler).handle(eq(this.request), eq(this.response), verify(this.deniedHandler).handle(eq(this.request), eq(this.response),
any(InvalidCsrfTokenException.class)); any(InvalidCsrfTokenException.class));
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
} }
@ -307,7 +307,7 @@ public class CsrfFilterTests {
assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token);
assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token);
assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_FORBIDDEN); assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_FORBIDDEN);
verifyZeroInteractions(this.filterChain); verifyNoMoreInteractions(this.filterChain);
} }
@Test @Test
@ -318,7 +318,7 @@ public class CsrfFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
CsrfFilter.skipRequest(request); CsrfFilter.skipRequest(request);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
verifyZeroInteractions(repository); verifyNoMoreInteractions(repository);
} }
// gh-9561 // gh-9561

View File

@ -32,7 +32,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -82,7 +82,7 @@ public class LazyCsrfTokenRepositoryTests {
@Test @Test
public void saveNonNullDoesNothing() { public void saveNonNullDoesNothing() {
this.repository.saveToken(this.token, this.request, this.response); this.repository.saveToken(this.token, this.request, this.response);
verifyZeroInteractions(this.delegate); verifyNoMoreInteractions(this.delegate);
} }
@Test @Test

View File

@ -38,7 +38,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* Tests for the {@code HeadersFilter} * Tests for the {@code HeadersFilter}
@ -92,7 +91,7 @@ public class HeaderWriterFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
filter.doFilter(request, response, (request1, response1) -> { filter.doFilter(request, response, (request1, response1) -> {
verifyZeroInteractions(HeaderWriterFilterTests.this.writer1); verifyNoMoreInteractions(HeaderWriterFilterTests.this.writer1);
response1.flushBuffer(); response1.flushBuffer();
verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class), verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class),
any(HttpServletResponse.class)); any(HttpServletResponse.class));
@ -107,7 +106,7 @@ public class HeaderWriterFilterTests {
MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpServletRequest mockRequest = new MockHttpServletRequest();
MockHttpServletResponse mockResponse = new MockHttpServletResponse(); MockHttpServletResponse mockResponse = new MockHttpServletResponse();
filter.doFilter(mockRequest, mockResponse, (request, response) -> { filter.doFilter(mockRequest, mockResponse, (request, response) -> {
verifyZeroInteractions(HeaderWriterFilterTests.this.writer1); verifyNoMoreInteractions(HeaderWriterFilterTests.this.writer1);
request.getRequestDispatcher("/").include(request, response); request.getRequestDispatcher("/").include(request, response);
verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class), verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class),
any(HttpServletResponse.class)); any(HttpServletResponse.class));

View File

@ -30,7 +30,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -59,7 +59,7 @@ public class DefaultServerRedirectStrategyTests {
@Test @Test
public void sendRedirectWhenNoSubscribersThenNoActions() { public void sendRedirectWhenNoSubscribersThenNoActions() {
this.strategy.sendRedirect(this.exchange, this.location); this.strategy.sendRedirect(this.exchange, this.location);
verifyZeroInteractions(this.exchange); verifyNoMoreInteractions(this.exchange);
} }
@Test @Test

View File

@ -34,7 +34,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -71,7 +71,7 @@ public class DelegatingServerAuthenticationEntryPointTests {
new DelegateEntry(this.matcher2, this.delegate2)); new DelegateEntry(this.matcher2, this.delegate2));
Mono<Void> actualResult = this.entryPoint.commence(this.exchange, this.e); Mono<Void> actualResult = this.entryPoint.commence(this.exchange, this.e);
actualResult.block(); actualResult.block();
verifyZeroInteractions(this.delegate1); verifyNoMoreInteractions(this.delegate1);
verify(this.delegate2).commence(this.exchange, this.e); verify(this.delegate2).commence(this.exchange, this.e);
} }
@ -82,7 +82,7 @@ public class DelegatingServerAuthenticationEntryPointTests {
new DelegateEntry(this.matcher1, this.delegate1)); new DelegateEntry(this.matcher1, this.delegate1));
this.entryPoint.commence(this.exchange, this.e).block(); this.entryPoint.commence(this.exchange, this.e).block();
assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
verifyZeroInteractions(this.delegate1); verifyNoMoreInteractions(this.delegate1);
} }
} }

View File

@ -42,7 +42,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -88,7 +88,7 @@ public class AuthenticationWebFilterTests {
EntityExchangeResult<String> result = client.get().uri("/").exchange().expectStatus().isOk() EntityExchangeResult<String> result = client.get().uri("/").exchange().expectStatus().isOk()
.expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"))
.returnResult(); .returnResult();
verifyZeroInteractions(this.authenticationManager); verifyNoMoreInteractions(this.authenticationManager);
assertThat(result.getResponseCookies()).isEmpty(); assertThat(result.getResponseCookies()).isEmpty();
} }
@ -99,7 +99,7 @@ public class AuthenticationWebFilterTests {
EntityExchangeResult<String> result = client.get().uri("/").exchange().expectStatus().isOk() EntityExchangeResult<String> result = client.get().uri("/").exchange().expectStatus().isOk()
.expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"))
.returnResult(); .returnResult();
verifyZeroInteractions(this.authenticationManagerResolver); verifyNoMoreInteractions(this.authenticationManagerResolver);
assertThat(result.getResponseCookies()).isEmpty(); assertThat(result.getResponseCookies()).isEmpty();
} }
@ -162,7 +162,7 @@ public class AuthenticationWebFilterTests {
client.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class) client.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class)
.consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")).returnResult(); .consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")).returnResult();
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.authenticationManager, this.successHandler, this.failureHandler); verifyNoMoreInteractions(this.authenticationManager, this.successHandler, this.failureHandler);
} }
@Test @Test
@ -171,7 +171,7 @@ public class AuthenticationWebFilterTests {
WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build();
client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty();
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.authenticationManager, this.successHandler, this.failureHandler); verifyNoMoreInteractions(this.authenticationManager, this.successHandler, this.failureHandler);
} }
@Test @Test
@ -185,7 +185,7 @@ public class AuthenticationWebFilterTests {
client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty(); client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty();
verify(this.successHandler).onAuthenticationSuccess(any(), eq(authentication.block())); verify(this.successHandler).onAuthenticationSuccess(any(), eq(authentication.block()));
verify(this.securityContextRepository).save(any(), any()); verify(this.securityContextRepository).save(any(), any());
verifyZeroInteractions(this.failureHandler); verifyNoMoreInteractions(this.failureHandler);
} }
@Test @Test
@ -196,7 +196,7 @@ public class AuthenticationWebFilterTests {
WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build();
client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty();
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.successHandler, this.failureHandler); verifyNoMoreInteractions(this.successHandler, this.failureHandler);
} }
@Test @Test
@ -208,7 +208,7 @@ public class AuthenticationWebFilterTests {
.expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok"))
.returnResult(); .returnResult();
assertThat(result.getResponseCookies()).isEmpty(); assertThat(result.getResponseCookies()).isEmpty();
verifyZeroInteractions(this.authenticationConverter, this.authenticationManager, this.successHandler); verifyNoMoreInteractions(this.authenticationConverter, this.authenticationManager, this.successHandler);
} }
@Test @Test
@ -222,7 +222,7 @@ public class AuthenticationWebFilterTests {
client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty(); client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty();
verify(this.failureHandler).onAuthenticationFailure(any(), any()); verify(this.failureHandler).onAuthenticationFailure(any(), any());
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.successHandler); verifyNoMoreInteractions(this.successHandler);
} }
@Test @Test
@ -233,7 +233,7 @@ public class AuthenticationWebFilterTests {
WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build();
client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty();
verify(this.securityContextRepository, never()).save(any(), any()); verify(this.securityContextRepository, never()).save(any(), any());
verifyZeroInteractions(this.successHandler, this.failureHandler); verifyNoMoreInteractions(this.successHandler, this.failureHandler);
} }
@Test @Test

View File

@ -30,7 +30,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -49,7 +49,7 @@ public class HttpBasicServerAuthenticationEntryPointTests {
@Test @Test
public void commenceWhenNoSubscribersThenNoActions() { public void commenceWhenNoSubscribersThenNoActions() {
this.entryPoint.commence(this.exchange, this.exception); this.entryPoint.commence(this.exchange, this.exception);
verifyZeroInteractions(this.exchange); verifyNoMoreInteractions(this.exchange);
} }
@Test @Test

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -81,7 +81,7 @@ public class DelegatingReactiveAuthorizationManagerTests {
given(this.delegate1.check(eq(this.authentication), any(AuthorizationContext.class))) given(this.delegate1.check(eq(this.authentication), any(AuthorizationContext.class)))
.willReturn(Mono.just(this.decision)); .willReturn(Mono.just(this.decision));
assertThat(this.manager.check(this.authentication, this.exchange).block()).isEqualTo(this.decision); assertThat(this.manager.check(this.authentication, this.exchange).block()).isEqualTo(this.decision);
verifyZeroInteractions(this.match2, this.delegate2); verifyNoMoreInteractions(this.match2, this.delegate2);
} }
@Test @Test
@ -91,7 +91,7 @@ public class DelegatingReactiveAuthorizationManagerTests {
given(this.delegate2.check(eq(this.authentication), any(AuthorizationContext.class))) given(this.delegate2.check(eq(this.authentication), any(AuthorizationContext.class)))
.willReturn(Mono.just(this.decision)); .willReturn(Mono.just(this.decision));
assertThat(this.manager.check(this.authentication, this.exchange).block()).isEqualTo(this.decision); assertThat(this.manager.check(this.authentication, this.exchange).block()).isEqualTo(this.decision);
verifyZeroInteractions(this.delegate1); verifyNoMoreInteractions(this.delegate1);
} }
} }

View File

@ -29,7 +29,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -55,7 +55,7 @@ public class HttpStatusServerAccessDeniedHandlerTests {
@Test @Test
public void commenceWhenNoSubscribersThenNoActions() { public void commenceWhenNoSubscribersThenNoActions() {
this.handler.handle(this.exchange, this.exception); this.handler.handle(this.exchange, this.exception);
verifyZeroInteractions(this.exchange); verifyNoMoreInteractions(this.exchange);
} }
@Test @Test

View File

@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -164,7 +164,7 @@ public class CsrfWebFilterTests {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.post("/post").build()); MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.post("/post").build());
CsrfWebFilter.skipExchange(exchange); CsrfWebFilter.skipExchange(exchange);
this.csrfFilter.filter(exchange, this.chain).block(); this.csrfFilter.filter(exchange, this.chain).block();
verifyZeroInteractions(matcher); verifyNoMoreInteractions(matcher);
} }
@Test @Test

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -108,7 +108,7 @@ public class PathMatcherServerWebExchangeMatcherTests {
assertThat(this.exchange.getRequest().getMethod()).isNotEqualTo(method); assertThat(this.exchange.getRequest().getMethod()).isNotEqualTo(method);
this.matcher = new PathPatternParserServerWebExchangeMatcher(this.pattern, method); this.matcher = new PathPatternParserServerWebExchangeMatcher(this.pattern, method);
assertThat(this.matcher.matches(this.exchange).block().isMatch()).isFalse(); assertThat(this.matcher.matches(this.exchange).block().isMatch()).isFalse();
verifyZeroInteractions(this.pattern); verifyNoMoreInteractions(this.pattern);
} }
} }

View File

@ -25,7 +25,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -69,7 +69,7 @@ public class ServerWebExchangeMatchersTests {
public void anyExchangeWhenMockThenMatches() { public void anyExchangeWhenMockThenMatches() {
ServerWebExchange mockExchange = mock(ServerWebExchange.class); ServerWebExchange mockExchange = mock(ServerWebExchange.class);
assertThat(ServerWebExchangeMatchers.anyExchange().matches(mockExchange).block().isMatch()).isTrue(); assertThat(ServerWebExchangeMatchers.anyExchange().matches(mockExchange).block().isMatch()).isTrue();
verifyZeroInteractions(mockExchange); verifyNoMoreInteractions(mockExchange);
} }
/** /**

View File

@ -36,7 +36,7 @@ import org.springframework.web.servlet.handler.RequestMatchResult;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* @author Rob Winch * @author Rob Winch
@ -161,7 +161,7 @@ public class MvcRequestMatcherTests {
this.matcher.setMethod(HttpMethod.POST); this.matcher.setMethod(HttpMethod.POST);
assertThat(this.matcher.matches(this.request)).isFalse(); assertThat(this.matcher.matches(this.request)).isFalse();
// method compare should be done first since faster // method compare should be done first since faster
verifyZeroInteractions(this.introspector); verifyNoMoreInteractions(this.introspector);
} }
/** /**
@ -175,7 +175,7 @@ public class MvcRequestMatcherTests {
this.request.setMethod("invalid"); this.request.setMethod("invalid");
assertThat(this.matcher.matches(this.request)).isFalse(); assertThat(this.matcher.matches(this.request)).isFalse();
// method compare should be done first since faster // method compare should be done first since faster
verifyZeroInteractions(this.introspector); verifyNoMoreInteractions(this.introspector);
} }
@Test @Test

View File

@ -61,7 +61,7 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
/** /**
* Tests {@link SecurityContextHolderAwareRequestFilter}. * Tests {@link SecurityContextHolderAwareRequestFilter}.
@ -129,7 +129,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
assertThat(wrappedRequest().authenticate(this.response)).isFalse(); assertThat(wrappedRequest().authenticate(this.response)).isFalse();
verify(this.authenticationEntryPoint).commence(eq(this.requestCaptor.getValue()), eq(this.response), verify(this.authenticationEntryPoint).commence(eq(this.requestCaptor.getValue()), eq(this.response),
any(AuthenticationException.class)); any(AuthenticationException.class));
verifyZeroInteractions(this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler);
verify(this.request, times(0)).authenticate(any(HttpServletResponse.class)); verify(this.request, times(0)).authenticate(any(HttpServletResponse.class));
} }
@ -138,7 +138,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
SecurityContextHolder.getContext() SecurityContextHolder.getContext()
.setAuthentication(new TestingAuthenticationToken("test", "password", "ROLE_USER")); .setAuthentication(new TestingAuthenticationToken("test", "password", "ROLE_USER"));
assertThat(wrappedRequest().authenticate(this.response)).isTrue(); assertThat(wrappedRequest().authenticate(this.response)).isTrue();
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
verify(this.request, times(0)).authenticate(any(HttpServletResponse.class)); verify(this.request, times(0)).authenticate(any(HttpServletResponse.class));
} }
@ -148,7 +148,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
this.filter.afterPropertiesSet(); this.filter.afterPropertiesSet();
assertThat(wrappedRequest().authenticate(this.response)).isFalse(); assertThat(wrappedRequest().authenticate(this.response)).isFalse();
verify(this.request).authenticate(this.response); verify(this.request).authenticate(this.response);
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
} }
@Test @Test
@ -158,7 +158,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
this.filter.afterPropertiesSet(); this.filter.afterPropertiesSet();
assertThat(wrappedRequest().authenticate(this.response)).isTrue(); assertThat(wrappedRequest().authenticate(this.response)).isTrue();
verify(this.request).authenticate(this.response); verify(this.request).authenticate(this.response);
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
} }
@Test @Test
@ -168,7 +168,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
.willReturn(expectedAuth); .willReturn(expectedAuth);
wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials())); wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials()));
assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth); assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth);
verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler);
verify(this.request, times(0)).login(anyString(), anyString()); verify(this.request, times(0)).login(anyString(), anyString());
} }
@ -180,7 +180,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
assertThatExceptionOfType(ServletException.class).isThrownBy( assertThatExceptionOfType(ServletException.class).isThrownBy(
() -> wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials()))); () -> wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials())));
assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth); assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth);
verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler);
verify(this.request, times(0)).login(anyString(), anyString()); verify(this.request, times(0)).login(anyString(), anyString());
} }
@ -192,7 +192,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
assertThatExceptionOfType(ServletException.class) assertThatExceptionOfType(ServletException.class)
.isThrownBy(() -> wrappedRequest().login("invalid", "credentials")).withCause(authException); .isThrownBy(() -> wrappedRequest().login("invalid", "credentials")).withCause(authException);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull();
verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler);
verify(this.request, times(0)).login(anyString(), anyString()); verify(this.request, times(0)).login(anyString(), anyString());
} }
@ -204,7 +204,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
String password = "password"; String password = "password";
wrappedRequest().login(username, password); wrappedRequest().login(username, password);
verify(this.request).login(username, password); verify(this.request).login(username, password);
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
} }
@Test @Test
@ -217,7 +217,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
willThrow(authException).given(this.request).login(username, password); willThrow(authException).given(this.request).login(username, password);
assertThatExceptionOfType(ServletException.class).isThrownBy(() -> wrappedRequest().login(username, password)) assertThatExceptionOfType(ServletException.class).isThrownBy(() -> wrappedRequest().login(username, password))
.isEqualTo(authException); .isEqualTo(authException);
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
} }
@Test @Test
@ -248,7 +248,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
HttpServletRequest wrappedRequest = wrappedRequest(); HttpServletRequest wrappedRequest = wrappedRequest();
wrappedRequest.logout(); wrappedRequest.logout();
verify(this.logoutHandler).logout(wrappedRequest, this.response, expectedAuth); verify(this.logoutHandler).logout(wrappedRequest, this.response, expectedAuth);
verifyZeroInteractions(this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler);
verify(this.request, times(0)).logout(); verify(this.request, times(0)).logout();
} }
@ -258,7 +258,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
this.filter.afterPropertiesSet(); this.filter.afterPropertiesSet();
wrappedRequest().logout(); wrappedRequest().logout();
verify(this.request).logout(); verify(this.request).logout();
verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler);
} }
// gh-3780 // gh-3780
@ -279,7 +279,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
Runnable runnable = () -> { Runnable runnable = () -> {
}; };
wrappedRequest().getAsyncContext().start(runnable); wrappedRequest().getAsyncContext().start(runnable);
verifyZeroInteractions(this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler);
verify(asyncContext).start(runnableCaptor.capture()); verify(asyncContext).start(runnableCaptor.capture());
DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor
.getValue(); .getValue();
@ -299,7 +299,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
Runnable runnable = () -> { Runnable runnable = () -> {
}; };
wrappedRequest().startAsync().start(runnable); wrappedRequest().startAsync().start(runnable);
verifyZeroInteractions(this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler);
verify(asyncContext).start(runnableCaptor.capture()); verify(asyncContext).start(runnableCaptor.capture());
DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor
.getValue(); .getValue();
@ -319,7 +319,7 @@ public class SecurityContextHolderAwareRequestFilterTests {
Runnable runnable = () -> { Runnable runnable = () -> {
}; };
wrappedRequest().startAsync(this.request, this.response).start(runnable); wrappedRequest().startAsync(this.request, this.response).start(runnable);
verifyZeroInteractions(this.authenticationManager, this.logoutHandler); verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler);
verify(asyncContext).start(runnableCaptor.capture()); verify(asyncContext).start(runnableCaptor.capture());
DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor
.getValue(); .getValue();

View File

@ -43,7 +43,6 @@ import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* @author Luke Taylor * @author Luke Taylor
@ -76,7 +75,7 @@ public class SessionManagementFilterTests {
HttpServletRequest request = new MockHttpServletRequest(); HttpServletRequest request = new MockHttpServletRequest();
authenticateUser(); authenticateUser();
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
verifyZeroInteractions(strategy); verifyNoMoreInteractions(strategy);
} }
@Test @Test
@ -86,7 +85,7 @@ public class SessionManagementFilterTests {
SessionManagementFilter filter = new SessionManagementFilter(repo, strategy); SessionManagementFilter filter = new SessionManagementFilter(repo, strategy);
HttpServletRequest request = new MockHttpServletRequest(); HttpServletRequest request = new MockHttpServletRequest();
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
verifyZeroInteractions(strategy); verifyNoMoreInteractions(strategy);
} }
@Test @Test
@ -121,7 +120,7 @@ public class SessionManagementFilterTests {
willThrow(exception).given(strategy).onAuthentication(SecurityContextHolder.getContext().getAuthentication(), willThrow(exception).given(strategy).onAuthentication(SecurityContextHolder.getContext().getAuthentication(),
request, response); request, response);
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
verify(failureHandler).onAuthenticationFailure(request, response, exception); verify(failureHandler).onAuthenticationFailure(request, response, exception);
} }
@ -146,7 +145,7 @@ public class SessionManagementFilterTests {
filter.setInvalidSessionStrategy(iss); filter.setInvalidSessionStrategy(iss);
FilterChain fc = mock(FilterChain.class); FilterChain fc = mock(FilterChain.class);
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
assertThat(response.getRedirectedUrl()).isEqualTo("/timedOut"); assertThat(response.getRedirectedUrl()).isEqualTo("/timedOut");
} }
@ -172,7 +171,7 @@ public class SessionManagementFilterTests {
filter.setInvalidSessionStrategy(iss); filter.setInvalidSessionStrategy(iss);
FilterChain fc = mock(FilterChain.class); FilterChain fc = mock(FilterChain.class);
filter.doFilter(request, response, fc); filter.doFilter(request, response, fc);
verifyZeroInteractions(fc); verifyNoMoreInteractions(fc);
assertThat(response.getRedirectedUrl()).isEqualTo("/requested"); assertThat(response.getRedirectedUrl()).isEqualTo("/requested");
} }