summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_service_dhcp-server.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-03 10:56:08 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-03 10:56:08 +0100
commitbc599ab4610f8bfd5e19a9c4cfe6bb50b4ceb0b0 (patch)
tree13c6d30f65539e777b82207dbb654c13b2bb01db /smoketest/scripts/cli/test_service_dhcp-server.py
parentcdc1748b8489251a45875736a99633740529ea0c (diff)
downloadvyos-1x-bc599ab4610f8bfd5e19a9c4cfe6bb50b4ceb0b0.tar.gz
vyos-1x-bc599ab4610f8bfd5e19a9c4cfe6bb50b4ceb0b0.zip
dhcp: T2562: harden implementation for non existing shared-subnets
Diffstat (limited to 'smoketest/scripts/cli/test_service_dhcp-server.py')
-rwxr-xr-xsmoketest/scripts/cli/test_service_dhcp-server.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_service_dhcp-server.py b/smoketest/scripts/cli/test_service_dhcp-server.py
index c9ec9ebc0..db7b2dda4 100755
--- a/smoketest/scripts/cli/test_service_dhcp-server.py
+++ b/smoketest/scripts/cli/test_service_dhcp-server.py
@@ -369,7 +369,7 @@ class TestServiceDHCPServer(unittest.TestCase):
# commit changes
self.session.commit()
- # VErify
+ # Verify
config = read_file(DHCPD_CONF)
network = address_from_cidr(subnet)
netmask = netmask_from_cidr(subnet)
@@ -382,5 +382,39 @@ class TestServiceDHCPServer(unittest.TestCase):
# Check for running process
self.assertTrue(process_named_running(PROCESS_NAME))
+ def test_dhcp_relay_server(self):
+ # Listen on specific address and return DHCP leases from a non
+ # directly connected pool
+ self.session.set(base_path + ['listen-address', router])
+
+ relay_subnet = '10.0.0.0/16'
+ relay_router = inc_ip(relay_subnet, 1)
+
+ range_0_start = '10.0.1.0'
+ range_0_stop = '10.0.250.255'
+
+ pool = base_path + ['shared-network-name', 'RELAY', 'subnet', relay_subnet]
+ self.session.set(pool + ['default-router', relay_router])
+ self.session.set(pool + ['range', '0', 'start', range_0_start])
+ self.session.set(pool + ['range', '0', 'stop', range_0_stop])
+
+ # commit changes
+ self.session.commit()
+
+ config = read_file(DHCPD_CONF)
+ network = address_from_cidr(subnet)
+ netmask = netmask_from_cidr(subnet)
+ # Check the relay network
+ self.assertIn(f'subnet {network} netmask {netmask}' + r' { }', config)
+
+ relay_network = address_from_cidr(relay_subnet)
+ relay_netmask = netmask_from_cidr(relay_subnet)
+ self.assertIn(f'subnet {relay_network} netmask {relay_netmask}' + r' {', config)
+ self.assertIn(f'option routers {relay_router};', config)
+ self.assertIn(f'range {range_0_start} {range_0_stop};', config)
+
+ # Check for running process
+ self.assertTrue(process_named_running(PROCESS_NAME))
+
if __name__ == '__main__':
unittest.main(verbosity=2)