diff options
author | Mario Sanchez Prada <mario@endlessm.com> | 2016-07-20 16:24:41 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-07-28 22:22:14 +0200 |
commit | 570e8ee29684f16b4306f1eb94a1b756608ddd3b (patch) | |
tree | 0cfe6068b1bb9862e586fc6a06596d1dbd6cb164 /callouts/tests | |
parent | 3359368f287f6bfd8205d2e3505f6ec180c4f730 (diff) | |
download | NetworkManager-570e8ee29684f16b4306f1eb94a1b756608ddd3b.tar.gz |
nm-dispatcher: Handle the 'connectivity-state' parameter for 'Action'
Actually handle this new parameter in the nm-dispatcher process, setting
the value of a new CONNECTIVITY_STATE environment variable accordingly.
This patch also includes new tests to check the different cases.
https://bugzilla.gnome.org/show_bug.cgi?id=768969
Diffstat (limited to 'callouts/tests')
-rw-r--r-- | callouts/tests/Makefile.am | 2 | ||||
-rw-r--r-- | callouts/tests/dispatcher-connectivity-full | 23 | ||||
-rw-r--r-- | callouts/tests/dispatcher-connectivity-unknown | 22 | ||||
-rw-r--r-- | callouts/tests/test-dispatcher-envp.c | 18 |
4 files changed, 65 insertions, 0 deletions
diff --git a/callouts/tests/Makefile.am b/callouts/tests/Makefile.am index 6ac158746c..2450f372a9 100644 --- a/callouts/tests/Makefile.am +++ b/callouts/tests/Makefile.am @@ -32,6 +32,8 @@ TESTS = test-dispatcher-envp endif EXTRA_DIST= \ + dispatcher-connectivity-full \ + dispatcher-connectivity-unknown \ dispatcher-down \ dispatcher-external \ dispatcher-up \ diff --git a/callouts/tests/dispatcher-connectivity-full b/callouts/tests/dispatcher-connectivity-full new file mode 100644 index 0000000000..c370bc355b --- /dev/null +++ b/callouts/tests/dispatcher-connectivity-full @@ -0,0 +1,23 @@ +[main] +action=connectiviy-change +expected-iface=wlan0 +uuid=3fd2a33a-d81b-423f-ae99-e6baba742311 +id=Random Connection +connectivity-state=FULL + +[device] +state=30 +ip-interface=wlan0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[env] +PATH= +CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311 +CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5 +CONNECTION_ID=Random Connection +CONNECTION_FILENAME=/callouts/tests/dispatcher-connectivity-full +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=wlan0 +CONNECTIVITY_STATE=FULL diff --git a/callouts/tests/dispatcher-connectivity-unknown b/callouts/tests/dispatcher-connectivity-unknown new file mode 100644 index 0000000000..9622d017d9 --- /dev/null +++ b/callouts/tests/dispatcher-connectivity-unknown @@ -0,0 +1,22 @@ +[main] +action=connectiviy-change +expected-iface=wlan0 +uuid=3fd2a33a-d81b-423f-ae99-e6baba742311 +id=Random Connection +connectivity-state=UNKNOWN + +[device] +state=30 +ip-interface=wlan0 +type=2 +interface=wlan0 +path=/org/freedesktop/NetworkManager/Devices/0 + +[env] +PATH= +CONNECTION_UUID=3fd2a33a-d81b-423f-ae99-e6baba742311 +CONNECTION_DBUS_PATH=/org/freedesktop/NetworkManager/Connections/5 +CONNECTION_ID=Random Connection +CONNECTION_FILENAME=/callouts/tests/dispatcher-connectivity-unknown +DEVICE_IFACE=wlan0 +DEVICE_IP_IFACE=wlan0 diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c index 83e84d7472..55ccbd6050 100644 --- a/callouts/tests/test-dispatcher-envp.c +++ b/callouts/tests/test-dispatcher-envp.c @@ -39,6 +39,7 @@ parse_main (GKeyFile *kf, GVariant **out_con_props, char **out_expected_iface, char **out_action, + char **out_connectivity_state, char **out_vpn_ip_iface, GError **error) { @@ -51,6 +52,7 @@ parse_main (GKeyFile *kf, if (*out_expected_iface == NULL) return FALSE; + *out_connectivity_state = g_key_file_get_string (kf, "main", "connectivity-state", NULL); *out_vpn_ip_iface = g_key_file_get_string (kf, "main", "vpn-ip-iface", NULL); *out_action = g_key_file_get_string (kf, "main", "action", error); @@ -359,6 +361,7 @@ get_dispatcher_file (const char *file, GVariant **out_device_ip6_props, GVariant **out_device_dhcp4_props, GVariant **out_device_dhcp6_props, + char **out_connectivity_state, char **out_vpn_ip_iface, GVariant **out_vpn_ip4_props, GVariant **out_vpn_ip6_props, @@ -379,6 +382,7 @@ get_dispatcher_file (const char *file, g_assert (out_device_ip6_props && !*out_device_ip6_props); g_assert (out_device_dhcp4_props && !*out_device_dhcp4_props); g_assert (out_device_dhcp6_props && !*out_device_dhcp6_props); + g_assert (out_connectivity_state && !*out_connectivity_state); g_assert (out_vpn_ip_iface && !*out_vpn_ip_iface); g_assert (out_vpn_ip4_props && !*out_vpn_ip4_props); g_assert (out_vpn_ip6_props && !*out_vpn_ip6_props); @@ -396,6 +400,7 @@ get_dispatcher_file (const char *file, out_con_props, out_expected_iface, out_action, + out_connectivity_state, out_vpn_ip_iface, error)) goto out; @@ -451,6 +456,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface) GVariant *device_ip6_props = NULL; GVariant *device_dhcp4_props = NULL; GVariant *device_dhcp6_props = NULL; + char *connectivity_change = NULL; char *vpn_ip_iface = NULL; GVariant *vpn_ip4_props = NULL; GVariant *vpn_ip6_props = NULL; @@ -474,6 +480,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface) &device_ip6_props, &device_dhcp4_props, &device_dhcp6_props, + &connectivity_change, &vpn_ip_iface, &vpn_ip4_props, &vpn_ip6_props, @@ -494,6 +501,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface) device_ip6_props, device_dhcp4_props, device_dhcp6_props, + connectivity_change, override_vpn_ip_iface ? override_vpn_ip_iface : vpn_ip_iface, vpn_ip4_props, vpn_ip6_props, @@ -602,6 +610,15 @@ test_external (void) } static void +test_connectivity_changed (void) +{ + /* These tests will check that the CONNECTIVITY_STATE environment + * variable is only defined for known states, such as 'full'. */ + test_generic ("dispatcher-connectivity-unknown", NULL); + test_generic ("dispatcher-connectivity-full", NULL); +} + +static void test_up_empty_vpn_iface (void) { /* Test that an empty VPN iface variable, like is passed through D-Bus @@ -624,6 +641,7 @@ main (int argc, char **argv) g_test_add_func ("/dispatcher/vpn_up", test_vpn_up); g_test_add_func ("/dispatcher/vpn_down", test_vpn_down); g_test_add_func ("/dispatcher/external", test_external); + g_test_add_func ("/dispatcher/connectivity_changed", test_connectivity_changed); g_test_add_func ("/dispatcher/up_empty_vpn_iface", test_up_empty_vpn_iface); |