Skip to content
Snippets Groups Projects
Unverified Commit 889f5e4e authored by Farhanah Sheets's avatar Farhanah Sheets Committed by GitHub
Browse files

Merge pull request #21212 from edx/fsheets/PROD-500

Fix: Do not compare Software Secure expiry_date when NULL
parents 99868f9f fed53227
Branches
Tags
No related merge requests found
...@@ -943,7 +943,10 @@ class SoftwareSecurePhotoVerification(PhotoVerification): ...@@ -943,7 +943,10 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
Returns: Returns:
SoftwareSecurePhotoVerification (object) or None SoftwareSecurePhotoVerification (object) or None
""" """
recent_verification = SoftwareSecurePhotoVerification.objects.filter(status='approved', user_id=user.id) recent_verification = SoftwareSecurePhotoVerification.objects.filter(status='approved',
user_id=user.id,
expiry_date__isnull=False)
return recent_verification.latest('updated_at') if recent_verification.exists() else None return recent_verification.latest('updated_at') if recent_verification.exists() else None
@classmethod @classmethod
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from datetime import timedelta from datetime import datetime, timedelta
import boto import boto
import ddt import ddt
...@@ -380,6 +380,7 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase): ...@@ -380,6 +380,7 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase):
# Make an approved verification # Make an approved verification
attempt = SoftwareSecurePhotoVerification(user=user) attempt = SoftwareSecurePhotoVerification(user=user)
attempt.status = 'approved' attempt.status = 'approved'
attempt.expiry_date = datetime.now()
attempt.save() attempt.save()
# Test method 'get_recent_verification' returns the most recent # Test method 'get_recent_verification' returns the most recent
...@@ -388,6 +389,25 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase): ...@@ -388,6 +389,25 @@ class TestPhotoVerification(TestVerification, MockS3Mixin, ModuleStoreTestCase):
self.assertIsNotNone(recent_verification) self.assertIsNotNone(recent_verification)
self.assertEqual(recent_verification.id, attempt.id) self.assertEqual(recent_verification.id, attempt.id)
def test_get_recent_verification_expiry_null(self):
"""Test that method 'get_recent_verification' of model
'SoftwareSecurePhotoVerification' will return None when expiry_date
is NULL for 'approved' verifications based on updated_at value.
"""
user = UserFactory.create()
attempt = None
for _ in range(2):
# Make an approved verification
attempt = SoftwareSecurePhotoVerification(user=user)
attempt.status = 'approved'
attempt.save()
# Test method 'get_recent_verification' returns None
# as attempts don't have an expiry_date
recent_verification = SoftwareSecurePhotoVerification.get_recent_verification(user=user)
self.assertIsNone(recent_verification)
def test_no_approved_verification(self): def test_no_approved_verification(self):
"""Test that method 'get_recent_verification' of model """Test that method 'get_recent_verification' of model
'SoftwareSecurePhotoVerification' returns None if no 'SoftwareSecurePhotoVerification' returns None if no
......
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