mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-27 21:16:28 +02:00
Test cases
This commit is contained in:
parent
89a1390ec7
commit
bb1e7bdf78
2 changed files with 48 additions and 38 deletions
|
@ -647,6 +647,25 @@ class MockEppLib(TestCase):
|
||||||
registrant="regContact",
|
registrant="regContact",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
InfoDomainWithDefaultSecurityContact = fakedEppObject(
|
||||||
|
"fakepw",
|
||||||
|
cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35),
|
||||||
|
contacts=[
|
||||||
|
common.DomainContact(
|
||||||
|
contact="defaultSec",
|
||||||
|
type=PublicContact.ContactTypeChoices.SECURITY,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
hosts=["fake.host.com"],
|
||||||
|
statuses=[
|
||||||
|
common.Status(state="serverTransferProhibited", description="", lang="en"),
|
||||||
|
common.Status(state="inactive", description="", lang="en"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
mockDefaultSecurityContact = InfoDomainWithContacts.dummyInfoContactResultData(
|
||||||
|
"defaultSec", "dotgov@cisa.dhs.gov"
|
||||||
|
)
|
||||||
mockSecurityContact = InfoDomainWithContacts.dummyInfoContactResultData(
|
mockSecurityContact = InfoDomainWithContacts.dummyInfoContactResultData(
|
||||||
"securityContact", "security@mail.gov"
|
"securityContact", "security@mail.gov"
|
||||||
)
|
)
|
||||||
|
@ -681,6 +700,8 @@ class MockEppLib(TestCase):
|
||||||
return MagicMock(res_data=[self.infoDomainNoContact])
|
return MagicMock(res_data=[self.infoDomainNoContact])
|
||||||
elif getattr(_request, "name", None) == "freeman.gov":
|
elif getattr(_request, "name", None) == "freeman.gov":
|
||||||
return MagicMock(res_data=[self.InfoDomainWithContacts])
|
return MagicMock(res_data=[self.InfoDomainWithContacts])
|
||||||
|
elif getattr(_request, "name", None) == "defaultsecurity.gov":
|
||||||
|
return MagicMock(res_data=[self.InfoDomainWithDefaultSecurityContact])
|
||||||
else:
|
else:
|
||||||
return MagicMock(res_data=[self.mockDataInfoDomain])
|
return MagicMock(res_data=[self.mockDataInfoDomain])
|
||||||
elif isinstance(_request, commands.InfoContact):
|
elif isinstance(_request, commands.InfoContact):
|
||||||
|
@ -696,6 +717,8 @@ class MockEppLib(TestCase):
|
||||||
mocked_result = self.mockAdministrativeContact
|
mocked_result = self.mockAdministrativeContact
|
||||||
case "regContact":
|
case "regContact":
|
||||||
mocked_result = self.mockRegistrantContact
|
mocked_result = self.mockRegistrantContact
|
||||||
|
case "defaultSec":
|
||||||
|
mocked_result = self.mockDefaultSecurityContact
|
||||||
case _:
|
case _:
|
||||||
# Default contact return
|
# Default contact return
|
||||||
mocked_result = self.mockDataInfoContact
|
mocked_result = self.mockDataInfoContact
|
||||||
|
|
|
@ -705,7 +705,6 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
self.mockedSendFunction.assert_has_calls(expected_calls, any_order=True)
|
||||||
self.assertEqual(PublicContact.objects.filter(domain=self.domain).count(), 1)
|
self.assertEqual(PublicContact.objects.filter(domain=self.domain).count(), 1)
|
||||||
|
|
||||||
@skip("Dependent on #850")
|
|
||||||
def test_not_disclosed_on_other_contacts(self):
|
def test_not_disclosed_on_other_contacts(self):
|
||||||
"""
|
"""
|
||||||
Scenario: Registrant creates a new domain with multiple contacts
|
Scenario: Registrant creates a new domain with multiple contacts
|
||||||
|
@ -716,19 +715,19 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
on all fields except security
|
on all fields except security
|
||||||
"""
|
"""
|
||||||
# Generates a domain with four existing contacts
|
# Generates a domain with four existing contacts
|
||||||
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
domain, _ = Domain.objects.get_or_create(name="freeman.gov")
|
||||||
# Adds default emails to all fields
|
|
||||||
domain.addAllDefaults()
|
|
||||||
# Security contact should be disclosed
|
|
||||||
domain.security_contact.email = "test123@mail.gov"
|
|
||||||
# TODO - uncomment below when #850 is merged
|
|
||||||
domain.registrant_contact = domain.get_default_registrant_contact()
|
|
||||||
|
|
||||||
expected_admin = domain.get_default_administrative_contact()
|
expected_admin = domain.get_default_administrative_contact()
|
||||||
expected_registrant = domain.get_default_registrant_contact()
|
expected_registrant = domain.get_default_registrant_contact()
|
||||||
expected_security = domain.get_default_security_contact()
|
expected_security = domain.get_default_security_contact()
|
||||||
|
expected_security.email = "security@mail.gov"
|
||||||
expected_tech = domain.get_default_technical_contact()
|
expected_tech = domain.get_default_technical_contact()
|
||||||
|
|
||||||
|
domain.administrative_contact = expected_admin
|
||||||
|
domain.registrant_contact = expected_registrant
|
||||||
|
domain.security_contact = expected_security
|
||||||
|
domain.technical_contact = expected_tech
|
||||||
|
|
||||||
contacts = [
|
contacts = [
|
||||||
expected_admin,
|
expected_admin,
|
||||||
expected_registrant,
|
expected_registrant,
|
||||||
|
@ -737,19 +736,14 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
]
|
]
|
||||||
|
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
id = PublicContact.objects.get(
|
is_security = contact.contact_type == "security"
|
||||||
domain=self.domain,
|
|
||||||
contact_type=contact.contact_type_choice,
|
|
||||||
).registry_id
|
|
||||||
contact.registry_id = id
|
|
||||||
|
|
||||||
expectedCreateCommand = self._convertPublicContactToEpp(
|
expectedCreateCommand = self._convertPublicContactToEpp(
|
||||||
contact, disclose_email=False
|
contact,
|
||||||
|
disclose_email=is_security
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
||||||
|
|
||||||
@skip("Dependent on #850")
|
|
||||||
def test_not_disclosed_on_default_security_contact(self):
|
def test_not_disclosed_on_default_security_contact(self):
|
||||||
"""
|
"""
|
||||||
Scenario: Registrant creates a new domain with no security email
|
Scenario: Registrant creates a new domain with no security email
|
||||||
|
@ -757,25 +751,21 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
Then Domain sends `commands.CreateContact` to the registry
|
Then Domain sends `commands.CreateContact` to the registry
|
||||||
And the field `disclose` is set to false for DF.EMAIL
|
And the field `disclose` is set to false for DF.EMAIL
|
||||||
"""
|
"""
|
||||||
|
self.maxDiff = None
|
||||||
|
domain, _ = Domain.objects.get_or_create(name="defaultsecurity.gov")
|
||||||
expectedSecContact = PublicContact.get_default_security()
|
expectedSecContact = PublicContact.get_default_security()
|
||||||
expectedSecContact.domain = self.domain
|
expectedSecContact.domain = domain
|
||||||
self.domain.security_contact.email = "test123@mail.gov"
|
expectedSecContact.registry_id="defaultSec"
|
||||||
|
domain.security_contact = expectedSecContact
|
||||||
|
|
||||||
id = PublicContact.objects.get(
|
|
||||||
domain=self.domain,
|
|
||||||
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
|
||||||
).registry_id
|
|
||||||
|
|
||||||
expectedSecContact.registry_id = id
|
|
||||||
expectedCreateCommand = self._convertPublicContactToEpp(
|
expectedCreateCommand = self._convertPublicContactToEpp(
|
||||||
expectedSecContact, disclose_email=True
|
expectedSecContact, disclose_email=False
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
||||||
# Confirm that we are getting a default object
|
# Confirm that we are getting a default email
|
||||||
self.assertEqual(self.domain.security_contact, expectedSecContact)
|
self.assertEqual(domain.security_contact.email, expectedSecContact.email)
|
||||||
|
|
||||||
@skip("Dependent on #850")
|
|
||||||
def test_is_disclosed_on_security_contact(self):
|
def test_is_disclosed_on_security_contact(self):
|
||||||
"""
|
"""
|
||||||
Scenario: Registrant creates a new domain with a security email
|
Scenario: Registrant creates a new domain with a security email
|
||||||
|
@ -784,22 +774,19 @@ class TestRegistrantContacts(MockEppLib):
|
||||||
Then Domain sends `commands.CreateContact` to the registry
|
Then Domain sends `commands.CreateContact` to the registry
|
||||||
And the field `disclose` is set to true for DF.EMAIL
|
And the field `disclose` is set to true for DF.EMAIL
|
||||||
"""
|
"""
|
||||||
|
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||||
expectedSecContact = PublicContact.get_default_security()
|
expectedSecContact = PublicContact.get_default_security()
|
||||||
expectedSecContact.domain = self.domain
|
expectedSecContact.domain = domain
|
||||||
|
expectedSecContact.email = "123@mail.gov"
|
||||||
|
domain.security_contact = expectedSecContact
|
||||||
|
|
||||||
id = PublicContact.objects.get(
|
|
||||||
domain=self.domain,
|
|
||||||
contact_type=PublicContact.ContactTypeChoices.SECURITY,
|
|
||||||
).registry_id
|
|
||||||
|
|
||||||
expectedSecContact.registry_id = id
|
|
||||||
expectedCreateCommand = self._convertPublicContactToEpp(
|
expectedCreateCommand = self._convertPublicContactToEpp(
|
||||||
expectedSecContact, disclose_email=False
|
expectedSecContact, disclose_email=True
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True)
|
||||||
# Confirm that we are getting a default object
|
# Confirm that we are getting the desired email
|
||||||
self.assertEqual(self.domain.security_contact, expectedSecContact)
|
self.assertEqual(domain.security_contact.email, expectedSecContact.email)
|
||||||
|
|
||||||
@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