Commit 82b7c109 by Chris Dodge

allow for simulated postbacks for exam verification

parent ce5b7780
...@@ -12,6 +12,8 @@ import datetime ...@@ -12,6 +12,8 @@ import datetime
import json import json
import logging import logging
from django.conf import settings
from edx_proctoring.backends.backend import ProctoringBackendProvider from edx_proctoring.backends.backend import ProctoringBackendProvider
from edx_proctoring.exceptions import ( from edx_proctoring.exceptions import (
BackendProvideCannotRegisterAttempt, BackendProvideCannotRegisterAttempt,
...@@ -170,7 +172,11 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider): ...@@ -170,7 +172,11 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
# note that SoftwareSecure might send a case insensitive # note that SoftwareSecure might send a case insensitive
# ssiRecordLocator than what it returned when we registered the # ssiRecordLocator than what it returned when we registered the
# exam # exam
if attempt_obj.external_id.lower() != external_id.lower(): match = (
attempt_obj.external_id.lower() == external_id.lower() or
settings.PROCTORING_SETTINGS.get('ALLOW_CALLBACK_SIMULATION', False)
)
if not match:
err_msg = ( err_msg = (
'Found attempt_code {attempt_code}, but the recorded external_id did not ' 'Found attempt_code {attempt_code}, but the recorded external_id did not '
'match the ssiRecordLocator that had been recorded previously. Has {existing} ' 'match the ssiRecordLocator that had been recorded previously. Has {existing} '
......
...@@ -30,6 +30,7 @@ from edx_proctoring.exceptions import ( ...@@ -30,6 +30,7 @@ from edx_proctoring.exceptions import (
from edx_proctoring. models import ( from edx_proctoring. models import (
ProctoredExamSoftwareSecureReview, ProctoredExamSoftwareSecureReview,
ProctoredExamSoftwareSecureComment, ProctoredExamSoftwareSecureComment,
ProctoredExamStudentAttemptStatus,
) )
from edx_proctoring.backends.tests.test_review_payload import TEST_REVIEW_PAYLOAD from edx_proctoring.backends.tests.test_review_payload import TEST_REVIEW_PAYLOAD
...@@ -349,6 +350,46 @@ class SoftwareSecureTests(TestCase): ...@@ -349,6 +350,46 @@ class SoftwareSecureTests(TestCase):
with self.assertRaises(ProctoredExamSuspiciousLookup): with self.assertRaises(ProctoredExamSuspiciousLookup):
provider.on_review_callback(json.loads(test_payload)) provider.on_review_callback(json.loads(test_payload))
@patch.dict('django.conf.settings.PROCTORING_SETTINGS', {'ALLOW_CALLBACK_SIMULATION': True})
def test_allow_simulated_callbacks(self):
"""
Verify that the configuration switch to
not do confirmation of external_id/ssiRecordLocators
"""
provider = get_backend_provider()
exam_id = create_exam(
course_id='foo/bar/baz',
content_id='content',
exam_name='Sample Exam',
time_limit_mins=10,
is_proctored=True
)
# be sure to use the mocked out SoftwareSecure handlers
with HTTMock(mock_response_content):
attempt_id = create_exam_attempt(
exam_id,
self.user.id,
taking_as_proctored=True
)
attempt = get_exam_attempt_by_id(attempt_id)
self.assertIsNotNone(attempt['external_id'])
test_payload = Template(TEST_REVIEW_PAYLOAD).substitute(
attempt_code=attempt['attempt_code'],
external_id='bogus'
)
# this should not raise an exception since we have
# the ALLOW_CALLBACK_SIMULATION override
provider.on_review_callback(json.loads(test_payload))
attempt = get_exam_attempt_by_id(attempt_id)
self.assertEqual(attempt['status'], ProctoredExamStudentAttemptStatus.verified)
def test_review_on_archived_attempt(self): def test_review_on_archived_attempt(self):
""" """
Make sure we can process a review report for Make sure we can process a review report for
......
...@@ -88,5 +88,6 @@ PROCTORING_SETTINGS = { ...@@ -88,5 +88,6 @@ PROCTORING_SETTINGS = {
'faq': '', 'faq': '',
'contact_us': '', 'contact_us': '',
'tech_requirements': '', 'tech_requirements': '',
} },
'ALLOW_CALLBACK_SIMULATION': False
} }
Markdown is supported
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