diff options
Diffstat (limited to 'src/dhcp/tests/test-dhcp-dhclient.c')
| -rw-r--r-- | src/dhcp/tests/test-dhcp-dhclient.c | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c index 9e51fceb..761f9cdb 100644 --- a/src/dhcp/tests/test-dhcp-dhclient.c +++ b/src/dhcp/tests/test-dhcp-dhclient.c @@ -1,20 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * * Copyright (C) 2010 Red Hat, Inc. - * */ #include "nm-default.h" @@ -43,6 +29,7 @@ test_config (const char *orig, const char *hostname, guint32 timeout, gboolean use_fqdn, + NMDhcpHostnameFlags hostname_flags, const char *dhcp_client_id, GBytes *expected_new_client_id, const char *iface, @@ -64,6 +51,7 @@ test_config (const char *orig, hostname, timeout, use_fqdn, + hostname_flags, "/path/to/dhclient.conf", orig, &new_client_id); @@ -108,7 +96,11 @@ static const char *orig_missing_expected = \ static void test_orig_missing (void) { - test_config (NULL, orig_missing_expected, AF_INET, NULL, 0, FALSE, NULL, NULL, "eth0", NULL); + test_config (NULL, + orig_missing_expected, + AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, + NULL, NULL, "eth0", NULL); } /*****************************************************************************/ @@ -139,6 +131,7 @@ test_override_client_id (void) { test_config (override_client_id_orig, override_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "11:22:33:44:55:66", NULL, "eth0", @@ -169,6 +162,7 @@ test_quote_client_id (void) { test_config (NULL, quote_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "abcd", NULL, "eth0", @@ -199,6 +193,7 @@ test_quote_client_id_2 (void) { test_config (NULL, quote_client_id_expected_2, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "a\\bc", NULL, "eth0", @@ -229,6 +224,7 @@ test_hex_zero_client_id (void) { test_config (NULL, hex_zero_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "00:11:22:33", NULL, "eth0", @@ -259,6 +255,7 @@ test_ascii_client_id (void) { test_config (NULL, ascii_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "qb:cd:ef:12:34:56", NULL, "eth0", @@ -289,6 +286,7 @@ test_hex_single_client_id (void) { test_config (NULL, hex_single_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, "ab:cd:e:12:34:56", NULL, "eth0", @@ -327,6 +325,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, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, new_client_id, "eth0", @@ -364,6 +363,7 @@ test_existing_escaped_client_id (void) new_client_id = g_bytes_new ("$test\xfe", 6); test_config (existing_escaped_client_id_orig, existing_escaped_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, new_client_id, "eth0", @@ -405,6 +405,7 @@ test_existing_ascii_client_id (void) new_client_id = g_bytes_new (buf, sizeof (buf)); test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, new_client_id, "eth0", @@ -417,7 +418,8 @@ static const char *fqdn_expected = \ "\n" "send fqdn.fqdn \"foo.bar.com\"; # added by NetworkManager\n" "send fqdn.encoded on;\n" - "send fqdn.server-update on;\n" + "send fqdn.server-update off;\n" + "send fqdn.no-client-update on;\n" "\n" "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" @@ -435,7 +437,10 @@ test_fqdn (void) { test_config (NULL, fqdn_expected, AF_INET, "foo.bar.com", 0, - TRUE, NULL, + TRUE, + NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED + | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE, + NULL, NULL, "eth0", NULL); @@ -452,8 +457,9 @@ static const char *fqdn_options_override_expected = \ "# Merged from /path/to/dhclient.conf\n" "\n" "send fqdn.fqdn \"example2.com\"; # added by NetworkManager\n" - "send fqdn.encoded on;\n" + "send fqdn.encoded off;\n" "send fqdn.server-update on;\n" + "send fqdn.no-client-update off;\n" "\n" "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n" "option ms-classless-static-routes code 249 = array of unsigned integer 8;\n" @@ -476,6 +482,7 @@ test_fqdn_options_override (void) test_config (fqdn_options_override_orig, fqdn_options_override_expected, AF_INET, "example2.com", 0, + NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE, TRUE, NULL, NULL, "eth0", @@ -510,6 +517,7 @@ test_override_hostname (void) { test_config (override_hostname_orig, override_hostname_expected, AF_INET, "blahblah", 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", @@ -538,6 +546,7 @@ test_override_hostname6 (void) { test_config (override_hostname6_orig, override_hostname6_expected, AF_INET6, "blahblah.local", 0, TRUE, + NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE, NULL, NULL, "eth0", @@ -550,7 +559,7 @@ static const char *nonfqdn_hostname6_expected = \ "# Created by NetworkManager\n" "\n" "send fqdn.fqdn \"blahblah\"; # added by NetworkManager\n" - "send fqdn.server-update on;\n" + "send fqdn.no-client-update on;\n" "\n" "also request dhcp6.name-servers;\n" "also request dhcp6.domain-search;\n" @@ -563,6 +572,7 @@ test_nonfqdn_hostname6 (void) /* Non-FQDN hostname can now be used with dhclient */ test_config (NULL, nonfqdn_hostname6_expected, AF_INET6, "blahblah", 0, TRUE, + NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE, NULL, NULL, "eth0", @@ -599,6 +609,7 @@ test_existing_alsoreq (void) { test_config (existing_alsoreq_orig, existing_alsoreq_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", @@ -638,6 +649,7 @@ test_existing_req (void) { test_config (existing_req_orig, existing_req_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", @@ -678,6 +690,7 @@ test_existing_multiline_alsoreq (void) { test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", @@ -917,6 +930,7 @@ test_interface1 (void) { test_config (interface1_orig, interface1_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", @@ -963,6 +977,7 @@ test_interface2 (void) { test_config (interface2_orig, interface2_expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth1", @@ -1074,6 +1089,7 @@ test_structured (void) new_client_id = g_bytes_new (bytes, sizeof (bytes) - 1); test_config (orig, expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, new_client_id, "eth0", @@ -1129,6 +1145,7 @@ test_config_req_intf (void) test_config (orig, expected, AF_INET, NULL, 0, FALSE, + NM_DHCP_HOSTNAME_FLAG_NONE, NULL, NULL, "eth0", |