mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 01:27:03 +02:00
Running black / linter
This commit is contained in:
parent
fa8887d7b8
commit
df1d61b965
6 changed files with 85 additions and 53 deletions
|
@ -11,6 +11,7 @@ applications:
|
||||||
command: ./run.sh
|
command: ./run.sh
|
||||||
health-check-type: http
|
health-check-type: http
|
||||||
health-check-http-endpoint: /health
|
health-check-http-endpoint: /health
|
||||||
|
health-check-invocation-timeout: 30
|
||||||
env:
|
env:
|
||||||
# Send stdout and stderr straight to the terminal without buffering
|
# Send stdout and stderr straight to the terminal without buffering
|
||||||
PYTHONUNBUFFERED: yup
|
PYTHONUNBUFFERED: yup
|
||||||
|
|
|
@ -514,7 +514,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
.filter(domain=self, contact_type=contact.contact_type)
|
.filter(domain=self, contact_type=contact.contact_type)
|
||||||
.get()
|
.get()
|
||||||
)
|
)
|
||||||
logger.info(f"_set_singleton_contact() -> existing contact is... {existing_contact.__dict__}")
|
logger.info(
|
||||||
|
f"_set_singleton_contact() -> existing contact is... {existing_contact.__dict__}"
|
||||||
|
)
|
||||||
if isRegistrant:
|
if isRegistrant:
|
||||||
# send update domain only for registant contacts
|
# send update domain only for registant contacts
|
||||||
existing_contact.delete()
|
existing_contact.delete()
|
||||||
|
@ -664,7 +666,11 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# I'm sure though that there is an easier alternative...
|
# I'm sure though that there is an easier alternative...
|
||||||
# TLDR: This doesn't look as pretty, but it makes using this function easier
|
# TLDR: This doesn't look as pretty, but it makes using this function easier
|
||||||
def map_epp_contact_to_public_contact(
|
def map_epp_contact_to_public_contact(
|
||||||
self, contact: eppInfo.InfoContactResultData, contact_id, contact_type, create_object=True
|
self,
|
||||||
|
contact: eppInfo.InfoContactResultData,
|
||||||
|
contact_id,
|
||||||
|
contact_type,
|
||||||
|
create_object=True,
|
||||||
):
|
):
|
||||||
"""Maps the Epp contact representation to a PublicContact object.
|
"""Maps the Epp contact representation to a PublicContact object.
|
||||||
|
|
||||||
|
@ -685,7 +691,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
if contact_id is None:
|
if contact_id is None:
|
||||||
raise ValueError("contact_id is None")
|
raise ValueError("contact_id is None")
|
||||||
|
|
||||||
if len(contact_id) > 16 or len(contact_id) < 1:
|
if len(contact_id) > 16 or len(contact_id) < 1:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"contact_id is of invalid length. "
|
"contact_id is of invalid length. "
|
||||||
|
@ -728,18 +734,21 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
sp=addr.sp,
|
sp=addr.sp,
|
||||||
**streets,
|
**streets,
|
||||||
)
|
)
|
||||||
db_contact = PublicContact.objects.filter(registry_id=contact_id, contact_type=contact_type, domain=self)
|
db_contact = PublicContact.objects.filter(
|
||||||
|
registry_id=contact_id, contact_type=contact_type, domain=self
|
||||||
|
)
|
||||||
# Saves to DB
|
# Saves to DB
|
||||||
if(create_object and db_contact.count() == 0):
|
if create_object and db_contact.count() == 0:
|
||||||
|
# Doesn't run custom save logic, just saves to DB
|
||||||
desired_contact.save(skip_epp_save=True)
|
desired_contact.save(skip_epp_save=True)
|
||||||
logger.debug(f"Created a new PublicContact: {desired_contact}")
|
logger.debug(f"Created a new PublicContact: {desired_contact}")
|
||||||
return desired_contact
|
return desired_contact
|
||||||
|
|
||||||
if(db_contact.count() == 1):
|
if db_contact.count() == 1:
|
||||||
return db_contact.get()
|
return db_contact.get()
|
||||||
|
|
||||||
return desired_contact
|
return desired_contact
|
||||||
|
|
||||||
def _request_contact_info(self, contact: PublicContact):
|
def _request_contact_info(self, contact: PublicContact):
|
||||||
try:
|
try:
|
||||||
req = commands.InfoContact(id=contact.registry_id)
|
req = commands.InfoContact(id=contact.registry_id)
|
||||||
|
@ -751,7 +760,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
contact.contact_type,
|
contact.contact_type,
|
||||||
error.code,
|
error.code,
|
||||||
error,
|
error,
|
||||||
) # noqa
|
) # noqa
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
def get_contact_default(
|
def get_contact_default(
|
||||||
|
@ -844,13 +853,13 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
For example, check_type = 'security'
|
For example, check_type = 'security'
|
||||||
"""
|
"""
|
||||||
# Registrant doesn't exist as an array
|
# Registrant doesn't exist as an array
|
||||||
if(check_type == PublicContact.ContactTypeChoices.REGISTRANT):
|
if check_type == PublicContact.ContactTypeChoices.REGISTRANT:
|
||||||
if (
|
if (
|
||||||
isinstance(contacts, PublicContact)
|
isinstance(contacts, PublicContact)
|
||||||
and contacts.contact_type is not None
|
and contacts.contact_type is not None
|
||||||
and contacts.contact_type == check_type
|
and contacts.contact_type == check_type
|
||||||
):
|
):
|
||||||
if(contacts.registry_id is None):
|
if contacts.registry_id is None:
|
||||||
raise ValueError("registry_id cannot be None")
|
raise ValueError("registry_id cannot be None")
|
||||||
return contacts
|
return contacts
|
||||||
else:
|
else:
|
||||||
|
@ -863,7 +872,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
and contact.contact_type is not None
|
and contact.contact_type is not None
|
||||||
and contact.contact_type == check_type
|
and contact.contact_type == check_type
|
||||||
):
|
):
|
||||||
if(contact.registry_id is None):
|
if contact.registry_id is None:
|
||||||
raise ValueError("registry_id cannot be None")
|
raise ValueError("registry_id cannot be None")
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
|
@ -1162,7 +1171,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
if "registrant" in cleaned.keys():
|
if "registrant" in cleaned.keys():
|
||||||
# Registrant, if it exists, should always exist in EppLib.
|
# Registrant, if it exists, should always exist in EppLib.
|
||||||
# If it doesn't, that is bad. We expect this to exist
|
# If it doesn't, that is bad. We expect this to exist
|
||||||
cleaned["registrant"] = self._registrant_to_public_contact(cleaned["registrant"])
|
cleaned["registrant"] = self._registrant_to_public_contact(
|
||||||
|
cleaned["registrant"]
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
# fetch_contacts and
|
# fetch_contacts and
|
||||||
|
@ -1213,7 +1224,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
"tr_date": getattr(data, "tr_date", ...),
|
"tr_date": getattr(data, "tr_date", ...),
|
||||||
"up_date": getattr(data, "up_date", ...),
|
"up_date": getattr(data, "up_date", ...),
|
||||||
}
|
}
|
||||||
cleaned["hosts"].append({k: v for k, v in host.items() if v is not ...})
|
cleaned["hosts"].append(
|
||||||
|
{k: v for k, v in host.items() if v is not ...}
|
||||||
|
)
|
||||||
# replace the prior cache with new data
|
# replace the prior cache with new data
|
||||||
self._cache = cleaned
|
self._cache = cleaned
|
||||||
|
|
||||||
|
@ -1221,10 +1234,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
def _registrant_to_public_contact(self, registry_id: str):
|
def _registrant_to_public_contact(self, registry_id: str):
|
||||||
""" EPPLib returns the registrant as a string,
|
"""EPPLib returns the registrant as a string,
|
||||||
which is the registrants associated registry_id. This function is used to
|
which is the registrants associated registry_id. This function is used to
|
||||||
convert that id to a useable object by calling commands.InfoContact
|
convert that id to a useable object by calling commands.InfoContact
|
||||||
on that ID, then mapping that object to type PublicContact. """
|
on that ID, then mapping that object to type PublicContact."""
|
||||||
contact = PublicContact(
|
contact = PublicContact(
|
||||||
registry_id=registry_id,
|
registry_id=registry_id,
|
||||||
contact_type=PublicContact.ContactTypeChoices.REGISTRANT,
|
contact_type=PublicContact.ContactTypeChoices.REGISTRANT,
|
||||||
|
@ -1243,7 +1256,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
|
|
||||||
def _get_property(self, property):
|
def _get_property(self, property):
|
||||||
"""Get some piece of info about a domain."""
|
"""Get some piece of info about a domain."""
|
||||||
logger.info(f"_get_property() -> prop is... {property} prop in cache... {property not in self._cache} cache is {self._cache}")
|
logger.info(
|
||||||
|
f"_get_property() -> prop is... {property} prop in cache... {property not in self._cache} cache is {self._cache}"
|
||||||
|
)
|
||||||
if property not in self._cache:
|
if property not in self._cache:
|
||||||
self._fetch_cache(
|
self._fetch_cache(
|
||||||
fetch_hosts=(property == "hosts"),
|
fetch_hosts=(property == "hosts"),
|
||||||
|
|
|
@ -29,7 +29,7 @@ class PublicContact(TimeStampedModel):
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
"""Save to the registry and also locally in the registrar database."""
|
"""Save to the registry and also locally in the registrar database."""
|
||||||
skip_epp_save = kwargs.pop('skip_epp_save', False)
|
skip_epp_save = kwargs.pop("skip_epp_save", False)
|
||||||
if hasattr(self, "domain") and not skip_epp_save:
|
if hasattr(self, "domain") and not skip_epp_save:
|
||||||
match self.contact_type:
|
match self.contact_type:
|
||||||
case PublicContact.ContactTypeChoices.REGISTRANT:
|
case PublicContact.ContactTypeChoices.REGISTRANT:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="usa-button"
|
class="usa-button"
|
||||||
>{% if domain.security_email is None or domain.security_email.email == 'testdotgov@cisa.dhs.gov'%}Add security email{% else %}Save{% endif %}</button>
|
>{% if domain.security_contact is None or domain.security_contact.email == 'dotgov@cisa.dhs.gov'%}Add security email{% else %}Save{% endif %}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %} {# domain_content #}
|
{% endblock %} {# domain_content #}
|
||||||
|
|
|
@ -549,14 +549,13 @@ class MockEppLib(TestCase):
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
||||||
self,
|
self,
|
||||||
auth_info=...,
|
auth_info=...,
|
||||||
cr_date=...,
|
cr_date=...,
|
||||||
contacts=...,
|
contacts=...,
|
||||||
hosts=...,
|
hosts=...,
|
||||||
statuses=...,
|
statuses=...,
|
||||||
registrant=...
|
registrant=...,
|
||||||
):
|
):
|
||||||
self.auth_info = auth_info
|
self.auth_info = auth_info
|
||||||
self.cr_date = cr_date
|
self.cr_date = cr_date
|
||||||
|
@ -619,7 +618,11 @@ class MockEppLib(TestCase):
|
||||||
mockDataInfoDomain = fakedEppObject(
|
mockDataInfoDomain = fakedEppObject(
|
||||||
"lastPw",
|
"lastPw",
|
||||||
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
||||||
contacts=[common.DomainContact(contact="123", type=PublicContact.ContactTypeChoices.SECURITY)],
|
contacts=[
|
||||||
|
common.DomainContact(
|
||||||
|
contact="123", type=PublicContact.ContactTypeChoices.SECURITY
|
||||||
|
)
|
||||||
|
],
|
||||||
hosts=["fake.host.com"],
|
hosts=["fake.host.com"],
|
||||||
statuses=[
|
statuses=[
|
||||||
common.Status(state="serverTransferProhibited", description="", lang="en"),
|
common.Status(state="serverTransferProhibited", description="", lang="en"),
|
||||||
|
@ -630,9 +633,18 @@ class MockEppLib(TestCase):
|
||||||
"fakepw",
|
"fakepw",
|
||||||
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
||||||
contacts=[
|
contacts=[
|
||||||
common.DomainContact(contact="securityContact", type=PublicContact.ContactTypeChoices.SECURITY),
|
common.DomainContact(
|
||||||
common.DomainContact(contact="technicalContact", type=PublicContact.ContactTypeChoices.TECHNICAL),
|
contact="securityContact",
|
||||||
common.DomainContact(contact="adminContact", type=PublicContact.ContactTypeChoices.ADMINISTRATIVE),
|
type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
|
),
|
||||||
|
common.DomainContact(
|
||||||
|
contact="technicalContact",
|
||||||
|
type=PublicContact.ContactTypeChoices.TECHNICAL,
|
||||||
|
),
|
||||||
|
common.DomainContact(
|
||||||
|
contact="adminContact",
|
||||||
|
type=PublicContact.ContactTypeChoices.ADMINISTRATIVE,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
hosts=["fake.host.com"],
|
hosts=["fake.host.com"],
|
||||||
statuses=[
|
statuses=[
|
||||||
|
|
|
@ -22,6 +22,7 @@ from epplibwrapper import (
|
||||||
common,
|
common,
|
||||||
)
|
)
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,10 +31,10 @@ class TestDomainCache(MockEppLib):
|
||||||
PublicContact.objects.all().delete()
|
PublicContact.objects.all().delete()
|
||||||
Domain.objects.all().delete()
|
Domain.objects.all().delete()
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
def test_cache_sets_resets(self):
|
def test_cache_sets_resets(self):
|
||||||
"""Cache should be set on getter and reset on setter calls"""
|
"""Cache should be set on getter and reset on setter calls"""
|
||||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||||
self.maxDiff = None
|
|
||||||
# trigger getter
|
# trigger getter
|
||||||
_ = domain.creation_date
|
_ = domain.creation_date
|
||||||
domain._get_property("contacts")
|
domain._get_property("contacts")
|
||||||
|
@ -51,9 +52,12 @@ class TestDomainCache(MockEppLib):
|
||||||
# send should have been called only once
|
# send should have been called only once
|
||||||
self.mockedSendFunction.assert_has_calls(
|
self.mockedSendFunction.assert_has_calls(
|
||||||
[
|
[
|
||||||
call(commands.InfoDomain(name='igorville.gov', auth_info=None), cleaned=True),
|
call(
|
||||||
call(commands.InfoContact(id='123', auth_info=None), cleaned=True),
|
commands.InfoDomain(name="igorville.gov", auth_info=None),
|
||||||
call(commands.InfoHost(name='fake.host.com'), cleaned=True)
|
cleaned=True,
|
||||||
|
),
|
||||||
|
call(commands.InfoContact(id="123", auth_info=None), cleaned=True),
|
||||||
|
call(commands.InfoHost(name="fake.host.com"), cleaned=True),
|
||||||
],
|
],
|
||||||
any_order=False, # Ensure calls are in the specified order
|
any_order=False, # Ensure calls are in the specified order
|
||||||
)
|
)
|
||||||
|
@ -69,7 +73,7 @@ class TestDomainCache(MockEppLib):
|
||||||
# value should still be set correctly
|
# value should still be set correctly
|
||||||
self.assertEqual(cr_date, self.mockDataInfoDomain.cr_date)
|
self.assertEqual(cr_date, self.mockDataInfoDomain.cr_date)
|
||||||
self.assertEqual(domain._cache["cr_date"], self.mockDataInfoDomain.cr_date)
|
self.assertEqual(domain._cache["cr_date"], self.mockDataInfoDomain.cr_date)
|
||||||
|
|
||||||
# send was only called once & not on the second getter call
|
# send was only called once & not on the second getter call
|
||||||
expectedCalls = [
|
expectedCalls = [
|
||||||
call(
|
call(
|
||||||
|
@ -90,9 +94,7 @@ class TestDomainCache(MockEppLib):
|
||||||
expectedUnfurledContactsList = [
|
expectedUnfurledContactsList = [
|
||||||
common.DomainContact(contact="123", type="security"),
|
common.DomainContact(contact="123", type="security"),
|
||||||
]
|
]
|
||||||
expectedContactsList = [
|
expectedContactsList = [domain.security_contact]
|
||||||
domain.security_contact
|
|
||||||
]
|
|
||||||
expectedHostsDict = {
|
expectedHostsDict = {
|
||||||
"name": self.mockDataInfoDomain.hosts[0],
|
"name": self.mockDataInfoDomain.hosts[0],
|
||||||
"cr_date": self.mockDataInfoDomain.cr_date,
|
"cr_date": self.mockDataInfoDomain.cr_date,
|
||||||
|
@ -111,10 +113,7 @@ class TestDomainCache(MockEppLib):
|
||||||
# as _fetch_cache will transform the type to PublicContact
|
# as _fetch_cache will transform the type to PublicContact
|
||||||
self.assertNotEqual(domain._cache["contacts"], expectedUnfurledContactsList)
|
self.assertNotEqual(domain._cache["contacts"], expectedUnfurledContactsList)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(domain._cache["contacts"], expectedContactsList)
|
||||||
domain._cache["contacts"],
|
|
||||||
expectedContactsList
|
|
||||||
)
|
|
||||||
|
|
||||||
# get and check hosts is set correctly
|
# get and check hosts is set correctly
|
||||||
domain._get_property("hosts")
|
domain._get_property("hosts")
|
||||||
|
@ -126,10 +125,11 @@ class TestDomainCache(MockEppLib):
|
||||||
mapped = domain.map_epp_contact_to_public_contact(
|
mapped = domain.map_epp_contact_to_public_contact(
|
||||||
self.mockDataInfoContact,
|
self.mockDataInfoContact,
|
||||||
self.mockDataInfoContact.id,
|
self.mockDataInfoContact.id,
|
||||||
PublicContact.ContactTypeChoices.SECURITY
|
PublicContact.ContactTypeChoices.SECURITY,
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_contact = PublicContact(
|
expected_contact = PublicContact(
|
||||||
id=1,
|
id=4,
|
||||||
domain=domain,
|
domain=domain,
|
||||||
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
registry_id="123",
|
registry_id="123",
|
||||||
|
@ -143,7 +143,7 @@ class TestDomainCache(MockEppLib):
|
||||||
pc="22201",
|
pc="22201",
|
||||||
cc="US",
|
cc="US",
|
||||||
sp="VA",
|
sp="VA",
|
||||||
street1="4200 Wilson Blvd."
|
street1="4200 Wilson Blvd.",
|
||||||
)
|
)
|
||||||
# Match when these both were updated/created
|
# Match when these both were updated/created
|
||||||
expected_contact.updated_at = mapped.updated_at
|
expected_contact.updated_at = mapped.updated_at
|
||||||
|
@ -153,7 +153,7 @@ class TestDomainCache(MockEppLib):
|
||||||
|
|
||||||
in_db = PublicContact.objects.filter(
|
in_db = PublicContact.objects.filter(
|
||||||
registry_id=domain.security_contact.registry_id,
|
registry_id=domain.security_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.SECURITY
|
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
).get()
|
).get()
|
||||||
# DB Object is the same as the mapped object
|
# DB Object is the same as the mapped object
|
||||||
self.assertEqual(mapped, in_db)
|
self.assertEqual(mapped, in_db)
|
||||||
|
@ -161,12 +161,12 @@ class TestDomainCache(MockEppLib):
|
||||||
mapped_second = domain.map_epp_contact_to_public_contact(
|
mapped_second = domain.map_epp_contact_to_public_contact(
|
||||||
self.mockDataInfoContact,
|
self.mockDataInfoContact,
|
||||||
self.mockDataInfoContact.id,
|
self.mockDataInfoContact.id,
|
||||||
PublicContact.ContactTypeChoices.SECURITY
|
PublicContact.ContactTypeChoices.SECURITY,
|
||||||
)
|
)
|
||||||
|
|
||||||
in_db_once = PublicContact.objects.filter(
|
in_db_once = PublicContact.objects.filter(
|
||||||
registry_id=domain.security_contact.registry_id,
|
registry_id=domain.security_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.SECURITY
|
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
)
|
)
|
||||||
self.assertEqual(mapped_second, in_db)
|
self.assertEqual(mapped_second, in_db)
|
||||||
# If mapper is called a second time,
|
# If mapper is called a second time,
|
||||||
|
@ -275,7 +275,9 @@ class TestDomainStatuses(MockEppLib):
|
||||||
_ = domain.statuses
|
_ = domain.statuses
|
||||||
status_list = [status.state for status in self.mockDataInfoDomain.statuses]
|
status_list = [status.state for status in self.mockDataInfoDomain.statuses]
|
||||||
self.assertEquals(domain._cache["statuses"], status_list)
|
self.assertEquals(domain._cache["statuses"], status_list)
|
||||||
expectedCreateContact = self._convertPublicContactToEpp(domain.security_contact, True, createContact=True)
|
expectedCreateContact = self._convertPublicContactToEpp(
|
||||||
|
domain.security_contact, True, createContact=True
|
||||||
|
)
|
||||||
# Called in _fetch_cache
|
# Called in _fetch_cache
|
||||||
self.mockedSendFunction.assert_has_calls(
|
self.mockedSendFunction.assert_has_calls(
|
||||||
[
|
[
|
||||||
|
@ -328,7 +330,7 @@ class TestDomainStatuses(MockEppLib):
|
||||||
|
|
||||||
class TestRegistrantContacts(MockEppLib):
|
class TestRegistrantContacts(MockEppLib):
|
||||||
"""Rule: Registrants may modify their WHOIS data"""
|
"""Rule: Registrants may modify their WHOIS data"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Background:
|
Background:
|
||||||
|
@ -552,7 +554,6 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
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()
|
|
||||||
self.domain.security_contact = security_contact
|
self.domain.security_contact = security_contact
|
||||||
|
|
||||||
expectedCreateCommand = self._convertPublicContactToEpp(
|
expectedCreateCommand = self._convertPublicContactToEpp(
|
||||||
|
@ -575,7 +576,6 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
updateContact = self._convertPublicContactToEpp(
|
updateContact = self._convertPublicContactToEpp(
|
||||||
security_contact, disclose_email=True, createContact=False
|
security_contact, disclose_email=True, createContact=False
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_calls = [
|
expected_calls = [
|
||||||
call(expectedCreateCommand, cleaned=True),
|
call(expectedCreateCommand, cleaned=True),
|
||||||
call(expectedUpdateDomain, cleaned=True),
|
call(expectedUpdateDomain, cleaned=True),
|
||||||
|
@ -616,11 +616,13 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
# Create prexisting object...
|
# Create prexisting object...
|
||||||
expected_security_contact = PublicContact.objects.filter(
|
expected_security_contact = PublicContact.objects.filter(
|
||||||
registry_id=self.domain_contact.security_contact.registry_id,
|
registry_id=self.domain_contact.security_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.SECURITY
|
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
).get()
|
).get()
|
||||||
|
|
||||||
# Checks if we grab the correct PublicContact...
|
# Checks if we grab the correct PublicContact...
|
||||||
self.assertEqual(self.domain_contact.security_contact, expected_security_contact)
|
self.assertEqual(
|
||||||
|
self.domain_contact.security_contact, expected_security_contact
|
||||||
|
)
|
||||||
self.mockedSendFunction.assert_has_calls(
|
self.mockedSendFunction.assert_has_calls(
|
||||||
[
|
[
|
||||||
call(
|
call(
|
||||||
|
@ -630,12 +632,14 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
# Checks if we are recieving the cache we expect...
|
# Checks if we are recieving the cache we expect...
|
||||||
self.assertEqual(self.domain_contact._cache["contacts"][0], expected_security_contact)
|
self.assertEqual(
|
||||||
|
self.domain_contact._cache["contacts"][0], expected_security_contact
|
||||||
|
)
|
||||||
|
|
||||||
def test_contact_getter_technical(self):
|
def test_contact_getter_technical(self):
|
||||||
expected_contact = PublicContact.objects.filter(
|
expected_contact = PublicContact.objects.filter(
|
||||||
registry_id=self.domain_contact.technical_contact.registry_id,
|
registry_id=self.domain_contact.technical_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.TECHNICAL
|
contact_type=PublicContact.ContactTypeChoices.TECHNICAL,
|
||||||
).get()
|
).get()
|
||||||
|
|
||||||
# Checks if we grab the correct PublicContact...
|
# Checks if we grab the correct PublicContact...
|
||||||
|
@ -654,7 +658,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
def test_contact_getter_administrative(self):
|
def test_contact_getter_administrative(self):
|
||||||
expected_contact = PublicContact.objects.filter(
|
expected_contact = PublicContact.objects.filter(
|
||||||
registry_id=self.domain_contact.administrative_contact.registry_id,
|
registry_id=self.domain_contact.administrative_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.ADMINISTRATIVE
|
contact_type=PublicContact.ContactTypeChoices.ADMINISTRATIVE,
|
||||||
).get()
|
).get()
|
||||||
|
|
||||||
# Checks if we grab the correct PublicContact...
|
# Checks if we grab the correct PublicContact...
|
||||||
|
@ -673,7 +677,7 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
def test_contact_getter_registrant(self):
|
def test_contact_getter_registrant(self):
|
||||||
expected_contact = PublicContact.objects.filter(
|
expected_contact = PublicContact.objects.filter(
|
||||||
registry_id=self.domain_contact.registrant_contact.registry_id,
|
registry_id=self.domain_contact.registrant_contact.registry_id,
|
||||||
contact_type = PublicContact.ContactTypeChoices.REGISTRANT
|
contact_type=PublicContact.ContactTypeChoices.REGISTRANT,
|
||||||
).get()
|
).get()
|
||||||
|
|
||||||
# Checks if we grab the correct PublicContact...
|
# Checks if we grab the correct PublicContact...
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue