Skip to content

Commit 924b9e9

Browse files
committed
Polish MethodSecurityEvaluationContext
Issue: gh-6224
1 parent 150b668 commit 924b9e9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

config/src/test/java/org/springframework/security/config/annotation/method/configuration/ReactiveMethodSecurityConfigurationTests.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.security.config.annotation.method.configuration;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.mockito.Mockito.mock;
2120

2221
import org.junit.Rule;
2322
import org.junit.Test;
@@ -44,12 +43,12 @@ public class ReactiveMethodSecurityConfigurationTests {
4443
DefaultMethodSecurityExpressionHandler methodSecurityExpressionHandler;
4544

4645
@Test
47-
public void rolePrefixWithGrantedAuthorityDefaults() {
46+
public void rolePrefixWithGrantedAuthorityDefaults() throws NoSuchMethodException {
4847
this.spring.register(WithRolePrefixConfiguration.class).autowire();
4948

5049
TestingAuthenticationToken authentication = new TestingAuthenticationToken(
5150
"principal", "credential", "CUSTOM_ABC");
52-
MockMethodInvocation methodInvocation = mock(MockMethodInvocation.class);
51+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new Foo(), Foo.class, "bar", String.class);
5352

5453
EvaluationContext context = this.methodSecurityExpressionHandler
5554
.createEvaluationContext(authentication, methodInvocation);
@@ -63,12 +62,12 @@ public void rolePrefixWithGrantedAuthorityDefaults() {
6362
}
6463

6564
@Test
66-
public void rolePrefixWithDefaultConfig() {
65+
public void rolePrefixWithDefaultConfig() throws NoSuchMethodException {
6766
this.spring.register(ReactiveMethodSecurityConfiguration.class).autowire();
6867

6968
TestingAuthenticationToken authentication = new TestingAuthenticationToken(
7069
"principal", "credential", "ROLE_ABC");
71-
MockMethodInvocation methodInvocation = mock(MockMethodInvocation.class);
70+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new Foo(), Foo.class, "bar", String.class);
7271

7372
EvaluationContext context = this.methodSecurityExpressionHandler
7473
.createEvaluationContext(authentication, methodInvocation);
@@ -89,12 +88,12 @@ GrantedAuthorityDefaults grantedAuthorityDefaults() {
8988
}
9089

9190
@Test
92-
public void rolePrefixWithGrantedAuthorityDefaultsAndSubclassWithProxyingEnabled() {
91+
public void rolePrefixWithGrantedAuthorityDefaultsAndSubclassWithProxyingEnabled() throws NoSuchMethodException {
9392
this.spring.register(SubclassConfig.class).autowire();
9493

9594
TestingAuthenticationToken authentication = new TestingAuthenticationToken(
9695
"principal", "credential", "ROLE_ABC");
97-
MockMethodInvocation methodInvocation = mock(MockMethodInvocation.class);
96+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new Foo(), Foo.class, "bar", String.class);
9897

9998
EvaluationContext context = this.methodSecurityExpressionHandler
10099
.createEvaluationContext(authentication, methodInvocation);
@@ -108,4 +107,9 @@ public void rolePrefixWithGrantedAuthorityDefaultsAndSubclassWithProxyingEnabled
108107
@Configuration
109108
static class SubclassConfig extends ReactiveMethodSecurityConfiguration {
110109
}
110+
111+
private static class Foo {
112+
public void bar(String param){
113+
}
114+
}
111115
}

0 commit comments

Comments
 (0)