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