Merge branch '5.8.x'

Closes gh-11749
This commit is contained in:
Rob Winch 2022-08-23 16:03:50 -05:00
commit 670b71363d
46 changed files with 179 additions and 177 deletions

View File

@ -34,7 +34,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.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);
}
}

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.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

View File

@ -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

View File

@ -56,7 +56,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;
@ -128,7 +128,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));

View File

@ -44,7 +44,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;
@ -103,7 +102,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(

View File

@ -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);
}
}

View File

@ -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

View File

@ -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));
}

View File

@ -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() {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -61,7 +61,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}.
@ -302,7 +302,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
@ -321,7 +321,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

View File

@ -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() {

View File

@ -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);
}
}

View File

@ -11,6 +11,7 @@ dependencies {
api platform("io.projectreactor:reactor-bom:2022.0.0-M4")
api platform("io.rsocket:rsocket-bom:1.1.2")
api platform("org.junit:junit-bom:5.9.0-RC1")
api platform("org.mockito:mockito-bom:4.7.0")
api platform("org.springframework.data:spring-data-bom:2022.0.0-M5")
api platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")
api platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4")
@ -54,9 +55,16 @@ dependencies {
api "org.hibernate.orm:hibernate-core:6.1.1.Final"
api "org.hsqldb:hsqldb:2.6.1"
api "org.jasig.cas.client:cas-client-core:3.6.4"
<<<<<<< HEAD
api "org.mockito:mockito-core:3.12.4"
api "org.mockito:mockito-inline:3.12.4"
api "org.mockito:mockito-junit-jupiter:3.12.4"
<<<<<<< HEAD
=======
api "org.openid4java:openid4java-nodeps:0.9.6"
=======
>>>>>>> 8e018fd921 (Update to mockito 4.7.0)
>>>>>>> 5.8.x
api "org.opensaml:opensaml-core:$openSamlVersion"
api "org.opensaml:opensaml-saml-api:$openSamlVersion"
api "org.opensaml:opensaml-saml-impl:$openSamlVersion"

View File

@ -53,7 +53,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;
/**
* Tests for {@link OAuth2AuthorizationRequestRedirectFilter}.
@ -138,7 +138,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());
}
@ -152,7 +152,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");
@ -170,7 +170,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));
}
@ -186,7 +186,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");
@ -224,7 +224,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());
}
@ -250,7 +250,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&"
@ -291,7 +291,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&"
@ -316,7 +316,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))

View File

@ -68,7 +68,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}.
@ -309,7 +309,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));
}

View File

@ -114,7 +114,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
@ -822,7 +822,7 @@ public class ServerOAuth2AuthorizedClientExchangeFilterFunctionTests {
// @formatter:on
List<ClientRequest> requests = this.exchange.getRequests();
assertThat(requests).hasSize(1);
verifyZeroInteractions(this.clientRegistrationRepository, this.authorizedClientRepository);
verifyNoMoreInteractions(this.clientRegistrationRepository, this.authorizedClientRepository);
}
@Test

View File

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

View File

@ -52,7 +52,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
@ -108,7 +108,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));
}
@ -146,7 +146,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));
}

View File

@ -36,7 +36,6 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
import static org.assertj.core.api.Assertions.assertThat;
import static org.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();
}

View File

@ -54,7 +54,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}.
@ -283,7 +283,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

View File

@ -52,7 +52,7 @@ import static org.mockito.Mockito.mock;
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;
/**
* 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

View File

@ -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 Sergey Bespalov
@ -96,7 +96,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();
}
@ -109,7 +109,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();
}
@ -207,7 +207,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();
}
@ -226,7 +226,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();
}
@ -243,7 +243,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();
}
@ -257,7 +257,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();
}

View File

@ -34,7 +34,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
@ -76,7 +76,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);
}
@ -87,7 +87,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);
}
@ -99,7 +99,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);
}

View File

@ -31,7 +31,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
@ -82,7 +82,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
@ -91,7 +91,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
@ -99,13 +99,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);
}
}

View File

@ -51,7 +51,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
@ -170,7 +170,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am);
filter.afterPropertiesSet();
filter.doFilter(request, response, chain);
verifyZeroInteractions(am);
verifyNoMoreInteractions(am);
}
@Test
@ -273,7 +273,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am);
filter.afterPropertiesSet();
filter.doFilter(request, response, chain);
verifyZeroInteractions(am);
verifyNoMoreInteractions(am);
}
@Test
@ -293,7 +293,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am);
filter.afterPropertiesSet();
filter.doFilter(request, response, chain);
verifyZeroInteractions(am);
verifyNoMoreInteractions(am);
}
@Test
@ -358,7 +358,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am);
filter.afterPropertiesSet();
filter.doFilter(request, response, chain);
verifyZeroInteractions(am);
verifyNoMoreInteractions(am);
}
@Test
@ -372,7 +372,7 @@ public class AbstractPreAuthenticatedProcessingFilterTests {
filter.setAuthenticationManager(am);
filter.afterPropertiesSet();
filter.doFilter(request, response, chain);
verifyZeroInteractions(am);
verifyNoMoreInteractions(am);
}
@Test

View File

@ -44,7 +44,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}.
@ -150,7 +150,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

View File

@ -33,7 +33,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
@ -79,7 +79,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();
}

View File

@ -51,7 +51,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}.
@ -110,7 +110,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");
}
@ -127,7 +127,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).");

View File

@ -48,7 +48,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
@ -128,7 +128,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
@ -140,7 +140,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
@ -152,7 +152,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
@ -166,7 +166,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
@ -177,7 +177,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
@ -188,7 +188,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
@ -200,7 +200,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
@ -214,7 +214,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
@ -226,7 +226,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));
}
@ -243,7 +243,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
@ -256,7 +256,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);
}
}
@ -277,7 +277,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);
}
}
@ -292,7 +292,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);
}
}
@ -306,7 +306,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
@ -317,7 +317,7 @@ public class CsrfFilterTests {
MockHttpServletRequest request = new MockHttpServletRequest();
CsrfFilter.skipRequest(request);
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
verifyZeroInteractions(repository);
verifyNoMoreInteractions(repository);
}
// gh-9561

View File

@ -31,7 +31,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
@ -81,7 +81,7 @@ public class LazyCsrfTokenRepositoryTests {
@Test
public void saveNonNullDoesNothing() {
this.repository.saveToken(this.token, this.request, this.response);
verifyZeroInteractions(this.delegate);
verifyNoMoreInteractions(this.delegate);
}
@Test

View File

@ -37,7 +37,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}
@ -91,7 +90,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));
@ -106,7 +105,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));

View File

@ -30,7 +30,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.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

View File

@ -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<Void> 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);
}
}

View File

@ -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<String> 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<String> 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

View File

@ -30,7 +30,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.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

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.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);
}
}

View File

@ -29,7 +29,7 @@ import org.springframework.web.server.ServerWebExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.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

View File

@ -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

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.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);
}
}

View File

@ -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);
}
/**

View File

@ -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

View File

@ -60,7 +60,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}.
@ -128,7 +128,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));
}
@ -137,7 +137,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));
}
@ -147,7 +147,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
@ -157,7 +157,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
@ -167,7 +167,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());
}
@ -179,7 +179,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());
}
@ -191,7 +191,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());
}
@ -203,7 +203,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
@ -216,7 +216,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
@ -247,7 +247,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();
}
@ -257,7 +257,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
@ -278,7 +278,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();
@ -298,7 +298,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();
@ -318,7 +318,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();

View File

@ -42,7 +42,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
@ -75,7 +74,7 @@ public class SessionManagementFilterTests {
HttpServletRequest request = new MockHttpServletRequest();
authenticateUser();
filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
verifyZeroInteractions(strategy);
verifyNoMoreInteractions(strategy);
}
@Test
@ -85,7 +84,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
@ -120,7 +119,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);
}
@ -145,7 +144,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");
}
@ -171,7 +170,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");
}