Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
f33b451e
Commit
f33b451e
authored
Jul 28, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9081 from edx/clintonb/course-detail-whitelist
White-listed course detail API calls
parents
41d9338f
e5ba2a58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
common/djangoapps/embargo/middleware.py
+4
-0
common/djangoapps/embargo/tests/test_middleware.py
+31
-0
No files found.
common/djangoapps/embargo/middleware.py
View file @
f33b451e
...
...
@@ -54,6 +54,10 @@ class EmbargoMiddleware(object):
# accidentally lock ourselves out of Django admin
# during testing.
re
.
compile
(
r'^/admin/'
),
# Do not block access to course metadata. This information is needed for
# sever-to-server calls.
re
.
compile
(
r'^/api/course_structure/v[\d+]/courses/{}/$'
.
format
(
settings
.
COURSE_ID_PATTERN
)),
]
def
__init__
(
self
):
...
...
common/djangoapps/embargo/tests/test_middleware.py
View file @
f33b451e
...
...
@@ -170,3 +170,34 @@ class EmbargoMiddlewareAccessTests(UrlResetMixin, ModuleStoreTestCase):
# even though we would have been blocked by country
# access rules.
self
.
assertEqual
(
response
.
status_code
,
200
)
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
test_always_allow_course_detail_access
(
self
):
""" Access to the Course Structure API's course detail endpoint should always be granted. """
# Make the user staff so that it has permissions to access the views.
self
.
user
.
is_staff
=
True
self
.
user
.
save
()
# pylint: disable=no-member
# Blacklist an IP address
ip_address
=
"192.168.10.20"
IPFilter
.
objects
.
create
(
blacklist
=
ip_address
,
enabled
=
True
)
url
=
reverse
(
'course_structure_api:v0:detail'
,
kwargs
=
{
'course_id'
:
unicode
(
self
.
course
.
id
)})
response
=
self
.
client
.
get
(
url
,
HTTP_X_FORWARDED_FOR
=
ip_address
,
REMOTE_ADDR
=
ip_address
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# Test with a fully-restricted course
with
restrict_course
(
self
.
course
.
id
):
response
=
self
.
client
.
get
(
url
,
HTTP_X_FORWARDED_FOR
=
ip_address
,
REMOTE_ADDR
=
ip_address
)
self
.
assertEqual
(
response
.
status_code
,
200
)
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