tests: add wireguard tests
This commit is contained in:
parent
f32481deb9
commit
acb555b75a
4 changed files with 52 additions and 1 deletions
9
tests/fixtures/wireguard.interfaces
vendored
Normal file
9
tests/fixtures/wireguard.interfaces
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
iface eth0
|
||||||
|
address 203.0.113.2/24
|
||||||
|
gateway 203.0.113.1
|
||||||
|
|
||||||
|
auto wg0
|
||||||
|
iface wg0
|
||||||
|
use wireguard
|
||||||
|
address 1.2.3.4/24
|
||||||
|
requires eth0
|
|
@ -33,7 +33,8 @@ tests_init \
|
||||||
gre_dependency \
|
gre_dependency \
|
||||||
vlan_explicit_learned_dependency \
|
vlan_explicit_learned_dependency \
|
||||||
vlan_guessed_learned_dependency \
|
vlan_guessed_learned_dependency \
|
||||||
vlan_complex_learned_dependency
|
vlan_complex_learned_dependency \
|
||||||
|
wireguard
|
||||||
|
|
||||||
noargs_body() {
|
noargs_body() {
|
||||||
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
||||||
|
@ -218,3 +219,10 @@ vlan_complex_learned_dependency_body() {
|
||||||
-o match:"vlan-raw-device eth0" \
|
-o match:"vlan-raw-device eth0" \
|
||||||
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan-complex.interfaces servers
|
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vlan-complex.interfaces servers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wireguard_body() {
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:"requires eth0" \
|
||||||
|
-o match:"use wireguard" \
|
||||||
|
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/wireguard.interfaces wg0
|
||||||
|
}
|
||||||
|
|
|
@ -10,3 +10,4 @@ atf_test_program{name='vrf_test'}
|
||||||
atf_test_program{name='ppp_test'}
|
atf_test_program{name='ppp_test'}
|
||||||
atf_test_program{name='tunnel_test'}
|
atf_test_program{name='tunnel_test'}
|
||||||
atf_test_program{name='gre_test'}
|
atf_test_program{name='gre_test'}
|
||||||
|
atf_test_program{name='wireguard_test'}
|
||||||
|
|
33
tests/linux/wireguard_test
Executable file
33
tests/linux/wireguard_test
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/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}
|
||||||
|
}
|
Loading…
Reference in a new issue