summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorIndrajit Raychaudhuri <irc@indrajit.com>2023-11-09 16:12:58 -0600
committerIndrajit Raychaudhuri <irc@indrajit.com>2023-11-30 21:42:24 -0600
commit7092d85ea7d949e65655debe531e17a2220889ad (patch)
tree6d699c39bd3fb99552428439fc9f973c16d8fe9a /smoketest/scripts/cli
parent521713e40f9605da81ec3ffa7a71b48486d692e2 (diff)
downloadvyos-1x-7092d85ea7d949e65655debe531e17a2220889ad.tar.gz
vyos-1x-7092d85ea7d949e65655debe531e17a2220889ad.zip
ddclient: T5708: Additional smoketests for web-options
Add additional smoketests for web-options validation. Also, format error messages to optionally include protocol name.
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_service_dns_dynamic.py53
1 files changed, 52 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_service_dns_dynamic.py b/smoketest/scripts/cli/test_service_dns_dynamic.py
index 69ea5c1b3..a3b220f69 100755
--- a/smoketest/scripts/cli/test_service_dns_dynamic.py
+++ b/smoketest/scripts/cli/test_service_dns_dynamic.py
@@ -245,7 +245,58 @@ class TestServiceDDNS(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'password=\'{password}\'', ddclient_conf)
self.assertIn(f'{name}', ddclient_conf)
- def test_06_dyndns_vrf(self):
+ def test_06_dyndns_web_options(self):
+ # Check if DDNS service can be configured and runs
+ base_path_iface = base_path + ['address', interface]
+ base_path_web = base_path + ['address', 'web']
+ svc_path_iface = base_path_iface + ['service', 'cloudflare']
+ svc_path_web = base_path_web + ['service', 'cloudflare']
+ proto = 'cloudflare'
+ web_url_good = 'https://ifconfig.me/ip'
+ web_url_bad = 'http:/ifconfig.me/ip'
+
+ self.cli_set(svc_path_iface + ['protocol', proto])
+ self.cli_set(svc_path_iface + ['zone', zone])
+ self.cli_set(svc_path_iface + ['password', password])
+ self.cli_set(svc_path_iface + ['host-name', hostname])
+ self.cli_set(base_path_iface + ['web-options', 'url', web_url_good])
+
+ # web-options is supported only with web service based address lookup
+ # exception is raised for interface based address lookup
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+ self.cli_delete(base_path_iface + ['web-options'])
+
+ # commit changes
+ self.cli_commit()
+
+ # web-options is supported with web service based address lookup
+ # this should work, but clear interface based config first
+ self.cli_delete(base_path_iface)
+ self.cli_set(svc_path_web + ['protocol', proto])
+ self.cli_set(svc_path_web + ['zone', zone])
+ self.cli_set(svc_path_web + ['password', password])
+ self.cli_set(svc_path_web + ['host-name', hostname])
+
+ # web-options must be a valid URL
+ with self.assertRaises(ConfigSessionError) as cm:
+ self.cli_set(base_path_web + ['web-options', 'url', web_url_bad])
+ self.assertIn(f'"{web_url_bad.removeprefix("http:")}" is not a valid URI', str(cm.exception))
+ self.cli_set(base_path_web + ['web-options', 'url', web_url_good])
+
+ # commit changes
+ self.cli_commit()
+
+ # Check the generating config parameters
+ ddclient_conf = cmd(f'sudo cat {DDCLIENT_CONF}')
+ self.assertIn(f'usev4=webv4', ddclient_conf)
+ self.assertIn(f'webv4={web_url_good}', ddclient_conf)
+ self.assertIn(f'protocol={proto}', ddclient_conf)
+ self.assertIn(f'zone={zone}', ddclient_conf)
+ self.assertIn(f'password=\'{password}\'', ddclient_conf)
+ self.assertIn(f'{hostname}', ddclient_conf)
+
+ def test_07_dyndns_vrf(self):
vrf_table = "".join(random.choices(string.digits, k=5))
vrf_name = f'vyos-test-{vrf_table}'
svc_path = ['address', interface, 'service', 'cloudflare']