diff --git a/src/registrar/migrations/0100_domain_dsdata_last_change.py b/src/registrar/migrations/0100_domain_dsdata_last_change.py deleted file mode 100644 index 0ce0f6255..000000000 --- a/src/registrar/migrations/0100_domain_dsdata_last_change.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.10 on 2024-06-11 22:44 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("registrar", "0099_federalagency_federal_type"), - ] - - operations = [ - migrations.AddField( - model_name="domain", - name="dsdata_last_change", - field=models.TextField(blank=True, help_text="Most recent time that ds data was updated", null=True), - ), - ] diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 335c6470e..ebd1b39e5 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -692,7 +692,7 @@ class Domain(TimeStampedModel, DomainHelper): dsdata_change_log = f"{user_email} deleted a DS data record" if dsdata_change_log != "": self.dsdata_last_change = dsdata_change_log - self.save() # Audit log will now record this as a change + self.save() # audit log will now record this as a change except RegistryError as e: logger.error("Error updating DNSSEC, code was %s error was %s" % (e.code, e)) @@ -1074,11 +1074,11 @@ class Domain(TimeStampedModel, DomainHelper): verbose_name="first ready on", ) - dsdata_last_change = TextField( - null=True, - blank=True, - help_text="Most recent time that ds data was updated", - ) + # dsdata_last_change = TextField( + # null=True, + # blank=True, + # help_text="Most recent time that ds data was updated", + # ) def isActive(self): return self.state == Domain.State.CREATED diff --git a/src/registrar/tests/test_models_domain.py b/src/registrar/tests/test_models_domain.py index abad6f57e..e65143123 100644 --- a/src/registrar/tests/test_models_domain.py +++ b/src/registrar/tests/test_models_domain.py @@ -1901,12 +1901,8 @@ class TestRegistrantDNSSEC(MockEppLib): 3 - setter adds the UpdateDNSSECExtension extension to the command 4 - setter causes the getter to call info domain on next get from cache 5 - getter properly parses dnssecdata from InfoDomain response and sets to cache - """ - # need to use a separate patcher and side_effect for this test, as - # response from InfoDomain must be different for different iterations - # of the same command def side_effect(_request, cleaned): if isinstance(_request, commands.InfoDomain): if mocked_send.call_count == 1: @@ -1924,17 +1920,30 @@ class TestRegistrantDNSSEC(MockEppLib): mocked_send = patcher.start() mocked_send.side_effect = side_effect domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov") + + # Check initial dsdata_last_change value (should be None) + initial_change_time = domain.dsdata_last_change + + # Adding dnssec data domain.dnssecdata = self.dnssecExtensionWithDsData - # get the DNS SEC extension added to the UpdateDomain command and + + # Check dsdata_last_change is updated after adding data + domain = Domain.objects.get(name="dnssec-dsdata.gov") + self.assertIsNotNone(domain.dsdata_last_change) + + self.assertNotEqual(domain.dsdata_last_change, initial_change_time) + + # Get the DNS SEC extension added to the UpdateDomain command and # verify that it is properly sent # args[0] is the _request sent to registry args, _ = mocked_send.call_args - # assert that the extension on the update matches + # Assert that the extension on the update matches self.assertEquals( args[0].extensions[0], self.createUpdateExtension(self.dnssecExtensionWithDsData), ) - # test that the dnssecdata getter is functioning properly + + # Test that the dnssecdata getter is functioning properly dnssecdata_get = domain.dnssecdata mocked_send.assert_has_calls( [ @@ -2129,13 +2138,9 @@ class TestRegistrantDNSSEC(MockEppLib): 2 - first setter calls UpdateDomain command 3 - second setter calls InfoDomain command again 3 - setter then calls UpdateDomain command - 4 - setter adds the UpdateDNSSECExtension extension to the command with rem - + 4 - setter adds the UpdateDNSSExtension extension to the command with rem """ - # need to use a separate patcher and side_effect for this test, as - # response from InfoDomain must be different for different iterations - # of the same command def side_effect(_request, cleaned): if isinstance(_request, commands.InfoDomain): if mocked_send.call_count == 1: @@ -2153,10 +2158,25 @@ class TestRegistrantDNSSEC(MockEppLib): mocked_send = patcher.start() mocked_send.side_effect = side_effect domain, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov") - # dnssecdata_get_initial = domain.dnssecdata # call to force initial mock - # domain._invalidate_cache() + + # Initial setting of dnssec data domain.dnssecdata = self.dnssecExtensionWithDsData + + # Check dsdata_last_change is updated + domain = Domain.objects.get(name="dnssec-dsdata.gov") + self.assertIsNotNone(domain.dsdata_last_change) + + initial_change_time = domain.dsdata_last_change + + # Remove dnssec data domain.dnssecdata = self.dnssecExtensionRemovingDsData + + # Check that dsdata_last_change is updated again + domain = Domain.objects.get(name="dnssec-dsdata.gov") + self.assertIsNotNone(domain.dsdata_last_change) + + self.assertNotEqual(domain.dsdata_last_change, initial_change_time) + # get the DNS SEC extension added to the UpdateDomain command and # verify that it is properly sent # args[0] is the _request sent to registry