From 2e63def05b3f014b09604aa2ba1c866457a97be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 14 Aug 2019 00:56:26 -0500 Subject: [PATCH] Add tests --- .../main/resources/META-INF/spring.schemas | 4 +- .../util/InMemoryXmlApplicationContext.java | 2 +- ...test-ldap-embedded-apacheds-default.gradle | 13 ++++ .../LdapServerBeanDefinitionParserTests.java | 23 ++++--- .../resources/applicationContext-security.xml | 9 +++ .../src/integration-test/resources/users.ldif | 60 +++++++++++++++++++ ...y-itest-ldap-embedded-mode-apacheds.gradle | 13 ++++ .../LdapServerBeanDefinitionParserTests.java | 56 +++++++++++++++++ .../resources/applicationContext-security.xml | 9 +++ .../src/integration-test/resources/users.ldif | 60 +++++++++++++++++++ ...-itest-ldap-embedded-mode-unboundid.gradle | 13 ++++ .../LdapServerBeanDefinitionParserTests.java | 56 +++++++++++++++++ .../resources/applicationContext-security.xml | 9 +++ .../src/integration-test/resources/users.ldif | 60 +++++++++++++++++++ ...g-security-itest-ldap-embedded-none.gradle | 11 ++++ .../LdapServerBeanDefinitionParserTests.java | 53 ++++++++++++++++ .../resources/applicationContext-security.xml | 9 +++ .../src/integration-test/resources/users.ldif | 60 +++++++++++++++++++ ...est-ldap-embedded-unboundid-default.gradle | 13 ++++ .../LdapServerBeanDefinitionParserTests.java | 56 +++++++++++++++++ .../resources/applicationContext-security.xml | 9 +++ .../src/integration-test/resources/users.ldif | 60 +++++++++++++++++++ 22 files changed, 642 insertions(+), 16 deletions(-) create mode 100644 itest/ldap/embedded-ldap-apacheds-default/spring-security-itest-ldap-embedded-apacheds-default.gradle rename config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTest.java => itest/ldap/embedded-ldap-apacheds-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java (62%) create mode 100644 itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/applicationContext-security.xml create mode 100644 itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/users.ldif create mode 100644 itest/ldap/embedded-ldap-mode-apacheds/spring-security-itest-ldap-embedded-mode-apacheds.gradle create mode 100644 itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java create mode 100644 itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/applicationContext-security.xml create mode 100644 itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/users.ldif create mode 100644 itest/ldap/embedded-ldap-mode-unboundid/spring-security-itest-ldap-embedded-mode-unboundid.gradle create mode 100644 itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java create mode 100644 itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/applicationContext-security.xml create mode 100644 itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/users.ldif create mode 100644 itest/ldap/embedded-ldap-none/spring-security-itest-ldap-embedded-none.gradle create mode 100644 itest/ldap/embedded-ldap-none/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java create mode 100644 itest/ldap/embedded-ldap-none/src/integration-test/resources/applicationContext-security.xml create mode 100644 itest/ldap/embedded-ldap-none/src/integration-test/resources/users.ldif create mode 100644 itest/ldap/embedded-ldap-unboundid-default/spring-security-itest-ldap-embedded-unboundid-default.gradle create mode 100644 itest/ldap/embedded-ldap-unboundid-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java create mode 100644 itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/applicationContext-security.xml create mode 100644 itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/users.ldif diff --git a/config/src/main/resources/META-INF/spring.schemas b/config/src/main/resources/META-INF/spring.schemas index e6197602a6..6efb761990 100644 --- a/config/src/main/resources/META-INF/spring.schemas +++ b/config/src/main/resources/META-INF/spring.schemas @@ -1,5 +1,5 @@ -http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd -http\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd +https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd +https\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd http\://www.springframework.org/schema/security/spring-security-5.1.xsd=org/springframework/security/config/spring-security-5.1.xsd http\://www.springframework.org/schema/security/spring-security-5.0.xsd=org/springframework/security/config/spring-security-5.0.xsd http\://www.springframework.org/schema/security/spring-security-4.2.xsd=org/springframework/security/config/spring-security-4.2.xsd diff --git a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java index 4b7ac18d8a..658369d6ca 100644 --- a/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java +++ b/config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java @@ -38,7 +38,7 @@ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext + "http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd\n" + "http://www.springframework.org/schema/websocket https://www.springframework.org/schema/websocket/spring-websocket.xsd\n" + "http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-2.5.xsd\n" - + "http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-"; + + "http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-"; static final String BEANS_CLOSE = "\n"; static final String SPRING_SECURITY_VERSION = "5.2"; diff --git a/itest/ldap/embedded-ldap-apacheds-default/spring-security-itest-ldap-embedded-apacheds-default.gradle b/itest/ldap/embedded-ldap-apacheds-default/spring-security-itest-ldap-embedded-apacheds-default.gradle new file mode 100644 index 0000000000..980de93e6b --- /dev/null +++ b/itest/ldap/embedded-ldap-apacheds-default/spring-security-itest-ldap-embedded-apacheds-default.gradle @@ -0,0 +1,13 @@ +apply plugin: 'io.spring.convention.spring-test' + +dependencies { + compile project(':spring-security-core') + compile 'org.springframework:spring-beans' + compile 'org.springframework:spring-context' + compile 'org.springframework:spring-core' + compile 'org.springframework:spring-tx' + compile project(':spring-security-config') + compile project(':spring-security-ldap') + + runtime apachedsDependencies +} diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTest.java b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java similarity index 62% rename from config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTest.java rename to itest/ldap/embedded-ldap-apacheds-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java index 54e655e7f6..3898aea503 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTest.java +++ b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java @@ -14,13 +14,14 @@ * limitations under the License. */ -package org.springframework.security.config.ldap; +package org.springframework.security; import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.security.config.BeanIds; -import org.springframework.security.config.util.InMemoryXmlApplicationContext; import org.springframework.security.ldap.server.ApacheDSContainer; import static org.assertj.core.api.Assertions.assertThat; @@ -28,9 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Eddú Meléndez */ -public class LdapServerBeanDefinitionParserTest { +public class LdapServerBeanDefinitionParserTests { - private InMemoryXmlApplicationContext context; + private ClassPathXmlApplicationContext context; + + @Before + public void setup() { + this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"); + } @After public void closeAppContext() { @@ -42,15 +48,6 @@ public class LdapServerBeanDefinitionParserTest { @Test public void apacheDirectoryServerIsStartedByDefault() { - this.context = new InMemoryXmlApplicationContext("", "5.2", null); - String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class); - assertThat(beanNames).hasSize(1); - assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS); - } - - @Test - public void apacheDirectoryServerIsStartedWhenIsSet() { - this.context = new InMemoryXmlApplicationContext("", "5.2", null); String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class); assertThat(beanNames).hasSize(1); assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS); diff --git a/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/applicationContext-security.xml b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/applicationContext-security.xml new file mode 100644 index 0000000000..da547d0b04 --- /dev/null +++ b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/applicationContext-security.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/users.ldif b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/users.ldif new file mode 100644 index 0000000000..222e03793c --- /dev/null +++ b/itest/ldap/embedded-ldap-apacheds-default/src/integration-test/resources/users.ldif @@ -0,0 +1,60 @@ +dn: ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: groups + +dn: ou=people,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=rod,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Rod Johnson +sn: Johnson +uid: rod +userPassword: koala + +dn: uid=dianne,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Dianne Emu +sn: Emu +uid: dianne +userPassword: emu + +dn: uid=scott,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Scott +sn: Wombat +uid: scott +userPassword: wombat + +dn: cn=user,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org +member: uid=scott,ou=people,dc=springframework,dc=org + +dn: cn=teller,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: teller +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org + +dn: cn=supervisor,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: supervisor +member: uid=rod,ou=people,dc=springframework,dc=org diff --git a/itest/ldap/embedded-ldap-mode-apacheds/spring-security-itest-ldap-embedded-mode-apacheds.gradle b/itest/ldap/embedded-ldap-mode-apacheds/spring-security-itest-ldap-embedded-mode-apacheds.gradle new file mode 100644 index 0000000000..980de93e6b --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-apacheds/spring-security-itest-ldap-embedded-mode-apacheds.gradle @@ -0,0 +1,13 @@ +apply plugin: 'io.spring.convention.spring-test' + +dependencies { + compile project(':spring-security-core') + compile 'org.springframework:spring-beans' + compile 'org.springframework:spring-context' + compile 'org.springframework:spring-core' + compile 'org.springframework:spring-tx' + compile project(':spring-security-config') + compile project(':spring-security-ldap') + + runtime apachedsDependencies +} diff --git a/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java new file mode 100644 index 0000000000..3898aea503 --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.security.config.BeanIds; +import org.springframework.security.ldap.server.ApacheDSContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Eddú Meléndez + */ +public class LdapServerBeanDefinitionParserTests { + + private ClassPathXmlApplicationContext context; + + @Before + public void setup() { + this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"); + } + + @After + public void closeAppContext() { + if (this.context != null) { + this.context.close(); + this.context = null; + } + } + + @Test + public void apacheDirectoryServerIsStartedByDefault() { + String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class); + assertThat(beanNames).hasSize(1); + assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS); + } + +} diff --git a/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/applicationContext-security.xml b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/applicationContext-security.xml new file mode 100644 index 0000000000..f980c6ca98 --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/applicationContext-security.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/users.ldif b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/users.ldif new file mode 100644 index 0000000000..222e03793c --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-apacheds/src/integration-test/resources/users.ldif @@ -0,0 +1,60 @@ +dn: ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: groups + +dn: ou=people,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=rod,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Rod Johnson +sn: Johnson +uid: rod +userPassword: koala + +dn: uid=dianne,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Dianne Emu +sn: Emu +uid: dianne +userPassword: emu + +dn: uid=scott,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Scott +sn: Wombat +uid: scott +userPassword: wombat + +dn: cn=user,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org +member: uid=scott,ou=people,dc=springframework,dc=org + +dn: cn=teller,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: teller +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org + +dn: cn=supervisor,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: supervisor +member: uid=rod,ou=people,dc=springframework,dc=org diff --git a/itest/ldap/embedded-ldap-mode-unboundid/spring-security-itest-ldap-embedded-mode-unboundid.gradle b/itest/ldap/embedded-ldap-mode-unboundid/spring-security-itest-ldap-embedded-mode-unboundid.gradle new file mode 100644 index 0000000000..45f180468b --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-unboundid/spring-security-itest-ldap-embedded-mode-unboundid.gradle @@ -0,0 +1,13 @@ +apply plugin: 'io.spring.convention.spring-test' + +dependencies { + compile project(':spring-security-core') + compile 'org.springframework:spring-beans' + compile 'org.springframework:spring-context' + compile 'org.springframework:spring-core' + compile 'org.springframework:spring-tx' + compile project(':spring-security-config') + compile project(':spring-security-ldap') + + testCompile "com.unboundid:unboundid-ldapsdk" +} diff --git a/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java new file mode 100644 index 0000000000..e169615b21 --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.security.config.BeanIds; +import org.springframework.security.ldap.server.UnboundIdContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Eddú Meléndez + */ +public class LdapServerBeanDefinitionParserTests { + + private ClassPathXmlApplicationContext context; + + @Before + public void setup() { + this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"); + } + + @After + public void closeAppContext() { + if (this.context != null) { + this.context.close(); + this.context = null; + } + } + + @Test + public void apacheDirectoryServerIsStartedByDefault() { + String[] beanNames = this.context.getBeanNamesForType(UnboundIdContainer.class); + assertThat(beanNames).hasSize(1); + assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_UNBOUNDID); + } + +} diff --git a/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/applicationContext-security.xml b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/applicationContext-security.xml new file mode 100644 index 0000000000..6254829b43 --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/applicationContext-security.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/users.ldif b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/users.ldif new file mode 100644 index 0000000000..222e03793c --- /dev/null +++ b/itest/ldap/embedded-ldap-mode-unboundid/src/integration-test/resources/users.ldif @@ -0,0 +1,60 @@ +dn: ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: groups + +dn: ou=people,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=rod,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Rod Johnson +sn: Johnson +uid: rod +userPassword: koala + +dn: uid=dianne,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Dianne Emu +sn: Emu +uid: dianne +userPassword: emu + +dn: uid=scott,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Scott +sn: Wombat +uid: scott +userPassword: wombat + +dn: cn=user,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org +member: uid=scott,ou=people,dc=springframework,dc=org + +dn: cn=teller,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: teller +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org + +dn: cn=supervisor,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: supervisor +member: uid=rod,ou=people,dc=springframework,dc=org diff --git a/itest/ldap/embedded-ldap-none/spring-security-itest-ldap-embedded-none.gradle b/itest/ldap/embedded-ldap-none/spring-security-itest-ldap-embedded-none.gradle new file mode 100644 index 0000000000..79d8418fde --- /dev/null +++ b/itest/ldap/embedded-ldap-none/spring-security-itest-ldap-embedded-none.gradle @@ -0,0 +1,11 @@ +apply plugin: 'io.spring.convention.spring-test' + +dependencies { + compile project(':spring-security-core') + compile 'org.springframework:spring-beans' + compile 'org.springframework:spring-context' + compile 'org.springframework:spring-core' + compile 'org.springframework:spring-tx' + compile project(':spring-security-config') + compile project(':spring-security-ldap') +} diff --git a/itest/ldap/embedded-ldap-none/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java b/itest/ldap/embedded-ldap-none/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java new file mode 100644 index 0000000000..ce6677bd68 --- /dev/null +++ b/itest/ldap/embedded-ldap-none/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java @@ -0,0 +1,53 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security; + +import org.junit.After; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import org.springframework.beans.factory.BeanDefinitionStoreException; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author Eddú Meléndez + */ +public class LdapServerBeanDefinitionParserTests { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private ClassPathXmlApplicationContext context; + + @After + public void closeAppContext() { + if (this.context != null) { + this.context.close(); + this.context = null; + } + } + + @Test + public void apacheDirectoryServerIsStartedByDefault() { + this.thrown.expect(BeanDefinitionStoreException.class); + this.thrown.expectMessage("Embedded LDAP server is not provided"); + + this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"); + } + +} diff --git a/itest/ldap/embedded-ldap-none/src/integration-test/resources/applicationContext-security.xml b/itest/ldap/embedded-ldap-none/src/integration-test/resources/applicationContext-security.xml new file mode 100644 index 0000000000..da547d0b04 --- /dev/null +++ b/itest/ldap/embedded-ldap-none/src/integration-test/resources/applicationContext-security.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/itest/ldap/embedded-ldap-none/src/integration-test/resources/users.ldif b/itest/ldap/embedded-ldap-none/src/integration-test/resources/users.ldif new file mode 100644 index 0000000000..222e03793c --- /dev/null +++ b/itest/ldap/embedded-ldap-none/src/integration-test/resources/users.ldif @@ -0,0 +1,60 @@ +dn: ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: groups + +dn: ou=people,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=rod,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Rod Johnson +sn: Johnson +uid: rod +userPassword: koala + +dn: uid=dianne,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Dianne Emu +sn: Emu +uid: dianne +userPassword: emu + +dn: uid=scott,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Scott +sn: Wombat +uid: scott +userPassword: wombat + +dn: cn=user,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org +member: uid=scott,ou=people,dc=springframework,dc=org + +dn: cn=teller,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: teller +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org + +dn: cn=supervisor,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: supervisor +member: uid=rod,ou=people,dc=springframework,dc=org diff --git a/itest/ldap/embedded-ldap-unboundid-default/spring-security-itest-ldap-embedded-unboundid-default.gradle b/itest/ldap/embedded-ldap-unboundid-default/spring-security-itest-ldap-embedded-unboundid-default.gradle new file mode 100644 index 0000000000..45f180468b --- /dev/null +++ b/itest/ldap/embedded-ldap-unboundid-default/spring-security-itest-ldap-embedded-unboundid-default.gradle @@ -0,0 +1,13 @@ +apply plugin: 'io.spring.convention.spring-test' + +dependencies { + compile project(':spring-security-core') + compile 'org.springframework:spring-beans' + compile 'org.springframework:spring-context' + compile 'org.springframework:spring-core' + compile 'org.springframework:spring-tx' + compile project(':spring-security-config') + compile project(':spring-security-ldap') + + testCompile "com.unboundid:unboundid-ldapsdk" +} diff --git a/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java new file mode 100644 index 0000000000..e169615b21 --- /dev/null +++ b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.security; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.security.config.BeanIds; +import org.springframework.security.ldap.server.UnboundIdContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Eddú Meléndez + */ +public class LdapServerBeanDefinitionParserTests { + + private ClassPathXmlApplicationContext context; + + @Before + public void setup() { + this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"); + } + + @After + public void closeAppContext() { + if (this.context != null) { + this.context.close(); + this.context = null; + } + } + + @Test + public void apacheDirectoryServerIsStartedByDefault() { + String[] beanNames = this.context.getBeanNamesForType(UnboundIdContainer.class); + assertThat(beanNames).hasSize(1); + assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_UNBOUNDID); + } + +} diff --git a/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/applicationContext-security.xml b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/applicationContext-security.xml new file mode 100644 index 0000000000..da547d0b04 --- /dev/null +++ b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/applicationContext-security.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/users.ldif b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/users.ldif new file mode 100644 index 0000000000..222e03793c --- /dev/null +++ b/itest/ldap/embedded-ldap-unboundid-default/src/integration-test/resources/users.ldif @@ -0,0 +1,60 @@ +dn: ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: groups + +dn: ou=people,dc=springframework,dc=org +objectclass: top +objectclass: organizationalUnit +ou: people + +dn: uid=rod,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Rod Johnson +sn: Johnson +uid: rod +userPassword: koala + +dn: uid=dianne,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Dianne Emu +sn: Emu +uid: dianne +userPassword: emu + +dn: uid=scott,ou=people,dc=springframework,dc=org +objectclass: top +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +cn: Scott +sn: Wombat +uid: scott +userPassword: wombat + +dn: cn=user,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: user +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org +member: uid=scott,ou=people,dc=springframework,dc=org + +dn: cn=teller,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: teller +member: uid=rod,ou=people,dc=springframework,dc=org +member: uid=dianne,ou=people,dc=springframework,dc=org + +dn: cn=supervisor,ou=groups,dc=springframework,dc=org +objectclass: top +objectclass: groupOfNames +cn: supervisor +member: uid=rod,ou=people,dc=springframework,dc=org