ifupdown-ng/tests/linux/wireguard_test
2020-09-04 13:10:57 -06:00

33 lines
793 B
Text
Executable file

#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/../test_env.sh
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/wireguard"
tests_init \
pre_up \
pre_up_specified_config \
post_down
pre_up_body() {
export IFACE=wg0 PHASE=pre-up MOCK=echo
atf_check -s exit:0 \
-o match:'ip link add wg0 type wireguard' \
-o match:'wg setconf wg0 /etc/wireguard/wg0.conf' \
${EXECUTOR}
}
pre_up_specified_config_body() {
export IFACE=wg0 PHASE=pre-up MOCK=echo \
IF_WIREGUARD_CONFIG_PATH=/etc/wireguard/vpn.conf
atf_check -s exit:0 \
-o match:'ip link add wg0 type wireguard' \
-o match:'wg setconf wg0 /etc/wireguard/vpn.conf' \
${EXECUTOR}
}
post_down_body() {
export IFACE=wg0 PHASE=post-down MOCK=echo
atf_check -s exit:0 \
-o match:'ip link delete dev wg0' \
${EXECUTOR}
}