diff --git a/common/djangoapps/student/roles.py b/common/djangoapps/student/roles.py index e61fafe89aa1..f96cc5f35375 100644 --- a/common/djangoapps/student/roles.py +++ b/common/djangoapps/student/roles.py @@ -90,7 +90,7 @@ def has_role(self, role, course_id, org): return any( access_role.role in self.get_roles(role) and access_role.course_id == course_id and - access_role.org == org + access_role.org.lower() == org.lower() for access_role in self._roles ) diff --git a/common/djangoapps/student/tests/test_roles.py b/common/djangoapps/student/tests/test_roles.py index 6c344352a142..88e10f31efb5 100644 --- a/common/djangoapps/student/tests/test_roles.py +++ b/common/djangoapps/student/tests/test_roles.py @@ -190,3 +190,14 @@ def test_only_in_role(self, role, target): def test_empty_cache(self, role, target): # lint-amnesty, pylint: disable=unused-argument cache = RoleCache(self.user) assert not cache.has_role(*target) + + @ddt.data(IN_KEY.org, 'edx', 'EDX', 'EdX') + def test_org_case_insensitive(self, compare_to_org): + org_role = OrgStaffRole(self.IN_KEY.org) + course_role = CourseInstructorRole(self.IN_KEY) + org_role.add_users(self.user) + course_role.add_users(self.user) + + role_cache = RoleCache(self.user) + assert role_cache.has_role('staff', None, compare_to_org) + assert role_cache.has_role('instructor', self.IN_KEY, compare_to_org)