Skip to content

Commit 79f1fce

Browse files
Integration test updated for multi LDAP (#243)
* Add test for multiple LDAP servers
1 parent da60ce9 commit 79f1fce

File tree

10 files changed

+143
-54
lines changed

10 files changed

+143
-54
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ before_install:
3434
- |
3535
if [[ $TRAVIS_JOB_NAME = integrationTests ]]; then
3636
source src/main/docker/env.bash
37-
docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed
37+
docker-compose -f src/main/docker/docker-compose.yml up -d eiffel-er mongodb rabbitmq jenkins mail-server ldap ldap-seed ldap2 ldap2-seed
3838
fi
3939
4040

src/integrationtest/resources/features/auth.feature

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,55 @@ Feature: Authentication test
8484
When a 'GET' request is prepared for REST API '/auth/checkStatus'
8585
And username "gauss" and password "invalid_password" is used as credentials
8686
And request is sent
87-
Then response code 401 is received
87+
Then response code 401 is received
88+
89+
@AuthUniqueUsersInDifferentLDAPServers
90+
Scenario: Login using unique users from two different LDAP servers
91+
# Action: First user logging in on first LDAP
92+
When a 'GET' request is prepared for REST API '/auth/login'
93+
And username "gauss" and password "password" is used as credentials
94+
Then request is saved to request list at index 0
95+
When request is performed from request list at index 0
96+
Then response code 200 is received
97+
And response body '{"user":"gauss"}' is received
98+
99+
# Action: First user logging out
100+
When '/auth/logout' endpoint is set in request list at index 0
101+
And request is performed from request list at index 0
102+
Then response code 204 is received
103+
104+
# Action: Second user logging in on second LDAP
105+
When a 'GET' request is prepared for REST API '/auth/login'
106+
And username "einstein" and password "e=mc2" is used as credentials
107+
Then request is saved to request list at index 0
108+
When request is performed from request list at index 0
109+
Then response code 200 is received
110+
And response body '{"user":"einstein"}' is received
111+
112+
# Action: Second user logging out
113+
When '/auth/logout' endpoint is set in request list at index 0
114+
And request is performed from request list at index 0
115+
Then response code 204 is received
116+
117+
@AuthIdenticalUsernamesInDifferentLDAPServers
118+
Scenario: Login using identical usernames with different passwords from two different LDAP servers
119+
# Action: User logging in on first LDAP
120+
When a 'GET' request is prepared for REST API '/auth/login'
121+
And username "newton" and password "password" is used as credentials
122+
Then request is saved to request list at index 0
123+
When request is performed from request list at index 0
124+
Then response code 200 is received
125+
And response body '{"user":"newton"}' is received
126+
127+
# Action: User logging out
128+
When '/auth/logout' endpoint is set in request list at index 0
129+
And request is performed from request list at index 0
130+
Then response code 204 is received
131+
132+
# Action: User logging in on second LDAP
133+
When a 'GET' request is prepared for REST API '/auth/login'
134+
And username "newton" and password "password2" is used as credentials
135+
Then request is saved to request list at index 0
136+
When request is performed from request list at index 0
137+
Then response code 200 is received
138+
And response body '{"user":"newton"}' is received

src/integrationtest/resources/integration-test.properties

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,27 @@ spring.mail.password:
116116
spring.mail.properties.mail.smtp.auth: false
117117
spring.mail.properties.mail.smtp.starttls.enable: false
118118

119-
# end point for downstream and upstream search in
120-
# event repository
121-
er.url:
119+
# end point for downstream and upstream search in event repository
122120
#er.url: http://localhost:8080/eventrepository/search/
123-
# settings for ldap server if ldap authentication is needed
124-
ldap.enabled: true
125-
ldap.url: ldap://localhost:389/dc=example,dc=org
126-
ldap.base.dn:
127-
ldap.username: cn=admin,dc=example,dc=org
121+
er.url:
122+
123+
# Settings for ldap server if ldap authentication is needed.
128124
# For security reasons and to avoid authorization problems this
129-
# password should be encoded. It will be decoded in EndpointSecurity.java.
130-
# Password needs to be encoded with base64.
131-
ldap.password: YWRtaW4=
132-
ldap.user.filter: uid={0}
125+
# password should be encoded in base64. It will be decoded in EndpointSecurity.java.
126+
ldap.enabled: true
127+
ldap.server.list: [\
128+
{\
129+
"url": "ldap://localhost:3891/dc=example,dc=org",\
130+
"base.dn": "",\
131+
"username": "cn=admin,dc=example,dc=org",\
132+
"password": "YWRtaW4=",\
133+
"user.filter": "uid={0}"\
134+
},\
135+
{\
136+
"url": "ldap://localhost:3892/dc=example,dc=org",\
137+
"base.dn": "",\
138+
"username": "cn=admin,dc=example,dc=org",\
139+
"password": "YWRtaW4=",\
140+
"user.filter": "uid={0}"\
141+
}\
142+
]\

src/main/docker/docker-compose.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,12 @@ services:
421421

422422
ldap:
423423
restart: always
424-
image: osixia/openldap
424+
image: ${LDAP_IMAGE}
425425
hostname: "example.org"
426426
expose:
427427
- "389"
428-
- "636"
429428
ports:
430-
- "389:389"
431-
- "636:636"
429+
- "${LDAP_FIRST_PORT}:389"
432430
environment:
433431
LDAP_TLS: 'false'
434432
LDAP_ORGANISATION: "Test"
@@ -437,13 +435,35 @@ services:
437435
LDAP_ADMIN_PASSWORD: "admin"
438436

439437
ldap-seed:
440-
image: osixia/openldap
438+
image: ${LDAP_IMAGE}
441439
volumes:
442440
- ./ldap-seed:/container/service/slapd/assets/test/
443441
links:
444442
- ldap
445-
command: chmod +x /container/service/slapd/assets/test/addAll.sh
446-
entrypoint: sh -c '/container/service/slapd/assets/test/addAll.sh'
443+
entrypoint: bash -c 'sleep 5s && ldapadd -h ldap -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/ldap-users-first.ldif'
444+
445+
ldap2:
446+
restart: always
447+
image: ${LDAP_IMAGE}
448+
hostname: "example.org"
449+
expose:
450+
- "389"
451+
ports:
452+
- "${LDAP_SECOND_PORT}:389"
453+
environment:
454+
LDAP_TLS: 'false'
455+
LDAP_ORGANISATION: "Test"
456+
LDAP_DOMAIN: "example.org"
457+
LDAP_BASE_DN: "dc=example,dc=org"
458+
LDAP_ADMIN_PASSWORD: "admin"
459+
460+
ldap2-seed:
461+
image: ${LDAP_IMAGE}
462+
volumes:
463+
- ./ldap-seed:/container/service/slapd/assets/test/
464+
links:
465+
- ldap2
466+
entrypoint: bash -c 'sleep 5s && ldapadd -h ldap2 -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/ldap-users-second.ldif'
447467

448468
networks:
449469
eiffel_2.0_1:

src/main/docker/env.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export REMREM_PUBLISH_IMAGE="eiffelericsson/eiffel-remrem-publish:2.0.2"
1616
export JENKINS_IMAGE="bitnami/jenkins:2.138.3"
1717
export EI_BACKEND_IMAGE="eiffelericsson/eiffel-intelligence-backend:1.0.2"
1818
export EI_FRONTEND_IMAGE="eiffelericsson/eiffel-intelligence-frontend:1.0.3"
19+
export LDAP_IMAGE="osixia/openldap:1.2.4"
1920

2021
export MONGODB_PORT=27017
2122
export RABBITMQ_AMQP_PORT=5672
@@ -32,7 +33,8 @@ export EI_BACKEND_ARTIFACT_PORT=8070
3233
export EI_BACKEND_SOURCECHANGE_PORT=8072
3334
export EI_BACKEND_TESTEXECUTION_PORT=8074
3435
export EI_FRONTEND_PORT=8081
35-
36+
export LDAP_FIRST_PORT=3891
37+
export LDAP_SECOND_PORT=3892
3638

3739
export EI_INSTANCES_LIST="[\
3840
{ \"contextPath\": \"\", \"port\": \"8080\", \"name\": \"ei-backend-artifact\", \"host\": \"ei-backend-artifact\", \"https\": false, \"defaultBackend\": true},\

src/main/docker/ldap-seed/addAll.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/docker/ldap-seed/gauss.ldif

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
dn: uid=gauss,dc=example,dc=org
2+
objectClass: top
3+
objectClass: organizationalPerson
4+
objectClass: person
5+
objectClass: inetOrgPerson
6+
uid: gauss
7+
cn: gauss
8+
sn: 3
9+
userPassword: password
10+
11+
dn: uid=newton,dc=example,dc=org
12+
objectClass: top
13+
objectClass: organizationalPerson
14+
objectClass: person
15+
objectClass: inetOrgPerson
16+
uid: newton
17+
cn: newton
18+
sn: 3
19+
userPassword: password
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
dn: uid=einstein,dc=example,dc=org
2+
objectClass: top
3+
objectClass: organizationalPerson
4+
objectClass: person
5+
objectClass: inetOrgPerson
6+
uid: einstein
7+
cn: einstein
8+
sn: 3
9+
userPassword: e=mc2
10+
11+
dn: uid=newton,dc=example,dc=org
12+
objectClass: top
13+
objectClass: organizationalPerson
14+
objectClass: person
15+
objectClass: inetOrgPerson
16+
uid: newton
17+
cn: newton
18+
sn: 3
19+
userPassword: password2

src/main/docker/ldap-seed/newton.ldif

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)