]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test cases for global [DHCPv4] ClientIdentifier= setting 35783/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Dec 2024 02:18:59 +0000 (11:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Dec 2024 02:19:02 +0000 (11:19 +0900)
test/test-network/conf/10-dhcp-client-id-duid.conf [new file with mode: 0644]
test/test-network/conf/10-dhcp-client-id-mac.conf [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/10-dhcp-client-id-duid.conf b/test/test-network/conf/10-dhcp-client-id-duid.conf
new file mode 100644 (file)
index 0000000..8d87fb0
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[DHCPv4]
+ClientIdentifier=duid
diff --git a/test/test-network/conf/10-dhcp-client-id-mac.conf b/test/test-network/conf/10-dhcp-client-id-mac.conf
new file mode 100644 (file)
index 0000000..130e916
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[DHCPv4]
+ClientIdentifier=mac
index 136a6ed7448f414cb162b335797b37617656b0ad..9203948d6ca13c070286603486c6e6343cbf8f54 100755 (executable)
@@ -6742,8 +6742,9 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities):
         self.assertIn('Gateway: 192.168.5.1', output)
         self.assertIn('Time Zone: Europe/Berlin', output)
 
-    def test_dhcp_server_static_lease(self):
+    def test_dhcp_server_static_lease_mac_by_network(self):
         copy_network_unit('25-veth.netdev', '25-dhcp-client-static-lease.network', '25-dhcp-server-static-lease.network')
+        copy_networkd_conf_dropin('10-dhcp-client-id-duid.conf')
         start_networkd()
         self.wait_online('veth99:routable', 'veth-peer:routable')
 
@@ -6752,7 +6753,18 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities):
         self.assertIn('Address: 10.1.1.200 (DHCPv4 via 10.1.1.1)', output)
         self.assertIn('DHCPv4 Client ID: 12:34:56:78:9a:bc', output)
 
-    def test_dhcp_server_static_lease_default_client_id(self):
+    def test_dhcp_server_static_lease_mac_by_global(self):
+        copy_network_unit('25-veth.netdev', '25-dhcp-client.network', '25-dhcp-server-static-lease.network')
+        copy_networkd_conf_dropin('10-dhcp-client-id-mac.conf')
+        start_networkd()
+        self.wait_online('veth99:routable', 'veth-peer:routable')
+
+        output = networkctl_status('veth99')
+        print(output)
+        self.assertIn('Address: 10.1.1.200 (DHCPv4 via 10.1.1.1)', output)
+        self.assertIn('DHCPv4 Client ID: 12:34:56:78:9a:bc', output)
+
+    def test_dhcp_server_static_lease_duid(self):
         copy_network_unit('25-veth.netdev', '25-dhcp-client.network', '25-dhcp-server-static-lease.network')
         start_networkd()
         self.wait_online('veth99:routable', 'veth-peer:routable')