Skip to content

Commit c524ae2

Browse files
author
Bertrand Gouny
committed
merge
2 parents 838028f + 41d58dd commit c524ae2

File tree

7 files changed

+69
-12
lines changed

7 files changed

+69
-12
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME = osixia/phpldapadmin
2-
VERSION = 0.3.0
2+
VERSION = 0.4.0
33

44
.PHONY: all build test tag_latest release
55

@@ -9,7 +9,7 @@ build:
99
docker.io build -t $(NAME):$(VERSION) --rm .
1010

1111
test:
12-
env NAME=$(NAME) VERSION=$(VERSION) ./test.sh
12+
env NAME=$(NAME) VERSION=$(VERSION) ./test.sh debug
1313

1414
tag_latest:
1515
docker.io tag $(NAME):$(VERSION) $(NAME):latest

service/phpldapadmin/phpldapadmin.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
#!/bin/sh
22

33
# -e Exit immediately if a command exits with a non-zero status
4-
# -u Treat unset variables as an error when substituting
5-
set -eu
4+
set -e
65

76
status () {
87
echo "---> ${@}" >&2
98
}
109

11-
set -x
12-
: LDAP_HOST=${LDAP_HOST}
13-
: LDAP_BASE_DN=${LDAP_BASE_DN}
14-
: LDAP_LOGIN_DN=${LDAP_LOGIN_DN}
15-
: LDAP_SERVER_NAME=${LDAP_SERVER_NAME}
10+
getBaseDn () {
11+
IFS="."
12+
export IFS
13+
14+
domain=$1
15+
init=1
16+
17+
for s in $domain; do
18+
dc="dc=$s"
19+
if [ "$init" -eq 1 ]; then
20+
baseDn=$dc
21+
init=0
22+
else
23+
baseDn="$baseDn,$dc"
24+
fi
25+
done
26+
}
27+
28+
# a ldap container is linked to this phpLDAPadmin container
29+
if [ -n "${LDAP_NAME}" ]; then
30+
LDAP_HOST=${LDAP_PORT_389_TCP_ADDR}
31+
32+
# Get base dn from ldap domain
33+
getBaseDn ${LDAP_ENV_LDAP_DOMAIN}
34+
35+
LDAP_BASE_DN=$baseDn
36+
LDAP_LOGIN_DN="cn=admin,$baseDn"
37+
LDAP_SERVER_NAME=${LDAP_ENV_LDAP_ORGANISATION}
38+
else
39+
LDAP_HOST=${LDAP_HOST}
40+
LDAP_BASE_DN=${LDAP_BASE_DN}
41+
LDAP_LOGIN_DN=${LDAP_LOGIN_DN}
42+
LDAP_SERVER_NAME=${LDAP_SERVER_NAME}
43+
fi
1644

1745
if [ ! -e /etc/phpldapadmin/docker_bootstrapped ]; then
1846
status "configuring LDAP for first run"

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
run_test tools/build-container.sh "Successfully built"
1111
run_test simple.sh "Use the menu to the left to navigate"
12+
run_test link.sh "Logged in as:"
1213

1314
. test/tools/end.sh
14-

test/link.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
#start a openldap container
4+
openldap="osixia-phpldapadmin-openldap"
5+
6+
echo "docker.io run --name $openldap -d osixia/openldap"
7+
docker.io run --name $openldap -d osixia/openldap
8+
sleep 10
9+
10+
dir=$(dirname $0)
11+
12+
runOptions="--link osixia-phpldapadmin-openldap:ldap"
13+
. $dir/tools/run-container.sh
14+
15+
echo "curl -c $testDir/cookie.txt $IP"
16+
curl -c $testDir/cookie.txt $IP
17+
18+
echo "curl http://$IP/cmd.php -L -b $testDir/cookie.txt -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Connection: keep-alive' --data 'cmd=login&server_id=1&nodecode%5Blogin_pass%5D=1&login=cn%3Dadmin%2Cdc%3Dexample%2Cdc%3Dcom&login_pass=toor&submit=Authenticate' --compressed"
19+
20+
curl http://$IP/cmd.php -L -b $testDir/cookie.txt -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Connection: keep-alive' --data 'cmd=login&server_id=1&nodecode%5Blogin_pass%5D=1&login=cn%3Dadmin%2Cdc%3Dexample%2Cdc%3Dcom&login_pass=toor&submit=Authenticate' --compressed
21+
22+
docker.io stop $openldap
23+
docker.io rm $openldap
24+
25+
$dir/tools/delete-container.sh

test/tools/end.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
4+
rm -rf $testDir
35
./test/tools/delete-container.sh
46
./test/tools/delete-image.sh > /dev/null 2>&1
57

test/tools/prepare.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
mkdir -p $testDir
4+
35
dir=$(dirname $0)
46
$dir/delete-container.sh
57
$dir/delete-image.sh

test/tools/run-container.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
echo "docker.io run --name $testContainer $runOptions -d $testImage"
4-
ID=`docker.io run --name $testContainer $runOptions -d $testImage`
3+
echo "docker.io run --name $testContainer $runOptions -d $testImage $runCommand"
4+
ID=`docker.io run --name $testContainer $runOptions -d $testImage $runCommand`
55
sleep 10
66

77
echo " --> Obtaining IP"

0 commit comments

Comments
 (0)