summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndrajit Raychaudhuri <irc@indrajit.com>2023-09-23 19:06:03 -0500
committerIndrajit Raychaudhuri <irc@indrajit.com>2023-11-30 21:42:23 -0600
commit25588799dd5f655ee093b650f607d0bab1fd3d00 (patch)
tree74bef6b16a2f51fb6ad4f3cc5f9f5bbd36f2e065
parentc545758552ababa069fc090ac50b79a69ad72457 (diff)
downloadvyos-1x-25588799dd5f655ee093b650f607d0bab1fd3d00.tar.gz
vyos-1x-25588799dd5f655ee093b650f607d0bab1fd3d00.zip
ddclient: T5612: Relax hostname validation for apex and wildcard entry
Some porvides (like 'namecheap') allow to use '@' or '*' as hostname prefix for apex and wildcard records. This commit relaxes the hostname validation to allow these prefixes.
-rw-r--r--interface-definitions/include/dns/dynamic-service-host-name-server.xml.i3
-rwxr-xr-xsmoketest/scripts/cli/test_service_dns_dynamic.py26
2 files changed, 27 insertions, 2 deletions
diff --git a/interface-definitions/include/dns/dynamic-service-host-name-server.xml.i b/interface-definitions/include/dns/dynamic-service-host-name-server.xml.i
index ee1af2a36..9dd14f97c 100644
--- a/interface-definitions/include/dns/dynamic-service-host-name-server.xml.i
+++ b/interface-definitions/include/dns/dynamic-service-host-name-server.xml.i
@@ -4,8 +4,9 @@
<help>Hostname to register with Dynamic DNS service</help>
<constraint>
#include <include/constraint/host-name.xml.i>
+ <regex>(\@|\*)[-.A-Za-z0-9]*</regex>
</constraint>
- <constraintErrorMessage>Host-name must be alphanumeric and can contain hyphens</constraintErrorMessage>
+ <constraintErrorMessage>Host-name must be alphanumeric, can contain hyphens and can be prefixed with '@' or '*'</constraintErrorMessage>
<multi/>
</properties>
</leafNode>
diff --git a/smoketest/scripts/cli/test_service_dns_dynamic.py b/smoketest/scripts/cli/test_service_dns_dynamic.py
index aa4891829..f1870320e 100755
--- a/smoketest/scripts/cli/test_service_dns_dynamic.py
+++ b/smoketest/scripts/cli/test_service_dns_dynamic.py
@@ -203,7 +203,31 @@ class TestServiceDDNS(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'password={key_file.name}', ddclient_conf)
self.assertIn(f'ttl={ttl}', ddclient_conf)
- def test_05_dyndns_vrf(self):
+ def test_05_dyndns_hostname(self):
+ # Check if DDNS service can be configured and runs
+ svc_path = ['address', interface, 'service', 'namecheap']
+ proto = 'namecheap'
+ hostnames = ['@', 'www', hostname, f'@.{hostname}']
+
+ for name in hostnames:
+ self.cli_set(base_path + svc_path + ['protocol', proto])
+ self.cli_set(base_path + svc_path + ['server', server])
+ self.cli_set(base_path + svc_path + ['username', username])
+ self.cli_set(base_path + svc_path + ['password', password])
+ self.cli_set(base_path + svc_path + ['host-name', name])
+
+ # commit changes
+ self.cli_commit()
+
+ # Check the generating config parameters
+ ddclient_conf = cmd(f'sudo cat {DDCLIENT_CONF}')
+ self.assertIn(f'protocol={proto}', ddclient_conf)
+ self.assertIn(f'server={server}', ddclient_conf)
+ self.assertIn(f'login={username}', ddclient_conf)
+ self.assertIn(f'password={password}', ddclient_conf)
+ self.assertIn(f'{name}', ddclient_conf)
+
+ def test_06_dyndns_vrf(self):
vrf_name = f'vyos-test-{"".join(random.choices(string.ascii_letters + string.digits, k=5))}'
svc_path = ['address', interface, 'service', 'cloudflare']