Fix test
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
This commit is contained in:
parent
b6182eb29a
commit
3de359c580
|
@ -85,7 +85,6 @@ class AuthorizationManagerWebInvocationPrivilegeEvaluatorTests {
|
|||
@Test
|
||||
void isAllowedWhenServletContextExistsThenFilterInvocationHasServletContext() {
|
||||
ServletContext servletContext = new MockServletContext();
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.privilegeEvaluator.setServletContext(servletContext);
|
||||
this.privilegeEvaluator.isAllowed("/test", TestAuthentication.authenticatedUser());
|
||||
ArgumentCaptor<HttpServletRequest> captor = ArgumentCaptor.forClass(HttpServletRequest.class);
|
||||
|
@ -102,7 +101,6 @@ class AuthorizationManagerWebInvocationPrivilegeEvaluatorTests {
|
|||
void isAllowedWhenRequestTransformerThenUsesRequestTransformerResult() {
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
given(this.requestTransformer.transform(any())).willReturn(request);
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.privilegeEvaluator.setRequestTransformer(this.requestTransformer);
|
||||
|
||||
this.privilegeEvaluator.isAllowed("/test", TestAuthentication.authenticatedUser());
|
||||
|
|
|
@ -118,7 +118,6 @@ public class AuthorizationFilterTests {
|
|||
@Test
|
||||
public void filterWhenAuthorizationManagerVerifyThrowsAccessDeniedExceptionThenStopFilterChain() {
|
||||
AuthorizationManager<HttpServletRequest> mockAuthorizationManager = mock(AuthorizationManager.class);
|
||||
given(mockAuthorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
AuthorizationFilter filter = new AuthorizationFilter(mockAuthorizationManager);
|
||||
TestingAuthenticationToken authenticationToken = new TestingAuthenticationToken("user", "password");
|
||||
|
||||
|
@ -196,7 +195,6 @@ public class AuthorizationFilterTests {
|
|||
@Test
|
||||
public void doFilterWhenErrorThenDoFilter() throws Exception {
|
||||
AuthorizationManager<HttpServletRequest> authorizationManager = mock(AuthorizationManager.class);
|
||||
given(authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
AuthorizationFilter authorizationFilter = new AuthorizationFilter(authorizationManager);
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest(null, "/path");
|
||||
mockRequest.setDispatcherType(DispatcherType.ERROR);
|
||||
|
@ -233,7 +231,6 @@ public class AuthorizationFilterTests {
|
|||
|
||||
@Test
|
||||
public void doFilterWhenObserveOncePerRequestTrueAndNotAppliedThenInvoked() throws ServletException, IOException {
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.filter.setObserveOncePerRequest(true);
|
||||
this.filter.doFilter(this.request, this.response, this.chain);
|
||||
verify(this.authorizationManager).authorize(any(), any());
|
||||
|
@ -242,7 +239,6 @@ public class AuthorizationFilterTests {
|
|||
@Test
|
||||
public void doFilterWhenObserveOncePerRequestFalseAndIsAppliedThenInvoked() throws ServletException, IOException {
|
||||
setIsAppliedTrue();
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.filter.setObserveOncePerRequest(false);
|
||||
this.filter.doFilter(this.request, this.response, this.chain);
|
||||
verify(this.authorizationManager).authorize(any(), any());
|
||||
|
@ -250,7 +246,6 @@ public class AuthorizationFilterTests {
|
|||
|
||||
@Test
|
||||
public void doFilterWhenObserveOncePerRequestFalseAndNotAppliedThenInvoked() throws ServletException, IOException {
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.filter.setObserveOncePerRequest(false);
|
||||
this.filter.doFilter(this.request, this.response, this.chain);
|
||||
verify(this.authorizationManager).authorize(any(), any());
|
||||
|
@ -266,7 +261,6 @@ public class AuthorizationFilterTests {
|
|||
|
||||
@Test
|
||||
public void doFilterWhenFilterErrorDispatchTrueAndIsErrorThenInvoked() throws ServletException, IOException {
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.request.setDispatcherType(DispatcherType.ERROR);
|
||||
this.filter.setFilterErrorDispatch(true);
|
||||
this.filter.doFilter(this.request, this.response, this.chain);
|
||||
|
@ -290,7 +284,6 @@ public class AuthorizationFilterTests {
|
|||
|
||||
@Test
|
||||
public void doFilterWhenFilterAsyncDispatchTrueAndIsAsyncThenInvoked() throws ServletException, IOException {
|
||||
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
|
||||
this.request.setDispatcherType(DispatcherType.ASYNC);
|
||||
this.filter.setFilterAsyncDispatch(true);
|
||||
this.filter.doFilter(this.request, this.response, this.chain);
|
||||
|
|
|
@ -81,7 +81,6 @@ public class DelegatingReactiveAuthorizationManagerTests {
|
|||
given(this.match1.matches(any())).willReturn(ServerWebExchangeMatcher.MatchResult.match());
|
||||
given(this.delegate1.authorize(eq(this.authentication), any(AuthorizationContext.class)))
|
||||
.willReturn(Mono.just(this.decision));
|
||||
given(this.delegate1.authorize(eq(this.authentication), any(AuthorizationContext.class))).willCallRealMethod();
|
||||
assertThat(this.manager.authorize(this.authentication, this.exchange).block()).isEqualTo(this.decision);
|
||||
verifyNoMoreInteractions(this.match2, this.delegate2);
|
||||
}
|
||||
|
@ -92,7 +91,6 @@ public class DelegatingReactiveAuthorizationManagerTests {
|
|||
given(this.match2.matches(any())).willReturn(ServerWebExchangeMatcher.MatchResult.match());
|
||||
given(this.delegate2.authorize(eq(this.authentication), any(AuthorizationContext.class)))
|
||||
.willReturn(Mono.just(this.decision));
|
||||
given(this.delegate2.authorize(eq(this.authentication), any(AuthorizationContext.class))).willCallRealMethod();
|
||||
assertThat(this.manager.authorize(this.authentication, this.exchange).block()).isEqualTo(this.decision);
|
||||
verifyNoMoreInteractions(this.delegate1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue