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