-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add advanced settings view permission for course roles #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ p, role^course_auditor, act^courses.view_grading_settings, course-v1^*, allow | |
| p, role^course_auditor, act^courses.view_checklists, course-v1^*, allow | ||
| p, role^course_auditor, act^courses.view_course_team, course-v1^*, allow | ||
| p, role^course_auditor, act^courses.view_schedule_and_details, course-v1^*, allow | ||
| p, role^course_auditor, act^courses.view_advanced_settings, course-v1^*, allow | ||
|
|
||
| # Course Editor Role Policies | ||
| p, role^course_editor, act^courses.view_course, course-v1^*, allow | ||
|
|
@@ -91,6 +92,7 @@ p, role^course_editor, act^courses.view_grading_settings, course-v1^*, allow | |
| p, role^course_editor, act^courses.view_checklists, course-v1^*, allow | ||
| p, role^course_editor, act^courses.view_course_team, course-v1^*, allow | ||
| p, role^course_editor, act^courses.view_schedule_and_details, course-v1^*, allow | ||
| p, role^course_editor, act^courses.view_advanced_settings, course-v1^*, allow | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need to add this permission to the Course Admin and Course Staff roles |
||
| p, role^course_editor, act^courses.edit_course_content, course-v1^*, allow | ||
| p, role^course_editor, act^courses.manage_library_updates, course-v1^*, allow | ||
| p, role^course_editor, act^courses.manage_course_updates, course-v1^*, allow | ||
|
|
@@ -101,6 +103,7 @@ p, role^course_editor, act^courses.edit_grading_settings, course-v1^*, allow | |
| p, role^course_editor, act^courses.manage_group_configurations, course-v1^*, allow | ||
| p, role^course_editor, act^courses.edit_details, course-v1^*, allow | ||
| p, role^course_editor, act^courses.manage_tags, course-v1^*, allow | ||
| p, role^course_editor, act^courses.manage_advanced_settings, course-v1^*, allow | ||
|
|
||
| # Course Staff Role Policies | ||
| p, role^course_staff, act^courses.legacy_staff_role_permissions, course-v1^*, allow | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ | |
| from openedx_authz.constants import roles | ||
| from openedx_authz.constants.permissions import ( | ||
| COURSES_CREATE_FILES, | ||
| COURSES_MANAGE_ADVANCED_SETTINGS, | ||
| COURSES_VIEW_ADVANCED_SETTINGS, | ||
| COURSES_VIEW_COURSE, | ||
| MANAGE_LIBRARY_TEAM, | ||
| VIEW_LIBRARY, | ||
|
|
@@ -897,3 +899,56 @@ def test_is_admin_or_superuser_check( | |
| """ | ||
| request = {"subject": subject, "action": action, "scope": scope, "expected_result": expected_result} | ||
| self._test_enforcement(self.POLICY, request) | ||
|
|
||
|
|
||
| @ddt | ||
| class AdvancedSettingsPermissionsTests(CasbinEnforcementTestCase): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should test the admin and staff roles as well |
||
| """ | ||
| Tests for advanced settings permissions for course_auditor and course_editor roles. | ||
|
|
||
| Verifies the two-tier access model: | ||
| - course_auditor: VIEW only (read-only access) | ||
| - course_editor: both VIEW and MANAGE (full access) | ||
| """ | ||
|
|
||
| COURSE = "course-v1:TestOrg+TestCourse+2024_T1" | ||
|
|
||
| POLICIES = [ | ||
| make_policy( | ||
| roles.COURSE_AUDITOR.external_key, | ||
| COURSES_VIEW_ADVANCED_SETTINGS.identifier, | ||
| CourseOverviewData.NAMESPACE, | ||
| ), | ||
| make_policy( | ||
| roles.COURSE_EDITOR.external_key, | ||
| COURSES_VIEW_ADVANCED_SETTINGS.identifier, | ||
| CourseOverviewData.NAMESPACE, | ||
| ), | ||
| make_policy( | ||
| roles.COURSE_EDITOR.external_key, | ||
| COURSES_MANAGE_ADVANCED_SETTINGS.identifier, | ||
| CourseOverviewData.NAMESPACE, | ||
| ), | ||
| ] | ||
|
|
||
| ASSIGNMENTS = [ | ||
| make_course_assignment("auditor", roles.COURSE_AUDITOR.external_key, COURSE), | ||
| make_course_assignment("editor", roles.COURSE_EDITOR.external_key, COURSE), | ||
| ] | ||
|
|
||
| CASES = [ | ||
| # course_auditor: view allowed, manage denied | ||
| make_course_case("auditor", COURSES_VIEW_ADVANCED_SETTINGS.identifier, COURSE, True), | ||
| make_course_case("auditor", COURSES_MANAGE_ADVANCED_SETTINGS.identifier, COURSE, False), | ||
| # course_editor: both view and manage allowed | ||
| make_course_case("editor", COURSES_VIEW_ADVANCED_SETTINGS.identifier, COURSE, True), | ||
| make_course_case("editor", COURSES_MANAGE_ADVANCED_SETTINGS.identifier, COURSE, True), | ||
| # unassigned user: both denied | ||
| make_course_case("other", COURSES_VIEW_ADVANCED_SETTINGS.identifier, COURSE, False), | ||
| make_course_case("other", COURSES_MANAGE_ADVANCED_SETTINGS.identifier, COURSE, False), | ||
| ] | ||
|
|
||
| @data(*CASES) | ||
| def test_advanced_settings_enforcement(self, request: AuthRequest): | ||
| """Test that advanced settings permissions are enforced correctly per role.""" | ||
| self._test_enforcement(self.POLICIES + self.ASSIGNMENTS, request) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update all references in this file from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add this permission to the Course Admin and Course Staff roles