if_ovpn tests: test explicit exit notifications

Test that when a client exits the server notices this, even without
keepalive traffic.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
Kristof Provost 2022-10-17 17:42:35 +02:00
parent 7b5d62bb73
commit 188e069670

View file

@ -475,6 +475,92 @@ timeout_client_cleanup()
ovpn_cleanup
}
atf_test_case "explicit_exit" "cleanup"
explicit_exit_head()
{
atf_set descr 'Text explicit exit notification'
atf_set require.user root
atf_set require.progs openvpn
}
explicit_exit_body()
{
ovpn_init
l=$(vnet_mkepair)
vnet_mkjail a ${l}a
jexec a ifconfig ${l}a 192.0.2.1/24 up
jexec a ifconfig lo0 127.0.0.1/8 up
vnet_mkjail b ${l}b
jexec b ifconfig ${l}b 192.0.2.2/24 up
# Sanity check
atf_check -s exit:0 -o ignore jexec a ping -c 1 192.0.2.2
ovpn_start a "
dev ovpn0
dev-type tun
proto udp4
cipher AES-256-GCM
auth SHA256
local 192.0.2.1
server 198.51.100.0 255.255.255.0
ca $(atf_get_srcdir)/ca.crt
cert $(atf_get_srcdir)/server.crt
key $(atf_get_srcdir)/server.key
dh $(atf_get_srcdir)/dh.pem
mode server
script-security 2
auth-user-pass-verify /usr/bin/true via-env
topology subnet
management 192.0.2.1 1234
"
ovpn_start b "
dev tun0
dev-type tun
client
remote 192.0.2.1
auth-user-pass $(atf_get_srcdir)/user.pass
ca $(atf_get_srcdir)/ca.crt
cert $(atf_get_srcdir)/client.crt
key $(atf_get_srcdir)/client.key
dh $(atf_get_srcdir)/dh.pem
explicit-exit-notify
"
# Give the tunnel time to come up
sleep 10
atf_check -s exit:0 -o ignore jexec b ping -c 3 198.51.100.1
if ! echo "status" | jexec a nc -N 192.0.2.1 1234 | grep 192.0.2.2; then
atf_fail "Client not found in status list!"
fi
# Kill the client
jexec b killall openvpn
while echo "status" | jexec a nc -N 192.0.2.1 1234 | grep 192.0.2.2; do
jexec a ps auxf
echo "Client disconnect not discovered"
sleep 1
done
}
explicit_exit_cleanup()
{
ovpn_cleanup
}
atf_test_case "multi_client" "cleanup"
multi_client_head()
{
@ -909,6 +995,7 @@ atf_init_test_cases()
atf_add_test_case "6in6"
atf_add_test_case "4in6"
atf_add_test_case "timeout_client"
atf_add_test_case "explicit_exit"
atf_add_test_case "multi_client"
atf_add_test_case "route_to"
atf_add_test_case "ra"