Merge branch '6.3.x'
This commit is contained in:
commit
dff3780c5e
|
@ -104,6 +104,8 @@ import static org.mockito.Mockito.atLeastOnce;
|
|||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
|
@ -995,6 +997,18 @@ public class PrePostMethodSecurityConfigurationTests {
|
|||
"postFilterAuthorizationMethodInterceptor", "authorizeReturnObjectMethodInterceptor");
|
||||
}
|
||||
|
||||
// gh-15651
|
||||
@Test
|
||||
@WithMockUser(roles = "ADMIN")
|
||||
public void adviseWhenPrePostEnabledThenEachInterceptorRunsExactlyOnce() {
|
||||
this.spring.register(MethodSecurityServiceConfig.class, CustomMethodSecurityExpressionHandlerConfig.class)
|
||||
.autowire();
|
||||
MethodSecurityExpressionHandler expressionHandler = this.spring.getContext()
|
||||
.getBean(MethodSecurityExpressionHandler.class);
|
||||
this.methodSecurityService.manyAnnotations(new ArrayList<>(Arrays.asList("harold", "jonathan", "tim", "bo")));
|
||||
verify(expressionHandler, times(4)).createEvaluationContext(any(Supplier.class), any());
|
||||
}
|
||||
|
||||
private static Consumer<ConfigurableWebApplicationContext> disallowBeanOverriding() {
|
||||
return (context) -> ((AnnotationConfigWebApplicationContext) context).setAllowBeanDefinitionOverriding(false);
|
||||
}
|
||||
|
@ -1090,6 +1104,19 @@ public class PrePostMethodSecurityConfigurationTests {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@EnableMethodSecurity
|
||||
static class CustomMethodSecurityExpressionHandlerConfig {
|
||||
|
||||
private final MethodSecurityExpressionHandler expressionHandler = spy(
|
||||
new DefaultMethodSecurityExpressionHandler());
|
||||
|
||||
@Bean
|
||||
MethodSecurityExpressionHandler methodSecurityExpressionHandler() {
|
||||
return this.expressionHandler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EnableMethodSecurity
|
||||
static class CustomPermissionEvaluatorConfig {
|
||||
|
||||
|
|
Loading…
Reference in New Issue