From df81b9ec7e31f1df34afdee51139a5eca2be0e54 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:57:33 +0200 Subject: [PATCH 1/5] [twgit] Init feature 'feature-tests'. From 4800e140cfc20ced06a29c4f0db26e55b3f81e3b Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:57:57 +0200 Subject: [PATCH 2/5] [twgit] Init feature 'feature-ldapi'. From bd87b91d3acde17fa72e48f4e6a9bf77542b2285 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 10:59:52 +0200 Subject: [PATCH 3/5] ldapi --- slapd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slapd.sh b/slapd.sh index 86a98cf..ed43102 100755 --- a/slapd.sh +++ b/slapd.sh @@ -49,7 +49,7 @@ if [ ! -e /etc/ldap/config/docker_bootstrapped ]; then # permission error on /etc/ldap/slapd.conf if not set?! :'( adduser openldap root - slapd -h "ldap:/// ldapi:///" -u openldap -g openldap + slapd -h "ldapi:///" -u openldap -g openldap chown -R openldap:openldap /etc/ldap # TLS From 31b6c31d5ea8223a4309b9739f94261c231d9669 Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 14:09:20 +0200 Subject: [PATCH 4/5] tests --- test.sh | 5 +++-- test/build.sh | 4 ++-- test/db.sh | 23 +++++++++++++++++++++++ test/run-tls.sh | 24 ------------------------ test/{run-simple.sh => simple.sh} | 3 +-- test/tls.sh | 9 +++++++++ test/tools/config.prop | 1 + test/tools/end-tls.sh | 7 +++++++ test/tools/end.sh | 5 +++-- test/tools/prepare.sh | 5 +++-- test/tools/run-simple.sh | 5 +++++ test/tools/run-tls.sh | 16 ++++++++++++++++ 12 files changed, 73 insertions(+), 34 deletions(-) create mode 100755 test/db.sh delete mode 100755 test/run-tls.sh rename test/{run-simple.sh => simple.sh} (62%) create mode 100755 test/tls.sh create mode 100755 test/tools/end-tls.sh create mode 100755 test/tools/run-simple.sh create mode 100755 test/tools/run-tls.sh diff --git a/test.sh b/test.sh index 97282b2..024ccd8 100755 --- a/test.sh +++ b/test.sh @@ -46,8 +46,9 @@ run_test () { ./test/tools/prepare.sh > /dev/null 2>&1 run_test build "Successfully built" -run_test run-simple "dn: dc=example,dc=com" -run_test run-tls "dn: dc=example,dc=com" +run_test simple "dn: dc=example,dc=com" +run_test tls "dn: dc=example,dc=com" +run_test db "dn: dc=otherdomain,dc=com" ./test/tools/end.sh > /dev/null 2>&1 echo "------- Test finished -------" diff --git a/test/build.sh b/test/build.sh index 66aa324..71bdf01 100755 --- a/test/build.sh +++ b/test/build.sh @@ -3,6 +3,6 @@ dir=$(dirname $0) . $dir/tools/config.prop -sudo docker.io build -t $openldapTestImage . -#sudo docker.io build --no-cache=true -t openldap-test . +docker.io build -t $openldapTestImage . +#docker.io build --no-cache=true -t openldap-test . diff --git a/test/db.sh b/test/db.sh new file mode 100755 index 0000000..a650fbd --- /dev/null +++ b/test/db.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +dir=$(dirname $0) +. $dir/tools/config.prop + +if [ -d "$openldapTestDir" ]; then + rm -r $openldapTestDir +fi + +mkdir $openldapTestDir +mkdir $openldapTestDir/db +mkdir $openldapTestDir/config + +runOptions="-e LDAP_DOMAIN=otherdomain.com -v $openldapTestDir/db:/var/lib/ldap -v $openldapTestDir/config:/etc/ldap/slapd.d" +. $dir/tools/run-simple.sh +$dir/tools/delete-container.sh + +runOptions="-v $openldapTestDir/db:/var/lib/ldap -v $openldapTestDir/config:/etc/ldap/slapd.d" +. $dir/tools/run-simple.sh +ldapsearch -x -h localhost -p 65389 -b dc=otherdomain,dc=com + +rm -r $openldapTestDir +$dir/tools/delete-container.sh diff --git a/test/run-tls.sh b/test/run-tls.sh deleted file mode 100755 index b4209a4..0000000 --- a/test/run-tls.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -dir=$(dirname $0) -. $dir/tools/config.prop - -docker.io run --name $openldapTestContainer --dns=127.0.0.1 -v `pwd`/test/ssl:/etc/ldap/ssl -p 65389:389 -d $openldapTestImage - -cert=$(echo $dir/ssl/ldap.crt) -certCN=$(openssl x509 -in $cert -subject -noout | sed -n 's/.*CN=\(.*\)\/*\(.*\)/\1/p') -addLine=$(echo "127.0.0.1" $certCN) - -echo $addLine >> /etc/hosts -cp /etc/ldap/ldap.conf /etc/ldap/ldap.conf.old -sed -i 's,TLS_CACERT.*,TLS_CACERT '"$cert"',g' /etc/ldap/ldap.conf - - -sleep 5 -ldapsearch -x -h $certCN -p 65389 -b dc=example,dc=com -ZZ - -sed -i '/'"$addLine"'/d' /etc/hosts -cp /etc/ldap/ldap.conf.old /etc/ldap/ldap.conf -rm /etc/ldap/ldap.conf.old - -$dir/tools/delete-container.sh diff --git a/test/run-simple.sh b/test/simple.sh similarity index 62% rename from test/run-simple.sh rename to test/simple.sh index 27a93f1..9832191 100755 --- a/test/run-simple.sh +++ b/test/simple.sh @@ -3,8 +3,7 @@ dir=$(dirname $0) . $dir/tools/config.prop -docker.io run --name $openldapTestContainer -p 65389:389 -d $openldapTestImage -sleep 5 +. $dir/tools/run-simple.sh ldapsearch -x -h localhost -p 65389 -b dc=example,dc=com $dir/tools/delete-container.sh diff --git a/test/tls.sh b/test/tls.sh new file mode 100755 index 0000000..ea1758e --- /dev/null +++ b/test/tls.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +dir=$(dirname $0) +. $dir/tools/config.prop + +. $dir/tools/run-tls.sh +ldapsearch -x -h $certCN -p 65389 -b dc=example,dc=com -ZZ + +. $dir/tools/end-tls.sh diff --git a/test/tools/config.prop b/test/tools/config.prop index 2b16157..30c3a6f 100644 --- a/test/tools/config.prop +++ b/test/tools/config.prop @@ -1,2 +1,3 @@ openldapTestImage=openldap-test openldapTestContainer=openldap-test-container +openldapTestDir=/osixia-test-docker-openldap diff --git a/test/tools/end-tls.sh b/test/tools/end-tls.sh new file mode 100755 index 0000000..05d4bb0 --- /dev/null +++ b/test/tools/end-tls.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +sed -i '/'"$addLine"'/d' /etc/hosts +cp /etc/ldap/ldap.conf.old /etc/ldap/ldap.conf +rm /etc/ldap/ldap.conf.old + +$dir/tools/delete-container.sh diff --git a/test/tools/end.sh b/test/tools/end.sh index 05428a0..ea88ee1 100755 --- a/test/tools/end.sh +++ b/test/tools/end.sh @@ -1,4 +1,5 @@ #!/bin/sh -$(dirname $0)/delete-container.sh -$(dirname $0)/delete-image.sh +dir=$(dirname $0) +$dir/delete-container.sh +$dir/delete-image.sh diff --git a/test/tools/prepare.sh b/test/tools/prepare.sh index 05428a0..ea88ee1 100755 --- a/test/tools/prepare.sh +++ b/test/tools/prepare.sh @@ -1,4 +1,5 @@ #!/bin/sh -$(dirname $0)/delete-container.sh -$(dirname $0)/delete-image.sh +dir=$(dirname $0) +$dir/delete-container.sh +$dir/delete-image.sh diff --git a/test/tools/run-simple.sh b/test/tools/run-simple.sh new file mode 100755 index 0000000..d090b21 --- /dev/null +++ b/test/tools/run-simple.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "docker.io run --name $openldapTestContainer $runOptions -p 65389:389 -d $openldapTestImage" +docker.io run --name $openldapTestContainer $runOptions -p 65389:389 -d $openldapTestImage +sleep 5 diff --git a/test/tools/run-tls.sh b/test/tools/run-tls.sh new file mode 100755 index 0000000..9f6ce74 --- /dev/null +++ b/test/tools/run-tls.sh @@ -0,0 +1,16 @@ +#!/bin/sh + + +runOptions="--dns=127.0.0.1 -v `pwd`/test/ssl:/etc/ldap/ssl" +. $dir/tools/run-simple.sh + +cert=$(echo $dir/ssl/ldap.crt) +certCN=$(openssl x509 -in $cert -subject -noout | sed -n 's/.*CN=\(.*\)\/*\(.*\)/\1/p') +addLine=$(echo "127.0.0.1" $certCN) + +echo $addLine >> /etc/hosts +cp /etc/ldap/ldap.conf /etc/ldap/ldap.conf.old +sed -i 's,TLS_CACERT.*,TLS_CACERT '"$cert"',g' /etc/ldap/ldap.conf + +sleep 5 + From bcaa13ac7789425bb4d21fa4266b05ee0aaae3ed Mon Sep 17 00:00:00 2001 From: Bertrand Gouny Date: Wed, 7 May 2014 14:11:29 +0200 Subject: [PATCH 5/5] [twgit] Init release 'release-0.5.0'.