mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-30 01:10:04 +02:00
ran linter
This commit is contained in:
parent
a9f608e353
commit
6a3a5534db
5 changed files with 116 additions and 111 deletions
|
@ -146,21 +146,18 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
readonly_fields = ["state"]
|
readonly_fields = ["state"]
|
||||||
|
|
||||||
def response_change(self, request, obj):
|
def response_change(self, request, obj):
|
||||||
print(request.POST)
|
|
||||||
ACTION_BUTTON = "_place_client_hold"
|
ACTION_BUTTON = "_place_client_hold"
|
||||||
GET_SECURITY_EMAIL = "_get_security_email"
|
GET_SECURITY_EMAIL = "_get_security_email"
|
||||||
SET_SECURITY_CONTACT = "_set_security_contact"
|
SET_SECURITY_CONTACT = "_set_security_contact"
|
||||||
MAKE_DOMAIN = "_make_domain_in_registry"
|
MAKE_DOMAIN = "_make_domain_in_registry"
|
||||||
MAKE_NAMESERVERS = "_make_nameservers"
|
MAKE_NAMESERVERS = "_make_nameservers"
|
||||||
GET_NAMESERVERS="_get_nameservers"
|
GET_NAMESERVERS = "_get_nameservers"
|
||||||
GET_STATUS = "_get_status"
|
GET_STATUS = "_get_status"
|
||||||
SET_CLIENT_HOLD="_set_client_hold"
|
SET_CLIENT_HOLD = "_set_client_hold"
|
||||||
REMOVE_CLIENT_HOLD="_rem_client_hold"
|
REMOVE_CLIENT_HOLD = "_rem_client_hold"
|
||||||
DELETE_DOMAIN="_delete_domain"
|
DELETE_DOMAIN = "_delete_domain"
|
||||||
logger.info("in response")
|
|
||||||
if ACTION_BUTTON in request.POST:
|
if ACTION_BUTTON in request.POST:
|
||||||
logger.info("in action button")
|
|
||||||
print("in action button")
|
|
||||||
try:
|
try:
|
||||||
obj.place_client_hold()
|
obj.place_client_hold()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -178,13 +175,17 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
|
|
||||||
if GET_SECURITY_EMAIL in request.POST:
|
if GET_SECURITY_EMAIL in request.POST:
|
||||||
try:
|
try:
|
||||||
contacts=obj._get_property("contacts")
|
contacts = obj._get_property("contacts")
|
||||||
email=None
|
email = None
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
if ["type","email"] in contact.keys() and contact["type"]=="security":
|
if ["type", "email"] in contact.keys() and contact[
|
||||||
email=contact["email"]
|
"type"
|
||||||
|
] == "security":
|
||||||
|
email = contact["email"]
|
||||||
if email is None:
|
if email is None:
|
||||||
raise ValueError("Security contact type is not available on this domain")
|
raise ValueError(
|
||||||
|
"Security contact type is not available on this domain"
|
||||||
|
)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
|
@ -196,13 +197,17 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
|
|
||||||
if SET_SECURITY_CONTACT in request.POST:
|
if SET_SECURITY_CONTACT in request.POST:
|
||||||
try:
|
try:
|
||||||
fake_email="manuallyEnteredEmail@test.gov"
|
fake_email = "manuallyEnteredEmail@test.gov"
|
||||||
if PublicContact.objects.filter(domain=obj, contact_type="security").exists():
|
if PublicContact.objects.filter(
|
||||||
sec_contact=PublicContact.objects.filter(domain=obj, contact_type="security").get()
|
domain=obj, contact_type="security"
|
||||||
|
).exists():
|
||||||
|
sec_contact = PublicContact.objects.filter(
|
||||||
|
domain=obj, contact_type="security"
|
||||||
|
).get()
|
||||||
else:
|
else:
|
||||||
sec_contact=obj.get_default_security_contact()
|
sec_contact = obj.get_default_security_contact()
|
||||||
|
|
||||||
sec_contact.email=fake_email
|
sec_contact.email = fake_email
|
||||||
sec_contact.save()
|
sec_contact.save()
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -212,11 +217,8 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
request,
|
request,
|
||||||
("The security email is %" ". Thanks!") % fake_email,
|
("The security email is %" ". Thanks!") % fake_email,
|
||||||
)
|
)
|
||||||
print("above make domain")
|
|
||||||
|
|
||||||
if MAKE_DOMAIN in request.POST:
|
if MAKE_DOMAIN in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj._get_or_create_domain()
|
obj._get_or_create_domain()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -228,14 +230,12 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
|
||||||
#make nameservers here
|
# make nameservers here
|
||||||
|
|
||||||
if MAKE_NAMESERVERS in request.POST:
|
if MAKE_NAMESERVERS in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hosts=[("ns1.example.com",None),("ns2.example.com",None) ]
|
hosts = [("ns1.example.com", None), ("ns2.example.com", None)]
|
||||||
obj.nameservers=hosts
|
obj.nameservers = hosts
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
|
@ -245,10 +245,8 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
if GET_NAMESERVERS in request.POST:
|
if GET_NAMESERVERS in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
nameservers=obj.nameservers
|
nameservers = obj.nameservers
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
|
@ -259,10 +257,8 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
|
||||||
if GET_STATUS in request.POST:
|
if GET_STATUS in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
statuses=obj.statuses
|
statuses = obj.statuses
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.message_user(request, err, messages.ERROR)
|
self.message_user(request, err, messages.ERROR)
|
||||||
else:
|
else:
|
||||||
|
@ -273,8 +269,6 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
|
||||||
if SET_CLIENT_HOLD in request.POST:
|
if SET_CLIENT_HOLD in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj.clientHold()
|
obj.clientHold()
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -288,8 +282,6 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
|
||||||
if REMOVE_CLIENT_HOLD in request.POST:
|
if REMOVE_CLIENT_HOLD in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj.revertClientHold()
|
obj.revertClientHold()
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -302,8 +294,6 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
if DELETE_DOMAIN in request.POST:
|
if DELETE_DOMAIN in request.POST:
|
||||||
print("in make domain")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj.deleted()
|
obj.deleted()
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -318,7 +308,6 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
return super().response_change(request, obj)
|
return super().response_change(request, obj)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ContactAdmin(ListHeaderAdmin):
|
class ContactAdmin(ListHeaderAdmin):
|
||||||
"""Custom contact admin class to add search."""
|
"""Custom contact admin class to add search."""
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
hosts = self._get_property("hosts")
|
hosts = self._get_property("hosts")
|
||||||
except KeyError as err:
|
except Exception as err:
|
||||||
logger.info("Domain is missing nameservers")
|
logger.info("Domain is missing nameservers")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -260,10 +260,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""Call _check_host first before using this function,
|
"""Call _check_host first before using this function,
|
||||||
This creates the host object in the registry
|
This creates the host object in the registry
|
||||||
doesn't add the created host to the domain
|
doesn't add the created host to the domain
|
||||||
returns int response code"""
|
returns ErrorCode (int)"""
|
||||||
logger.info("_create_host()->addresses is NONE")
|
logger.info("_create_host()->addresses is NONE")
|
||||||
|
# TODO - # [epp.Ip(addr="127.0.0.1"), epp.Ip(addr="0:0:0:0:0:0:0:1", ip="v6")]
|
||||||
if not addrs is None and addrs!=[]:
|
if not addrs is None:
|
||||||
logger.info("addresses is not None %s" % addrs)
|
logger.info("addresses is not None %s" % addrs)
|
||||||
addresses = [epp.Ip(addr=addr) for addr in addrs]
|
addresses = [epp.Ip(addr=addr) for addr in addrs]
|
||||||
request = commands.CreateHost(name=host, addrs=addresses)
|
request = commands.CreateHost(name=host, addrs=addresses)
|
||||||
|
@ -271,7 +271,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
logger.info("_create_host()-> address IS None")
|
logger.info("_create_host()-> address IS None")
|
||||||
|
|
||||||
request = commands.CreateHost(name=host)
|
request = commands.CreateHost(name=host)
|
||||||
# [epp.Ip(addr="127.0.0.1"), epp.Ip(addr="0:0:0:0:0:0:0:1", ip="v6")]
|
|
||||||
try:
|
try:
|
||||||
logger.info("_create_host()-> sending req as %s" % request)
|
logger.info("_create_host()-> sending req as %s" % request)
|
||||||
response = registry.send(request, cleaned=True)
|
response = registry.send(request, cleaned=True)
|
||||||
|
@ -287,7 +287,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
example: [(ns1.okay.gov, 127.0.0.1, others ips)]"""
|
example: [(ns1.okay.gov, 127.0.0.1, others ips)]"""
|
||||||
# TODO: call EPP to set this info.
|
# TODO: call EPP to set this info.
|
||||||
# if two nameservers change state to created, don't do it automatically
|
# if two nameservers change state to created, don't do it automatically
|
||||||
hostSuccessCount = 0
|
|
||||||
if len(hosts) > 13:
|
if len(hosts) > 13:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Too many hosts provided, you may not have more than 13 nameservers."
|
"Too many hosts provided, you may not have more than 13 nameservers."
|
||||||
|
@ -303,10 +303,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
avail = self._check_host([host])
|
avail = self._check_host([host])
|
||||||
if avail:
|
if avail:
|
||||||
createdCode = self._create_host(host=host, addrs=addrs)
|
createdCode = self._create_host(host=host, addrs=addrs)
|
||||||
if createdCode == ErrorCode.OBJECT_EXISTS:
|
|
||||||
hostSuccessCount += 1
|
# update the domain obj
|
||||||
# update the object instead
|
if createdCode == ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY:
|
||||||
elif createdCode == ErrorCode.COMMAND_COMPLETED_SUCCESSFULLY:
|
|
||||||
# add host to domain
|
# add host to domain
|
||||||
request = commands.UpdateDomain(
|
request = commands.UpdateDomain(
|
||||||
name=self.name, add=[epp.HostObjSet([host])]
|
name=self.name, add=[epp.HostObjSet([host])]
|
||||||
|
@ -314,16 +313,19 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
registry.send(request, cleaned=True)
|
registry.send(request, cleaned=True)
|
||||||
hostSuccessCount += 1
|
|
||||||
except RegistryError as e:
|
except RegistryError as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Error adding nameserver, code was %s error was %s"
|
"Error adding nameserver, code was %s error was %s"
|
||||||
% (e.code, e)
|
% (e.code, e)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.state == self.State.DNS_NEEDED and hostSuccessCount >= 2:
|
try:
|
||||||
self.created()
|
self.created()
|
||||||
self.save()
|
self.save()
|
||||||
|
except:
|
||||||
|
logger.info(
|
||||||
|
"nameserver setter checked for create state and it did not succeed"
|
||||||
|
)
|
||||||
##TODO - handle removed nameservers here will need to change the state go back to DNS_NEEDED
|
##TODO - handle removed nameservers here will need to change the state go back to DNS_NEEDED
|
||||||
|
|
||||||
@Cache
|
@Cache
|
||||||
|
@ -592,7 +594,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# remove the old contact and add a new one
|
# remove the old contact and add a new one
|
||||||
try:
|
try:
|
||||||
self._update_domain_with_contact(contact=existing_contact, rem=True)
|
self._update_domain_with_contact(contact=existing_contact, rem=True)
|
||||||
print("deleting %s "%existing_contact)
|
print("deleting %s " % existing_contact)
|
||||||
existing_contact.delete()
|
existing_contact.delete()
|
||||||
print("after deleting")
|
print("after deleting")
|
||||||
if isEmptySecurity:
|
if isEmptySecurity:
|
||||||
|
@ -633,6 +635,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
security_contact = self.get_default_security_contact()
|
security_contact = self.get_default_security_contact()
|
||||||
security_contact.save()
|
security_contact.save()
|
||||||
logger.info("done with contacts")
|
logger.info("done with contacts")
|
||||||
|
|
||||||
@security_contact.setter # type: ignore
|
@security_contact.setter # type: ignore
|
||||||
def security_contact(self, contact: PublicContact):
|
def security_contact(self, contact: PublicContact):
|
||||||
"""makes the contact in the registry,
|
"""makes the contact in the registry,
|
||||||
|
@ -683,20 +686,20 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
def _place_client_hold(self):
|
def _place_client_hold(self):
|
||||||
"""This domain should not be active.
|
"""This domain should not be active.
|
||||||
may raises RegistryError, should be caught or handled correctly by caller """
|
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||||
request=commands.UpdateDomain(name=self.name,add=[self.clientHoldStatus()])
|
request = commands.UpdateDomain(name=self.name, add=[self.clientHoldStatus()])
|
||||||
registry.send(request)
|
registry.send(request)
|
||||||
|
|
||||||
def _remove_client_hold(self):
|
def _remove_client_hold(self):
|
||||||
"""This domain is okay to be active.
|
"""This domain is okay to be active.
|
||||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||||
request=commands.UpdateDomain(name=self.name,rem=[self.clientHoldStatus() ])
|
request = commands.UpdateDomain(name=self.name, rem=[self.clientHoldStatus()])
|
||||||
registry.send(request)
|
registry.send(request)
|
||||||
|
|
||||||
def _delete_domain(self):
|
def _delete_domain(self):
|
||||||
"""This domain should be deleted from the registry
|
"""This domain should be deleted from the registry
|
||||||
may raises RegistryError, should be caught or handled correctly by caller"""
|
may raises RegistryError, should be caught or handled correctly by caller"""
|
||||||
request=commands.DeleteDomain(name=self.name)
|
request = commands.DeleteDomain(name=self.name)
|
||||||
registry.send(request)
|
registry.send(request)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
@ -758,7 +761,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
def _get_or_create_domain(self):
|
def _get_or_create_domain(self):
|
||||||
"""Try to fetch info about this domain. Create it if it does not exist."""
|
"""Try to fetch info about this domain. Create it if it does not exist."""
|
||||||
already_tried_to_create = False
|
already_tried_to_create = False
|
||||||
exitEarly=False
|
exitEarly = False
|
||||||
count = 0
|
count = 0
|
||||||
while not exitEarly and count < 3:
|
while not exitEarly and count < 3:
|
||||||
try:
|
try:
|
||||||
|
@ -768,7 +771,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
req = commands.InfoDomain(name=self.name)
|
req = commands.InfoDomain(name=self.name)
|
||||||
domainInfo = registry.send(req, cleaned=True).res_data[0]
|
domainInfo = registry.send(req, cleaned=True).res_data[0]
|
||||||
exitEarly=True
|
exitEarly = True
|
||||||
return domainInfo
|
return domainInfo
|
||||||
except RegistryError as e:
|
except RegistryError as e:
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -787,18 +790,19 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
logger.error(e.code)
|
logger.error(e.code)
|
||||||
raise e
|
raise e
|
||||||
def addRegistrant(self):
|
|
||||||
|
|
||||||
|
def addRegistrant(self):
|
||||||
registrant = PublicContact.get_default_registrant()
|
registrant = PublicContact.get_default_registrant()
|
||||||
registrant.domain = self
|
registrant.domain = self
|
||||||
registrant.save() ##calls the registrant_contact.setter
|
registrant.save() ##calls the registrant_contact.setter
|
||||||
logger.info("registrant is %s" % registrant)
|
logger.info("registrant is %s" % registrant)
|
||||||
return registrant.registry_id
|
return registrant.registry_id
|
||||||
|
|
||||||
@transition(field="state", source=State.UNKNOWN, target=State.DNS_NEEDED)
|
@transition(field="state", source=State.UNKNOWN, target=State.DNS_NEEDED)
|
||||||
def pendingCreate(self):
|
def pendingCreate(self):
|
||||||
logger.info("In make domain in registry ")
|
logger.info("In make domain in registry ")
|
||||||
|
|
||||||
registrantID=self.addRegistrant()
|
registrantID = self.addRegistrant()
|
||||||
|
|
||||||
# TODO-notes no chg item for registrant in the epplib should
|
# TODO-notes no chg item for registrant in the epplib should
|
||||||
|
|
||||||
|
@ -877,14 +881,18 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
target=State.READY,
|
target=State.READY,
|
||||||
)
|
)
|
||||||
def created(self):
|
def created(self):
|
||||||
|
nameserverList = self.nameservers
|
||||||
logger.info("created()-> inside setting create")
|
logger.info("created()-> inside setting create")
|
||||||
|
if len(nameserverList) < 2 or len(nameserverList) > 13:
|
||||||
|
raise ValueError("Not ready to become created, cannot transition yet")
|
||||||
|
logger.info("able to transition to created state")
|
||||||
|
|
||||||
# TODO - in nameservers ticket check if has everything for creation
|
# TODO - in nameservers ticket check if has everything for creation
|
||||||
#admin, tech and security
|
# admin, tech and security
|
||||||
#2 or more (but less than 13) nameservers
|
# 2 or more (but less than 13) nameservers
|
||||||
#if any of the above is violated raise the user raise a human readable error
|
# if any of the above is violated raise the user raise a human readable error
|
||||||
#not there is another ticket for error handling keep a todo here if
|
# not there is another ticket for error handling keep a todo here if
|
||||||
#user friendly error portion is postponed
|
# user friendly error portion is postponed
|
||||||
|
|
||||||
def _disclose_fields(self, contact: PublicContact):
|
def _disclose_fields(self, contact: PublicContact):
|
||||||
"""creates a disclose object that can be added to a contact Create using
|
"""creates a disclose object that can be added to a contact Create using
|
||||||
|
@ -1032,9 +1040,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
cleaned = {k: v for k, v in cache.items() if v is not ...}
|
cleaned = {k: v for k, v in cache.items() if v is not ...}
|
||||||
logger.info("_fetch_cache()-> cleaned is " + str(cleaned))
|
logger.info("_fetch_cache()-> cleaned is " + str(cleaned))
|
||||||
|
|
||||||
#statuses can just be a list no need to keep the epp object
|
# statuses can just be a list no need to keep the epp object
|
||||||
if "statuses" in cleaned.keys():
|
if "statuses" in cleaned.keys():
|
||||||
cleaned["statuses"]=[status.state for status in cleaned["statuses"]]
|
cleaned["statuses"] = [status.state for status in cleaned["statuses"]]
|
||||||
# get contact info, if there are any
|
# get contact info, if there are any
|
||||||
if (
|
if (
|
||||||
# fetch_contacts and
|
# fetch_contacts and
|
||||||
|
@ -1048,8 +1056,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# just asked the registry for still exists --
|
# just asked the registry for still exists --
|
||||||
# if not, that's a problem
|
# if not, that's a problem
|
||||||
|
|
||||||
#TODO- discuss-should we check if contact is in public contacts
|
# TODO- discuss-should we check if contact is in public contacts
|
||||||
#and add it if not- this is really to keep in mine the transisiton
|
# and add it if not- this is really to keep in mine the transisiton
|
||||||
req = commands.InfoContact(id=domainContact.contact)
|
req = commands.InfoContact(id=domainContact.contact)
|
||||||
data = registry.send(req, cleaned=True).res_data[0]
|
data = registry.send(req, cleaned=True).res_data[0]
|
||||||
|
|
||||||
|
@ -1059,7 +1067,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
logger.info(data)
|
logger.info(data)
|
||||||
contact = {
|
contact = {
|
||||||
"id": id,
|
"id": id,
|
||||||
"type":domainContact.type,
|
"type": domainContact.type,
|
||||||
"auth_info": getattr(data, "auth_info", ...),
|
"auth_info": getattr(data, "auth_info", ...),
|
||||||
"cr_date": getattr(data, "cr_date", ...),
|
"cr_date": getattr(data, "cr_date", ...),
|
||||||
"disclose": getattr(data, "disclose", ...),
|
"disclose": getattr(data, "disclose", ...),
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
<input type="submit" value="add nameservers" name="_make_nameservers">
|
<input type="submit" value="add nameservers" name="_make_nameservers">
|
||||||
<input type="submit" value="get nameservers" name="_get_nameservers">
|
<input type="submit" value="get nameservers" name="_get_nameservers">
|
||||||
<input type="submit" value="get status" name="_get_status">
|
<input type="submit" value="get status" name="_get_status">
|
||||||
<input type="submit" value="add nameservers" name="_set_client_hold">
|
<input type="submit" value="Actual Client Hold Set" name="_set_client_hold">
|
||||||
<input type="submit" value="get nameservers" name="_rem_client_hold">
|
<input type="submit" value="remove Client Hold" name="_rem_client_hold">
|
||||||
<input type="submit" value="get status" name="_delete_domain">
|
<input type="submit" value="EPP Delete Domain" name="_delete_domain">
|
||||||
</div>
|
</div>
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -31,7 +31,7 @@ class MockEppLib(TestCase):
|
||||||
mockDataInfoDomain = fakedEppObject(
|
mockDataInfoDomain = fakedEppObject(
|
||||||
"fakepw",
|
"fakepw",
|
||||||
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
||||||
contacts=["123"],
|
contacts=[common.DomainContact(contact="123", type="security")],
|
||||||
hosts=["fake.host.com"],
|
hosts=["fake.host.com"],
|
||||||
)
|
)
|
||||||
infoDomainNoContact = fakedEppObject(
|
infoDomainNoContact = fakedEppObject(
|
||||||
|
@ -73,7 +73,9 @@ class MockEppLib(TestCase):
|
||||||
self.mockedSendFunction = self.mockSendPatch.start()
|
self.mockedSendFunction = self.mockSendPatch.start()
|
||||||
self.mockedSendFunction.side_effect = self.mockSend
|
self.mockedSendFunction.side_effect = self.mockSend
|
||||||
|
|
||||||
def _convertPublicContactToEpp(self, contact: PublicContact, disclose_email=False, createContact=True):
|
def _convertPublicContactToEpp(
|
||||||
|
self, contact: PublicContact, disclose_email=False, createContact=True
|
||||||
|
):
|
||||||
DF = common.DiscloseField
|
DF = common.DiscloseField
|
||||||
fields = {DF.FAX, DF.VOICE, DF.ADDR}
|
fields = {DF.FAX, DF.VOICE, DF.ADDR}
|
||||||
|
|
||||||
|
@ -120,12 +122,12 @@ class MockEppLib(TestCase):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return commands.UpdateContact(
|
return commands.UpdateContact(
|
||||||
id=contact.registry_id,
|
id=contact.registry_id,
|
||||||
postal_info=pi,
|
postal_info=pi,
|
||||||
email=contact.email,
|
email=contact.email,
|
||||||
voice=contact.voice,
|
voice=contact.voice,
|
||||||
fax=contact.fax,
|
fax=contact.fax,
|
||||||
)
|
)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.mockSendPatch.stop()
|
self.mockSendPatch.stop()
|
||||||
|
@ -174,6 +176,7 @@ class TestDomainCache(MockEppLib):
|
||||||
# send was only called once & not on the second getter call
|
# send was only called once & not on the second getter call
|
||||||
self.mockedSendFunction.assert_called_once()
|
self.mockedSendFunction.assert_called_once()
|
||||||
|
|
||||||
|
# @skip("BROKEN by newest changes-fix in getter ticket")
|
||||||
def test_cache_nested_elements(self):
|
def test_cache_nested_elements(self):
|
||||||
"""Cache works correctly with the nested objects cache and hosts"""
|
"""Cache works correctly with the nested objects cache and hosts"""
|
||||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||||
|
@ -276,8 +279,8 @@ class TestDomainCreation(TestCase):
|
||||||
self.assertIn("ok", domain.status)
|
self.assertIn("ok", domain.status)
|
||||||
|
|
||||||
def tearDown(self) -> None:
|
def tearDown(self) -> None:
|
||||||
Domain.objects.delete()
|
Domain.objects.filter(name="igorville.gov").delete()
|
||||||
# User.objects.delete()
|
Domain.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
class TestRegistrantContacts(MockEppLib):
|
class TestRegistrantContacts(MockEppLib):
|
||||||
|
@ -484,9 +487,11 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
new_contact = self.domain.get_default_security_contact()
|
new_contact = self.domain.get_default_security_contact()
|
||||||
new_contact.registry_id = "fail"
|
new_contact.registry_id = "fail"
|
||||||
new_contact.email = ""
|
new_contact.email = ""
|
||||||
self.domain.security_contact=new_contact
|
self.domain.security_contact = new_contact
|
||||||
|
|
||||||
print("old contact %s email is %s" % (str(old_contact), str(old_contact.email)))
|
print(
|
||||||
|
"old contact %s email is %s" % (str(old_contact), str(old_contact.email))
|
||||||
|
)
|
||||||
print("new contact %s " % new_contact)
|
print("new contact %s " % new_contact)
|
||||||
firstCreateContactCall = self._convertPublicContactToEpp(
|
firstCreateContactCall = self._convertPublicContactToEpp(
|
||||||
old_contact, disclose_email=True
|
old_contact, disclose_email=True
|
||||||
|
@ -497,7 +502,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
common.DomainContact(contact=old_contact.registry_id, type="security")
|
common.DomainContact(contact=old_contact.registry_id, type="security")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
print( PublicContact.objects.filter(domain=self.domain))
|
print(PublicContact.objects.filter(domain=self.domain))
|
||||||
print("just printed the objects for public contact!!")
|
print("just printed the objects for public contact!!")
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
|
@ -550,7 +555,6 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
print(expected_calls)
|
print(expected_calls)
|
||||||
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
||||||
|
|
||||||
|
|
||||||
def test_updates_security_email(self):
|
def test_updates_security_email(self):
|
||||||
"""
|
"""
|
||||||
Scenario: Registrant replaces one valid security contact email with another
|
Scenario: Registrant replaces one valid security contact email with another
|
||||||
|
@ -560,13 +564,13 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
Then Domain sends `commands.UpdateContact` to the registry
|
Then Domain sends `commands.UpdateContact` to the registry
|
||||||
"""
|
"""
|
||||||
security_contact = self.domain.get_default_security_contact()
|
security_contact = self.domain.get_default_security_contact()
|
||||||
security_contact.email="originalUserEmail@gmail.com"
|
security_contact.email = "originalUserEmail@gmail.com"
|
||||||
security_contact.registry_id = "fail"
|
security_contact.registry_id = "fail"
|
||||||
security_contact.save()
|
security_contact.save()
|
||||||
expectedCreateCommand = self._convertPublicContactToEpp(
|
expectedCreateCommand = self._convertPublicContactToEpp(
|
||||||
security_contact, disclose_email=True
|
security_contact, disclose_email=True
|
||||||
)
|
)
|
||||||
print(expectedCreateCommand)
|
|
||||||
expectedUpdateDomain = commands.UpdateDomain(
|
expectedUpdateDomain = commands.UpdateDomain(
|
||||||
name=self.domain.name,
|
name=self.domain.name,
|
||||||
add=[
|
add=[
|
||||||
|
@ -575,11 +579,16 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
security_contact.email="changedEmail@email.com"
|
security_contact.email = "changedEmail@email.com"
|
||||||
|
print("\n\n\n***********\n\n")
|
||||||
|
security_contact.save()
|
||||||
expectedSecondCreateCommand = self._convertPublicContactToEpp(
|
expectedSecondCreateCommand = self._convertPublicContactToEpp(
|
||||||
security_contact, disclose_email=True
|
security_contact, disclose_email=True
|
||||||
)
|
)
|
||||||
updateContact=self._convertPublicContactToEpp(security_contact,disclose_email=True,createContact=False)
|
updateContact = self._convertPublicContactToEpp(
|
||||||
|
security_contact, disclose_email=True, createContact=False
|
||||||
|
)
|
||||||
|
print("SECOND EXPECTED CREATE")
|
||||||
print(expectedSecondCreateCommand)
|
print(expectedSecondCreateCommand)
|
||||||
|
|
||||||
print(self.mockedSendFunction.call_args_list)
|
print(self.mockedSendFunction.call_args_list)
|
||||||
|
@ -587,13 +596,12 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
expected_calls = [
|
expected_calls = [
|
||||||
call(expectedCreateCommand, cleaned=True),
|
call(expectedCreateCommand, cleaned=True),
|
||||||
call(expectedUpdateDomain, cleaned=True),
|
call(expectedUpdateDomain, cleaned=True),
|
||||||
call(expectedSecondCreateCommand,cleaned=True),
|
call(expectedSecondCreateCommand, cleaned=True),
|
||||||
call(updateContact, cleaned=True),
|
call(updateContact, cleaned=True),
|
||||||
]
|
]
|
||||||
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
||||||
assert PublicContact.objects.filter(domain=self.domain).count() == 1
|
assert PublicContact.objects.filter(domain=self.domain).count() == 1
|
||||||
|
|
||||||
|
|
||||||
@skip("not implemented yet")
|
@skip("not implemented yet")
|
||||||
def test_update_is_unsuccessful(self):
|
def test_update_is_unsuccessful(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -135,7 +135,7 @@ class DomainNameserversView(DomainPermissionView, FormMixin):
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""The initial value for the form (which is a formset here)."""
|
"""The initial value for the form (which is a formset here)."""
|
||||||
domain = self.get_object()
|
domain = self.get_object()
|
||||||
nameservers=domain.nameservers
|
nameservers = domain.nameservers
|
||||||
if nameservers is None:
|
if nameservers is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue