Skip to content

Commit

Permalink
fix: encode course id and username for lms request (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto authored Jan 29, 2025
1 parent 1109ef3 commit bc9e56f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions edx_exams/apps/router/interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ def get_user_onboarding_data(course_id, username=None):
Get user onboarding data given a course_id and optional username
"""
template = LMS_PROCTORED_EXAM_ONBOARDING_DATA_API_TPL
url_safe_course_id = quote_plus(course_id)

if username:
template += '&username={}'
path = template.format(course_id, username)
url_safe_username = quote_plus(username)
path = template.format(url_safe_course_id, url_safe_username)
else:
path = template.format(course_id)
path = template.format(url_safe_course_id)

response = _make_proctoring_request(path, 'GET')

Expand Down
11 changes: 7 additions & 4 deletions edx_exams/apps/router/tests/test_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def test_get_provider_settings(self, response_status):
@ddt.data(
(200, None),
(422, None),
(200, 'edx'),
(422, 'edx')
(200, 'edx@edx.org'),
(422, 'edx@edx.org')
)
@mock_oauth_login
@responses.activate
Expand All @@ -171,12 +171,15 @@ def test_get_onboarding_data(self, response_status, username):
HTTP exceptions are handled and response is returned for
non-200 states codes
"""
url_course_id = 'course-v1%3Aedx%2Btest%2Bf19'
url_username = 'edx%40edx.org'

self.lms_url = (
f'{settings.LMS_ROOT_URL}/api/edx_proctoring/v1/user_onboarding/status'
f'?is_learning_mfe=true&course_id={self.course_id}'
f'?is_learning_mfe=true&course_id={url_course_id}'
)
if username:
self.lms_url += f'&username={username}'
self.lms_url += f'&username={url_username}'

responder = responses.add(
responses.GET,
Expand Down

0 comments on commit bc9e56f

Please sign in to comment.