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 \
|
2020-09-09 21:36:11 +00:00
|
|
|
create \
|
2020-09-04 19:10:57 +00:00
|
|
|
pre_up \
|
|
|
|
pre_up_specified_config \
|
2020-09-09 21:36:11 +00:00
|
|
|
destroy
|
|
|
|
|
|
|
|
create_body() {
|
|
|
|
export IFACE=wg0 PHASE=create MOCK=echo
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'ip link add wg0 type wireguard' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
2020-09-04 19:10:57 +00:00
|
|
|
|
|
|
|
pre_up_body() {
|
|
|
|
export IFACE=wg0 PHASE=pre-up MOCK=echo
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-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:'wg setconf wg0 /etc/wireguard/vpn.conf' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
|
|
|
|
2020-09-09 21:36:11 +00:00
|
|
|
destroy_body() {
|
|
|
|
export IFACE=wg0 PHASE=destroy MOCK=echo
|
2020-09-04 19:10:57 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'ip link delete dev wg0' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|