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
fa7c80b4
Commit
fa7c80b4
authored
Nov 01, 2016
by
Jesse Shapiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove access to CCX courses from Studio entirely and test that revocation
parent
9d1e77e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletions
+56
-1
common/djangoapps/student/auth.py
+15
-0
common/djangoapps/student/tests/test_authz.py
+41
-1
No files found.
common/djangoapps/student/auth.py
View file @
fa7c80b4
...
@@ -20,6 +20,18 @@ STUDIO_VIEW_CONTENT = 1
...
@@ -20,6 +20,18 @@ STUDIO_VIEW_CONTENT = 1
# In addition to the above, one is always allowed to "demote" oneself to a lower role within a course, or remove oneself
# In addition to the above, one is always allowed to "demote" oneself to a lower role within a course, or remove oneself
def
is_ccx_course
(
course_key
):
"""
Check whether the course locator maps to a CCX course; this is important
because we don't allow access to CCX courses in Studio.
"""
ccx_namespaces
=
(
'ccx-v1'
,
'ccx-block-v1'
,
)
return
course_key
.
CANONICAL_NAMESPACE
in
ccx_namespaces
def
user_has_role
(
user
,
role
):
def
user_has_role
(
user
,
role
):
"""
"""
Check whether this user has access to this role (either direct or implied)
Check whether this user has access to this role (either direct or implied)
...
@@ -61,6 +73,9 @@ def get_user_permissions(user, course_key, org=None):
...
@@ -61,6 +73,9 @@ def get_user_permissions(user, course_key, org=None):
else
:
else
:
assert
course_key
is
None
assert
course_key
is
None
all_perms
=
STUDIO_EDIT_ROLES
|
STUDIO_VIEW_USERS
|
STUDIO_EDIT_CONTENT
|
STUDIO_VIEW_CONTENT
all_perms
=
STUDIO_EDIT_ROLES
|
STUDIO_VIEW_USERS
|
STUDIO_EDIT_CONTENT
|
STUDIO_VIEW_CONTENT
# No one has studio permissions for CCX courses
if
is_ccx_course
(
course_key
):
return
0
# global staff, org instructors, and course instructors have all permissions:
# global staff, org instructors, and course instructors have all permissions:
if
GlobalStaff
()
.
has_user
(
user
)
or
OrgInstructorRole
(
org
=
org
)
.
has_user
(
user
):
if
GlobalStaff
()
.
has_user
(
user
)
or
OrgInstructorRole
(
org
=
org
)
.
has_user
(
user
):
return
all_perms
return
all_perms
...
...
common/djangoapps/student/tests/test_authz.py
View file @
fa7c80b4
...
@@ -9,8 +9,9 @@ from django.core.exceptions import PermissionDenied
...
@@ -9,8 +9,9 @@ from django.core.exceptions import PermissionDenied
from
student.roles
import
CourseInstructorRole
,
CourseStaffRole
,
CourseCreatorRole
from
student.roles
import
CourseInstructorRole
,
CourseStaffRole
,
CourseCreatorRole
from
student.tests.factories
import
AdminFactory
from
student.tests.factories
import
AdminFactory
from
student.auth
import
user_has_role
,
add_users
,
remove_users
from
student.auth
import
user_has_role
,
add_users
,
remove_users
,
has_studio_write_access
,
has_studio_read_access
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
ccx_keys.locator
import
CCXLocator
class
CreatorGroupTest
(
TestCase
):
class
CreatorGroupTest
(
TestCase
):
...
@@ -132,6 +133,45 @@ class CreatorGroupTest(TestCase):
...
@@ -132,6 +133,45 @@ class CreatorGroupTest(TestCase):
remove_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
remove_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
class
CCXCourseGroupTest
(
TestCase
):
"""
Test that access to a CCX course in Studio is disallowed
"""
def
setUp
(
self
):
"""
Set up test variables
"""
super
(
CourseGroupTest
,
self
)
.
setUp
()
self
.
global_admin
=
AdminFactory
()
self
.
staff
=
User
.
objects
.
create_user
(
'teststaff'
,
'teststaff+courses@edx.org'
,
'foo'
)
self
.
ccx_course_key
=
CCXLocator
.
from_string
(
'ccx-v1:edX+DemoX+Demo_Course+ccx@1'
)
add_users
(
self
.
global_admin
,
CourseStaffRole
(
self
.
ccx_course_key
),
self
.
staff
)
def
test_no_global_admin_write_access
(
self
):
"""
Test that global admins have no write access
"""
self
.
assertFalse
(
has_studio_write_access
(
self
.
global_admin
,
self
.
ccx_course_key
))
def
test_no_staff_write_access
(
self
):
"""
Test that course staff have no write access
"""
self
.
assertFalse
(
has_studio_write_access
(
self
.
staff
,
self
.
ccx_course_key
))
def
test_no_global_admin_read_access
(
self
):
"""
Test that global admins have no read access
"""
self
.
assertFalse
(
has_studio_write_access
(
self
.
global_admin
,
self
.
ccx_course_key
))
def
test_no_staff_write_access
(
self
):
"""
Test that course staff have no read access
"""
self
.
assertFalse
(
has_studio_write_access
(
self
.
staff
,
self
.
ccx_course_key
))
class
CourseGroupTest
(
TestCase
):
class
CourseGroupTest
(
TestCase
):
"""
"""
Tests for instructor and staff groups for a particular course.
Tests for instructor and staff groups for a particular course.
...
...
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