diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index 1257abe29..20c08b9f4 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -663,6 +663,25 @@ class MockEppLib(TestCase): ], ) + InfoDomainWithDefaultTechnicalContact = fakedEppObject( + "fakepw", + cr_date=datetime.datetime(2023, 5, 25, 19, 45, 35), + contacts=[ + common.DomainContact( + contact="defaultTech", + type=PublicContact.ContactTypeChoices.TECHNICAL, + ) + ], + hosts=["fake.host.com"], + statuses=[ + common.Status(state="serverTransferProhibited", description="", lang="en"), + common.Status(state="inactive", description="", lang="en"), + ], + ) + + mockDefaultTechnicalContact = InfoDomainWithContacts.dummyInfoContactResultData( + "defaultTech", "dotgov@cisa.dhs.gov" + ) mockDefaultSecurityContact = InfoDomainWithContacts.dummyInfoContactResultData( "defaultSec", "dotgov@cisa.dhs.gov" ) @@ -702,6 +721,8 @@ class MockEppLib(TestCase): return MagicMock(res_data=[self.InfoDomainWithContacts]) elif getattr(_request, "name", None) == "defaultsecurity.gov": return MagicMock(res_data=[self.InfoDomainWithDefaultSecurityContact]) + elif getattr(_request, "name", None) == "defaulttechnical.gov": + return MagicMock(res_data=[self.InfoDomainWithDefaultTechnicalContact]) else: return MagicMock(res_data=[self.mockDataInfoDomain]) elif isinstance(_request, commands.InfoContact): @@ -719,6 +740,8 @@ class MockEppLib(TestCase): mocked_result = self.mockRegistrantContact case "defaultSec": mocked_result = self.mockDefaultSecurityContact + case "defaultTech": + mocked_result = self.mockDefaultTechnicalContact case _: # Default contact return mocked_result = self.mockDataInfoContact diff --git a/src/registrar/tests/test_models_domain.py b/src/registrar/tests/test_models_domain.py index 666d93c93..296389808 100644 --- a/src/registrar/tests/test_models_domain.py +++ b/src/registrar/tests/test_models_domain.py @@ -750,7 +750,6 @@ class TestRegistrantContacts(MockEppLib): Then Domain sends `commands.CreateContact` to the registry 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.domain = domain @@ -765,6 +764,27 @@ class TestRegistrantContacts(MockEppLib): # Confirm that we are getting a default email self.assertEqual(domain.security_contact.email, expectedSecContact.email) + def test_not_disclosed_on_default_technical_contact(self): + """ + Scenario: Registrant creates a new domain with no technical contact + When `domain.technical_contact.email` is equal to the default + Then Domain sends `commands.CreateContact` to the registry + And the field `disclose` is set to false for DF.EMAIL + """ + domain, _ = Domain.objects.get_or_create(name="defaulttechnical.gov") + expectedTechContact = PublicContact.get_default_technical() + expectedTechContact.domain = domain + expectedTechContact.registry_id = "defaultTech" + domain.technical_contact = expectedTechContact + + expectedCreateCommand = self._convertPublicContactToEpp( + expectedTechContact, disclose_email=False + ) + + self.mockedSendFunction.assert_any_call(expectedCreateCommand, cleaned=True) + # Confirm that we are getting a default email + self.assertEqual(domain.technical_contact.email, expectedTechContact.email) + def test_is_disclosed_on_security_contact(self): """ Scenario: Registrant creates a new domain with a security email