Skip to content
Snippets Groups Projects
Commit e4366646 authored by Bianca Severino's avatar Bianca Severino
Browse files

Default to expiry_date for older software secure photo verifications

parent 6424a3f3
No related merge requests found
......@@ -647,6 +647,13 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
# to notify for expired verification is already sent.
expiry_email_date = models.DateTimeField(null=True, blank=True, db_index=True)
@property
def expiration_datetime(self):
"""Use expiry_date for older entries if it still exists."""
if self.expiry_date:
return self.expiry_date
return super(SoftwareSecurePhotoVerification, self).expiration_datetime
@classmethod
def get_initial_verification(cls, user, earliest_allowed_date=None):
"""Get initial verification for a user with the 'photo_id_key'.
......
......@@ -396,6 +396,25 @@ class TestPhotoVerification(TestVerificationBase, MockS3BotoMixin, ModuleStoreTe
verification.created_at + timedelta(days=FAKE_SETTINGS["DAYS_GOOD_FOR"])
)
def test_deprecated_expiry_date(self):
"""
Test `expiration_datetime` returns `expiry_date` if it is not null.
"""
user = UserFactory.create()
with freeze_time(now()):
verification = SoftwareSecurePhotoVerification(user=user)
# First, assert that expiration_date is set correctly
self.assertEqual(
verification.expiration_datetime,
now() + timedelta(days=FAKE_SETTINGS["DAYS_GOOD_FOR"])
)
verification.expiry_date = now() + timedelta(days=10)
# Then, assert that expiration_datetime favors expiry_date's value if set
self.assertEqual(
verification.expiration_datetime,
now() + timedelta(days=10)
)
class SSOVerificationTest(TestVerificationBase):
"""
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment