Debian Codegraph @

tests/functional/scopes/test_scope_data_behaviors.py

raw
1 import uuid
2
3 import pytest
4
5 from globus_sdk.scopes import (
6 AuthScopes,
7 ComputeScopes,
8 FlowsScopes,
9 GCSCollectionScopes,
10 GCSEndpointScopes,
11 GroupsScopes,
12 NexusScopes,
13 Scope,
14 SearchScopes,
15 SpecificFlowScopes,
16 TimersScopes,
17 TransferScopes,
18 )
19
20
21 @pytest.mark.parametrize(
22 "collection, expect_resource_server",
23 (
24 (AuthScopes, "auth.globus.org"),
25 (ComputeScopes, "funcx_service"),
26 (FlowsScopes, "flows.globus.org"),
27 (GroupsScopes, "groups.api.globus.org"),
28 (NexusScopes, "nexus.api.globus.org"),
29 (SearchScopes, "search.api.globus.org"),
30 (TimersScopes, "524230d7-ea86-4a52-8312-86065a9e0417"),
31 (TransferScopes, "transfer.api.globus.org"),
32 ),
33 )
34 def test_static_resource_server_attributes(collection, expect_resource_server):
35 assert collection.resource_server == expect_resource_server
36
37
38 @pytest.mark.parametrize(
39 "collection_cls", (GCSEndpointScopes, GCSCollectionScopes, SpecificFlowScopes)
40 )
41 def test_dynamic_resource_server_attributes(collection_cls):
42 some_id = str(uuid.UUID(int=1))
43 coll = collection_cls(some_id)
44 assert coll.resource_server == some_id
45
46
47 def test_oidc_scope_formatting():
48 assert str(AuthScopes.openid) == "openid"
49 assert str(AuthScopes.email) == "email"
50 assert str(AuthScopes.profile) == "profile"
51
52
53 def test_non_oidc_auth_scope_formatting():
54 non_oidc_scopes = set(AuthScopes).difference(
55 (AuthScopes.openid, AuthScopes.email, AuthScopes.profile)
56 )
57
58 assert len(non_oidc_scopes) > 0
59 assert all(isinstance(x, Scope) for x in non_oidc_scopes)
60
61 scope_strs = [str(s) for s in non_oidc_scopes]
62 assert all(
63 s.startswith("urn:globus:auth:scope:auth.globus.org:") for s in scope_strs
64 )