diff --git a/CHANGES.rst b/CHANGES.rst index 28520f21..0d65a73e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -22,6 +22,7 @@ Fixes: - fixed misc. crashes - fixed Domain.generate_ns_secret() storing bytes object into Domain.nameserver_update_secret leading to trying to insert the string representation of the bytes object, so 91 characters in a varchar(88) +- fixed connectivity test when editing domains, #479 Other changes: diff --git a/src/nsupdate/main/dnstools.py b/src/nsupdate/main/dnstools.py index fa10b3e1..1b66c17e 100644 --- a/src/nsupdate/main/dnstools.py +++ b/src/nsupdate/main/dnstools.py @@ -105,14 +105,16 @@ def check_ip(ipaddr, keys=('ipv4', 'ipv6')): return keys[af == dns.inet.AF_INET6] -def check_domain(domain): +def check_domain(domain, nameserver_ip): fqdn = FQDN(host="connectivity-test", domain=domain) from .models import Domain d = Domain.objects.get(name=domain) - # temporarily set domain to available to allow add/update/deletes + # temporarily update domain to allow add/update/deletes domain_available_state = d.available + domain_nameserver_ip = d.nameserver_ip d.available = True + d.nameserver_ip = nameserver_ip d.save() try: @@ -123,8 +125,9 @@ def check_domain(domain): raise NameServerNotAvailable(str(e)) finally: - # reset domain available + # reset domain d.available = domain_available_state + d.nameserver_ip = domain_nameserver_ip d.save() diff --git a/src/nsupdate/main/forms.py b/src/nsupdate/main/forms.py index 79441986..56d4e8dd 100644 --- a/src/nsupdate/main/forms.py +++ b/src/nsupdate/main/forms.py @@ -76,7 +76,7 @@ def clean(self): if self.cleaned_data['available']: try: - check_domain(self.instance.name) + check_domain(self.instance.name, cleaned_data['nameserver_ip']) except (NameServerNotAvailable, ): raise forms.ValidationError(