summaryrefslogtreecommitdiff
path: root/src/dhcp-manager/tests/test-dhcp-dhclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhcp-manager/tests/test-dhcp-dhclient.c')
-rw-r--r--src/dhcp-manager/tests/test-dhcp-dhclient.c79
1 files changed, 68 insertions, 11 deletions
diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c
index 4f7e96afd..e1a96cabf 100644
--- a/src/dhcp-manager/tests/test-dhcp-dhclient.c
+++ b/src/dhcp-manager/tests/test-dhcp-dhclient.c
@@ -39,6 +39,7 @@
static void
test_config (const char *orig,
const char *expected,
+ gboolean ipv6,
const char *hostname,
const char *dhcp_client_id,
GBytes *expected_new_client_id,
@@ -55,7 +56,7 @@ test_config (const char *orig,
}
new = nm_dhcp_dhclient_create_config (iface,
- FALSE,
+ ipv6,
client_id,
anycast_addr,
hostname,
@@ -103,7 +104,7 @@ static const char *orig_missing_expected = \
static void
test_orig_missing (void)
{
- test_config (NULL, orig_missing_expected, NULL, NULL, NULL, "eth0", NULL);
+ test_config (NULL, orig_missing_expected, FALSE, NULL, NULL, NULL, "eth0", NULL);
}
/*******************************************/
@@ -132,7 +133,7 @@ static void
test_override_client_id (void)
{
test_config (override_client_id_orig, override_client_id_expected,
- NULL,
+ FALSE, NULL,
"11:22:33:44:55:66",
NULL,
"eth0",
@@ -161,7 +162,7 @@ static void
test_quote_client_id (void)
{
test_config (NULL, quote_client_id_expected,
- NULL,
+ FALSE, NULL,
"1234",
NULL,
"eth0",
@@ -190,7 +191,7 @@ static void
test_ascii_client_id (void)
{
test_config (NULL, ascii_client_id_expected,
- NULL,
+ FALSE, NULL,
"qb:cd:ef:12:34:56",
NULL,
"eth0",
@@ -219,7 +220,7 @@ static void
test_hex_single_client_id (void)
{
test_config (NULL, hex_single_client_id_expected,
- NULL,
+ FALSE, NULL,
"ab:cd:e:12:34:56",
NULL,
"eth0",
@@ -256,7 +257,7 @@ test_existing_hex_client_id (void)
new_client_id = g_bytes_new (bytes, sizeof (bytes));
test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
- NULL,
+ FALSE, NULL,
NULL,
new_client_id,
"eth0",
@@ -296,7 +297,7 @@ test_existing_ascii_client_id (void)
memcpy (buf + 1, EACID, STRLEN (EACID));
new_client_id = g_bytes_new (buf, sizeof (buf));
test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected,
- NULL,
+ FALSE, NULL,
NULL,
new_client_id,
"eth0",
@@ -329,7 +330,58 @@ static void
test_override_hostname (void)
{
test_config (override_hostname_orig, override_hostname_expected,
- "blahblah",
+ FALSE, "blahblah",
+ NULL,
+ NULL,
+ "eth0",
+ NULL);
+}
+
+/*******************************************/
+
+static const char *override_hostname6_orig = \
+ "send fqdn.fqdn \"foobar\";\n";
+
+static const char *override_hostname6_expected = \
+ "# Created by NetworkManager\n"
+ "# Merged from /path/to/dhclient.conf\n"
+ "\n"
+ "send fqdn.fqdn \"blahblah.local\"; # added by NetworkManager\n"
+ "send fqdn.encoded on;\n"
+ "send fqdn.server-update on;\n"
+ "\n"
+ "also request dhcp6.name-servers;\n"
+ "also request dhcp6.domain-search;\n"
+ "also request dhcp6.client-id;\n"
+ "\n";
+
+static void
+test_override_hostname6 (void)
+{
+ test_config (override_hostname6_orig, override_hostname6_expected,
+ TRUE, "blahblah.local",
+ NULL,
+ NULL,
+ "eth0",
+ NULL);
+}
+
+/*******************************************/
+
+static const char *nonfqdn_hostname6_expected = \
+ "# Created by NetworkManager\n"
+ "\n"
+ "also request dhcp6.name-servers;\n"
+ "also request dhcp6.domain-search;\n"
+ "also request dhcp6.client-id;\n"
+ "\n";
+
+static void
+test_nonfqdn_hostname6 (void)
+{
+ /* Non-FQDN hostname can't be used with dhclient */
+ test_config (NULL, nonfqdn_hostname6_expected,
+ TRUE, "blahblah",
NULL,
NULL,
"eth0",
@@ -364,7 +416,7 @@ static void
test_existing_alsoreq (void)
{
test_config (existing_alsoreq_orig, existing_alsoreq_expected,
- NULL,
+ FALSE, NULL,
NULL,
NULL,
"eth0",
@@ -403,7 +455,7 @@ static void
test_existing_multiline_alsoreq (void)
{
test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected,
- NULL,
+ FALSE, NULL,
NULL,
NULL,
"eth0",
@@ -430,6 +482,9 @@ test_one_duid (const char *escaped, const guint8 *unescaped, guint len)
g_assert (w);
g_assert_cmpint (strlen (escaped), ==, strlen (w));
g_assert_cmpstr (escaped, ==, w);
+
+ g_byte_array_free (t, TRUE);
+ g_free (w);
}
static void
@@ -718,6 +773,8 @@ main (int argc, char **argv)
g_test_add_func ("/dhcp/dhclient/existing-hex-client-id", test_existing_hex_client_id);
g_test_add_func ("/dhcp/dhclient/existing-ascii-client-id", test_existing_ascii_client_id);
g_test_add_func ("/dhcp/dhclient/override_hostname", test_override_hostname);
+ g_test_add_func ("/dhcp/dhclient/override_hostname6", test_override_hostname6);
+ g_test_add_func ("/dhcp/dhclient/nonfqdn_hostname6", test_nonfqdn_hostname6);
g_test_add_func ("/dhcp/dhclient/existing_alsoreq", test_existing_alsoreq);
g_test_add_func ("/dhcp/dhclient/existing_multiline_alsoreq", test_existing_multiline_alsoreq);
g_test_add_func ("/dhcp/dhclient/duids", test_duids);