mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-28 15:23:33 +02:00
fixed linting issues
This commit is contained in:
parent
71054a4c16
commit
bc0b07d8bf
6 changed files with 98 additions and 72 deletions
|
@ -50,11 +50,11 @@ request = commands.InfoContact(id='sh8013')
|
||||||
```
|
```
|
||||||
DF = common.DiscloseField
|
DF = common.DiscloseField
|
||||||
di = common.Disclose(flag=False, fields={DF.FAX, DF.VOICE, DF.ADDR}, types={DF.ADDR: "loc"})
|
di = common.Disclose(flag=False, fields={DF.FAX, DF.VOICE, DF.ADDR}, types={DF.ADDR: "loc"})
|
||||||
addr = common.ContactAddr(street=['123 Example Dr.'], city='Dulles', pc='20166-6503', cc='US', sp='VA')
|
addr = common.ContactAddr(street=['123 Example Dr.',None ,None], city='Dulles', pc='20166-6503', cc='US', sp='VA')
|
||||||
pi = common.PostalInfo(name='John Doe', addr=addr, org="Example Inc.", type="loc")
|
pi = common.PostalInfo(name='John Doe', addr=addr, org="Example Inc.", type="loc")
|
||||||
ai = common.ContactAuthInfo(pw='feedabee')
|
ai = common.ContactAuthInfo(pw='feedabee')
|
||||||
|
|
||||||
request = commands.CreateContact(id='sh8013', postal_info=pi, email='jdoe@example.com', voice='+1.7035555555', fax='+1.7035555556', auth_info=ai, disclose=di, vat=None, ident=None, notify_email=None)
|
request = commands.CreateContact(id='1234ab', postal_info=pi, email='jdoe@example.com', voice='+1.7035555555', fax='+1.7035555556', auth_info=ai, disclose=di, vat=None, ident=None, notify_email=None)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create a new domain
|
### Create a new domain
|
||||||
|
|
|
@ -175,7 +175,7 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
change_form_template = "django/admin/domain_change_form.html"
|
change_form_template = "django/admin/domain_change_form.html"
|
||||||
readonly_fields = ["state"]
|
readonly_fields = ["state"]
|
||||||
|
|
||||||
def response_change(self, request, obj):
|
def response_change(self, request, obj): # noqa
|
||||||
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"
|
||||||
|
@ -246,7 +246,7 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
else:
|
else:
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request,
|
||||||
("The security email is %" ". Thanks!") % fake_email,
|
"The security email is %s. Thanks!" % fake_email,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif MAKE_DOMAIN in request.POST:
|
elif MAKE_DOMAIN in request.POST:
|
||||||
|
|
|
@ -108,7 +108,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# the state is indeterminate
|
# the state is indeterminate
|
||||||
UNKNOWN = "unknown"
|
UNKNOWN = "unknown"
|
||||||
|
|
||||||
# The domain object exists in the registry but nameservers don't exist for it yet
|
# The domain object exists in the registry
|
||||||
|
# but nameservers don't exist for it yet
|
||||||
DNS_NEEDED = "dns needed"
|
DNS_NEEDED = "dns needed"
|
||||||
|
|
||||||
# Domain has had nameservers set, may or may not be active
|
# Domain has had nameservers set, may or may not be active
|
||||||
|
@ -229,8 +230,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
hosts = self._get_property("hosts")
|
hosts = self._get_property("hosts")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# Don't throw error as this is normal for a new domain
|
# Don't throw error as this is normal for a new domain
|
||||||
logger.info("Domain is missing nameservers")
|
logger.info("Domain is missing nameservers %s" % err)
|
||||||
return None
|
return []
|
||||||
|
|
||||||
hostList = []
|
hostList = []
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
|
@ -250,7 +251,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
return response.res_data[0].avail
|
return response.res_data[0].avail
|
||||||
except RegistryError as err:
|
except RegistryError as err:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Couldn't check hosts %. Errorcode was %s, error was %s" % (hostnames),
|
"Couldn't check hosts %s. Errorcode was %s, error was %s",
|
||||||
|
hostnames,
|
||||||
err.code,
|
err.code,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
@ -262,7 +264,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
doesn't add the created host to the domain
|
doesn't add the created host to the domain
|
||||||
returns ErrorCode (int)"""
|
returns ErrorCode (int)"""
|
||||||
logger.info("Creating host")
|
logger.info("Creating host")
|
||||||
if not addrs is None:
|
if addrs is not None:
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
|
@ -318,11 +320,13 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
try:
|
try:
|
||||||
self.ready()
|
self.ready()
|
||||||
self.save()
|
self.save()
|
||||||
except:
|
except Exception as err:
|
||||||
logger.info(
|
logger.info(
|
||||||
"nameserver setter checked for create state and it did not succeed"
|
"nameserver setter checked for create state "
|
||||||
|
"and it did not succeed. Error: %s" % err
|
||||||
)
|
)
|
||||||
##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
|
||||||
|
# then go back to DNS_NEEDED
|
||||||
|
|
||||||
@Cache
|
@Cache
|
||||||
def statuses(self) -> list[str]:
|
def statuses(self) -> list[str]:
|
||||||
|
@ -333,9 +337,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"""
|
"""
|
||||||
# implementation note: the Status object from EPP stores the string in
|
# implementation note: the Status object from EPP stores the string in
|
||||||
# a dataclass property `state`, not to be confused with the `state` field here
|
# a dataclass property `state`, not to be confused with the `state` field here
|
||||||
if not "statuses" in self._cache:
|
if "statuses" not in self._cache:
|
||||||
self._fetch_cache()
|
self._fetch_cache()
|
||||||
if not "statuses" in self._cache:
|
if "statuses" not in self._cache:
|
||||||
raise Exception("Can't retreive status from domain info")
|
raise Exception("Can't retreive status from domain info")
|
||||||
else:
|
else:
|
||||||
return self._cache["statuses"]
|
return self._cache["statuses"]
|
||||||
|
@ -354,7 +358,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
@registrant_contact.setter # type: ignore
|
@registrant_contact.setter # type: ignore
|
||||||
def registrant_contact(self, contact: PublicContact):
|
def registrant_contact(self, contact: PublicContact):
|
||||||
"""Registrant is set when a domain is created, so follow on additions will update the current registrant"""
|
"""Registrant is set when a domain is created,
|
||||||
|
so follow on additions will update the current registrant"""
|
||||||
|
|
||||||
logger.info("making registrant contact")
|
logger.info("making registrant contact")
|
||||||
self._set_singleton_contact(
|
self._set_singleton_contact(
|
||||||
|
@ -383,16 +388,19 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
def _update_epp_contact(self, contact: PublicContact):
|
def _update_epp_contact(self, contact: PublicContact):
|
||||||
"""Sends UpdateContact to update the actual contact object, domain object remains unaffected
|
"""Sends UpdateContact to update the actual contact object,
|
||||||
should be used when changing email address or other contact infor on an existing domain
|
domain object remains unaffected
|
||||||
|
should be used when changing email address
|
||||||
|
or other contact info on an existing domain
|
||||||
"""
|
"""
|
||||||
updateContact = commands.UpdateContact(
|
updateContact = commands.UpdateContact(
|
||||||
id=contact.registry_id,
|
id=contact.registry_id,
|
||||||
|
# type: ignore
|
||||||
postal_info=self._make_epp_contact_postal_info(contact=contact),
|
postal_info=self._make_epp_contact_postal_info(contact=contact),
|
||||||
email=contact.email,
|
email=contact.email,
|
||||||
voice=contact.voice,
|
voice=contact.voice,
|
||||||
fax=contact.fax,
|
fax=contact.fax,
|
||||||
)
|
) # type: ignore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
registry.send(updateContact, cleaned=True)
|
registry.send(updateContact, cleaned=True)
|
||||||
|
@ -403,9 +411,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# TODO - ticket 433 human readable error handling here
|
# TODO - ticket 433 human readable error handling here
|
||||||
|
|
||||||
def _update_domain_with_contact(self, contact: PublicContact, rem=False):
|
def _update_domain_with_contact(self, contact: PublicContact, rem=False):
|
||||||
# TODO - consider making this use both add and rem at the same time, separating it out may not be needed
|
"""adds or removes a contact from a domain"""
|
||||||
# good addition for ticket 850
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"_update_domain_with_contact() received type %s " % contact.contact_type
|
"_update_domain_with_contact() received type %s " % contact.contact_type
|
||||||
)
|
)
|
||||||
|
@ -448,10 +454,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
except Exception as err: # use better error handling
|
except Exception as err: # use better error handling
|
||||||
logger.info("Couldn't get contact")
|
logger.info("Couldn't get contact %s" % err)
|
||||||
## send public contact to the thingy
|
|
||||||
|
|
||||||
##TODO - remove this! ideally it should return None, but error handling needs to be
|
# TODO - remove this! ideally it should return None,
|
||||||
|
# but error handling needs to be
|
||||||
# added on the security email page so that it can handle it being none
|
# added on the security email page so that it can handle it being none
|
||||||
return self.get_default_security_contact()
|
return self.get_default_security_contact()
|
||||||
|
|
||||||
|
@ -470,17 +476,18 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
# TODO-error handling better here?
|
# TODO-error handling better here?
|
||||||
|
|
||||||
def _set_singleton_contact(self, contact: PublicContact, expectedType: str):
|
def _set_singleton_contact(self, contact: PublicContact, expectedType: str): # noqa
|
||||||
"""Sets the contacts by adding them to the registry as new contacts,
|
"""Sets the contacts by adding them to the registry as new contacts,
|
||||||
updates the contact if it is already in epp,
|
updates the contact if it is already in epp,
|
||||||
deletes any additional contacts of the matching type for this domain
|
deletes any additional contacts of the matching type for this domain
|
||||||
does not create the PublicContact object, this should be made beforehand
|
does not create the PublicContact object, this should be made beforehand
|
||||||
(call save() on a public contact to trigger the contact setters which call this function)
|
(call save() on a public contact to trigger the contact setters
|
||||||
|
which inturn call this function)
|
||||||
Raises ValueError if expected type doesn't match the contact type"""
|
Raises ValueError if expected type doesn't match the contact type"""
|
||||||
if expectedType != contact.contact_type:
|
if expectedType != contact.contact_type:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Cannot set a contact with a different contact type, expected type was %s"
|
"Cannot set a contact with a different contact type,"
|
||||||
% expectedType
|
" expected type was %s" % expectedType
|
||||||
)
|
)
|
||||||
|
|
||||||
isRegistrant = contact.contact_type == contact.ContactTypeChoices.REGISTRANT
|
isRegistrant = contact.contact_type == contact.ContactTypeChoices.REGISTRANT
|
||||||
|
@ -489,7 +496,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
and contact.email == ""
|
and contact.email == ""
|
||||||
)
|
)
|
||||||
|
|
||||||
# get publicContact objects that have the matching domain and type but a different id
|
# get publicContact objects that have the matching
|
||||||
|
# domain and type but a different id
|
||||||
# like in highlander we there can only be one
|
# like in highlander we there can only be one
|
||||||
hasOtherContact = (
|
hasOtherContact = (
|
||||||
PublicContact.objects.exclude(registry_id=contact.registry_id)
|
PublicContact.objects.exclude(registry_id=contact.registry_id)
|
||||||
|
@ -497,7 +505,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
.exists()
|
.exists()
|
||||||
)
|
)
|
||||||
|
|
||||||
##if no record exists with this contact type
|
# if no record exists with this contact type
|
||||||
# make contact in registry, duplicate and errors handled there
|
# make contact in registry, duplicate and errors handled there
|
||||||
errorCode = self._make_contact_in_registry(contact)
|
errorCode = self._make_contact_in_registry(contact)
|
||||||
|
|
||||||
|
@ -517,7 +525,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# if has conflicting contacts in our db remove them
|
# if has conflicting contacts in our db remove them
|
||||||
if hasOtherContact:
|
if hasOtherContact:
|
||||||
logger.info(
|
logger.info(
|
||||||
"_set_singleton_contact()-> updating domain by removing old contact and adding new one"
|
"_set_singleton_contact()-> updating domain, removing old contact"
|
||||||
)
|
)
|
||||||
if isEmptySecurity:
|
if isEmptySecurity:
|
||||||
existing_contact = PublicContact.objects.filter(
|
existing_contact = PublicContact.objects.filter(
|
||||||
|
@ -547,7 +555,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
raise (err)
|
raise (err)
|
||||||
|
|
||||||
# TODO- This could switch to just creating a list of ones to remove and a list of ones to add
|
# TODO- This could switch to just creating a
|
||||||
|
# list of ones to remove and a list of ones to add
|
||||||
# or Change it to add contacts before deleting the old ones
|
# or Change it to add contacts before deleting the old ones
|
||||||
|
|
||||||
# update domain with contact or update the contact itself
|
# update domain with contact or update the contact itself
|
||||||
|
@ -603,7 +612,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_active(self) -> bool:
|
def is_active(self) -> bool:
|
||||||
"""Currently just returns if the state is created, because then it should be live, theoretically.
|
"""Currently just returns if the state is created,
|
||||||
|
because then it should be live, theoretically.
|
||||||
Post mvp this should indicate
|
Post mvp this should indicate
|
||||||
Is the domain live on the inter webs?
|
Is the domain live on the inter webs?
|
||||||
could be replaced with request to see if ok status is set
|
could be replaced with request to see if ok status is set
|
||||||
|
@ -736,7 +746,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
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
|
||||||
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)
|
||||||
|
@ -754,7 +764,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = registry.send(req, cleaned=True)
|
registry.send(req, cleaned=True)
|
||||||
|
|
||||||
except RegistryError as err:
|
except RegistryError as err:
|
||||||
if err.code != ErrorCode.OBJECT_EXISTS:
|
if err.code != ErrorCode.OBJECT_EXISTS:
|
||||||
|
@ -777,7 +787,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
@transition(field="state", source=State.DNS_NEEDED, target=State.ON_HOLD)
|
@transition(field="state", source=State.DNS_NEEDED, target=State.ON_HOLD)
|
||||||
def clientHold(self):
|
def clientHold(self):
|
||||||
"""place a clienthold on a domain (no longer should resolve)"""
|
"""place a clienthold on a domain (no longer should resolve)"""
|
||||||
##TODO - check to see if client hold is allowed should happen outside of this function
|
# TODO - ensure all requirements for client hold are made here
|
||||||
# (check prohibited statuses)
|
# (check prohibited statuses)
|
||||||
logger.info("clientHold()-> inside clientHold")
|
logger.info("clientHold()-> inside clientHold")
|
||||||
self._place_client_hold()
|
self._place_client_hold()
|
||||||
|
@ -786,8 +796,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
@transition(field="state", source=State.ON_HOLD, target=State.DNS_NEEDED)
|
@transition(field="state", source=State.ON_HOLD, target=State.DNS_NEEDED)
|
||||||
def revertClientHold(self):
|
def revertClientHold(self):
|
||||||
"""undo a clienthold placed on a domain"""
|
"""undo a clienthold placed on a domain"""
|
||||||
##TODO - check to see if client hold is allowed should happen outside of this function
|
|
||||||
# (check prohibited statuses)
|
|
||||||
logger.info("clientHold()-> inside clientHold")
|
logger.info("clientHold()-> inside clientHold")
|
||||||
self._remove_client_hold()
|
self._remove_client_hold()
|
||||||
# TODO -on the client hold ticket any additional error handling here
|
# TODO -on the client hold ticket any additional error handling here
|
||||||
|
@ -795,6 +804,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
@transition(field="state", source=State.ON_HOLD, target=State.DELETED)
|
@transition(field="state", source=State.ON_HOLD, target=State.DELETED)
|
||||||
def deleted(self):
|
def deleted(self):
|
||||||
"""domain is deleted in epp but is saved in our database"""
|
"""domain is deleted in epp but is saved in our database"""
|
||||||
|
# TODO Domains may not be deleted if:
|
||||||
|
# a child host is being used by
|
||||||
|
# another .gov domains. The host must be first removed
|
||||||
|
# and/or renamed before the parent domain may be deleted.
|
||||||
logger.info("pendingCreate()-> inside pending create")
|
logger.info("pendingCreate()-> inside pending create")
|
||||||
self._delete_domain()
|
self._delete_domain()
|
||||||
# TODO - delete ticket any additional error handling here
|
# TODO - delete ticket any additional error handling here
|
||||||
|
@ -806,9 +819,11 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
)
|
)
|
||||||
def ready(self):
|
def ready(self):
|
||||||
"""Transition to the ready state
|
"""Transition to the ready state
|
||||||
domain should have nameservers and all contacts and now should be considered live on a domain
|
domain should have nameservers and all contacts
|
||||||
|
and now should be considered live on a domain
|
||||||
"""
|
"""
|
||||||
# TODO - in nameservers tickets 848 and 562 check here if updates need to be made
|
# TODO - in nameservers tickets 848 and 562
|
||||||
|
# check here if updates need to be made
|
||||||
nameserverList = self.nameservers
|
nameserverList = self.nameservers
|
||||||
logger.info("Changing to ready state")
|
logger.info("Changing to ready state")
|
||||||
if len(nameserverList) < 2 or len(nameserverList) > 13:
|
if len(nameserverList) < 2 or len(nameserverList) > 13:
|
||||||
|
@ -833,7 +848,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
types={DF.ADDR: "loc"},
|
types={DF.ADDR: "loc"},
|
||||||
)
|
)
|
||||||
|
|
||||||
def _make_epp_contact_postal_info(self, contact: PublicContact):
|
def _make_epp_contact_postal_info(self, contact: PublicContact): # type: ignore
|
||||||
return epp.PostalInfo( # type: ignore
|
return epp.PostalInfo( # type: ignore
|
||||||
name=contact.name,
|
name=contact.name,
|
||||||
addr=epp.ContactAddr(
|
addr=epp.ContactAddr(
|
||||||
|
@ -841,7 +856,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
getattr(contact, street)
|
getattr(contact, street)
|
||||||
for street in ["street1", "street2", "street3"]
|
for street in ["street1", "street2", "street3"]
|
||||||
if hasattr(contact, street)
|
if hasattr(contact, street)
|
||||||
],
|
], # type: ignore
|
||||||
city=contact.city,
|
city=contact.city,
|
||||||
pc=contact.pc,
|
pc=contact.pc,
|
||||||
cc=contact.cc,
|
cc=contact.cc,
|
||||||
|
@ -862,7 +877,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
voice=contact.voice,
|
voice=contact.voice,
|
||||||
fax=contact.fax,
|
fax=contact.fax,
|
||||||
auth_info=epp.ContactAuthInfo(pw="2fooBAR123fooBaz"),
|
auth_info=epp.ContactAuthInfo(pw="2fooBAR123fooBaz"),
|
||||||
)
|
) # type: ignore
|
||||||
# security contacts should only show email addresses, for now
|
# security contacts should only show email addresses, for now
|
||||||
create.disclose = self._disclose_fields(contact=contact)
|
create.disclose = self._disclose_fields(contact=contact)
|
||||||
try:
|
try:
|
||||||
|
@ -872,7 +887,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# don't throw an error if it is just saying this is a duplicate contact
|
# don't throw an error if it is just saying this is a duplicate contact
|
||||||
if err.code != ErrorCode.OBJECT_EXISTS:
|
if err.code != ErrorCode.OBJECT_EXISTS:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Registry threw error for contact id %s contact type is %s, error code is\n %s full error is %s",
|
"Registry threw error for contact id %s"
|
||||||
|
" contact type is %s,"
|
||||||
|
" error code is\n %s"
|
||||||
|
" full error is %s",
|
||||||
contact.registry_id,
|
contact.registry_id,
|
||||||
contact.contact_type,
|
contact.contact_type,
|
||||||
err.code,
|
err.code,
|
||||||
|
@ -907,7 +925,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
return self._request_contact_info(contact=contact)
|
return self._request_contact_info(contact=contact)
|
||||||
else:
|
else:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Registry threw error for contact id %s contact type is %s, error code is\n %s full error is %s",
|
"Registry threw error for contact id %s"
|
||||||
|
" contact type is %s,"
|
||||||
|
" error code is\n %s"
|
||||||
|
" full error is %s",
|
||||||
contact.registry_id,
|
contact.registry_id,
|
||||||
contact.contact_type,
|
contact.contact_type,
|
||||||
e.code,
|
e.code,
|
||||||
|
@ -994,7 +1015,8 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
and isinstance(cleaned["_hosts"], list)
|
and isinstance(cleaned["_hosts"], list)
|
||||||
and len(cleaned["_hosts"])
|
and len(cleaned["_hosts"])
|
||||||
):
|
):
|
||||||
##TODO- add elif in cache set it to be the old cache value, no point in removing
|
# TODO- add elif in cache set it to be the old cache value
|
||||||
|
# no point in removing
|
||||||
cleaned["hosts"] = []
|
cleaned["hosts"] = []
|
||||||
for name in cleaned["_hosts"]:
|
for name in cleaned["_hosts"]:
|
||||||
# we do not use _get_or_create_* because we expect the object we
|
# we do not use _get_or_create_* because we expect the object we
|
||||||
|
|
|
@ -150,4 +150,8 @@ class PublicContact(TimeStampedModel):
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name} <{self.email}> id: {self.registry_id} type: {self.contact_type}"
|
return (
|
||||||
|
f"{self.name} <{self.email}>"
|
||||||
|
"id: {self.registry_id} "
|
||||||
|
"type: {self.contact_type}"
|
||||||
|
)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="margin-top-4 tablet:grid-col-10">
|
<div class="margin-top-4 tablet:grid-col-10">
|
||||||
|
|
||||||
{% url 'domain-nameservers' pk=domain.id as url %}
|
{% url 'domain-nameservers' pk=domain.id as url %}
|
||||||
{% if domain.nameservers %}
|
{% if domain.nameservers!==[] %}
|
||||||
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' edit_link=url %}
|
{% include "includes/summary_item.html" with title='DNS name servers' value=domain.nameservers list='true' edit_link=url %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<h2 class="margin-top-neg-1"> DNS name servers </h2>
|
<h2 class="margin-top-neg-1"> DNS name servers </h2>
|
||||||
|
|
|
@ -12,7 +12,6 @@ from registrar.models import Domain # add in DomainApplication, User,
|
||||||
from unittest import skip
|
from unittest import skip
|
||||||
from epplibwrapper import commands, common, RegistryError, ErrorCode
|
from epplibwrapper import commands, common, RegistryError, ErrorCode
|
||||||
from registrar.models.domain_application import DomainApplication
|
from registrar.models.domain_application import DomainApplication
|
||||||
from registrar.models.domain_information import DomainInformation
|
|
||||||
from registrar.models.draft_domain import DraftDomain
|
from registrar.models.draft_domain import DraftDomain
|
||||||
from registrar.models.public_contact import PublicContact
|
from registrar.models.public_contact import PublicContact
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
|
@ -88,18 +87,19 @@ class MockEppLib(TestCase):
|
||||||
fields=fields,
|
fields=fields,
|
||||||
types={DF.ADDR: "loc"},
|
types={DF.ADDR: "loc"},
|
||||||
)
|
)
|
||||||
|
|
||||||
# check docs here looks like we may have more than one address field but
|
# check docs here looks like we may have more than one address field but
|
||||||
addr = common.ContactAddr(
|
addr = common.ContactAddr(
|
||||||
street=[
|
[
|
||||||
contact.street1,
|
getattr(contact, street)
|
||||||
contact.street2,
|
for street in ["street1", "street2", "street3"]
|
||||||
contact.street3,
|
if hasattr(contact, street)
|
||||||
],
|
], # type: ignore
|
||||||
city=contact.city,
|
city=contact.city,
|
||||||
pc=contact.pc,
|
pc=contact.pc,
|
||||||
cc=contact.cc,
|
cc=contact.cc,
|
||||||
sp=contact.sp,
|
sp=contact.sp,
|
||||||
)
|
) # type: ignore
|
||||||
|
|
||||||
pi = common.PostalInfo(
|
pi = common.PostalInfo(
|
||||||
name=contact.name,
|
name=contact.name,
|
||||||
|
@ -107,11 +107,12 @@ class MockEppLib(TestCase):
|
||||||
org=contact.org,
|
org=contact.org,
|
||||||
type="loc",
|
type="loc",
|
||||||
)
|
)
|
||||||
|
|
||||||
ai = common.ContactAuthInfo(pw="2fooBAR123fooBaz")
|
ai = common.ContactAuthInfo(pw="2fooBAR123fooBaz")
|
||||||
if createContact:
|
if createContact:
|
||||||
return commands.CreateContact(
|
return commands.CreateContact(
|
||||||
id=contact.registry_id,
|
id=contact.registry_id,
|
||||||
postal_info=pi,
|
postal_info=pi, # type: ignore
|
||||||
email=contact.email,
|
email=contact.email,
|
||||||
voice=contact.voice,
|
voice=contact.voice,
|
||||||
fax=contact.fax,
|
fax=contact.fax,
|
||||||
|
@ -120,7 +121,7 @@ class MockEppLib(TestCase):
|
||||||
vat=None,
|
vat=None,
|
||||||
ident=None,
|
ident=None,
|
||||||
notify_email=None,
|
notify_email=None,
|
||||||
)
|
) # type: ignore
|
||||||
else:
|
else:
|
||||||
return commands.UpdateContact(
|
return commands.UpdateContact(
|
||||||
id=contact.registry_id,
|
id=contact.registry_id,
|
||||||
|
@ -315,14 +316,14 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
|
|
||||||
self.domain.pendingCreate()
|
self.domain.pendingCreate()
|
||||||
|
|
||||||
assert self.mockedSendFunction.call_count == 8
|
self.assertEqual(self.mockedSendFunction.call_count, 8)
|
||||||
assert PublicContact.objects.filter(domain=self.domain).count() == 4
|
self.assertEqual(PublicContact.objects.filter(domain=self.domain).count(), 4)
|
||||||
assert (
|
self.assertEqual(
|
||||||
PublicContact.objects.get(
|
PublicContact.objects.get(
|
||||||
domain=self.domain,
|
domain=self.domain,
|
||||||
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
).email
|
).email,
|
||||||
== expectedSecContact.email
|
expectedSecContact.email,
|
||||||
)
|
)
|
||||||
|
|
||||||
id = PublicContact.objects.get(
|
id = PublicContact.objects.get(
|
||||||
|
@ -356,7 +357,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
created contact of type 'security'
|
created contact of type 'security'
|
||||||
"""
|
"""
|
||||||
# make a security contact that is a PublicContact
|
# make a security contact that is a PublicContact
|
||||||
self.domain.pendingCreate() ##make sure a security email already exists
|
self.domain.pendingCreate() # make sure a security email already exists
|
||||||
expectedSecContact = PublicContact.get_default_security()
|
expectedSecContact = PublicContact.get_default_security()
|
||||||
expectedSecContact.domain = self.domain
|
expectedSecContact.domain = self.domain
|
||||||
expectedSecContact.email = "newEmail@fake.com"
|
expectedSecContact.email = "newEmail@fake.com"
|
||||||
|
@ -386,7 +387,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
domain=self.domain, contact_type=PublicContact.ContactTypeChoices.SECURITY
|
domain=self.domain, contact_type=PublicContact.ContactTypeChoices.SECURITY
|
||||||
)
|
)
|
||||||
|
|
||||||
assert receivedSecurityContact == expectedSecContact
|
self.assertEqual(receivedSecurityContact, expectedSecContact)
|
||||||
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
||||||
self.mockedSendFunction.assert_any_call(expectedUpdateDomain, cleaned=True)
|
self.mockedSendFunction.assert_any_call(expectedUpdateDomain, cleaned=True)
|
||||||
|
|
||||||
|
@ -397,7 +398,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
to the registry twice with identical data
|
to the registry twice with identical data
|
||||||
Then no errors are raised in Domain
|
Then no errors are raised in Domain
|
||||||
"""
|
"""
|
||||||
# self.domain.pendingCreate() ##make sure a security email already exists
|
|
||||||
security_contact = self.domain.get_default_security_contact()
|
security_contact = self.domain.get_default_security_contact()
|
||||||
security_contact.registry_id = "fail"
|
security_contact.registry_id = "fail"
|
||||||
security_contact.save()
|
security_contact.save()
|
||||||
|
@ -422,7 +423,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
call(expectedUpdateDomain, cleaned=True),
|
call(expectedUpdateDomain, 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
|
self.assertEqual(PublicContact.objects.filter(domain=self.domain).count(), 1)
|
||||||
|
|
||||||
def test_user_deletes_security_email(self):
|
def test_user_deletes_security_email(self):
|
||||||
"""
|
"""
|
||||||
|
@ -454,9 +455,9 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
common.DomainContact(contact=old_contact.registry_id, type="security")
|
common.DomainContact(contact=old_contact.registry_id, type="security")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
assert (
|
self.assertEqual(
|
||||||
PublicContact.objects.filter(domain=self.domain).get().email
|
PublicContact.objects.filter(domain=self.domain).get().email,
|
||||||
== PublicContact.get_default_security().email
|
PublicContact.get_default_security().email,
|
||||||
)
|
)
|
||||||
# this one triggers the fail
|
# this one triggers the fail
|
||||||
secondCreateContact = self._convertPublicContactToEpp(
|
secondCreateContact = self._convertPublicContactToEpp(
|
||||||
|
@ -468,7 +469,6 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
common.DomainContact(contact=old_contact.registry_id, type="security")
|
common.DomainContact(contact=old_contact.registry_id, type="security")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
args = self.mockedSendFunction.call_args_list
|
|
||||||
|
|
||||||
defaultSecID = (
|
defaultSecID = (
|
||||||
PublicContact.objects.filter(domain=self.domain).get().registry_id
|
PublicContact.objects.filter(domain=self.domain).get().registry_id
|
||||||
|
@ -534,7 +534,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
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
|
self.assertEqual(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):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue