mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Merge pull request #1391 from cisagov/dk/1218-update-expiration-date
Issue #1218 - Update the stored expiration date value anytime it's received (STAGED ON BL)
This commit is contained in:
commit
211d22da6f
3 changed files with 16 additions and 4 deletions
|
@ -212,11 +212,9 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
@Cache
|
||||
def registry_expiration_date(self) -> date:
|
||||
"""Get or set the `ex_date` element from the registry.
|
||||
Additionally, update the expiration date in the registrar"""
|
||||
Additionally, _get_property updates the expiration date in the registrar"""
|
||||
try:
|
||||
self.expiration_date = self._get_property("ex_date")
|
||||
self.save()
|
||||
return self.expiration_date
|
||||
return self._get_property("ex_date")
|
||||
except Exception as e:
|
||||
# exception raised during the save to registrar
|
||||
logger.error(f"error updating expiration date in registrar: {e}")
|
||||
|
@ -1610,6 +1608,12 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
if old_cache_contacts is not None:
|
||||
cleaned["contacts"] = old_cache_contacts
|
||||
|
||||
# if expiration date from registry does not match what is in db,
|
||||
# update the db
|
||||
if "ex_date" in cleaned and cleaned["ex_date"] != self.expiration_date:
|
||||
self.expiration_date = cleaned["ex_date"]
|
||||
self.save()
|
||||
|
||||
self._cache = cleaned
|
||||
|
||||
except RegistryError as e:
|
||||
|
|
|
@ -617,6 +617,7 @@ class MockEppLib(TestCase):
|
|||
common.Status(state="serverTransferProhibited", description="", lang="en"),
|
||||
common.Status(state="inactive", description="", lang="en"),
|
||||
],
|
||||
ex_date=datetime.date(2023, 5, 25),
|
||||
)
|
||||
mockDataInfoContact = mockDataInfoDomain.dummyInfoContactResultData(
|
||||
"123", "123@mail.gov", datetime.datetime(2023, 5, 25, 19, 45, 35), "lastPw"
|
||||
|
|
|
@ -1987,6 +1987,13 @@ class TestExpirationDate(MockEppLib):
|
|||
with self.assertRaises(RegistryError):
|
||||
self.domain_w_error.renew_domain()
|
||||
|
||||
def test_expiration_date_updated_on_info_domain_call(self):
|
||||
"""assert that expiration date in db is updated on info domain call"""
|
||||
# force fetch_cache to be called
|
||||
self.domain.statuses
|
||||
test_date = datetime.date(2023, 5, 25)
|
||||
self.assertEquals(self.domain.expiration_date, test_date)
|
||||
|
||||
|
||||
class TestAnalystClientHold(MockEppLib):
|
||||
"""Rule: Analysts may suspend or restore a domain by using client hold"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue