some error validation, light refactor of ip checking in model

This commit is contained in:
Rachid Mrad 2023-10-18 15:36:41 -04:00
parent 16164f1f05
commit 51307d3b12
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF
4 changed files with 45 additions and 13 deletions

View file

@ -313,14 +313,14 @@ class Domain(TimeStampedModel, DomainHelper):
NameserverError (if exception hit)
Returns:
None"""
if self.isSubdomain(nameserver) and (ip is None or ip == []):
if self.isSubdomain(nameserver) and (ip is None or ip == [] or ip != []):
raise NameserverError(code=nsErrorCodes.MISSING_IP, nameserver=nameserver)
elif not self.isSubdomain(nameserver) and (ip is not None and ip != []):
elif not self.isSubdomain(nameserver) and (ip is not None and ip != [] and ip != ['']):
raise NameserverError(
code=nsErrorCodes.GLUE_RECORD_NOT_ALLOWED, nameserver=nameserver, ip=ip
)
elif ip is not None and ip != []:
elif ip is not None and ip != [] and ip != ['']:
for addr in ip:
logger.info(f"ip address {addr}")
if not self._valid_ip_addr(addr):