Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-proctoring
Commits
003e24e3
Commit
003e24e3
authored
Nov 07, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add all illegal characters
parent
d6ba142e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
28 deletions
+38
-28
edx_proctoring/backends/software_secure.py
+7
-2
edx_proctoring/backends/tests/test_software_secure.py
+30
-25
setup.py
+1
-1
No files found.
edx_proctoring/backends/software_secure.py
View file @
003e24e3
...
@@ -33,6 +33,9 @@ from edx_proctoring. models import (
...
@@ -33,6 +33,9 @@ from edx_proctoring. models import (
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
SOFTWARE_SECURE_INVALID_CHARS
=
'[]<>#:|?/
\'
"*
\\
'
class
SoftwareSecureBackendProvider
(
ProctoringBackendProvider
):
class
SoftwareSecureBackendProvider
(
ProctoringBackendProvider
):
"""
"""
Implementation of the ProctoringBackendProvider for Software Secure's
Implementation of the ProctoringBackendProvider for Software Secure's
...
@@ -355,8 +358,10 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
...
@@ -355,8 +358,10 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
now
=
datetime
.
datetime
.
utcnow
()
now
=
datetime
.
datetime
.
utcnow
()
start_time_str
=
now
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
start_time_str
=
now
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
end_time_str
=
(
now
+
datetime
.
timedelta
(
minutes
=
time_limit_mins
))
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
end_time_str
=
(
now
+
datetime
.
timedelta
(
minutes
=
time_limit_mins
))
.
strftime
(
"
%
a,
%
d
%
b
%
Y
%
H:
%
M:
%
S GMT"
)
# note, SoftwareSecure does not appear to allow colons in the exam names
# remove all illegal characters from the exam name
exam_name
=
exam
[
'exam_name'
]
.
replace
(
':'
,
'-'
)
exam_name
=
exam
[
'exam_name'
]
for
character
in
SOFTWARE_SECURE_INVALID_CHARS
:
exam_name
=
exam_name
.
replace
(
character
,
'_'
)
return
{
return
{
"examCode"
:
attempt_code
,
"examCode"
:
attempt_code
,
"organization"
:
self
.
organization
,
"organization"
:
self
.
organization
,
...
...
edx_proctoring/backends/tests/test_software_secure.py
View file @
003e24e3
...
@@ -41,9 +41,12 @@ from edx_proctoring.models import (
...
@@ -41,9 +41,12 @@ from edx_proctoring.models import (
ProctoredExamStudentAttemptHistory
,
ProctoredExamStudentAttemptHistory
,
ProctoredExamStudentAllowance
ProctoredExamStudentAllowance
)
)
from
edx_proctoring.backends.tests.test_review_payload
import
TEST_REVIEW_PAYLOAD
from
edx_proctoring.backends.tests.test_review_payload
import
(
TEST_REVIEW_PAYLOAD
)
from
edx_proctoring.tests.test_services
import
MockCreditService
from
edx_proctoring.tests.test_services
import
MockCreditService
from
edx_proctoring.backends.software_secure
import
SOFTWARE_SECURE_INVALID_CHARS
@all_requests
@all_requests
...
@@ -216,14 +219,6 @@ class SoftwareSecureTests(TestCase):
...
@@ -216,14 +219,6 @@ class SoftwareSecureTests(TestCase):
Create an unstarted proctoring attempt with no review policy associated with it.
Create an unstarted proctoring attempt with no review policy associated with it.
"""
"""
exam_id
=
create_exam
(
course_id
=
'foo/bar/baz'
,
content_id
=
'content'
,
exam_name
=
'Sample Exam with : Colon'
,
time_limit_mins
=
10
,
is_proctored
=
True
)
def
assert_get_payload_mock_no_policy
(
exam
,
context
):
def
assert_get_payload_mock_no_policy
(
exam
,
context
):
"""
"""
Add a mock shim so we can assert that the _get_payload has been called with the right
Add a mock shim so we can assert that the _get_payload has been called with the right
...
@@ -240,26 +235,36 @@ class SoftwareSecureTests(TestCase):
...
@@ -240,26 +235,36 @@ class SoftwareSecureTests(TestCase):
# the check that if a colon was passed in for the exam name, then the colon was changed to
# the check that if a colon was passed in for the exam name, then the colon was changed to
# a dash. This is because SoftwareSecure cannot handle a colon in the exam name
# a dash. This is because SoftwareSecure cannot handle a colon in the exam name
if
':'
in
exam
[
'exam_name'
]:
if
':'
in
exam
[
'exam_name'
]:
self
.
assertIn
(
'-'
,
result
[
'examName'
])
for
illegal_char
in
SOFTWARE_SECURE_INVALID_CHARS
:
self
.
assertNotIn
(
':'
,
result
[
'examName'
])
self
.
assertNotIn
(
illegal_char
,
result
[
'examName'
])
self
.
assertIn
(
'_'
,
result
[
'examName'
])
return
result
return
result
with
HTTMock
(
mock_response_content
):
for
illegal_char
in
SOFTWARE_SECURE_INVALID_CHARS
:
# patch the _get_payload method on the backend provider
exam_id
=
create_exam
(
# so that we can assert that we are called with the review policy
course_id
=
'foo/bar/baz'
,
# undefined and that we use the system default
content_id
=
'content with {}'
.
format
(
illegal_char
),
with
patch
.
object
(
get_backend_provider
(),
'_get_payload'
,
assert_get_payload_mock_no_policy
):
# pylint: disable=protected-access
exam_name
=
'Sample Exam with {} character'
.
format
(
illegal_char
),
attempt_id
=
create_exam_attempt
(
time_limit_mins
=
10
,
exam_id
,
is_proctored
=
True
self
.
user
.
id
,
)
taking_as_proctored
=
True
)
self
.
assertGreater
(
attempt_id
,
0
)
# make sure we recorded that there is no review policy
with
HTTMock
(
mock_response_content
):
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
# patch the _get_payload method on the backend provider
self
.
assertIsNone
(
attempt
[
'review_policy_id'
])
# so that we can assert that we are called with the review policy
# undefined and that we use the system default
with
patch
.
object
(
get_backend_provider
(),
'_get_payload'
,
assert_get_payload_mock_no_policy
):
# pylint: disable=protected-access
attempt_id
=
create_exam_attempt
(
exam_id
,
self
.
user
.
id
,
taking_as_proctored
=
True
)
self
.
assertGreater
(
attempt_id
,
0
)
# make sure we recorded that there is no review policy
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
self
.
assertIsNone
(
attempt
[
'review_policy_id'
])
def
test_single_name_attempt
(
self
):
def
test_single_name_attempt
(
self
):
"""
"""
...
...
setup.py
View file @
003e24e3
...
@@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):
...
@@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):
setup
(
setup
(
name
=
'edx-proctoring'
,
name
=
'edx-proctoring'
,
version
=
'0.10.1
8
'
,
version
=
'0.10.1
9
'
,
description
=
'Proctoring subsystem for Open edX'
,
description
=
'Proctoring subsystem for Open edX'
,
long_description
=
open
(
'README.md'
)
.
read
(),
long_description
=
open
(
'README.md'
)
.
read
(),
author
=
'edX'
,
author
=
'edX'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment