From 953666f1fb50a6b0955413a0748d18b21603ae2a Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 19 Aug 2020 03:13:02 -0600 Subject: [PATCH] tests: add tests for managing the tunnel executor --- tests/fixtures/tunnel-ifupdown2.interfaces | 1 + tests/fixtures/tunnel-legacy.interfaces | 1 + tests/fixtures/tunnel.interfaces | 1 + tests/ifquery_test | 38 +++++++++++++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/tunnel-ifupdown2.interfaces b/tests/fixtures/tunnel-ifupdown2.interfaces index 82a36c5..4e93b91 100644 --- a/tests/fixtures/tunnel-ifupdown2.interfaces +++ b/tests/fixtures/tunnel-ifupdown2.interfaces @@ -2,6 +2,7 @@ auto tun0 iface tun0 tunnel-local 203.0.113.2 tunnel-endpoint 203.0.113.1 + tunnel-mode gre tunnel-physdev eth0 address 203.0.113.10/30 gateway 203.0.113.9 diff --git a/tests/fixtures/tunnel-legacy.interfaces b/tests/fixtures/tunnel-legacy.interfaces index ff6505c..bb030bd 100644 --- a/tests/fixtures/tunnel-legacy.interfaces +++ b/tests/fixtures/tunnel-legacy.interfaces @@ -2,6 +2,7 @@ auto tun0 iface tun0 local 203.0.113.2 endpoint 203.0.113.1 + mode gre tunnel-dev eth0 address 203.0.113.10/30 gateway 203.0.113.9 diff --git a/tests/fixtures/tunnel.interfaces b/tests/fixtures/tunnel.interfaces index 586b401..4bf46de 100644 --- a/tests/fixtures/tunnel.interfaces +++ b/tests/fixtures/tunnel.interfaces @@ -2,6 +2,7 @@ auto tun0 iface tun0 tunnel-local 203.0.113.2 tunnel-remote 203.0.113.1 + tunnel-mode gre tunnel-dev eth0 address 203.0.113.10/30 gateway 203.0.113.9 diff --git a/tests/ifquery_test b/tests/ifquery_test index 67284ec..79f9341 100755 --- a/tests/ifquery_test +++ b/tests/ifquery_test @@ -23,7 +23,12 @@ tests_init \ vrf_ifupdown2_rewrite \ vrf_ifupdown2_dependency \ ppp_dependency \ - ppp_legacy_rewrite + ppp_legacy_rewrite \ + tunnel_dependency \ + tunnel_legacy_dependency \ + tunnel_legacy_rewrite \ + tunnel_ifupdown2_dependency \ + tunnel_ifupdown2_rewrite noargs_body() { atf_check -s exit:1 -e ignore ifquery -S/dev/null @@ -142,3 +147,34 @@ ppp_legacy_rewrite_body() { atf_check -s exit:0 -o match:"ppp-provider someisp" \ ifquery -E $EXECUTORS_LINUX -i $FIXTURES/ppp-legacy.interfaces ppp0 } + +tunnel_dependency_body() { + atf_check -s exit:0 -o match:"requires eth0" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel.interfaces tun0 +} + +tunnel_legacy_dependency_body() { + atf_check -s exit:0 -o match:"requires eth0" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-legacy.interfaces tun0 +} + +tunnel_ifupdown2_dependency_body() { + atf_check -s exit:0 -o match:"requires eth0" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-ifupdown2.interfaces tun0 +} + +tunnel_legacy_rewrite_body() { + atf_check -s exit:0 \ + -o match:"tunnel-local 203.0.113.2" \ + -o match:"tunnel-remote 203.0.113.1" \ + -o match:"tunnel-mode gre" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-legacy.interfaces tun0 +} + +tunnel_ifupdown2_rewrite_body() { + atf_check -s exit:0 \ + -o match:"tunnel-local 203.0.113.2" \ + -o match:"tunnel-remote 203.0.113.1" \ + -o match:"tunnel-mode gre" \ + ifquery -E $EXECUTORS_LINUX -i $FIXTURES/tunnel-ifupdown2.interfaces tun0 +}