summary refs log tree commit diff
path: root/src/settings/plugins/ifnet/tests/test_all.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2012-03-24 01:37:02 +0100
committerMichael Biebl <biebl@debian.org>2012-03-24 01:37:02 +0100
commitde06e5715e780baade318f3490ac7a4c9ce84e32 (patch)
tree23fbc3fafc12072476eff98bee60100eb54c29db /src/settings/plugins/ifnet/tests/test_all.c
parentb436a68a20ff3114ded32a7a3d70cdd4954039f9 (diff)
Imported Upstream version 0.9.4.0 upstream/0.9.4.0
Diffstat (limited to 'src/settings/plugins/ifnet/tests/test_all.c')
-rw-r--r--src/settings/plugins/ifnet/tests/test_all.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c
index 52d9ce2a..50441d4e 100644
--- a/src/settings/plugins/ifnet/tests/test_all.c
+++ b/src/settings/plugins/ifnet/tests/test_all.c
@@ -33,11 +33,21 @@
 #include "wpa_parser.h"
 #include "connection_parser.h"
 
+/* Fake config file function to make the linker happy */
+const char *ifnet_plugin_get_conf_file (void);
+
+const char *
+ifnet_plugin_get_conf_file (void)
+{
+	return "/etc/foo/barasdfasdfasdfasdf";
+}
+
+
 static void
 test_getdata ()
 {
 	ASSERT (ifnet_get_data ("eth1", "config")
-		&& strcmp (ifnet_get_data ("eth1", "config"), "dhcp") == 0,
+		&& strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0,
 		"get data", "config_eth1 is not correct");
 	ASSERT (ifnet_get_data ("ppp0", "username")
 		&& strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0,
@@ -84,7 +94,7 @@ test_is_static ()
 	ASSERT (is_static_ip4 ("eth0") == TRUE, "is static",
 		"a static interface is recognized as dhcp");
 	ASSERT (!is_static_ip6 ("eth0") == TRUE, "is static",
-		"a static interface is recognized as dhcp");
+		"a dhcp interface is recognized as static");
 }
 
 static void
@@ -182,10 +192,6 @@ test_convert_ipv4_config_block ()
 	ASSERT (iblock == NULL, "convert config_block",
 		"convert error configuration");
 	destroy_ip_block (iblock);
-	iblock = convert_ip4_config_block ("eth6");
-	ASSERT (iblock != NULL, "convert config_block",
-		"convert error configuration");
-	destroy_ip_block (iblock);
 }
 
 static void
@@ -200,6 +206,16 @@ test_convert_ipv4_routes_block ()
 	destroy_ip_block (tmp);
 	ASSERT (iblock == NULL, "convert ip4 routes",
 		"should only get one route");
+
+	iblock = convert_ip4_routes_block ("eth9");
+	tmp = iblock;
+
+	ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
+	check_ip_block (iblock, "10.0.0.0", "255.0.0.0", "192.168.0.1");
+	iblock = iblock->next;
+	destroy_ip_block (tmp);
+	ASSERT (iblock == NULL, "convert ip4 routes",
+		"should only get one route");
 }
 
 static void
@@ -222,6 +238,9 @@ test_wpa_parser ()
 		"wep_key0 of static-wep-test should be abcde, find %s", value);
 	ASSERT (exist_ssid ("leap-example"), "get wsec",
 		"ssid leap-example is not found");
+
+	value = wpa_get_value ("test-with-hash-in-psk", "psk");
+	g_assert_cmpstr (value, ==, "\"xjtudlc3731###asdfasdfasdf\"");
 }
 
 static void
@@ -272,6 +291,18 @@ test_new_connection ()
 		"new connection failed: %s",
 		error ? error->message : "NONE");
 	g_object_unref (connection);
+
+	connection = ifnet_update_connection_from_config_block ("eth9", &error);
+	ASSERT (connection != NULL, "new connection",
+		"new connection(eth9) failed: %s",
+		error ? error->message : "NONE");
+	g_object_unref (connection);
+
+	connection = ifnet_update_connection_from_config_block ("eth10", &error);
+	ASSERT (connection != NULL, "new connection",
+		"new connection(eth10) failed: %s",
+		error ? error->message : "NONE");
+	g_object_unref (connection);
 }
 
 #define NET_GEN_NAME "net.generate"