Skip to content

Commit

Permalink
fix: roles cache organization case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
shadinaif committed Jan 14, 2025
1 parent 0630c65 commit 76c3d5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/djangoapps/student/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def has_role(self, role, course_id, org):
course_id_string = get_role_cache_key_for_course(course_id)
course_roles = self._roles_by_course_id.get(course_id_string, [])
return any(
# access_role.role in self.get_roles(role) and access_role.org.lower() == org.lower()
access_role.role in self.get_roles(role) and access_role.org == org
for access_role in course_roles
)
Expand Down
3 changes: 3 additions & 0 deletions common/djangoapps/student/tests/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ class RoleCacheTestCase(TestCase): # lint-amnesty, pylint: disable=missing-clas

ROLES = (
(CourseStaffRole(IN_KEY), ('staff', IN_KEY, 'edX')),
(CourseStaffRole(IN_KEY), ('staff', IN_KEY, 'EDX')),
(CourseLimitedStaffRole(IN_KEY), ('limited_staff', IN_KEY, 'edX')),
(CourseLimitedStaffRole(IN_KEY), ('limited_staff', IN_KEY, 'EDX')),
(CourseInstructorRole(IN_KEY), ('instructor', IN_KEY, 'edX')),
(OrgStaffRole(IN_KEY.org), ('staff', None, 'edX')),
(OrgStaffRole(IN_KEY.org), ('staff', None, 'EDX')),
(CourseFinanceAdminRole(IN_KEY), ('finance_admin', IN_KEY, 'edX')),
(CourseSalesAdminRole(IN_KEY), ('sales_admin', IN_KEY, 'edX')),
(LibraryUserRole(IN_KEY), ('library_user', IN_KEY, 'edX')),
Expand Down

0 comments on commit 76c3d5a

Please sign in to comment.