@@ -29,7 +29,7 @@ function finish {
29
29
trap finish EXIT
30
30
31
31
# Put the server in the background
32
- docker run -d -v $OVPN_DATA :/etc/openvpn --cap-add=NET_ADMIN -p 1194:1194/udp - -name $NAME $IMG
32
+ docker run -d -v $OVPN_DATA :/etc/openvpn --cap-add=NET_ADMIN --name $NAME $IMG
33
33
34
34
#
35
35
# Test that easy_rsa generate CRLs with 'next publish' set to 3650 days.
@@ -51,10 +51,18 @@ docker exec -it $NAME easyrsa build-client-full $CLIENT1 nopass
51
51
docker exec -it $NAME ovpn_getclient $CLIENT1 > $CLIENT_DIR /config.ovpn
52
52
docker exec -it $NAME bash -c " echo 'yes' | ovpn_revokeclient $CLIENT1 "
53
53
54
+ # Determine IP address of container running daemon and update config
55
+ for i in $( seq 10) ; do
56
+ SERV_IP_INTERNAL=$( docker inspect --format ' {{ .NetworkSettings.IPAddress }}' " $NAME " 2> /dev/null || true)
57
+ test -n " $SERV_IP_INTERNAL " && break
58
+ sleep 0.1
59
+ done
60
+ sed -i -e s:$SERV_IP :$SERV_IP_INTERNAL :g $CLIENT_DIR /config.ovpn
61
+
54
62
#
55
63
# Test that openvpn client can't connect using $CLIENT1 config.
56
64
#
57
- if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN --cap-add=NET_ADMIN --net=host $IMG /client/wait-for-connect.sh; then
65
+ if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN -e DEBUG $IMG /client/wait-for-connect.sh; then
58
66
echo " Client was able to connect after revocation test #1." >&2
59
67
exit 2
60
68
fi
@@ -66,7 +74,14 @@ docker exec -it $NAME easyrsa build-client-full $CLIENT2 nopass
66
74
docker exec -it $NAME ovpn_getclient $CLIENT2 > $CLIENT_DIR /config.ovpn
67
75
docker exec -it $NAME bash -c " echo 'yes' | ovpn_revokeclient $CLIENT2 "
68
76
69
- if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN --cap-add=NET_ADMIN --net=host $IMG /client/wait-for-connect.sh; then
77
+ # Determine IP address of container running daemon and update config
78
+ for i in $( seq 10) ; do
79
+ SERV_IP_INTERNAL=$( docker inspect --format ' {{ .NetworkSettings.IPAddress }}' " $NAME " 2> /dev/null || true)
80
+ test -n " $SERV_IP_INTERNAL " && break
81
+ sleep 0.1
82
+ done
83
+
84
+ if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN -e DEBUG $IMG /client/wait-for-connect.sh; then
70
85
echo " Client was able to connect after revocation test #2." >&2
71
86
exit 2
72
87
fi
@@ -79,7 +94,7 @@ docker stop $NAME && docker start $NAME
79
94
#
80
95
# Test for failed connection using $CLIENT2 config again.
81
96
#
82
- if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN --cap-add=NET_ADMIN --net=host $IMG /client/wait-for-connect.sh; then
97
+ if docker run --rm -v $CLIENT_DIR :/client --cap-add=NET_ADMIN -e DEBUG $IMG /client/wait-for-connect.sh; then
83
98
echo " Client was able to connect after revocation test #3." >&2
84
99
exit 2
85
100
fi
0 commit comments