Skip to content

Commit 03fd33b

Browse files
author
Anton Ustyuzhanin
committed
Tests: create tests launcher script
1 parent ef5ce18 commit 03fd33b

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

run_tests.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
3+
# set -x
4+
5+
echo "Create LDAP users"
6+
CUSTOM_LDIF_DIR=$(mktemp --directory)
7+
8+
cat <<EOF >${CUSTOM_LDIF_DIR}/test.ldif
9+
dn: uid=test,dc=example,dc=org
10+
uid: test
11+
cn: test
12+
sn: Test
13+
objectClass: top
14+
objectClass: posixAccount
15+
objectClass: inetOrgPerson
16+
objectClass: ldapPublicKey
17+
loginShell: /bin/bash
18+
homeDirectory: /home/test
19+
uidNumber: 5000
20+
gidNumber: 5000
21+
22+
gecos: Test User
23+
sshPublicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYaGyXcqdQUIxjPr3eqXro9X/2LrLH2o+OrFeGRB2u3WxigroynxD8vLjtG6qyYYtgnvR9+2usVhbNNS3QdF3G5wenCR4Zpk6VIYofQrBYmrzJG9Bsig3G4SgnGF2x4KimupjCdD4+1S9OMF/4GzQZdaLl2HkSTYE+6430FbSD8i3IdpbRI526X8q4njrTHgIYUtAVFTPSudZ/3fIzFpfNlWq5wy1CXCGc7aqmHECQzareeoAM5NfgrUkw7TFrKP/zelDkqpJ6pwYTWg2VZYmoXmh2o+ttWFatGzJPUoeU/r+SjMn4YvMunT+L6NIrbJQkXwB9i3upMx2bQcuPl0cl test-key
24+
EOF
25+
26+
cat <<EOF >${CUSTOM_LDIF_DIR}/filtered.ldif
27+
dn: uid=filtered,dc=example,dc=org
28+
uid: filtered
29+
cn: filtered
30+
sn: Filtered
31+
objectClass: top
32+
objectClass: posixAccount
33+
objectClass: inetOrgPerson
34+
loginShell: /bin/bash
35+
homeDirectory: /home/filtered
36+
uidNumber: 5001
37+
gidNumber: 5001
38+
39+
gecos: Filtered User
40+
EOF
41+
42+
echo "Starting docker container running OpenLDAP server"
43+
LDAP_CONTAINER_NAME="openldap"
44+
LDAP_ADMIN_PASSWORD="s3cr3t"
45+
docker run --detach --name ${LDAP_CONTAINER_NAME} \
46+
--env LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD} \
47+
--volume ${CUSTOM_LDIF_DIR}:/container/service/slapd/assets/config/bootstrap/ldif/custom \
48+
osixia/openldap:1.2.0 --copy-service
49+
50+
echo -n "Waiting for ldap server to be ready"
51+
until docker logs openldap 2>&1 | grep "slapd starting" >/dev/null 2>&1
52+
do echo -n "."; sleep 1; done
53+
echo
54+
55+
echo "Prepare python virtual env for running tests"
56+
virtualenv --version >/dev/null
57+
if [ $? != 0 ]
58+
then
59+
echo -e "Please install python virtualenv package to perform the tests"
60+
exit 1
61+
fi
62+
virtualenv venv
63+
. ./venv/bin/activate
64+
pip install ansible docker-py molecule
65+
66+
echo "Run molecule tests"
67+
molecule test
68+
69+
echo "Cleanup"
70+
deactivate
71+
rm -rf ./venv/
72+
docker rm -f ${LDAP_CONTAINER_NAME}
73+
rm -rf ${CUSTOM_LDIF_DIR}

0 commit comments

Comments
 (0)