Fix tests

Some assumptions were being made in tests, e.g. about
there being an AuthenticationManager @Bean, which were
false with the new Security 3.2.1 updates from Rob.

Also parent-child contexts with the actuator were
problematic because they didn't exclude the web configuration
for the management security in the parent context.

Fixes gh-244
This commit is contained in:
Dave Syer
2014-02-26 18:15:05 +00:00
parent 6b0eba3759
commit b0b7bc0e7f
5 changed files with 45 additions and 51 deletions

View File

@@ -98,8 +98,8 @@ public class ManagementSecurityAutoConfigurationTests {
private UserDetails getUser() {
ProviderManager manager = this.context.getBean(ProviderManager.class);
ProviderManager parent = (ProviderManager) ReflectionTestUtils.getField(
manager, "parent");
ProviderManager parent = (ProviderManager) ReflectionTestUtils.getField(manager,
"parent");
DaoAuthenticationProvider provider = (DaoAuthenticationProvider) parent
.getProviders().get(0);
UserDetailsService service = (UserDetailsService) ReflectionTestUtils.getField(
@@ -159,7 +159,7 @@ public class ManagementSecurityAutoConfigurationTests {
public void testSecurityPropertiesNotAvailable() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(TestConfiguration.class,
this.context.register(TestConfiguration.class, SecurityAutoConfiguration.class,
ManagementSecurityAutoConfiguration.class,
EndpointAutoConfiguration.class,
ManagementServerPropertiesAutoConfiguration.class,

View File

@@ -19,8 +19,6 @@ package org.springframework.boot.actuate.autoconfigure;
import org.junit.After;
import org.junit.Test;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
@@ -61,9 +59,8 @@ public class SpringApplicationHierarchyTests {
public static class Child {
}
@EnableAutoConfiguration(exclude = { ServerPropertiesAutoConfiguration.class,
JolokiaAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class,
SecurityAutoConfiguration.class })
@EnableAutoConfiguration(exclude = { JolokiaAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class })
public static class Parent {
}