Skip to content

Commit ac3cb44

Browse files
committed
Added test for multiple extra options
1 parent 39996ed commit ac3cb44

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

test/tests/conf_options/container.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ abort() { cat <<< "$@" 1>&2; exit 1; }
77
#
88
# Generate openvpn.config file
99
#
10-
read -d '' EXTRA_SERVER_CONF << EOF
10+
read -d '' MULTILINE_EXTRA_SERVER_CONF << EOF
1111
management localhost 7505
1212
max-clients 10
1313
EOF
1414

1515
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
16-
ovpn_genconfig -u udp://$SERV_IP -f 1400 -e "$EXTRA_SERVER_CONF"
16+
ovpn_genconfig -u udp://$SERV_IP -f 1400 -e "$MULTILINE_EXTRA_SERVER_CONF" -e "duplicate-cn" -e "topology subnet"
1717

1818
#
1919
# grep for config lines from openvpn.conf
@@ -28,6 +28,7 @@ CONFIG_MATCH_VERB=$(busybox grep verb /etc/openvpn/openvpn.conf)
2828
CONFIG_REQUIRED_FRAGMENT="fragment 1400"
2929
CONFIG_MATCH_FRAGMENT=$(busybox grep fragment /etc/openvpn/openvpn.conf)
3030

31+
## Tests for extra configs
3132
# 3. management config
3233
CONFIG_REQUIRED_MANAGEMENT="^management localhost 7505"
3334
CONFIG_MATCH_MANAGEMENT=$(busybox grep management /etc/openvpn/openvpn.conf)
@@ -36,6 +37,14 @@ CONFIG_MATCH_MANAGEMENT=$(busybox grep management /etc/openvpn/openvpn.conf)
3637
CONFIG_REQUIRED_MAX_CLIENTS="^max-clients 10"
3738
CONFIG_MATCH_MAX_CLIENTS=$(busybox grep max-clients /etc/openvpn/openvpn.conf)
3839

40+
# 5. duplicate-cn config
41+
CONFIG_REQUIRED_DUPCN="^duplicate-cn"
42+
CONFIG_MATCH_DUPCN=$(busybox grep duplicate-cn /etc/openvpn/openvpn.conf)
43+
44+
# 6. topology config
45+
CONFIG_REQUIRED_TOPOLOGY="^topology subnet"
46+
CONFIG_MATCH_TOPOLOGY=$(busybox grep 'topology subnet' /etc/openvpn/openvpn.conf)
47+
3948
#
4049
# Tests
4150
#
@@ -61,9 +70,24 @@ else
6170
abort "==> Config match not found: $CONFIG_REQUIRED_MANAGEMENT != $CONFIG_MATCH_MANAGEMENT"
6271
fi
6372

73+
6474
if [[ $CONFIG_MATCH_MAX_CLIENTS =~ $CONFIG_REQUIRED_MAX_CLIENTS ]]
6575
then
6676
echo "==> Config match found: $CONFIG_REQUIRED_MAX_CLIENTS == $CONFIG_MATCH_MAX_CLIENTS"
6777
else
6878
abort "==> Config match not found: $CONFIG_REQUIRED_MAX_CLIENTS != $CONFIG_MATCH_MAX_CLIENTS"
6979
fi
80+
81+
if [[ $CONFIG_MATCH_DUPCN =~ $CONFIG_REQUIRED_DUPCN ]]
82+
then
83+
echo "==> Config match found: $CONFIG_REQUIRED_DUPCN == $CONFIG_MATCH_DUPCN"
84+
else
85+
abort "==> Config match not found: $CONFIG_REQUIRED_DUPCN != $CONFIG_MATCH_DUPCN"
86+
fi
87+
88+
if [[ $CONFIG_MATCH_TOPOLOGY =~ $CONFIG_REQUIRED_TOPOLOGY ]]
89+
then
90+
echo "==> Config match found: $CONFIG_REQUIRED_TOPOLOGY == $CONFIG_MATCH_TOPOLOGY"
91+
else
92+
abort "==> Config match not found: $CONFIG_REQUIRED_TOPOLOGY != $CONFIG_MATCH_TOPOLOGY"
93+
fi

0 commit comments

Comments
 (0)