| 1 |
import urllib.parse |
| 2 |
|
| 3 |
from globus_sdk.scopes import Scope |
| 4 |
from globus_sdk.testing import get_last_request, load_response |
| 5 |
|
| 6 |
|
| 7 |
def test_oauth2_client_credentials_tokens(auth_client): |
| 8 |
meta = load_response(auth_client.oauth2_client_credentials_tokens).metadata |
| 9 |
|
| 10 |
response = auth_client.oauth2_client_credentials_tokens(meta["scope"]) |
| 11 |
assert ( |
| 12 |
response.by_resource_server[meta["resource_server"]]["access_token"] |
| 13 |
== meta["access_token"] |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
def test_oauth2_client_credentials_tokens_can_accept_scope_object(auth_client): |
| 18 |
meta = load_response(auth_client.oauth2_client_credentials_tokens).metadata |
| 19 |
|
| 20 |
response = auth_client.oauth2_client_credentials_tokens(Scope(meta["scope"])) |
| 21 |
assert ( |
| 22 |
response.by_resource_server[meta["resource_server"]]["access_token"] |
| 23 |
== meta["access_token"] |
| 24 |
) |
| 25 |
|
| 26 |
last_req = get_last_request() |
| 27 |
assert last_req.body |
| 28 |
body = last_req.body |
| 29 |
assert body != "" |
| 30 |
parsed_body = urllib.parse.parse_qs(body) |
| 31 |
assert parsed_body["scope"] == [meta["scope"]] |