diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java index c48803ceed..f3caec0faa 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.java @@ -160,7 +160,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa } @Bean - public AutowiredWebSecurityConfigurersIgnoreParents autowiredWebSecurityConfigurersIgnoreParents( + public static AutowiredWebSecurityConfigurersIgnoreParents autowiredWebSecurityConfigurersIgnoreParents( ConfigurableListableBeanFactory beanFactory) { return new AutowiredWebSecurityConfigurersIgnoreParents(beanFactory); } diff --git a/config/src/test/groovy/org/springframework/security/config/annotation/BaseSpringSpec.groovy b/config/src/test/groovy/org/springframework/security/config/annotation/BaseSpringSpec.groovy index 1385250b02..1549f10155 100644 --- a/config/src/test/groovy/org/springframework/security/config/annotation/BaseSpringSpec.groovy +++ b/config/src/test/groovy/org/springframework/security/config/annotation/BaseSpringSpec.groovy @@ -51,6 +51,7 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon * @author Rob Winch */ abstract class BaseSpringSpec extends Specification { + boolean allowCircularReferences = false @AutoCleanup ConfigurableApplicationContext context @AutoCleanup @@ -89,6 +90,7 @@ abstract class BaseSpringSpec extends Specification { def loadConfig(Class... configs) { context = new AnnotationConfigWebApplicationContext() + context.setAllowCircularReferences(allowCircularReferences) context.register(configs) context.setServletContext(new MockServletContext()) context.refresh() @@ -169,4 +171,4 @@ abstract class BaseSpringSpec extends Specification { def getObjectPostProcessor() { oppContext.getBean(ObjectPostProcessor) } -} \ No newline at end of file +} diff --git a/config/src/test/groovy/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.groovy b/config/src/test/groovy/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.groovy index b387def0e0..9c39942e8a 100644 --- a/config/src/test/groovy/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.groovy +++ b/config/src/test/groovy/org/springframework/security/config/annotation/web/WebSecurityConfigurerAdapterTests.groovy @@ -176,7 +176,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec { static ContentNegotiationStrategy CNS @Bean - public ContentNegotiationStrategy cns() { + public static ContentNegotiationStrategy cns() { return CNS } } @@ -193,6 +193,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec { def "UserDetailsService lazy"() { setup: + allowCircularReferences = true loadConfig(RequiresUserDetailsServiceConfig,UserDetailsServiceConfig) when: findFilter(MyFilter).userDetailsService.loadUserByUsername("user") @@ -274,7 +275,7 @@ class WebSecurityConfigurerAdapterTests extends BaseSpringSpec { static AuthenticationTrustResolver TR @Bean - public AuthenticationTrustResolver tr() { + public static AuthenticationTrustResolver tr() { return TR } } diff --git a/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerTests.groovy b/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerTests.groovy index c0ee2ae2a3..12c9ab4b26 100644 --- a/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerTests.groovy +++ b/config/src/test/groovy/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerTests.groovy @@ -155,7 +155,7 @@ class ExceptionHandlingConfigurerTests extends BaseSpringSpec { static ContentNegotiationStrategy CNS @Bean - public ContentNegotiationStrategy cns() { + public static ContentNegotiationStrategy cns() { return CNS } }