Permalink
Browse files

Add tests and README for \!private profile

Change-Id: I0e2c0c6c1371471d6d65c12febc88763afdcc67c
  • Loading branch information...
1 parent 6cdec0b commit 7a309ad6d95c00cdd676ae2866c2014e7a92b541 @dsyer dsyer committed Dec 21, 2011
Showing with 39 additions and 6 deletions.
  1. +6 −0 README.md
  2. +33 −6 uaa/src/test/java/org/cloudfoundry/identity/uaa/BootstrapTests.java
View
@@ -131,6 +131,12 @@ with an embedded HSQL database:
Or to use PostgreSQL instead of HSQL:
mvn -Dspring.profiles.active=default,jdbc,postgresql tomcat:run
+
+To launch in a microcloud type environment you need the SCIM user
+endpoints to be unsecure so that a user can create an account and set
+its password to bootstrap the system. For this use the Spring profile
+`private`. The opposite is `!private` which needs to be specified
+excplicitly if the any other profiles are active.
## The API Application
@@ -24,43 +24,70 @@
import org.junit.Test;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.core.io.FileSystemResource;
+import org.springframework.mock.web.MockFilterChain;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.security.web.FilterChainProxy;
/**
* @author Dave Syer
*
*/
public class BootstrapTests {
+ private GenericXmlApplicationContext context;
@After
public void cleanup() {
System.clearProperty("spring.profiles.active");
System.clearProperty("CLOUD_FOUNDRY_CONFIG_PATH");
+ if (context!=null) {
+ context.close();
+ }
}
@Test
public void testRootContextWithJdbcUsers() throws Exception {
System.setProperty("spring.profiles.active", "jdbc,hsqldb");
- GenericXmlApplicationContext context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
+ context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
assertNotNull(context.getBean("userDatabase", JdbcUaaUserDatabase.class));
- context.close();
}
@Test
public void testRootContextWithDevUsers() throws Exception {
- GenericXmlApplicationContext context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
+ context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
assertNotNull(context.getBean("userDatabase", InMemoryUaaUserDatabase.class));
- context.close();
+ }
+
+ @Test
+ public void testRootContextWithJdbcSecureUsers() throws Exception {
+ System.setProperty("spring.profiles.active", "jdbc,hsqldb,!private");
+ context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
+ assertNotNull(context.getBean("userDatabase", JdbcUaaUserDatabase.class));
+ FilterChainProxy filterChain = context.getBean(FilterChainProxy.class);
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ filterChain.doFilter(new MockHttpServletRequest("GET", "/Users"), response, new MockFilterChain());
+ assertEquals("http://localhost/login", response.getRedirectedUrl());
+ }
+
+ @Test
+ public void testRootContextWithJdbcUnsecureUsers() throws Exception {
+ System.setProperty("spring.profiles.active", "jdbc,hsqldb,private");
+ context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
+ assertNotNull(context.getBean("userDatabase", JdbcUaaUserDatabase.class));
+ FilterChainProxy filterChain = context.getBean(FilterChainProxy.class);
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ filterChain.doFilter(new MockHttpServletRequest("GET", "/Users"), response, new MockFilterChain());
+ assertEquals(null, response.getRedirectedUrl());
}
@Test
public void testOverrideYmlConfig() throws Exception {
System.setProperty("CLOUD_FOUNDRY_CONFIG_PATH", "src/test/resources/test/config");
System.setProperty("spring.profiles.active", "jdbc,hsqldb");
- GenericXmlApplicationContext context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
+ context = new GenericXmlApplicationContext(new FileSystemResource("src/main/webapp/WEB-INF/spring-servlet.xml"));
Properties properties = context.getBean("applicationProperties", Properties.class);
assertEquals("bar", properties.get("foo"));
- context.close();
}
}

0 comments on commit 7a309ad

Please sign in to comment.