Skip to content

Commit

Permalink
check_vpn: added openvpn integration test, using chap for l2tp
Browse files Browse the repository at this point in the history
  • Loading branch information
danfruehauf committed Nov 23, 2013
1 parent 533ad3b commit bc37970
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions check_vpn/shunit2_test_integ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_l2tp_vpn_integration() {
local tmp_output=`mktemp`

# setup the vpn server, using ssh :)
ssh root@$VPN_SERVER_L2TP "echo '$username * $password *' > /etc/ppp/pap-secrets"
ssh root@$VPN_SERVER_L2TP "echo '$username * $password *' > /etc/ppp/chap-secrets"

$CHECK_VPN -l -t l2tp -H $VPN_SERVER_L2TP -u $username -p $password -d ppp6 -- noccp > $tmp_output
retval=$?
Expand All @@ -54,9 +54,36 @@ test_l2tp_vpn_integration() {
###########
# test l2tp integration
test_openvpn_vpn_integration() {
# TODO implement!
_test_root || return
true

local -i retval=0
local username=root
local password=`pwmake $RANDOM`
local tmp_output=`mktemp`
local tmp_server_cert=`mktemp`

# setup the vpn server, using ssh :)
ssh root@$VPN_SERVER_OPENVPN \
"echo '$username' > /etc/openvpn/passwd && echo '$password' >> /etc/openvpn/passwd"

# get server certificate
scp root@$VPN_SERVER_OPENVPN:/etc/openvpn/ca.crt $tmp_server_cert > /dev/null
retval=$?
assertTrue "openvpn vpn server certificate copy" \
"[ $retval -eq 0 ]"

$CHECK_VPN -l -t openvpn -H $VPN_SERVER_PPTP -u $username -p $password -d tun91 -- --ca $tmp_server_cert --proto tcp --cipher AES-256-CBC --comp-lzo > $tmp_output
retval=$?

assertTrue "openvpn vpn connection" \
"[ $retval -eq 0 ]"

local expected_string="OK: VPN to '$VPN_SERVER_PPTP' up and running on 'tun91', 'http://www.google.com' reachable"
local output=`cut -d\| -f1 $tmp_output`
assertTrue "openvpn vpn connection output" \
"[ x'$output' = x'$expected_string' ]"

rm -f $tmp_output $tmp_server_cert
}

########
Expand Down

0 comments on commit bc37970

Please sign in to comment.