-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR changes the permissions for content libraries so that only people who can create courses should be allowed to create new content libraries.
- Loading branch information
Showing
10 changed files
with
71 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ class ContentLibrariesRestApiTest(APITransactionTestCase): | |
|
||
def setUp(self): | ||
super().setUp() | ||
self.user = UserFactory.create(username="Bob", email="[email protected]", password="edx") | ||
self.user = UserFactory.create(username="Bob", email="[email protected]", password="edx", is_staff=True) | ||
# Create an organization | ||
self.organization, _ = Organization.objects.get_or_create( | ||
short_name="CL-TEST", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,8 @@ def test_library_blocks(self): # pylint: disable=too-many-statements | |
Tests with some non-ASCII chars in slugs, titles, descriptions. | ||
""" | ||
admin = UserFactory.create(username="Admin", email="[email protected]", is_staff=True) | ||
|
||
lib = self._create_library(slug="téstlꜟط", title="A Tést Lꜟطrary", description="Tésting XBlocks") | ||
lib_id = lib["id"] | ||
assert lib['has_unpublished_changes'] is False | ||
|
@@ -531,7 +533,7 @@ def test_library_permissions(self): # pylint: disable=too-many-statements | |
Learning Core data models. | ||
""" | ||
# Create a few users to use for all of these tests: | ||
admin = UserFactory.create(username="Admin", email="[email protected]") | ||
admin = UserFactory.create(username="Admin", email="[email protected]", is_staff=True) | ||
author = UserFactory.create(username="Author", email="[email protected]") | ||
reader = UserFactory.create(username="Reader", email="[email protected]") | ||
group = Group.objects.create(name="group1") | ||
|
@@ -653,14 +655,15 @@ def test_library_permissions(self): # pylint: disable=too-many-statements | |
self._get_library_block_asset(block3_key, file_name="static/whatever.png", expect_response=403) | ||
# Nor can they preview the block: | ||
self._render_block_view(block3_key, view_name="student_view", expect_response=403) | ||
# But if we grant allow_public_read, then they can: | ||
# Even if we grant allow_public_read, then they can't: | ||
with self.as_user(admin): | ||
self._update_library(lib_id, allow_public_read=True) | ||
self._set_library_block_asset(block3_key, "static/whatever.png", b"data") | ||
with self.as_user(random_user): | ||
self._get_library_block_olx(block3_key) | ||
self._get_library_block_olx(block3_key, expect_response=403) | ||
self._get_library_block_fields(block3_key, expect_response=403) | ||
# But he can preview the block: | ||
self._render_block_view(block3_key, view_name="student_view") | ||
f = self._get_library_block_fields(block3_key) | ||
# self._get_library_block_assets(block3_key) | ||
# self._get_library_block_asset(block3_key, file_name="whatever.png") | ||
|
||
|
@@ -702,7 +705,7 @@ def test_no_lockout(self): | |
""" | ||
Test that administrators cannot be removed if they are the only administrator granted access. | ||
""" | ||
admin = UserFactory.create(username="Admin", email="[email protected]") | ||
admin = UserFactory.create(username="Admin", email="[email protected]", is_staff=True) | ||
successor = UserFactory.create(username="Successor", email="[email protected]") | ||
with self.as_user(admin): | ||
lib = self._create_library(slug="permtest", title="Permission Test Library", description="Testing") | ||
|
@@ -1026,7 +1029,7 @@ def test_library_paste_clipboard(self): | |
from openedx.core.djangoapps.content_staging.api import save_xblock_to_user_clipboard | ||
|
||
# Create user to perform tests on | ||
author = UserFactory.create(username="Author", email="[email protected]") | ||
author = UserFactory.create(username="Author", email="[email protected]", is_staff=True) | ||
with self.as_user(author): | ||
lib = self._create_library( | ||
slug="test_lib_paste_clipboard", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters