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