|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
22 | 22 | import java.util.List;
|
| 23 | +import java.util.function.Consumer; |
23 | 24 | import java.util.function.Supplier;
|
24 | 25 |
|
25 | 26 | import org.aopalliance.intercept.MethodInterceptor;
|
|
64 | 65 | import org.springframework.test.context.ContextConfiguration;
|
65 | 66 | import org.springframework.test.context.TestExecutionListeners;
|
66 | 67 | import org.springframework.test.context.junit.jupiter.SpringExtension;
|
| 68 | +import org.springframework.web.context.ConfigurableWebApplicationContext; |
| 69 | +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; |
67 | 70 |
|
68 | 71 | import static org.assertj.core.api.Assertions.assertThat;
|
69 | 72 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
@@ -418,6 +421,17 @@ public void configureWhenAspectJThenRegistersAspects() {
|
418 | 421 | assertThat(this.spring.getContext().containsBean("annotationSecurityAspect$0")).isFalse();
|
419 | 422 | }
|
420 | 423 |
|
| 424 | + // gh-13572 |
| 425 | + @Test |
| 426 | + public void configureWhenBeanOverridingDisallowedThenWorks() { |
| 427 | + this.spring.register(MethodSecurityServiceConfig.class, BusinessServiceConfig.class) |
| 428 | + .postProcessor(disallowBeanOverriding()).autowire(); |
| 429 | + } |
| 430 | + |
| 431 | + private static Consumer<ConfigurableWebApplicationContext> disallowBeanOverriding() { |
| 432 | + return (context) -> ((AnnotationConfigWebApplicationContext) context).setAllowBeanDefinitionOverriding(false); |
| 433 | + } |
| 434 | + |
421 | 435 | @Configuration
|
422 | 436 | @EnableMethodSecurity
|
423 | 437 | static class MethodSecurityServiceConfig {
|
|
0 commit comments