Skip to content

Commit 2e63def

Browse files
committed
Add tests
1 parent 93142f3 commit 2e63def

File tree

22 files changed

+642
-16
lines changed

22 files changed

+642
-16
lines changed

config/src/main/resources/META-INF/spring.schemas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
http\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd
2-
http\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd
1+
https\://www.springframework.org/schema/security/spring-security.xsd=org/springframework/security/config/spring-security-5.2.xsd
2+
https\://www.springframework.org/schema/security/spring-security-5.2.xsd=org/springframework/security/config/spring-security-5.2.xsd
33
http\://www.springframework.org/schema/security/spring-security-5.1.xsd=org/springframework/security/config/spring-security-5.1.xsd
44
http\://www.springframework.org/schema/security/spring-security-5.0.xsd=org/springframework/security/config/spring-security-5.0.xsd
55
http\://www.springframework.org/schema/security/spring-security-4.2.xsd=org/springframework/security/config/spring-security-4.2.xsd

config/src/test/java/org/springframework/security/config/util/InMemoryXmlApplicationContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class InMemoryXmlApplicationContext extends AbstractXmlApplicationContext
3838
+ "http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd\n"
3939
+ "http://www.springframework.org/schema/websocket https://www.springframework.org/schema/websocket/spring-websocket.xsd\n"
4040
+ "http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context-2.5.xsd\n"
41-
+ "http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-";
41+
+ "http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security-";
4242
static final String BEANS_CLOSE = "</b:beans>\n";
4343

4444
static final String SPRING_SECURITY_VERSION = "5.2";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apply plugin: 'io.spring.convention.spring-test'
2+
3+
dependencies {
4+
compile project(':spring-security-core')
5+
compile 'org.springframework:spring-beans'
6+
compile 'org.springframework:spring-context'
7+
compile 'org.springframework:spring-core'
8+
compile 'org.springframework:spring-tx'
9+
compile project(':spring-security-config')
10+
compile project(':spring-security-ldap')
11+
12+
runtime apachedsDependencies
13+
}

config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTest.java renamed to itest/ldap/embedded-ldap-apacheds-default/src/integration-test/java/org/springframework/security/LdapServerBeanDefinitionParserTests.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,29 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.security.config.ldap;
17+
package org.springframework.security;
1818

1919
import org.junit.After;
20+
import org.junit.Before;
2021
import org.junit.Test;
2122

23+
import org.springframework.context.support.ClassPathXmlApplicationContext;
2224
import org.springframework.security.config.BeanIds;
23-
import org.springframework.security.config.util.InMemoryXmlApplicationContext;
2425
import org.springframework.security.ldap.server.ApacheDSContainer;
2526

2627
import static org.assertj.core.api.Assertions.assertThat;
2728

2829
/**
2930
* @author Eddú Meléndez
3031
*/
31-
public class LdapServerBeanDefinitionParserTest {
32+
public class LdapServerBeanDefinitionParserTests {
3233

33-
private InMemoryXmlApplicationContext context;
34+
private ClassPathXmlApplicationContext context;
35+
36+
@Before
37+
public void setup() {
38+
this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml");
39+
}
3440

3541
@After
3642
public void closeAppContext() {
@@ -42,15 +48,6 @@ public void closeAppContext() {
4248

4349
@Test
4450
public void apacheDirectoryServerIsStartedByDefault() {
45-
this.context = new InMemoryXmlApplicationContext("<ldap-user-service user-search-filter='(uid={0})'/><ldap-server/>", "5.2", null);
46-
String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class);
47-
assertThat(beanNames).hasSize(1);
48-
assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS);
49-
}
50-
51-
@Test
52-
public void apacheDirectoryServerIsStartedWhenIsSet() {
53-
this.context = new InMemoryXmlApplicationContext("<ldap-user-service user-search-filter='(uid={0})' /><ldap-server mode='apacheds'/>", "5.2", null);
5451
String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class);
5552
assertThat(beanNames).hasSize(1);
5653
assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:s="http://www.springframework.org/schema/security"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
5+
http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
6+
7+
<s:ldap-server ldif="classpath:users.ldif"/>
8+
9+
</beans>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
dn: ou=groups,dc=springframework,dc=org
2+
objectclass: top
3+
objectclass: organizationalUnit
4+
ou: groups
5+
6+
dn: ou=people,dc=springframework,dc=org
7+
objectclass: top
8+
objectclass: organizationalUnit
9+
ou: people
10+
11+
dn: uid=rod,ou=people,dc=springframework,dc=org
12+
objectclass: top
13+
objectclass: person
14+
objectclass: organizationalPerson
15+
objectclass: inetOrgPerson
16+
cn: Rod Johnson
17+
sn: Johnson
18+
uid: rod
19+
userPassword: koala
20+
21+
dn: uid=dianne,ou=people,dc=springframework,dc=org
22+
objectclass: top
23+
objectclass: person
24+
objectclass: organizationalPerson
25+
objectclass: inetOrgPerson
26+
cn: Dianne Emu
27+
sn: Emu
28+
uid: dianne
29+
userPassword: emu
30+
31+
dn: uid=scott,ou=people,dc=springframework,dc=org
32+
objectclass: top
33+
objectclass: person
34+
objectclass: organizationalPerson
35+
objectclass: inetOrgPerson
36+
cn: Scott
37+
sn: Wombat
38+
uid: scott
39+
userPassword: wombat
40+
41+
dn: cn=user,ou=groups,dc=springframework,dc=org
42+
objectclass: top
43+
objectclass: groupOfNames
44+
cn: user
45+
member: uid=rod,ou=people,dc=springframework,dc=org
46+
member: uid=dianne,ou=people,dc=springframework,dc=org
47+
member: uid=scott,ou=people,dc=springframework,dc=org
48+
49+
dn: cn=teller,ou=groups,dc=springframework,dc=org
50+
objectclass: top
51+
objectclass: groupOfNames
52+
cn: teller
53+
member: uid=rod,ou=people,dc=springframework,dc=org
54+
member: uid=dianne,ou=people,dc=springframework,dc=org
55+
56+
dn: cn=supervisor,ou=groups,dc=springframework,dc=org
57+
objectclass: top
58+
objectclass: groupOfNames
59+
cn: supervisor
60+
member: uid=rod,ou=people,dc=springframework,dc=org
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apply plugin: 'io.spring.convention.spring-test'
2+
3+
dependencies {
4+
compile project(':spring-security-core')
5+
compile 'org.springframework:spring-beans'
6+
compile 'org.springframework:spring-context'
7+
compile 'org.springframework:spring-core'
8+
compile 'org.springframework:spring-tx'
9+
compile project(':spring-security-config')
10+
compile project(':spring-security-ldap')
11+
12+
runtime apachedsDependencies
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security;
18+
19+
import org.junit.After;
20+
import org.junit.Before;
21+
import org.junit.Test;
22+
23+
import org.springframework.context.support.ClassPathXmlApplicationContext;
24+
import org.springframework.security.config.BeanIds;
25+
import org.springframework.security.ldap.server.ApacheDSContainer;
26+
27+
import static org.assertj.core.api.Assertions.assertThat;
28+
29+
/**
30+
* @author Eddú Meléndez
31+
*/
32+
public class LdapServerBeanDefinitionParserTests {
33+
34+
private ClassPathXmlApplicationContext context;
35+
36+
@Before
37+
public void setup() {
38+
this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml");
39+
}
40+
41+
@After
42+
public void closeAppContext() {
43+
if (this.context != null) {
44+
this.context.close();
45+
this.context = null;
46+
}
47+
}
48+
49+
@Test
50+
public void apacheDirectoryServerIsStartedByDefault() {
51+
String[] beanNames = this.context.getBeanNamesForType(ApacheDSContainer.class);
52+
assertThat(beanNames).hasSize(1);
53+
assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_APACHE_DS);
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:s="http://www.springframework.org/schema/security"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
5+
http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
6+
7+
<s:ldap-server mode="apacheds" ldif="classpath:users.ldif"/>
8+
9+
</beans>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
dn: ou=groups,dc=springframework,dc=org
2+
objectclass: top
3+
objectclass: organizationalUnit
4+
ou: groups
5+
6+
dn: ou=people,dc=springframework,dc=org
7+
objectclass: top
8+
objectclass: organizationalUnit
9+
ou: people
10+
11+
dn: uid=rod,ou=people,dc=springframework,dc=org
12+
objectclass: top
13+
objectclass: person
14+
objectclass: organizationalPerson
15+
objectclass: inetOrgPerson
16+
cn: Rod Johnson
17+
sn: Johnson
18+
uid: rod
19+
userPassword: koala
20+
21+
dn: uid=dianne,ou=people,dc=springframework,dc=org
22+
objectclass: top
23+
objectclass: person
24+
objectclass: organizationalPerson
25+
objectclass: inetOrgPerson
26+
cn: Dianne Emu
27+
sn: Emu
28+
uid: dianne
29+
userPassword: emu
30+
31+
dn: uid=scott,ou=people,dc=springframework,dc=org
32+
objectclass: top
33+
objectclass: person
34+
objectclass: organizationalPerson
35+
objectclass: inetOrgPerson
36+
cn: Scott
37+
sn: Wombat
38+
uid: scott
39+
userPassword: wombat
40+
41+
dn: cn=user,ou=groups,dc=springframework,dc=org
42+
objectclass: top
43+
objectclass: groupOfNames
44+
cn: user
45+
member: uid=rod,ou=people,dc=springframework,dc=org
46+
member: uid=dianne,ou=people,dc=springframework,dc=org
47+
member: uid=scott,ou=people,dc=springframework,dc=org
48+
49+
dn: cn=teller,ou=groups,dc=springframework,dc=org
50+
objectclass: top
51+
objectclass: groupOfNames
52+
cn: teller
53+
member: uid=rod,ou=people,dc=springframework,dc=org
54+
member: uid=dianne,ou=people,dc=springframework,dc=org
55+
56+
dn: cn=supervisor,ou=groups,dc=springframework,dc=org
57+
objectclass: top
58+
objectclass: groupOfNames
59+
cn: supervisor
60+
member: uid=rod,ou=people,dc=springframework,dc=org
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apply plugin: 'io.spring.convention.spring-test'
2+
3+
dependencies {
4+
compile project(':spring-security-core')
5+
compile 'org.springframework:spring-beans'
6+
compile 'org.springframework:spring-context'
7+
compile 'org.springframework:spring-core'
8+
compile 'org.springframework:spring-tx'
9+
compile project(':spring-security-config')
10+
compile project(':spring-security-ldap')
11+
12+
testCompile "com.unboundid:unboundid-ldapsdk"
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security;
18+
19+
import org.junit.After;
20+
import org.junit.Before;
21+
import org.junit.Test;
22+
23+
import org.springframework.context.support.ClassPathXmlApplicationContext;
24+
import org.springframework.security.config.BeanIds;
25+
import org.springframework.security.ldap.server.UnboundIdContainer;
26+
27+
import static org.assertj.core.api.Assertions.assertThat;
28+
29+
/**
30+
* @author Eddú Meléndez
31+
*/
32+
public class LdapServerBeanDefinitionParserTests {
33+
34+
private ClassPathXmlApplicationContext context;
35+
36+
@Before
37+
public void setup() {
38+
this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml");
39+
}
40+
41+
@After
42+
public void closeAppContext() {
43+
if (this.context != null) {
44+
this.context.close();
45+
this.context = null;
46+
}
47+
}
48+
49+
@Test
50+
public void apacheDirectoryServerIsStartedByDefault() {
51+
String[] beanNames = this.context.getBeanNamesForType(UnboundIdContainer.class);
52+
assertThat(beanNames).hasSize(1);
53+
assertThat(beanNames[0]).isEqualTo(BeanIds.EMBEDDED_UNBOUNDID);
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:s="http://www.springframework.org/schema/security"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
5+
http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
6+
7+
<s:ldap-server mode="unboundid" ldif="classpath:users.ldif"/>
8+
9+
</beans>

0 commit comments

Comments
 (0)