Skip to content

Commit 8c9d88b

Browse files
committed
tests: client: Add client config test suite
* Test the client configuration to detect breakages
1 parent 78d612d commit 8c9d88b

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

test/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ imageTests+=(
99
[openvpn]='
1010
paranoid
1111
conf_options
12+
client
1213
basic
1314
dual-proto
1415
otp

test/tests/client/container.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Function to fail
4+
abort() { cat <<< "$@" 1>&2; exit 1; }
5+
6+
7+
#
8+
# Generate openvpn.config file
9+
#
10+
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
11+
12+
ovpn_genconfig \
13+
-u udp://$SERV_IP \
14+
-m 1337 \
15+
16+
17+
EASYRSA_BATCH=1 EASYRSA_REQ_CN="Travis-CI Test CA" ovpn_initpki nopass
18+
19+
easyrsa build-client-full test1 nopass 2>/dev/null
20+
21+
TEST1_OVPN="/etc/openvpn/test1.ovpn"
22+
ovpn_getclient test1 > "${TEST1_OVPN}"
23+
24+
# Check a config (haystack) for a given line (needle) exit with error if not found.
25+
test-client-config() {
26+
27+
local needle="${1}"
28+
29+
busybox grep -q "${needle}" "${TEST1_OVPN}"
30+
if [ $? -ne 0 ]; then
31+
abort "==> Config match not found: ${needle}"
32+
fi
33+
}
34+
35+
#
36+
# Test cases
37+
#
38+
39+
# Test 1: Check MTU
40+
test-client-config "^tun-mtu\s+1337"

test/tests/client/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../run-bash-in-container.sh

0 commit comments

Comments
 (0)