Debian Codegraph @

tests/functional/services/auth/confidential_client/test_create_child_client.py

raw
1 from __future__ import annotations
2
3 import pytest
4
5 from globus_sdk import GlobusSDKUsageError
6 from globus_sdk.testing import load_response
7
8
9 @pytest.mark.parametrize(
10 "case_name",
11 (
12 "name",
13 "public_client",
14 "private_client",
15 "publicly_visible",
16 "not_publicly_visible",
17 "redirect_uris",
18 "links",
19 "required_idp",
20 "preselect_idp",
21 "client_type_confidential_client",
22 "client_type_public_installed_client",
23 "client_type_client_identity",
24 "client_type_resource_server",
25 "client_type_globus_connect_server",
26 "client_type_hybrid_confidential_client_resource_server",
27 "client_type_public_webapp_client",
28 ),
29 )
30 def test_create_child_client_args(
31 auth_client,
32 case_name: str,
33 ):
34 meta = load_response(auth_client.create_child_client, case=case_name).metadata
35
36 res = auth_client.create_child_client(**meta["args"])
37 for k, v in meta["response"].items():
38 assert res["client"][k] == v
39
40
41 def test_links_requirement(auth_client):
42 """
43 Verify that terms_and_conditions and privacy_policy must be used together.
44 """
45 with pytest.raises(GlobusSDKUsageError):
46 auth_client.create_child_client(
47 "FOO",
48 visibility="public",
49 terms_and_conditions="https://foo.net",
50 )
51
52 with pytest.raises(GlobusSDKUsageError):
53 auth_client.create_child_client(
54 "FOO",
55 visibility="public",
56 privacy_policy="https://foo.net",
57 )
58
59
60 def test_public_client_and_client_type_requirement(auth_client):
61 """
62 Verify that exactly one of ``public_client` and ``client_type`` are expected.
63 """
64 # Neither public_client nor client_type
65 with pytest.raises(GlobusSDKUsageError):
66 auth_client.create_child_client(
67 "FOO",
68 )
69
70 # Both public_client and client_type
71 with pytest.raises(GlobusSDKUsageError):
72 auth_client.create_child_client(
73 "FOO",
74 public_client=True,
75 client_type="GCS",
76 )