summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_service_dns_forwarding.py
diff options
context:
space:
mode:
authorIndrajit Raychaudhuri <irc@indrajit.com>2023-03-27 03:56:13 -0500
committerIndrajit Raychaudhuri <irc@indrajit.com>2023-03-28 10:16:07 -0500
commit2bb5c5d0fd9ed07649b81a61e9c1a78a9f222405 (patch)
tree1dd4acf56be2818873b4a3c2c1cdc145f81063bd /smoketest/scripts/cli/test_service_dns_forwarding.py
parentb5d940d9f279a8391c8d8c56cc86f4855c9d38b5 (diff)
downloadvyos-1x-2bb5c5d0fd9ed07649b81a61e9c1a78a9f222405.tar.gz
vyos-1x-2bb5c5d0fd9ed07649b81a61e9c1a78a9f222405.zip
dns: T5115: Support custom port for name servers for forwarding zones.
This would allow using custom ports in name server operating on non- default port for forwarding zones. This is a follow-up to T5113 for sake of completeness and having consistent treatment of all name servers configured in PowerDNS recursor. Additionally, migrate `service dns forwarding domain example.com server` to `service dns forwarding domain foo3.com name-server` for consistency and reusability.
Diffstat (limited to 'smoketest/scripts/cli/test_service_dns_forwarding.py')
-rwxr-xr-xsmoketest/scripts/cli/test_service_dns_forwarding.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/smoketest/scripts/cli/test_service_dns_forwarding.py b/smoketest/scripts/cli/test_service_dns_forwarding.py
index 04dced292..88492e348 100755
--- a/smoketest/scripts/cli/test_service_dns_forwarding.py
+++ b/smoketest/scripts/cli/test_service_dns_forwarding.py
@@ -169,10 +169,13 @@ class TestServicePowerDNS(VyOSUnitTestSHIM.TestCase):
self.cli_set(base_path + ['listen-address', address])
domains = ['vyos.io', 'vyos.net', 'vyos.com']
- nameservers = ['192.0.2.1', '192.0.2.2']
+ nameservers = {'192.0.2.1': {}, '192.0.2.2': {'port': '53'}, '2001:db8::1': {'port': '853'}}
for domain in domains:
- for nameserver in nameservers:
- self.cli_set(base_path + ['domain', domain, 'server', nameserver])
+ for h,p in nameservers.items():
+ if 'port' in p:
+ self.cli_set(base_path + ['domain', domain, 'name-server', h, 'port', p['port']])
+ else:
+ self.cli_set(base_path + ['domain', domain, 'name-server', h])
# Test 'recursion-desired' flag for only one domain
if domain == domains[0]:
@@ -192,7 +195,9 @@ class TestServicePowerDNS(VyOSUnitTestSHIM.TestCase):
if domain == domains[0]: key =f'\+{domain}'
else: key =f'{domain}'
tmp = get_config_value(key, file=FORWARD_FILE)
- self.assertEqual(tmp, ', '.join(nameservers))
+ canonical_entries = [(lambda h, p: f"{bracketize_ipv6(h)}:{p['port'] if 'port' in p else 53}")(h, p)
+ for (h, p) in nameservers.items()]
+ self.assertEqual(tmp, ', '.join(canonical_entries))
# Test 'negative trust anchor' flag for the second domain only
if domain == domains[1]: