Skip to content

Commit 8cce705

Browse files
committed
refactor: rename org glob scopes
1 parent f7a21b9 commit 8cce705

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

openedx_authz/api/data.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"SubjectData",
3535
"ContentLibraryData",
3636
"CourseOverviewData",
37-
"OrgLevelLibraryGlob",
38-
"OrgLevelCourseGlob",
37+
"OrgLibraryGlobData",
38+
"OrgCourseGlobData",
3939
]
4040

4141
AUTHZ_POLICY_ATTRIBUTES_SEPARATOR = "^"
@@ -182,11 +182,11 @@ def __call__(cls, *args, **kwargs):
182182
1. external_key: Determines subclass from the key format. The namespace prefix
183183
before the first ':' is used to look up the appropriate subclass.
184184
Example: ScopeData(external_key='lib:DemoX:CSPROB') → ContentLibraryData
185-
Example: ScopeData(external_key='lib:DemoX*') → OrgLevelLibraryGlob
185+
Example: ScopeData(external_key='lib:DemoX*') → OrgLibraryGlobData
186186
187187
2. namespaced_key: Determines subclass from the namespace prefix before '^'.
188188
Example: ScopeData(namespaced_key='lib^lib:DemoX:CSPROB') → ContentLibraryData
189-
Example: ScopeData(namespaced_key='lib^lib:DemoX*') → OrgLevelLibraryGlob
189+
Example: ScopeData(namespaced_key='lib^lib:DemoX*') → OrgLibraryGlobData
190190
191191
Usage patterns:
192192
- namespaced_key: Used when retrieving objects from the policy store
@@ -199,7 +199,7 @@ def __call__(cls, *args, **kwargs):
199199
True
200200
>>> # From glob external key
201201
>>> scope = ScopeData(external_key='lib:DemoX*')
202-
>>> isinstance(scope, OrgLevelLibraryGlob)
202+
>>> isinstance(scope, OrgLibraryGlobData)
203203
True
204204
>>> # From namespaced key (e.g., policy store)
205205
>>> scope = ScopeData(namespaced_key='lib^lib:DemoX:CSPROB')
@@ -246,7 +246,7 @@ def get_subclass_by_namespaced_key(mcs, namespaced_key: str) -> Type["ScopeData"
246246
>>> ScopeMeta.get_subclass_by_namespaced_key('lib^lib:DemoX:CSPROB')
247247
<class 'ContentLibraryData'>
248248
>>> ScopeMeta.get_subclass_by_namespaced_key('lib^lib:DemoX*')
249-
<class 'OrgLevelLibraryGlob'>
249+
<class 'OrgLibraryGlobData'>
250250
>>> ScopeMeta.get_subclass_by_namespaced_key('global^generic')
251251
<class 'ScopeData'>
252252
"""
@@ -292,9 +292,9 @@ def get_subclass_by_external_key(mcs, external_key: str) -> Type["ScopeData"]:
292292
>>> ScopeMeta.get_subclass_by_external_key('course-v1:OpenedX+CS101+2024')
293293
<class 'CourseOverviewData'>
294294
>>> ScopeMeta.get_subclass_by_external_key('lib:DemoX*')
295-
<class 'OrgLevelLibraryGlob'>
295+
<class 'OrgLibraryGlobData'>
296296
>>> ScopeMeta.get_subclass_by_external_key('course-v1:OpenedX*')
297-
<class 'OrgLevelCourseGlob'>
297+
<class 'OrgCourseGlobData'>
298298
299299
Notes:
300300
- The external_key format should be 'namespace:some-identifier' (e.g., 'lib:DemoX:CSPROB').
@@ -527,7 +527,7 @@ def __repr__(self):
527527

528528

529529
@define
530-
class OrgLevelLibraryGlob(ContentLibraryData):
530+
class OrgLibraryGlobData(ContentLibraryData):
531531
"""Organization-level glob pattern for content libraries.
532532
533533
This class represents glob patterns that match multiple libraries within an organization.
@@ -549,7 +549,7 @@ class OrgLevelLibraryGlob(ContentLibraryData):
549549
- Cannot have wildcards at slug level (lib:ORG:SLUG* is invalid)
550550
551551
Examples:
552-
>>> glob = OrgLevelLibraryGlob(external_key='lib:DemoX*')
552+
>>> glob = OrgLibraryGlobData(external_key='lib:DemoX*')
553553
>>> glob.org
554554
'DemoX'
555555
@@ -748,7 +748,7 @@ def __repr__(self):
748748

749749

750750
@define
751-
class OrgLevelCourseGlob(CourseOverviewData):
751+
class OrgCourseGlobData(CourseOverviewData):
752752
"""Organization-level glob pattern for courses.
753753
754754
This class represents glob patterns that match multiple courses within an organization.
@@ -770,7 +770,7 @@ class OrgLevelCourseGlob(CourseOverviewData):
770770
- Cannot have wildcards at course or run level (course-v1:ORG+COURSE* is invalid)
771771
772772
Examples:
773-
>>> glob = OrgLevelCourseGlob(external_key='course-v1:OpenedX*')
773+
>>> glob = OrgCourseGlobData(external_key='course-v1:OpenedX*')
774774
>>> glob.org
775775
'OpenedX'
776776

openedx_authz/tests/test_enforcement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ class OrgGlobEnforcementTests(CasbinEnforcementTestCase):
639639
{
640640
"subject": make_user_key("user-2"),
641641
"action": make_action_key(permissions.VIEW_LIBRARY.action.external_key),
642-
"scope": make_library_key("lib:DemoX:OrgLevelGlobLib"),
642+
"scope": make_library_key("lib:DemoX:OrgGlobLib"),
643643
"expected_result": True,
644644
},
645645
# Permission denied
@@ -652,7 +652,7 @@ class OrgGlobEnforcementTests(CasbinEnforcementTestCase):
652652
{
653653
"subject": make_user_key("user-2"),
654654
"action": make_action_key(permissions.VIEW_LIBRARY.action.external_key),
655-
"scope": make_library_key("lib:InexistentOrg:OrgLevelGlobLib"),
655+
"scope": make_library_key("lib:InexistentOrg:OrgGlobLib"),
656656
"expected_result": False,
657657
},
658658
]

0 commit comments

Comments
 (0)