Commit b347ec53 by Chris Dodge

return 404 if the exam code does not exist

parent aade2803
...@@ -5,6 +5,8 @@ Various callback paths ...@@ -5,6 +5,8 @@ Various callback paths
from django.template import Context, loader from django.template import Context, loader
from django.http import HttpResponse from django.http import HttpResponse
from edx_proctoring.exceptions import StudentExamAttemptDoesNotExistsException
from edx_proctoring.api import ( from edx_proctoring.api import (
start_exam_attempt_by_code, start_exam_attempt_by_code,
) )
...@@ -22,7 +24,13 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume ...@@ -22,7 +24,13 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
""" """
# start the exam! # start the exam!
try:
start_exam_attempt_by_code(attempt_code) start_exam_attempt_by_code(attempt_code)
except StudentExamAttemptDoesNotExistsException:
return HttpResponse(
content='That exam code is not valid',
status=404
)
template = loader.get_template('proctoring/proctoring_launch_callback.html') template = loader.get_template('proctoring/proctoring_launch_callback.html')
......
...@@ -755,6 +755,18 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -755,6 +755,18 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt = get_exam_attempt_by_id(attempt_id) attempt = get_exam_attempt_by_id(attempt_id)
self.assertIsNotNone(attempt['started_at']) self.assertIsNotNone(attempt['started_at'])
def test_bad_exam_code_callback(self):
"""
Assert that we get a 404 when doing a callback on an exam code that does not exist
"""
response = self.client.get(
reverse(
'edx_proctoring.anonymous.proctoring_launch_callback.start_exam',
args=['foo']
)
)
self.assertEqual(response.status_code, 404)
class TestExamAllowanceView(LoggedInTestCase): class TestExamAllowanceView(LoggedInTestCase):
""" """
......
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