Skip to content

Commit b98fb70

Browse files
committed
Merge branch 'feature-new-tests' into release-0.7.0
2 parents e936973 + 940c5af commit b98fb70

File tree

15 files changed

+105
-98
lines changed

15 files changed

+105
-98
lines changed

test.sh

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,14 @@
22

33
# Usage
44
# sudo ./test.sh
5-
# add -v for verbose mode
5+
# add -v for verbose mode (or type whatever you like !) :p
66

7-
verbose=$1
8-
error=0
9-
ok=0
7+
. test/tools/run.sh
108

11-
echo_start () {
12-
echo "------- Start $* test -------"
13-
}
9+
run_test tools/build-container.sh "Successfully built"
10+
run_test simple.sh "dn: dc=example,dc=com"
11+
run_test tls.sh "dn: dc=example,dc=com"
12+
run_test db.sh "dn: dc=otherdomain,dc=com"
1413

15-
echo_error () {
16-
echo "\n$(tput setaf 1)/!\ $* failed$(tput sgr0)\n"
17-
error=`expr $error + 1`
18-
}
19-
20-
echo_ok () {
21-
echo "\n--> $* ok\n"
22-
ok=`expr $ok + 1`
23-
}
24-
25-
run_test () {
26-
fction=$1
27-
out=test/test.out
28-
29-
echo_start $fction
30-
31-
if [ -z ${verbose} ]; then
32-
./test/$1.sh > $out 2>&1
33-
else
34-
./test/$1.sh | tee $out 2>&1
35-
fi
36-
37-
if [ "$(grep -c "$2" $out)" -eq 0 ]; then
38-
echo_error $fction
39-
else
40-
echo_ok $fction
41-
fi
42-
43-
rm $out
44-
}
45-
46-
47-
./test/tools/prepare.sh > /dev/null 2>&1
48-
run_test build "Successfully built"
49-
run_test simple "dn: dc=example,dc=com"
50-
run_test tls "dn: dc=example,dc=com"
51-
run_test db "dn: dc=otherdomain,dc=com"
52-
./test/tools/end.sh > /dev/null 2>&1
53-
54-
echo "------- Test finished -------"
55-
echo $error " failed " $ok " passed"
14+
. test/tools/end.sh
5615

test/build.sh

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

test/db.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
dir=$(dirname $0)
44
. $dir/tools/config.prop
55

6-
if [ -d "$openldapTestDir" ]; then
7-
rm -r $openldapTestDir
6+
if [ -d "$testDir" ]; then
7+
rm -r $testDir
88
fi
99

10-
mkdir $openldapTestDir
11-
mkdir $openldapTestDir/db
12-
mkdir $openldapTestDir/config
10+
mkdir $testDir
11+
mkdir $testDir/db
12+
mkdir $testDir/config
1313

14-
runOptions="-e LDAP_DOMAIN=otherdomain.com -v $openldapTestDir/db:/var/lib/ldap -v $openldapTestDir/config:/etc/ldap/slapd.d"
15-
. $dir/tools/run-simple.sh
14+
runOptions="-e LDAP_DOMAIN=otherdomain.com -v $testDir/db:/var/lib/ldap -v $testDir/config:/etc/ldap/slapd.d"
15+
. $dir/tools/run-container.sh
1616
$dir/tools/delete-container.sh
1717

18-
runOptions="-v $openldapTestDir/db:/var/lib/ldap -v $openldapTestDir/config:/etc/ldap/slapd.d"
19-
. $dir/tools/run-simple.sh
18+
runOptions="-v $testDir/db:/var/lib/ldap -v $testDir/config:/etc/ldap/slapd.d"
19+
. $dir/tools/run-container.sh
2020
echo "ldapsearch -x -h $IP -b dc=otherdomain,dc=com"
2121
ldapsearch -x -h $IP -b dc=otherdomain,dc=com
2222

23-
rm -r $openldapTestDir
23+
rm -r $testDir
2424
$dir/tools/delete-container.sh

test/simple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
dir=$(dirname $0)
44
. $dir/tools/config.prop
55

6-
. $dir/tools/run-simple.sh
6+
. $dir/tools/run-container.sh
77
echo "ldapsearch -x -h $IP -b dc=example,dc=com"
88
ldapsearch -x -h $IP -b dc=example,dc=com
99

test/tls.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
dir=$(dirname $0)
44
. $dir/tools/config.prop
55

6-
. $dir/tools/run-tls.sh
6+
. $dir/tls/run.sh
77
echo "ldapsearch -x -h $certCN -b dc=example,dc=com -ZZ"
88
ldapsearch -x -h $certCN -b dc=example,dc=com -ZZ
99

10-
. $dir/tools/end-tls.sh
10+
. $dir/tls/end.sh
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
22

33

4-
runOptions="--dns=127.0.0.1 -v `pwd`/test/ssl:/etc/ldap/ssl"
5-
. $dir/tools/run-simple.sh
4+
runOptions="--dns=127.0.0.1 -v `pwd`/test/tls/ssl:/etc/ldap/ssl"
5+
. $dir/tools/run-container.sh
66

7-
cert=$(echo $dir/ssl/ldap.crt)
7+
cert=$(echo $dir/tls/ssl/ldap.crt)
88
certCN=$(openssl x509 -in $cert -subject -noout | sed -n 's/.*CN=\(.*\)\/*\(.*\)/\1/p')
99
addLine=$(echo $IP $certCN)
1010

test/tools/build-container.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
. $(dirname $0)/config.prop
4+
5+
docker.io build -t $testImage .
6+
#docker.io build --no-cache=true -t $testImage .
7+

test/tools/config.prop

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
openldapTestImage=openldap-test
2-
openldapTestContainer=openldap-test-container
3-
openldapTestDir=/osixia-test-docker-openldap
1+
testImage=openldap-test
2+
testContainer=openldap-test-container
3+
testDir=/osixia-test-docker-openldap

test/tools/delete-container.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
. $(dirname $0)/config.prop
44

5-
# remove openldap test container
6-
res=$(docker.io ps -a | grep -c "$openldapTestContainer")
5+
# remove test container
6+
res=$(docker.io ps -a | grep -c "$testContainer")
77

88
if [ $res -ne 0 ]; then
9-
docker.io stop $openldapTestContainer
10-
docker.io rm $openldapTestContainer
9+
docker.io stop $testContainer
10+
docker.io rm $testContainer
1111
fi

0 commit comments

Comments
 (0)