From 2fb625db8450f5a2423befc1a6b80afb9055cd28 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 23 Aug 2022 13:05:29 -0500 Subject: [PATCH] Remove mockito deprecations Issue gh-11748 --- .../AclPermissionCacheOptimizerTests.java | 4 +-- .../config/SecurityNamespaceHandlerTests.java | 4 +-- .../OAuth2ClientConfigurationTests.java | 4 +-- .../configurers/NamespaceRememberMeTests.java | 4 +-- .../DefaultFilterChainValidatorTests.java | 3 +- .../config/http/WebConfigUtilsTests.java | 4 +-- .../config/web/server/FormLoginTests.java | 4 +-- .../web/server/ServerHttpSecurityTests.java | 6 ++-- .../MethodSecurityInterceptorTests.java | 4 +-- ...AspectJMethodSecurityInterceptorTests.java | 4 +-- ...aultAuthenticationEventPublisherTests.java | 3 +- ...oryReactiveAuthenticationManagerTests.java | 8 ++--- .../dao/DaoAuthenticationProviderTests.java | 6 ++-- .../core/SpringSecurityCoreVersionTests.java | 8 ++--- .../DelegatingPasswordEncoderTests.java | 26 +++++++-------- ...thorizationRequestRedirectFilterTests.java | 18 +++++------ .../OAuth2LoginAuthenticationFilterTests.java | 4 +-- ...izedClientExchangeFilterFunctionTests.java | 4 +-- .../core/PayloadInterceptorRSocketTests.java | 6 ++-- .../security/web/FilterChainProxyTests.java | 6 ++-- ...tWebInvocationPrivilegeEvaluatorTests.java | 8 ++--- .../ExceptionTranslationFilterTests.java | 4 +-- .../FilterSecurityInterceptorTests.java | 4 +-- .../AuthenticationFilterTests.java | 14 ++++---- ...tingAuthenticationFailureHandlerTests.java | 8 ++--- .../DelegatingLogoutSuccessHandlerTests.java | 10 +++--- ...PreAuthenticatedProcessingFilterTests.java | 12 +++---- .../RememberMeAuthenticationFilterTests.java | 4 +-- .../BasicAuthenticationConverterTests.java | 4 +-- .../ConcurrentSessionFilterTests.java | 6 ++-- .../security/web/csrf/CsrfFilterTests.java | 32 +++++++++---------- .../csrf/LazyCsrfTokenRepositoryTests.java | 4 +-- .../web/header/HeaderWriterFilterTests.java | 5 ++- .../DefaultServerRedirectStrategyTests.java | 4 +-- ...ngServerAuthenticationEntryPointTests.java | 6 ++-- .../AuthenticationWebFilterTests.java | 20 ++++++------ ...icServerAuthenticationEntryPointTests.java | 4 +-- ...tingReactiveAuthorizationManagerTests.java | 6 ++-- ...pStatusServerAccessDeniedHandlerTests.java | 4 +-- .../web/server/csrf/CsrfWebFilterTests.java | 4 +-- ...hMatcherServerWebExchangeMatcherTests.java | 4 +-- .../ServerWebExchangeMatchersTests.java | 4 +-- .../util/matcher/MvcRequestMatcherTests.java | 6 ++-- ...yContextHolderAwareRequestFilterTests.java | 30 ++++++++--------- .../session/SessionManagementFilterTests.java | 11 +++---- 45 files changed, 171 insertions(+), 177 deletions(-) diff --git a/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java b/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java index 97d7f4f721..337df76d5c 100644 --- a/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java +++ b/acl/src/test/java/org/springframework/security/acls/AclPermissionCacheOptimizerTests.java @@ -34,7 +34,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Luke Taylor @@ -68,7 +68,7 @@ public class AclPermissionCacheOptimizerTests { pco.setObjectIdentityRetrievalStrategy(oids); pco.setSidRetrievalStrategy(sids); pco.cachePermissionsFor(mock(Authentication.class), Collections.emptyList()); - verifyZeroInteractions(service, sids, oids); + verifyNoMoreInteractions(service, sids, oids); } } diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java index 31d31c7a93..46a4aaa010 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Luke Taylor @@ -89,7 +89,7 @@ public class SecurityNamespaceHandlerTests { ReflectionTestUtils.setField(handler, "logger", logger); expectClassUtilsForNameThrowsNoClassDefFoundError(className); handler.init(); - verifyZeroInteractions(logger); + verifyNoMoreInteractions(logger); } @Test diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java index d70f27453c..491b05429a 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configuration/OAuth2ClientConfigurationTests.java @@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; 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.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -102,7 +102,7 @@ public class OAuth2ClientConfigurationTests { .andExpect(status().isOk()) .andExpect(content().string("resolved")); // @formatter:on - verifyZeroInteractions(accessTokenResponseClient); + verifyNoMoreInteractions(accessTokenResponseClient); } @Test diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceRememberMeTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceRememberMeTests.java index 9487d6ee0a..1a6ffbce86 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceRememberMeTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceRememberMeTests.java @@ -57,7 +57,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; 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.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -129,7 +129,7 @@ public class NamespaceRememberMeTests { AuthSuccessConfig.SUCCESS_HANDLER = mock(AuthenticationSuccessHandler.class); this.spring.register(AuthSuccessConfig.class).autowire(); 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"); assertThat(rememberMe).isNotNull(); this.mvc.perform(get("/somewhere").cookie(rememberMe)); diff --git a/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java b/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java index 560f9e0bde..06e1259bb5 100644 --- a/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java +++ b/config/src/test/java/org/springframework/security/config/http/DefaultFilterChainValidatorTests.java @@ -45,7 +45,6 @@ import org.springframework.security.web.util.matcher.AnyRequestMatcher; import org.springframework.test.util.ReflectionTestUtils; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.atLeastOnce; @@ -104,7 +103,7 @@ public class DefaultFilterChainValidatorTests { @Test public void validateCheckLoginPageIsntProtectedThrowsIllegalArgumentException() { 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)); this.validator.validate(this.chain); verify(this.logger).info( diff --git a/config/src/test/java/org/springframework/security/config/http/WebConfigUtilsTests.java b/config/src/test/java/org/springframework/security/config/http/WebConfigUtilsTests.java index 3682195fde..567c1d6880 100644 --- a/config/src/test/java/org/springframework/security/config/http/WebConfigUtilsTests.java +++ b/config/src/test/java/org/springframework/security/config/http/WebConfigUtilsTests.java @@ -23,7 +23,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.xml.ParserContext; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; @ExtendWith(MockitoExtension.class) public class WebConfigUtilsTests { @@ -38,7 +38,7 @@ public class WebConfigUtilsTests { public void validateHttpRedirectSpELNoParserWarning() { WebConfigUtils.validateHttpRedirect("#{T(org.springframework.security.config.http.WebConfigUtilsTest).URL}", this.parserContext, "fakeSource"); - verifyZeroInteractions(this.parserContext); + verifyNoMoreInteractions(this.parserContext); } } diff --git a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java index f737516bf2..3e9f76551d 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java @@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; 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; /** @@ -294,7 +294,7 @@ public class FormLoginTests { .submit(HomePage.class); // @formatter:on homePage.assertAt(); - verifyZeroInteractions(defaultAuthenticationManager); + verifyNoMoreInteractions(defaultAuthenticationManager); } @Test diff --git a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java index cf393366ee..5376ac9858 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java @@ -85,7 +85,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; 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; /** @@ -409,7 +409,7 @@ public class ServerHttpSecurityTests { .expectStatus().isOk() .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")); // @formatter:on - verifyZeroInteractions(this.authenticationManager); + verifyNoMoreInteractions(this.authenticationManager); } @Test @@ -438,7 +438,7 @@ public class ServerHttpSecurityTests { .expectStatus().isOk() .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")); // @formatter:on - verifyZeroInteractions(this.authenticationManager); + verifyNoMoreInteractions(this.authenticationManager); verify(customAuthenticationManager).authenticate(any(Authentication.class)); } diff --git a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java index a5096f83af..7cb627c169 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aopalliance/MethodSecurityInterceptorTests.java @@ -57,7 +57,7 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link MethodSecurityInterceptor}. @@ -318,7 +318,7 @@ public class MethodSecurityInterceptorTests { this.interceptor.setAfterInvocationManager(aim); given(mi.proceed()).willThrow(new Throwable()); assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.interceptor.invoke(mi)); - verifyZeroInteractions(aim); + verifyNoMoreInteractions(aim); } void mdsReturnsNull() { diff --git a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java index cb7f742259..21417d78a7 100644 --- a/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java +++ b/core/src/test/java/org/springframework/security/access/intercept/aspectj/AspectJMethodSecurityInterceptorTests.java @@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link AspectJMethodSecurityInterceptor}. @@ -154,7 +154,7 @@ public class AspectJMethodSecurityInterceptorTests { given(this.aspectJCallback.proceedWithObject()).willThrow(new RuntimeException()); assertThatExceptionOfType(RuntimeException.class) .isThrownBy(() -> this.interceptor.invoke(this.joinPoint, this.aspectJCallback)); - verifyZeroInteractions(aim); + verifyNoMoreInteractions(aim); } // SEC-1967 diff --git a/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java b/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java index 0010f96431..2eec7d4e9e 100644 --- a/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java +++ b/core/src/test/java/org/springframework/security/authentication/DefaultAuthenticationEventPublisherTests.java @@ -44,7 +44,6 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * @author Luke Taylor @@ -132,7 +131,7 @@ public class DefaultAuthenticationEventPublisherTests { this.publisher.setApplicationEventPublisher(appPublisher); this.publisher.publishAuthenticationFailure(new AuthenticationException("") { }, mock(Authentication.class)); - verifyZeroInteractions(appPublisher); + verifyNoMoreInteractions(appPublisher); } @Test diff --git a/core/src/test/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManagerTests.java b/core/src/test/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManagerTests.java index c8f39d52e3..b7cdf7989f 100644 --- a/core/src/test/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManagerTests.java +++ b/core/src/test/java/org/springframework/security/authentication/UserDetailsRepositoryReactiveAuthenticationManagerTests.java @@ -42,7 +42,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -128,7 +128,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests { this.user.getPassword()); assertThatExceptionOfType(BadCredentialsException.class) .isThrownBy(() -> this.manager.authenticate(token).block()); - verifyZeroInteractions(this.userDetailsPasswordService); + verifyNoMoreInteractions(this.userDetailsPasswordService); } @Test @@ -141,7 +141,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests { UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user, this.user.getPassword()); Authentication result = this.manager.authenticate(token).block(); - verifyZeroInteractions(this.userDetailsPasswordService); + verifyNoMoreInteractions(this.userDetailsPasswordService); } @Test @@ -165,7 +165,7 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests { UsernamePasswordAuthenticationToken token = UsernamePasswordAuthenticationToken.unauthenticated(this.user, this.user.getPassword()); this.manager.authenticate(token).block(); - verifyZeroInteractions(this.postAuthenticationChecks); + verifyNoMoreInteractions(this.postAuthenticationChecks); } @Test diff --git a/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java index 0eb2488b5c..0b6bf51210 100644 --- a/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java @@ -60,7 +60,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link DaoAuthenticationProvider}. @@ -301,7 +301,7 @@ public class DaoAuthenticationProviderTests { given(encoder.matches(any(), any())).willReturn(false); given(userDetailsService.loadUserByUsername(any())).willReturn(user); assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> provider.authenticate(token)); - verifyZeroInteractions(passwordManager); + verifyNoMoreInteractions(passwordManager); } @Test @@ -320,7 +320,7 @@ public class DaoAuthenticationProviderTests { given(encoder.upgradeEncoding(any())).willReturn(false); given(userDetailsService.loadUserByUsername(any())).willReturn(user); Authentication result = provider.authenticate(token); - verifyZeroInteractions(passwordManager); + verifyNoMoreInteractions(passwordManager); } @Test diff --git a/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java b/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java index fe2bfbadb1..a9f9bfdbd3 100644 --- a/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java +++ b/core/src/test/java/org/springframework/security/core/SpringSecurityCoreVersionTests.java @@ -38,7 +38,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; 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. @@ -94,7 +94,7 @@ public class SpringSecurityCoreVersionTests { expectSpringSecurityVersionThenReturn(version); expectSpringVersionThenReturn(version); performChecks(); - verifyZeroInteractions(this.logger); + verifyNoMoreInteractions(this.logger); } @Test @@ -103,7 +103,7 @@ public class SpringSecurityCoreVersionTests { expectSpringSecurityVersionThenReturn(version); expectSpringVersionThenReturn(null); performChecks(); - verifyZeroInteractions(this.logger); + verifyNoMoreInteractions(this.logger); } @Test @@ -139,7 +139,7 @@ public class SpringSecurityCoreVersionTests { expectSpringVersionThenReturn("2"); System.setProperty(getDisableChecksProperty(), Boolean.TRUE.toString()); performChecks(); - verifyZeroInteractions(this.logger); + verifyNoMoreInteractions(this.logger); } private String getDisableChecksProperty() { diff --git a/crypto/src/test/java/org/springframework/security/crypto/password/DelegatingPasswordEncoderTests.java b/crypto/src/test/java/org/springframework/security/crypto/password/DelegatingPasswordEncoderTests.java index 48dd89e28c..898b6df90c 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/password/DelegatingPasswordEncoderTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/password/DelegatingPasswordEncoderTests.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -150,7 +150,7 @@ public class DelegatingPasswordEncoderTests { this.passwordEncoder.setDefaultPasswordEncoderForMatches(this.invalidId); assertThat(this.passwordEncoder.matches(this.rawPassword, encodedPassword)).isFalse(); verify(this.invalidId).matches(this.rawPassword, encodedPassword); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -170,7 +170,7 @@ public class DelegatingPasswordEncoderTests { given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true); assertThat(this.passwordEncoder.matches(this.rawPassword, this.bcryptEncodedPassword)).isTrue(); verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword); - verifyZeroInteractions(this.noop); + verifyNoMoreInteractions(this.noop); } @Test @@ -178,7 +178,7 @@ public class DelegatingPasswordEncoderTests { given(this.bcrypt.matches(this.rawPassword, this.encodedPassword)).willReturn(true); assertThat(this.onlySuffixPasswordEncoder.matches(this.rawPassword, "bcrypt$" + this.encodedPassword)).isTrue(); verify(this.bcrypt).matches(this.rawPassword, this.encodedPassword); - verifyZeroInteractions(this.noop); + verifyNoMoreInteractions(this.noop); } @Test @@ -186,7 +186,7 @@ public class DelegatingPasswordEncoderTests { given(this.noop.matches(this.rawPassword, this.encodedPassword)).willReturn(true); assertThat(this.passwordEncoder.matches(this.rawPassword, this.noopEncodedPassword)).isTrue(); verify(this.noop).matches(this.rawPassword, this.encodedPassword); - verifyZeroInteractions(this.bcrypt); + verifyNoMoreInteractions(this.bcrypt); } @Test @@ -194,7 +194,7 @@ public class DelegatingPasswordEncoderTests { assertThatIllegalArgumentException() .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{unmapped}" + this.rawPassword)) .withMessage("There is no PasswordEncoder mapped for the id \"unmapped\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -202,7 +202,7 @@ public class DelegatingPasswordEncoderTests { assertThatIllegalArgumentException() .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{bcrypt" + this.rawPassword)) .withMessage("There is no PasswordEncoder mapped for the id \"null\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -210,7 +210,7 @@ public class DelegatingPasswordEncoderTests { assertThatIllegalArgumentException() .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "bcrypt}" + this.rawPassword)) .withMessage("There is no PasswordEncoder mapped for the id \"null\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -218,7 +218,7 @@ public class DelegatingPasswordEncoderTests { assertThatIllegalArgumentException() .isThrownBy(() -> this.passwordEncoder.matches(this.rawPassword, "{}" + this.rawPassword)) .withMessage("There is no PasswordEncoder mapped for the id \"\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -228,7 +228,7 @@ public class DelegatingPasswordEncoderTests { () -> this.passwordEncoder.matches(this.rawPassword, "invalid" + this.bcryptEncodedPassword)) .isInstanceOf(IllegalArgumentException.class) .withMessage("There is no PasswordEncoder mapped for the id \"null\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -238,7 +238,7 @@ public class DelegatingPasswordEncoderTests { assertThatIllegalArgumentException() .isThrownBy(() -> passwordEncoder.matches(this.rawPassword, this.rawPassword)) .withMessage("There is no PasswordEncoder mapped for the id \"null\""); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -248,7 +248,7 @@ public class DelegatingPasswordEncoderTests { given(this.invalidId.matches(this.rawPassword, this.encodedPassword)).willReturn(true); assertThat(this.passwordEncoder.matches(this.rawPassword, this.encodedPassword)).isTrue(); verify(this.invalidId).matches(this.rawPassword, this.encodedPassword); - verifyZeroInteractions(this.bcrypt, this.noop); + verifyNoMoreInteractions(this.bcrypt, this.noop); } @Test @@ -287,7 +287,7 @@ public class DelegatingPasswordEncoderTests { @Test public void upgradeEncodingWhenDifferentIdThenTrue() { assertThat(this.passwordEncoder.upgradeEncoding(this.noopEncodedPassword)).isTrue(); - verifyZeroInteractions(this.bcrypt); + verifyNoMoreInteractions(this.bcrypt); } } diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilterTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilterTests.java index 03e9c5fd40..9ca003f2d2 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilterTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2AuthorizationRequestRedirectFilterTests.java @@ -56,7 +56,7 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link OAuth2AuthorizationRequestRedirectFilter}. @@ -150,7 +150,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = mock(FilterChain.class); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); } @@ -164,7 +164,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = mock(FilterChain.class); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id"); @@ -182,7 +182,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { AuthorizationRequestRepository.class); this.filter.setAuthorizationRequestRepository(authorizationRequestRepository); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); verify(authorizationRequestRepository).saveAuthorizationRequest(any(OAuth2AuthorizationRequest.class), any(HttpServletRequest.class), any(HttpServletResponse.class)); } @@ -230,7 +230,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = mock(FilterChain.class); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id"); @@ -268,7 +268,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); filter.doFilter(request, response, filterChain); verify(filterChain).doFilter(any(HttpServletRequest.class), any(HttpServletResponse.class)); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(response.getErrorMessage()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); } @@ -294,7 +294,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { given(resolver.resolve(any())).willReturn(result); OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id&" @@ -335,7 +335,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { given(resolver.resolve(any())).willReturn(result); OAuth2AuthorizationRequestRedirectFilter filter = new OAuth2AuthorizationRequestRedirectFilter(resolver); filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getRedirectedUrl()).matches("https://example.com/login/oauth/authorize\\?" + "response_type=code&client_id=client-id&" + "scope=read:user&state=.{15,}&" + "redirect_uri=http://localhost/login/oauth2/code/registration-id&" @@ -360,7 +360,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests { }; this.filter.setAuthorizationRedirectStrategy(customRedirectStrategy); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); assertThat(response.getContentType()).isEqualTo(MediaType.TEXT_PLAIN_VALUE); assertThat(response.getContentAsString(StandardCharsets.UTF_8)) diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilterTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilterTests.java index d399f3c3db..84b3d4b938 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilterTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/OAuth2LoginAuthenticationFilterTests.java @@ -69,7 +69,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests for {@link OAuth2LoginAuthenticationFilter}. @@ -310,7 +310,7 @@ public class OAuth2LoginAuthenticationFilterTests { this.setUpAuthorizationRequest(request, response, this.registration2, state); this.setUpAuthenticationResult(this.registration2); this.filter.doFilter(request, response, filterChain); - verifyZeroInteractions(filterChain); + verifyNoMoreInteractions(filterChain); verify(this.filter).attemptAuthentication(any(HttpServletRequest.class), any(HttpServletResponse.class)); } diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunctionTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunctionTests.java index 6faf6657e3..740a888325 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunctionTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/ServerOAuth2AuthorizedClientExchangeFilterFunctionTests.java @@ -113,7 +113,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -846,7 +846,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests { // @formatter:on List requests = this.exchange.getRequests(); assertThat(requests).hasSize(1); - verifyZeroInteractions(this.clientRegistrationRepository, this.authorizedClientRepository); + verifyNoMoreInteractions(this.clientRegistrationRepository, this.authorizedClientRepository); } @Test diff --git a/rsocket/src/test/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocketTests.java b/rsocket/src/test/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocketTests.java index 17185e4a82..3519bc4b8f 100644 --- a/rsocket/src/test/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocketTests.java +++ b/rsocket/src/test/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocketTests.java @@ -66,7 +66,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -191,7 +191,7 @@ public class PayloadInterceptorRSocketTests { .isThrownBy(() -> interceptor.requestResponse(this.payload).block()).isEqualTo(expected); verify(this.interceptor).intercept(this.exchange.capture(), any()); assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload); - verifyZeroInteractions(this.delegate); + verifyNoMoreInteractions(this.delegate); } @Test @@ -442,7 +442,7 @@ public class PayloadInterceptorRSocketTests { .isThrownBy(() -> interceptor.fireAndForget(this.payload).block()).isEqualTo(expected); verify(this.interceptor).intercept(this.exchange.capture(), any()); assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload); - verifyZeroInteractions(this.interceptor2); + verifyNoMoreInteractions(this.interceptor2); this.voidResult.assertWasNotSubscribed(); } diff --git a/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java b/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java index 58169e6ee9..4620b1a017 100644 --- a/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java +++ b/web/src/test/java/org/springframework/security/web/FilterChainProxyTests.java @@ -53,7 +53,7 @@ import static org.mockito.BDDMockito.willAnswer; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Luke Taylor @@ -109,7 +109,7 @@ public class FilterChainProxyTests { this.fcp.doFilter(this.request, this.response, this.chain); assertThat(this.fcp.getFilterChains()).hasSize(1); 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 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); this.fcp.doFilter(this.request, this.response, this.chain); verify(this.matcher).matches(any(FirewalledRequest.class)); - verifyZeroInteractions(this.filter); + verifyNoMoreInteractions(this.filter); verify(this.chain).doFilter(any(FirewalledRequest.class), any(HttpServletResponse.class)); } diff --git a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java index e71e0ff65d..9e5b84e7f9 100644 --- a/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/DefaultWebInvocationPrivilegeEvaluatorTests.java @@ -36,7 +36,6 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willThrow; @@ -76,14 +75,14 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { @Test public void permitsAccessIfNoMatchingAttributesAndPublicInvocationsAllowed() { 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(); } @Test public void deniesAccessIfNoMatchingAttributesAndPublicInvocationsNotAllowed() { DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor); - given(this.ods.getAttributes(anyObject())).willReturn(null); + given(this.ods.getAttributes(any())).willReturn(null); this.interceptor.setRejectPublicInvocations(true); assertThat(wipe.isAllowed("/context", "/foo/index.jsp", "GET", mock(Authentication.class))).isFalse(); } @@ -106,8 +105,7 @@ public class DefaultWebInvocationPrivilegeEvaluatorTests { public void deniesAccessIfAccessDecisionManagerDoes() { Authentication token = new TestingAuthenticationToken("test", "Password", "MOCK_INDEX"); DefaultWebInvocationPrivilegeEvaluator wipe = new DefaultWebInvocationPrivilegeEvaluator(this.interceptor); - willThrow(new AccessDeniedException("")).given(this.adm).decide(any(Authentication.class), anyObject(), - anyList()); + willThrow(new AccessDeniedException("")).given(this.adm).decide(any(Authentication.class), any(), anyList()); assertThat(wipe.isAllowed("/foo/index.jsp", token)).isFalse(); } diff --git a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java index 9fd0888540..2c553a5832 100644 --- a/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/access/ExceptionTranslationFilterTests.java @@ -55,7 +55,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link ExceptionTranslationFilter}. @@ -284,7 +284,7 @@ public class ExceptionTranslationFilterTests { ExceptionTranslationFilter filter = new ExceptionTranslationFilter(this.mockEntryPoint); assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain)) .withCauseInstanceOf(AccessDeniedException.class); - verifyZeroInteractions(this.mockEntryPoint); + verifyNoMoreInteractions(this.mockEntryPoint); } @Test diff --git a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java index ee6ce48ddc..06fe897739 100644 --- a/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java +++ b/web/src/test/java/org/springframework/security/web/access/intercept/FilterSecurityInterceptorTests.java @@ -52,7 +52,7 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link FilterSecurityInterceptor}. @@ -137,7 +137,7 @@ public class FilterSecurityInterceptorTests { AfterInvocationManager aim = mock(AfterInvocationManager.class); this.interceptor.setAfterInvocationManager(aim); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> this.interceptor.invoke(fi)); - verifyZeroInteractions(aim); + verifyNoMoreInteractions(aim); } // SEC-1967 diff --git a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java index daccb7f689..5bec660fc0 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/AuthenticationFilterTests.java @@ -53,7 +53,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Sergey Bespalov @@ -97,7 +97,7 @@ public class AuthenticationFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain chain = mock(FilterChain.class); filter.doFilter(request, response, chain); - verifyZeroInteractions(this.authenticationManager); + verifyNoMoreInteractions(this.authenticationManager); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @@ -110,7 +110,7 @@ public class AuthenticationFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain chain = mock(FilterChain.class); filter.doFilter(request, response, chain); - verifyZeroInteractions(this.authenticationManagerResolver); + verifyNoMoreInteractions(this.authenticationManagerResolver); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @@ -208,7 +208,7 @@ public class AuthenticationFilterTests { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); FilterChain chain = mock(FilterChain.class); filter.doFilter(request, new MockHttpServletResponse(), chain); - verifyZeroInteractions(this.authenticationManagerResolver); + verifyNoMoreInteractions(this.authenticationManagerResolver); verify(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class)); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @@ -227,7 +227,7 @@ public class AuthenticationFilterTests { FilterChain chain = mock(FilterChain.class); filter.doFilter(request, response, chain); verify(this.successHandler).onAuthenticationSuccess(any(), any(), any(), eq(authentication)); - verifyZeroInteractions(this.failureHandler); + verifyNoMoreInteractions(this.failureHandler); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull(); } @@ -244,7 +244,7 @@ public class AuthenticationFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain chain = mock(FilterChain.class); assertThatExceptionOfType(ServletException.class).isThrownBy(() -> filter.doFilter(request, response, chain)); - verifyZeroInteractions(this.successHandler); + verifyNoMoreInteractions(this.successHandler); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } @@ -258,7 +258,7 @@ public class AuthenticationFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain chain = mock(FilterChain.class); filter.doFilter(request, response, chain); - verifyZeroInteractions(this.authenticationConverter, this.authenticationManagerResolver, this.successHandler); + verifyNoMoreInteractions(this.authenticationConverter, this.authenticationManagerResolver, this.successHandler); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationFailureHandlerTests.java b/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationFailureHandlerTests.java index 857be3a115..89455c11d9 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationFailureHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/DelegatingAuthenticationFailureHandlerTests.java @@ -35,7 +35,7 @@ import org.springframework.security.core.AuthenticationException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Test class for @@ -77,7 +77,7 @@ public class DelegatingAuthenticationFailureHandlerTests { this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); AuthenticationException exception = new AccountExpiredException(""); 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); } @@ -88,7 +88,7 @@ public class DelegatingAuthenticationFailureHandlerTests { this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); AuthenticationException exception = new BadCredentialsException(""); 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); } @@ -100,7 +100,7 @@ public class DelegatingAuthenticationFailureHandlerTests { this.handler = new DelegatingAuthenticationFailureHandler(this.handlers, this.defaultHandler); AuthenticationException exception = new CredentialsExpiredException(""); 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); } diff --git a/web/src/test/java/org/springframework/security/web/authentication/logout/DelegatingLogoutSuccessHandlerTests.java b/web/src/test/java/org/springframework/security/web/authentication/logout/DelegatingLogoutSuccessHandlerTests.java index 36c5879dc0..1bb0cb7452 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/logout/DelegatingLogoutSuccessHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/logout/DelegatingLogoutSuccessHandlerTests.java @@ -32,7 +32,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * DelegatingLogoutSuccessHandlerTests Tests @@ -83,7 +83,7 @@ public class DelegatingLogoutSuccessHandlerTests { given(this.matcher.matches(this.request)).willReturn(true); this.delegatingHandler.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 @@ -92,7 +92,7 @@ public class DelegatingLogoutSuccessHandlerTests { given(this.matcher2.matches(this.request)).willReturn(true); this.delegatingHandler.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 @@ -100,13 +100,13 @@ public class DelegatingLogoutSuccessHandlerTests { this.delegatingHandler.setDefaultLogoutSuccessHandler(this.defaultHandler); this.delegatingHandler.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 public void onLogoutSuccessNoMatchDefaultNull() throws Exception { this.delegatingHandler.onLogoutSuccess(this.request, this.response, this.authentication); - verifyZeroInteractions(this.handler, this.handler2, this.defaultHandler); + verifyNoMoreInteractions(this.handler, this.handler2, this.defaultHandler); } } diff --git a/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java index 562a35f652..4084de3b03 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/preauth/AbstractPreAuthenticatedProcessingFilterTests.java @@ -52,7 +52,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -171,7 +171,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { filter.setAuthenticationManager(am); filter.afterPropertiesSet(); filter.doFilter(request, response, chain); - verifyZeroInteractions(am); + verifyNoMoreInteractions(am); } @Test @@ -274,7 +274,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { filter.setAuthenticationManager(am); filter.afterPropertiesSet(); filter.doFilter(request, response, chain); - verifyZeroInteractions(am); + verifyNoMoreInteractions(am); } @Test @@ -294,7 +294,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { filter.setAuthenticationManager(am); filter.afterPropertiesSet(); filter.doFilter(request, response, chain); - verifyZeroInteractions(am); + verifyNoMoreInteractions(am); } @Test @@ -359,7 +359,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { filter.setAuthenticationManager(am); filter.afterPropertiesSet(); filter.doFilter(request, response, chain); - verifyZeroInteractions(am); + verifyNoMoreInteractions(am); } @Test @@ -373,7 +373,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests { filter.setAuthenticationManager(am); filter.afterPropertiesSet(); filter.doFilter(request, response, chain); - verifyZeroInteractions(am); + verifyNoMoreInteractions(am); } @Test diff --git a/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java b/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java index 44839268bd..f02b39960b 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/rememberme/RememberMeAuthenticationFilterTests.java @@ -45,7 +45,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link RememberMeAuthenticationFilter}. @@ -151,7 +151,7 @@ public class RememberMeAuthenticationFilterTests { filter.doFilter(request, response, fc); assertThat(response.getRedirectedUrl()).isEqualTo("/target"); // Should return after success handler is invoked, so chain should not proceed - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); } @Test diff --git a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java index 3561b3e9ad..07dbf54922 100644 --- a/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java +++ b/web/src/test/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverterTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Sergey Bespalov @@ -80,7 +80,7 @@ public class BasicAuthenticationConverterTests { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Bearer someOtherToken"); UsernamePasswordAuthenticationToken authentication = this.converter.convert(request); - verifyZeroInteractions(this.authenticationDetailsSource); + verifyNoMoreInteractions(this.authenticationDetailsSource); assertThat(authentication).isNull(); } diff --git a/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java b/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java index 42b4a49085..d6c4c56f09 100644 --- a/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/concurrent/ConcurrentSessionFilterTests.java @@ -52,7 +52,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link ConcurrentSessionFilter}. @@ -111,7 +111,7 @@ public class ConcurrentSessionFilterTests { FilterChain fc = mock(FilterChain.class); filter.doFilter(request, response, fc); // Expect that the filter chain will not be invoked, as we redirect to expiredUrl - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); assertThat(response.getRedirectedUrl()).isEqualTo("/expired.jsp"); } @@ -128,7 +128,7 @@ public class ConcurrentSessionFilterTests { ConcurrentSessionFilter filter = new ConcurrentSessionFilter(registry); FilterChain fc = mock(FilterChain.class); filter.doFilter(request, response, fc); - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); assertThat(response.getContentAsString()) .isEqualTo("This session has been expired (possibly due to multiple concurrent logins being " + "attempted as the same user)."); diff --git a/web/src/test/java/org/springframework/security/web/csrf/CsrfFilterTests.java b/web/src/test/java/org/springframework/security/web/csrf/CsrfFilterTests.java index 847f1b85da..f107df43b0 100644 --- a/web/src/test/java/org/springframework/security/web/csrf/CsrfFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/csrf/CsrfFilterTests.java @@ -49,7 +49,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -129,7 +129,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).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)); - verifyZeroInteractions(this.filterChain); + verifyNoMoreInteractions(this.filterChain); } @Test @@ -141,7 +141,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).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)); - verifyZeroInteractions(this.filterChain); + verifyNoMoreInteractions(this.filterChain); } @Test @@ -153,7 +153,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).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)); - verifyZeroInteractions(this.filterChain); + verifyNoMoreInteractions(this.filterChain); } @Test @@ -167,7 +167,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).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)); - verifyZeroInteractions(this.filterChain); + verifyNoMoreInteractions(this.filterChain); } @Test @@ -178,7 +178,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); verify(this.filterChain).doFilter(this.request, this.response); - verifyZeroInteractions(this.deniedHandler); + verifyNoMoreInteractions(this.deniedHandler); } @Test @@ -189,7 +189,7 @@ public class CsrfFilterTests { assertToken(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertToken(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); verify(this.filterChain).doFilter(this.request, this.response); - verifyZeroInteractions(this.deniedHandler); + verifyNoMoreInteractions(this.deniedHandler); } @Test @@ -201,7 +201,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); verify(this.filterChain).doFilter(this.request, this.response); - verifyZeroInteractions(this.deniedHandler); + verifyNoMoreInteractions(this.deniedHandler); } @Test @@ -215,7 +215,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); verify(this.filterChain).doFilter(this.request, this.response); - verifyZeroInteractions(this.deniedHandler); + verifyNoMoreInteractions(this.deniedHandler); } @Test @@ -227,7 +227,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(this.token.getParameterName())).isEqualTo(this.token); assertThat(this.request.getAttribute(CsrfToken.class.getName())).isEqualTo(this.token); 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), any(HttpServletResponse.class)); } @@ -244,7 +244,7 @@ public class CsrfFilterTests { assertThat(this.request.getAttribute(HttpServletResponse.class.getName())).isEqualTo(this.response); verify(this.filterChain).doFilter(this.request, this.response); verify(this.tokenRepository).saveToken(this.token, this.request, this.response); - verifyZeroInteractions(this.deniedHandler); + verifyNoMoreInteractions(this.deniedHandler); } @Test @@ -257,7 +257,7 @@ public class CsrfFilterTests { this.request.setMethod(method); this.filter.doFilter(this.request, this.response, this.filterChain); 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); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), 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); verify(this.deniedHandler).handle(eq(this.request), eq(this.response), 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(CsrfToken.class.getName())).isEqualTo(this.token); assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_FORBIDDEN); - verifyZeroInteractions(this.filterChain); + verifyNoMoreInteractions(this.filterChain); } @Test @@ -318,7 +318,7 @@ public class CsrfFilterTests { MockHttpServletRequest request = new MockHttpServletRequest(); CsrfFilter.skipRequest(request); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); - verifyZeroInteractions(repository); + verifyNoMoreInteractions(repository); } // gh-9561 diff --git a/web/src/test/java/org/springframework/security/web/csrf/LazyCsrfTokenRepositoryTests.java b/web/src/test/java/org/springframework/security/web/csrf/LazyCsrfTokenRepositoryTests.java index 35d57634af..e25ec37bff 100644 --- a/web/src/test/java/org/springframework/security/web/csrf/LazyCsrfTokenRepositoryTests.java +++ b/web/src/test/java/org/springframework/security/web/csrf/LazyCsrfTokenRepositoryTests.java @@ -32,7 +32,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -82,7 +82,7 @@ public class LazyCsrfTokenRepositoryTests { @Test public void saveNonNullDoesNothing() { this.repository.saveToken(this.token, this.request, this.response); - verifyZeroInteractions(this.delegate); + verifyNoMoreInteractions(this.delegate); } @Test diff --git a/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java b/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java index 712e03e01c..91b476b1a7 100644 --- a/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/header/HeaderWriterFilterTests.java @@ -38,7 +38,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Tests for the {@code HeadersFilter} @@ -92,7 +91,7 @@ public class HeaderWriterFilterTests { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); filter.doFilter(request, response, (request1, response1) -> { - verifyZeroInteractions(HeaderWriterFilterTests.this.writer1); + verifyNoMoreInteractions(HeaderWriterFilterTests.this.writer1); response1.flushBuffer(); verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class), any(HttpServletResponse.class)); @@ -107,7 +106,7 @@ public class HeaderWriterFilterTests { MockHttpServletRequest mockRequest = new MockHttpServletRequest(); MockHttpServletResponse mockResponse = new MockHttpServletResponse(); filter.doFilter(mockRequest, mockResponse, (request, response) -> { - verifyZeroInteractions(HeaderWriterFilterTests.this.writer1); + verifyNoMoreInteractions(HeaderWriterFilterTests.this.writer1); request.getRequestDispatcher("/").include(request, response); verify(HeaderWriterFilterTests.this.writer1).writeHeaders(any(HttpServletRequest.class), any(HttpServletResponse.class)); diff --git a/web/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java b/web/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java index 73decc437f..6a19069bdc 100644 --- a/web/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java +++ b/web/src/test/java/org/springframework/security/web/server/DefaultServerRedirectStrategyTests.java @@ -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.assertThatIllegalArgumentException; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -59,7 +59,7 @@ public class DefaultServerRedirectStrategyTests { @Test public void sendRedirectWhenNoSubscribersThenNoActions() { this.strategy.sendRedirect(this.exchange, this.location); - verifyZeroInteractions(this.exchange); + verifyNoMoreInteractions(this.exchange); } @Test diff --git a/web/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java index 7f06021216..a0f3b71c33 100644 --- a/web/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/server/DelegatingServerAuthenticationEntryPointTests.java @@ -34,7 +34,7 @@ import org.springframework.web.server.ServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -71,7 +71,7 @@ public class DelegatingServerAuthenticationEntryPointTests { new DelegateEntry(this.matcher2, this.delegate2)); Mono actualResult = this.entryPoint.commence(this.exchange, this.e); actualResult.block(); - verifyZeroInteractions(this.delegate1); + verifyNoMoreInteractions(this.delegate1); verify(this.delegate2).commence(this.exchange, this.e); } @@ -82,7 +82,7 @@ public class DelegatingServerAuthenticationEntryPointTests { new DelegateEntry(this.matcher1, this.delegate1)); this.entryPoint.commence(this.exchange, this.e).block(); assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); - verifyZeroInteractions(this.delegate1); + verifyNoMoreInteractions(this.delegate1); } } diff --git a/web/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java b/web/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java index 1d8271a847..a58f87adb1 100644 --- a/web/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java @@ -42,7 +42,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -88,7 +88,7 @@ public class AuthenticationWebFilterTests { EntityExchangeResult result = client.get().uri("/").exchange().expectStatus().isOk() .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .returnResult(); - verifyZeroInteractions(this.authenticationManager); + verifyNoMoreInteractions(this.authenticationManager); assertThat(result.getResponseCookies()).isEmpty(); } @@ -99,7 +99,7 @@ public class AuthenticationWebFilterTests { EntityExchangeResult result = client.get().uri("/").exchange().expectStatus().isOk() .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .returnResult(); - verifyZeroInteractions(this.authenticationManagerResolver); + verifyNoMoreInteractions(this.authenticationManagerResolver); assertThat(result.getResponseCookies()).isEmpty(); } @@ -162,7 +162,7 @@ public class AuthenticationWebFilterTests { client.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class) .consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")).returnResult(); verify(this.securityContextRepository, never()).save(any(), any()); - verifyZeroInteractions(this.authenticationManager, this.successHandler, this.failureHandler); + verifyNoMoreInteractions(this.authenticationManager, this.successHandler, this.failureHandler); } @Test @@ -171,7 +171,7 @@ public class AuthenticationWebFilterTests { WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); verify(this.securityContextRepository, never()).save(any(), any()); - verifyZeroInteractions(this.authenticationManager, this.successHandler, this.failureHandler); + verifyNoMoreInteractions(this.authenticationManager, this.successHandler, this.failureHandler); } @Test @@ -185,7 +185,7 @@ public class AuthenticationWebFilterTests { client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty(); verify(this.successHandler).onAuthenticationSuccess(any(), eq(authentication.block())); verify(this.securityContextRepository).save(any(), any()); - verifyZeroInteractions(this.failureHandler); + verifyNoMoreInteractions(this.failureHandler); } @Test @@ -196,7 +196,7 @@ public class AuthenticationWebFilterTests { WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); verify(this.securityContextRepository, never()).save(any(), any()); - verifyZeroInteractions(this.successHandler, this.failureHandler); + verifyNoMoreInteractions(this.successHandler, this.failureHandler); } @Test @@ -208,7 +208,7 @@ public class AuthenticationWebFilterTests { .expectBody(String.class).consumeWith((b) -> assertThat(b.getResponseBody()).isEqualTo("ok")) .returnResult(); assertThat(result.getResponseCookies()).isEmpty(); - verifyZeroInteractions(this.authenticationConverter, this.authenticationManager, this.successHandler); + verifyNoMoreInteractions(this.authenticationConverter, this.authenticationManager, this.successHandler); } @Test @@ -222,7 +222,7 @@ public class AuthenticationWebFilterTests { client.get().uri("/").exchange().expectStatus().isOk().expectBody().isEmpty(); verify(this.failureHandler).onAuthenticationFailure(any(), any()); verify(this.securityContextRepository, never()).save(any(), any()); - verifyZeroInteractions(this.successHandler); + verifyNoMoreInteractions(this.successHandler); } @Test @@ -233,7 +233,7 @@ public class AuthenticationWebFilterTests { WebTestClient client = WebTestClientBuilder.bindToWebFilters(this.filter).build(); client.get().uri("/").exchange().expectStatus().is5xxServerError().expectBody().isEmpty(); verify(this.securityContextRepository, never()).save(any(), any()); - verifyZeroInteractions(this.successHandler, this.failureHandler); + verifyNoMoreInteractions(this.successHandler, this.failureHandler); } @Test diff --git a/web/src/test/java/org/springframework/security/web/server/authentication/HttpBasicServerAuthenticationEntryPointTests.java b/web/src/test/java/org/springframework/security/web/server/authentication/HttpBasicServerAuthenticationEntryPointTests.java index 872e403b48..f223504353 100644 --- a/web/src/test/java/org/springframework/security/web/server/authentication/HttpBasicServerAuthenticationEntryPointTests.java +++ b/web/src/test/java/org/springframework/security/web/server/authentication/HttpBasicServerAuthenticationEntryPointTests.java @@ -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.assertThatIllegalArgumentException; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -49,7 +49,7 @@ public class HttpBasicServerAuthenticationEntryPointTests { @Test public void commenceWhenNoSubscribersThenNoActions() { this.entryPoint.commence(this.exchange, this.exception); - verifyZeroInteractions(this.exchange); + verifyNoMoreInteractions(this.exchange); } @Test diff --git a/web/src/test/java/org/springframework/security/web/server/authorization/DelegatingReactiveAuthorizationManagerTests.java b/web/src/test/java/org/springframework/security/web/server/authorization/DelegatingReactiveAuthorizationManagerTests.java index c14c391ab9..f7ef26d8bf 100644 --- a/web/src/test/java/org/springframework/security/web/server/authorization/DelegatingReactiveAuthorizationManagerTests.java +++ b/web/src/test/java/org/springframework/security/web/server/authorization/DelegatingReactiveAuthorizationManagerTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -81,7 +81,7 @@ public class DelegatingReactiveAuthorizationManagerTests { given(this.delegate1.check(eq(this.authentication), any(AuthorizationContext.class))) .willReturn(Mono.just(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 @@ -91,7 +91,7 @@ public class DelegatingReactiveAuthorizationManagerTests { given(this.delegate2.check(eq(this.authentication), any(AuthorizationContext.class))) .willReturn(Mono.just(this.decision)); assertThat(this.manager.check(this.authentication, this.exchange).block()).isEqualTo(this.decision); - verifyZeroInteractions(this.delegate1); + verifyNoMoreInteractions(this.delegate1); } } diff --git a/web/src/test/java/org/springframework/security/web/server/authorization/HttpStatusServerAccessDeniedHandlerTests.java b/web/src/test/java/org/springframework/security/web/server/authorization/HttpStatusServerAccessDeniedHandlerTests.java index a539cc64bf..4a59d381b7 100644 --- a/web/src/test/java/org/springframework/security/web/server/authorization/HttpStatusServerAccessDeniedHandlerTests.java +++ b/web/src/test/java/org/springframework/security/web/server/authorization/HttpStatusServerAccessDeniedHandlerTests.java @@ -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.assertThatIllegalArgumentException; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -55,7 +55,7 @@ public class HttpStatusServerAccessDeniedHandlerTests { @Test public void commenceWhenNoSubscribersThenNoActions() { this.handler.handle(this.exchange, this.exception); - verifyZeroInteractions(this.exchange); + verifyNoMoreInteractions(this.exchange); } @Test diff --git a/web/src/test/java/org/springframework/security/web/server/csrf/CsrfWebFilterTests.java b/web/src/test/java/org/springframework/security/web/server/csrf/CsrfWebFilterTests.java index aada7a4b62..ba20eaff1c 100644 --- a/web/src/test/java/org/springframework/security/web/server/csrf/CsrfWebFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/server/csrf/CsrfWebFilterTests.java @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -164,7 +164,7 @@ public class CsrfWebFilterTests { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.post("/post").build()); CsrfWebFilter.skipExchange(exchange); this.csrfFilter.filter(exchange, this.chain).block(); - verifyZeroInteractions(matcher); + verifyNoMoreInteractions(matcher); } @Test diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/PathMatcherServerWebExchangeMatcherTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/PathMatcherServerWebExchangeMatcherTests.java index 87a4369d79..1f33fe4b67 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/PathMatcherServerWebExchangeMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/PathMatcherServerWebExchangeMatcherTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -108,7 +108,7 @@ public class PathMatcherServerWebExchangeMatcherTests { assertThat(this.exchange.getRequest().getMethod()).isNotEqualTo(method); this.matcher = new PathPatternParserServerWebExchangeMatcher(this.pattern, method); assertThat(this.matcher.matches(this.exchange).block().isMatch()).isFalse(); - verifyZeroInteractions(this.pattern); + verifyNoMoreInteractions(this.pattern); } } diff --git a/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java b/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java index e37a4052ad..38631ae9c4 100644 --- a/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java +++ b/web/src/test/java/org/springframework/security/web/server/util/matcher/ServerWebExchangeMatchersTests.java @@ -25,7 +25,7 @@ import org.springframework.web.server.ServerWebExchange; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -69,7 +69,7 @@ public class ServerWebExchangeMatchersTests { public void anyExchangeWhenMockThenMatches() { ServerWebExchange mockExchange = mock(ServerWebExchange.class); assertThat(ServerWebExchangeMatchers.anyExchange().matches(mockExchange).block().isMatch()).isTrue(); - verifyZeroInteractions(mockExchange); + verifyNoMoreInteractions(mockExchange); } /** diff --git a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java index 414f343a2e..759cabd1a8 100644 --- a/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/servlet/util/matcher/MvcRequestMatcherTests.java @@ -36,7 +36,7 @@ import org.springframework.web.servlet.handler.RequestMatchResult; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * @author Rob Winch @@ -161,7 +161,7 @@ public class MvcRequestMatcherTests { this.matcher.setMethod(HttpMethod.POST); assertThat(this.matcher.matches(this.request)).isFalse(); // 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"); assertThat(this.matcher.matches(this.request)).isFalse(); // method compare should be done first since faster - verifyZeroInteractions(this.introspector); + verifyNoMoreInteractions(this.introspector); } @Test diff --git a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java index 78352903c1..33019fdbec 100644 --- a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java @@ -61,7 +61,7 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Tests {@link SecurityContextHolderAwareRequestFilter}. @@ -129,7 +129,7 @@ public class SecurityContextHolderAwareRequestFilterTests { assertThat(wrappedRequest().authenticate(this.response)).isFalse(); verify(this.authenticationEntryPoint).commence(eq(this.requestCaptor.getValue()), eq(this.response), any(AuthenticationException.class)); - verifyZeroInteractions(this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler); verify(this.request, times(0)).authenticate(any(HttpServletResponse.class)); } @@ -138,7 +138,7 @@ public class SecurityContextHolderAwareRequestFilterTests { SecurityContextHolder.getContext() .setAuthentication(new TestingAuthenticationToken("test", "password", "ROLE_USER")); 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)); } @@ -148,7 +148,7 @@ public class SecurityContextHolderAwareRequestFilterTests { this.filter.afterPropertiesSet(); assertThat(wrappedRequest().authenticate(this.response)).isFalse(); verify(this.request).authenticate(this.response); - verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); } @Test @@ -158,7 +158,7 @@ public class SecurityContextHolderAwareRequestFilterTests { this.filter.afterPropertiesSet(); assertThat(wrappedRequest().authenticate(this.response)).isTrue(); verify(this.request).authenticate(this.response); - verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); } @Test @@ -168,7 +168,7 @@ public class SecurityContextHolderAwareRequestFilterTests { .willReturn(expectedAuth); wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials())); assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth); - verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler); verify(this.request, times(0)).login(anyString(), anyString()); } @@ -180,7 +180,7 @@ public class SecurityContextHolderAwareRequestFilterTests { assertThatExceptionOfType(ServletException.class).isThrownBy( () -> wrappedRequest().login(expectedAuth.getName(), String.valueOf(expectedAuth.getCredentials()))); assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(expectedAuth); - verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler); verify(this.request, times(0)).login(anyString(), anyString()); } @@ -192,7 +192,7 @@ public class SecurityContextHolderAwareRequestFilterTests { assertThatExceptionOfType(ServletException.class) .isThrownBy(() -> wrappedRequest().login("invalid", "credentials")).withCause(authException); assertThat(SecurityContextHolder.getContext().getAuthentication()).isNull(); - verifyZeroInteractions(this.authenticationEntryPoint, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.logoutHandler); verify(this.request, times(0)).login(anyString(), anyString()); } @@ -204,7 +204,7 @@ public class SecurityContextHolderAwareRequestFilterTests { String password = "password"; wrappedRequest().login(username, password); verify(this.request).login(username, password); - verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); } @Test @@ -217,7 +217,7 @@ public class SecurityContextHolderAwareRequestFilterTests { willThrow(authException).given(this.request).login(username, password); assertThatExceptionOfType(ServletException.class).isThrownBy(() -> wrappedRequest().login(username, password)) .isEqualTo(authException); - verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); } @Test @@ -248,7 +248,7 @@ public class SecurityContextHolderAwareRequestFilterTests { HttpServletRequest wrappedRequest = wrappedRequest(); wrappedRequest.logout(); verify(this.logoutHandler).logout(wrappedRequest, this.response, expectedAuth); - verifyZeroInteractions(this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler); verify(this.request, times(0)).logout(); } @@ -258,7 +258,7 @@ public class SecurityContextHolderAwareRequestFilterTests { this.filter.afterPropertiesSet(); wrappedRequest().logout(); verify(this.request).logout(); - verifyZeroInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationEntryPoint, this.authenticationManager, this.logoutHandler); } // gh-3780 @@ -279,7 +279,7 @@ public class SecurityContextHolderAwareRequestFilterTests { Runnable runnable = () -> { }; wrappedRequest().getAsyncContext().start(runnable); - verifyZeroInteractions(this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler); verify(asyncContext).start(runnableCaptor.capture()); DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor .getValue(); @@ -299,7 +299,7 @@ public class SecurityContextHolderAwareRequestFilterTests { Runnable runnable = () -> { }; wrappedRequest().startAsync().start(runnable); - verifyZeroInteractions(this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler); verify(asyncContext).start(runnableCaptor.capture()); DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor .getValue(); @@ -319,7 +319,7 @@ public class SecurityContextHolderAwareRequestFilterTests { Runnable runnable = () -> { }; wrappedRequest().startAsync(this.request, this.response).start(runnable); - verifyZeroInteractions(this.authenticationManager, this.logoutHandler); + verifyNoMoreInteractions(this.authenticationManager, this.logoutHandler); verify(asyncContext).start(runnableCaptor.capture()); DelegatingSecurityContextRunnable wrappedRunnable = (DelegatingSecurityContextRunnable) runnableCaptor .getValue(); diff --git a/web/src/test/java/org/springframework/security/web/session/SessionManagementFilterTests.java b/web/src/test/java/org/springframework/security/web/session/SessionManagementFilterTests.java index b76367aa38..dd5fafd4eb 100644 --- a/web/src/test/java/org/springframework/security/web/session/SessionManagementFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/session/SessionManagementFilterTests.java @@ -43,7 +43,6 @@ import static org.mockito.BDDMockito.willThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * @author Luke Taylor @@ -76,7 +75,7 @@ public class SessionManagementFilterTests { HttpServletRequest request = new MockHttpServletRequest(); authenticateUser(); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); - verifyZeroInteractions(strategy); + verifyNoMoreInteractions(strategy); } @Test @@ -86,7 +85,7 @@ public class SessionManagementFilterTests { SessionManagementFilter filter = new SessionManagementFilter(repo, strategy); HttpServletRequest request = new MockHttpServletRequest(); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); - verifyZeroInteractions(strategy); + verifyNoMoreInteractions(strategy); } @Test @@ -121,7 +120,7 @@ public class SessionManagementFilterTests { willThrow(exception).given(strategy).onAuthentication(SecurityContextHolder.getContext().getAuthentication(), request, response); filter.doFilter(request, response, fc); - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); verify(failureHandler).onAuthenticationFailure(request, response, exception); } @@ -146,7 +145,7 @@ public class SessionManagementFilterTests { filter.setInvalidSessionStrategy(iss); FilterChain fc = mock(FilterChain.class); filter.doFilter(request, response, fc); - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); assertThat(response.getRedirectedUrl()).isEqualTo("/timedOut"); } @@ -172,7 +171,7 @@ public class SessionManagementFilterTests { filter.setInvalidSessionStrategy(iss); FilterChain fc = mock(FilterChain.class); filter.doFilter(request, response, fc); - verifyZeroInteractions(fc); + verifyNoMoreInteractions(fc); assertThat(response.getRedirectedUrl()).isEqualTo("/requested"); }