33import pytest
44from tests .utils .syncify import syncify
55from workos .authorization import AsyncAuthorization , Authorization
6+ from workos .types .authorization .resource_identifier import (
7+ ResourceIdentifierByExternalId ,
8+ ResourceIdentifierById ,
9+ )
610
711
812@pytest .mark .sync_and_async (Authorization , AsyncAuthorization )
@@ -31,7 +35,7 @@ def test_check_authorized(
3135 self .authorization .check (
3236 "om_01ABC" ,
3337 permission_slug = "documents:read" ,
34- resource_id = "res_01ABC" ,
38+ resource = ResourceIdentifierById ( resource_id = "res_01ABC" ) ,
3539 )
3640 )
3741
@@ -52,7 +56,7 @@ def test_check_unauthorized(
5256 self .authorization .check (
5357 "om_01ABC" ,
5458 permission_slug = "documents:write" ,
55- resource_id = "res_01ABC" ,
59+ resource = ResourceIdentifierById ( resource_id = "res_01ABC" ) ,
5660 )
5761 )
5862
@@ -70,7 +74,7 @@ def test_check_with_resource_id(
7074 self .authorization .check (
7175 "om_01ABC" ,
7276 permission_slug = "documents:read" ,
73- resource_id = "res_01XYZ" ,
77+ resource = ResourceIdentifierById ( resource_id = "res_01XYZ" ) ,
7478 )
7579 )
7680
@@ -90,8 +94,10 @@ def test_check_with_resource_external_id(
9094 self .authorization .check (
9195 "om_01ABC" ,
9296 permission_slug = "documents:read" ,
93- resource_external_id = "ext_doc_123" ,
94- resource_type_slug = "document" ,
97+ resource = ResourceIdentifierByExternalId (
98+ resource_external_id = "ext_doc_123" ,
99+ resource_type_slug = "document" ,
100+ ),
95101 )
96102 )
97103
@@ -112,32 +118,10 @@ def test_check_url_construction(
112118 self .authorization .check (
113119 "om_01MEMBERSHIP" ,
114120 permission_slug = "admin:access" ,
121+ resource = ResourceIdentifierById (resource_id = "res_01ABC" ),
115122 )
116123 )
117124
118125 assert request_kwargs ["url" ].endswith (
119126 "/authorization/organization_memberships/om_01MEMBERSHIP/check"
120127 )
121- assert request_kwargs ["json" ] == {"permission_slug" : "admin:access" }
122-
123- def test_check_raises_when_both_resource_identifiers_provided (self ):
124- with pytest .raises (ValueError , match = "mutually exclusive" ):
125- syncify (
126- self .authorization .check (
127- "om_01ABC" ,
128- permission_slug = "documents:read" ,
129- resource_id = "res_01ABC" ,
130- resource_external_id = "ext_doc_123" ,
131- resource_type_slug = "document" ,
132- )
133- )
134-
135- def test_check_raises_when_external_id_without_type_slug (self ):
136- with pytest .raises (ValueError , match = "resource_type_slug is required" ):
137- syncify (
138- self .authorization .check (
139- "om_01ABC" ,
140- permission_slug = "documents:read" ,
141- resource_external_id = "ext_doc_123" ,
142- )
143- )
0 commit comments