-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #984 from sirosen/add-query-params
Add 'query_params' to token introspect
- Loading branch information
Showing
4 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Added | ||
~~~~~ | ||
|
||
- Add support for added query parameters to | ||
``ConfidentialAppAuthClient.oauth2_token_introspect`` via a ``query_params`` | ||
argument. (:pr:`NUMBER`) |
44 changes: 44 additions & 0 deletions
44
src/globus_sdk/_testing/data/auth/oauth2_token_introspect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import uuid | ||
|
||
from globus_sdk._testing.models import RegisteredResponse, ResponseSet | ||
|
||
_kingfish = { | ||
"username": "kingfish@globus.org", | ||
"name": "Christone Ingram", | ||
"id": str(uuid.uuid1()), | ||
"email": "kingfish@globus.org", | ||
} | ||
_client_id = str(uuid.uuid1()) | ||
_scope = "urn:globus:auth:scope:auth.globus.org:view_identity_set profile email openid" | ||
|
||
|
||
RESPONSES = ResponseSet( | ||
default=RegisteredResponse( | ||
service="auth", | ||
path="/v2/oauth2/token/introspect", | ||
method="POST", | ||
json={ | ||
"active": True, | ||
"token_type": "Bearer", | ||
"scope": _scope, | ||
"client_id": _client_id, | ||
"username": _kingfish["username"], | ||
"name": _kingfish["name"], | ||
"email": _kingfish["email"], | ||
"exp": 1715289767, | ||
"iat": 1715116967, | ||
"nbf": 1715116967, | ||
"sub": _kingfish["id"], | ||
"aud": [ | ||
"auth.globus.org", | ||
_client_id, | ||
], | ||
"iss": "https://auth.globus.org", | ||
}, | ||
metadata={ | ||
"client_id": _client_id, | ||
"scope": _scope, | ||
**_kingfish, | ||
}, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 21 additions & 4 deletions
25
tests/functional/services/auth/confidential_client/test_oauth2_token_introspect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
import pytest | ||
from globus_sdk._testing import get_last_request, load_response | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_oauth2_token_introspect(): | ||
raise NotImplementedError | ||
def test_oauth2_token_introspect(auth_client): | ||
meta = load_response(auth_client.oauth2_token_introspect).metadata | ||
response = auth_client.oauth2_token_introspect("some_very_cool_token") | ||
assert response["username"] == meta["username"] | ||
assert response["sub"] == meta["id"] | ||
|
||
last_req = get_last_request() | ||
assert len(last_req.params) == 0 | ||
|
||
|
||
def test_oauth2_token_introspect_allows_added_query_params(auth_client): | ||
meta = load_response(auth_client.oauth2_token_introspect).metadata | ||
response = auth_client.oauth2_token_introspect( | ||
"some_very_cool_token", query_params={"foo": "bar"} | ||
) | ||
assert response["username"] == meta["username"] | ||
assert response["sub"] == meta["id"] | ||
|
||
last_req = get_last_request() | ||
assert last_req.params["foo"] == "bar" |