ifupdown-ng/tests/linux/wireguard_test

34 lines
793 B
Text
Raw Normal View History

2020-09-04 19:10:57 +00:00
#!/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}
}