Skip to content

Commit 3de359c

Browse files
Fix test
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent b6182eb commit 3de359c

File tree

3 files changed

+0
-11
lines changed

3 files changed

+0
-11
lines changed

web/src/test/java/org/springframework/security/web/access/AuthorizationManagerWebInvocationPrivilegeEvaluatorTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ void isAllowedWhenAuthorizationManagerAbstainsThenAllowedTrue() {
8585
@Test
8686
void isAllowedWhenServletContextExistsThenFilterInvocationHasServletContext() {
8787
ServletContext servletContext = new MockServletContext();
88-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
8988
this.privilegeEvaluator.setServletContext(servletContext);
9089
this.privilegeEvaluator.isAllowed("/test", TestAuthentication.authenticatedUser());
9190
ArgumentCaptor<HttpServletRequest> captor = ArgumentCaptor.forClass(HttpServletRequest.class);
@@ -102,7 +101,6 @@ void setRequestTransformerWhenNullThenIllegalArgumentException() {
102101
void isAllowedWhenRequestTransformerThenUsesRequestTransformerResult() {
103102
HttpServletRequest request = new MockHttpServletRequest();
104103
given(this.requestTransformer.transform(any())).willReturn(request);
105-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
106104
this.privilegeEvaluator.setRequestTransformer(this.requestTransformer);
107105

108106
this.privilegeEvaluator.isAllowed("/test", TestAuthentication.authenticatedUser());

web/src/test/java/org/springframework/security/web/access/intercept/AuthorizationFilterTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public void filterWhenAuthorizationManagerVerifyPassesThenNextFilter() throws Ex
118118
@Test
119119
public void filterWhenAuthorizationManagerVerifyThrowsAccessDeniedExceptionThenStopFilterChain() {
120120
AuthorizationManager<HttpServletRequest> mockAuthorizationManager = mock(AuthorizationManager.class);
121-
given(mockAuthorizationManager.authorize(any(), any())).willCallRealMethod();
122121
AuthorizationFilter filter = new AuthorizationFilter(mockAuthorizationManager);
123122
TestingAuthenticationToken authenticationToken = new TestingAuthenticationToken("user", "password");
124123

@@ -196,7 +195,6 @@ public void doFilterWhenAuthorizationEventPublisherThenUses() throws Exception {
196195
@Test
197196
public void doFilterWhenErrorThenDoFilter() throws Exception {
198197
AuthorizationManager<HttpServletRequest> authorizationManager = mock(AuthorizationManager.class);
199-
given(authorizationManager.authorize(any(), any())).willCallRealMethod();
200198
AuthorizationFilter authorizationFilter = new AuthorizationFilter(authorizationManager);
201199
MockHttpServletRequest mockRequest = new MockHttpServletRequest(null, "/path");
202200
mockRequest.setDispatcherType(DispatcherType.ERROR);
@@ -233,7 +231,6 @@ public void doFilterWhenObserveOncePerRequestTrueAndIsAppliedThenNotInvoked() th
233231

234232
@Test
235233
public void doFilterWhenObserveOncePerRequestTrueAndNotAppliedThenInvoked() throws ServletException, IOException {
236-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
237234
this.filter.setObserveOncePerRequest(true);
238235
this.filter.doFilter(this.request, this.response, this.chain);
239236
verify(this.authorizationManager).authorize(any(), any());
@@ -242,15 +239,13 @@ public void doFilterWhenObserveOncePerRequestTrueAndNotAppliedThenInvoked() thro
242239
@Test
243240
public void doFilterWhenObserveOncePerRequestFalseAndIsAppliedThenInvoked() throws ServletException, IOException {
244241
setIsAppliedTrue();
245-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
246242
this.filter.setObserveOncePerRequest(false);
247243
this.filter.doFilter(this.request, this.response, this.chain);
248244
verify(this.authorizationManager).authorize(any(), any());
249245
}
250246

251247
@Test
252248
public void doFilterWhenObserveOncePerRequestFalseAndNotAppliedThenInvoked() throws ServletException, IOException {
253-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
254249
this.filter.setObserveOncePerRequest(false);
255250
this.filter.doFilter(this.request, this.response, this.chain);
256251
verify(this.authorizationManager).authorize(any(), any());
@@ -266,7 +261,6 @@ public void doFilterWhenFilterErrorDispatchFalseAndIsErrorThenNotInvoked() throw
266261

267262
@Test
268263
public void doFilterWhenFilterErrorDispatchTrueAndIsErrorThenInvoked() throws ServletException, IOException {
269-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
270264
this.request.setDispatcherType(DispatcherType.ERROR);
271265
this.filter.setFilterErrorDispatch(true);
272266
this.filter.doFilter(this.request, this.response, this.chain);
@@ -290,7 +284,6 @@ public void doFilterWhenFilterThenRemoveAlreadyFilteredAttribute() throws Servle
290284

291285
@Test
292286
public void doFilterWhenFilterAsyncDispatchTrueAndIsAsyncThenInvoked() throws ServletException, IOException {
293-
given(this.authorizationManager.authorize(any(), any())).willCallRealMethod();
294287
this.request.setDispatcherType(DispatcherType.ASYNC);
295288
this.filter.setFilterAsyncDispatch(true);
296289
this.filter.doFilter(this.request, this.response, this.chain);

web/src/test/java/org/springframework/security/web/server/authorization/DelegatingReactiveAuthorizationManagerTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public void checkWhenFirstMatchesThenNoMoreMatchersAndNoMoreDelegatesInvoked() {
8181
given(this.match1.matches(any())).willReturn(ServerWebExchangeMatcher.MatchResult.match());
8282
given(this.delegate1.authorize(eq(this.authentication), any(AuthorizationContext.class)))
8383
.willReturn(Mono.just(this.decision));
84-
given(this.delegate1.authorize(eq(this.authentication), any(AuthorizationContext.class))).willCallRealMethod();
8584
assertThat(this.manager.authorize(this.authentication, this.exchange).block()).isEqualTo(this.decision);
8685
verifyNoMoreInteractions(this.match2, this.delegate2);
8786
}
@@ -92,7 +91,6 @@ public void checkWhenSecondMatchesThenNoMoreMatchersAndNoMoreDelegatesInvoked()
9291
given(this.match2.matches(any())).willReturn(ServerWebExchangeMatcher.MatchResult.match());
9392
given(this.delegate2.authorize(eq(this.authentication), any(AuthorizationContext.class)))
9493
.willReturn(Mono.just(this.decision));
95-
given(this.delegate2.authorize(eq(this.authentication), any(AuthorizationContext.class))).willCallRealMethod();
9694
assertThat(this.manager.authorize(this.authentication, this.exchange).block()).isEqualTo(this.decision);
9795
verifyNoMoreInteractions(this.delegate1);
9896
}

0 commit comments

Comments
 (0)