updated validation and removal of whitespace; raise RegistryErrors on create_host and update_host

This commit is contained in:
David Kennedy 2023-10-30 14:23:14 -04:00
parent 89a65e597f
commit 91e2a7906b
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 4 additions and 6 deletions

View file

@ -45,6 +45,8 @@ class DomainNameserverForm(forms.Form):
self.clean_empty_strings(cleaned_data) self.clean_empty_strings(cleaned_data)
server = cleaned_data.get("server", "") server = cleaned_data.get("server", "")
ip = cleaned_data.get("ip", None) ip = cleaned_data.get("ip", None)
# remove ANY spaces in the ip field
ip = ip.replace(" ", "")
domain = cleaned_data.get("domain", "") domain = cleaned_data.get("domain", "")
ip_list = self.extract_ip_list(ip) ip_list = self.extract_ip_list(ip)

View file

@ -277,7 +277,7 @@ class Domain(TimeStampedModel, DomainHelper):
return response.code return response.code
except RegistryError as e: except RegistryError as e:
logger.error("Error _create_host, code was %s error was %s" % (e.code, e)) logger.error("Error _create_host, code was %s error was %s" % (e.code, e))
return e.code raise e
def _convert_list_to_dict(self, listToConvert: list[tuple[str, list]]): def _convert_list_to_dict(self, listToConvert: list[tuple[str, list]]):
"""converts a list of hosts into a dictionary """converts a list of hosts into a dictionary
@ -1593,7 +1593,7 @@ class Domain(TimeStampedModel, DomainHelper):
return response.code return response.code
except RegistryError as e: except RegistryError as e:
logger.error("Error _update_host, code was %s error was %s" % (e.code, e)) logger.error("Error _update_host, code was %s error was %s" % (e.code, e))
return e.code raise e
def addAndRemoveHostsFromDomain( def addAndRemoveHostsFromDomain(
self, hostsToAdd: list[str], hostsToDelete: list[str] self, hostsToAdd: list[str], hostsToDelete: list[str]

View file

@ -295,10 +295,6 @@ class DomainNameserversView(DomainFormBaseView):
if ip_string: if ip_string:
# Split the string into a list using a comma as the delimiter # Split the string into a list using a comma as the delimiter
ip_list = ip_string.split(",") ip_list = ip_string.split(",")
# Remove any leading or trailing whitespace from each IP in the list
# this will return [] if no ips have been entered, which is taken
# into account in the model in checkHostIPCombo
ip_list = [ip.replace(" ", "").strip() for ip in ip_list]
as_tuple = ( as_tuple = (
form.cleaned_data["server"], form.cleaned_data["server"],