Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 7d9d288

Browse files
committed
Add tests for Token Exchange classes
1 parent 2b68bba commit 7d9d288

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_05_oauth2.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from oidcmsg.oauth2 import CCAccessTokenRequest
2121
from oidcmsg.oauth2 import ROPCAccessTokenRequest
2222
from oidcmsg.oauth2 import RefreshAccessTokenRequest
23+
from oidcmsg.oauth2 import TokenExchangeRequest
24+
from oidcmsg.oauth2 import TokenExchangeResponse
2325
from oidcmsg.oauth2 import ResponseMessage
2426
from oidcmsg.oauth2 import TokenErrorResponse
2527
from oidcmsg.oauth2 import factory
@@ -505,6 +507,45 @@ def test_init(self):
505507
assert ratr.verify()
506508

507509

510+
class TestTokenExchangeRequest(object):
511+
def test_init(self):
512+
request = TokenExchangeRequest(
513+
grant_type="urn:ietf:params:oauth:grant-type:token-exchange",
514+
subject_token="ababababab",
515+
subject_token_type="urn:ietf:params:oauth:token-type:access_token"
516+
)
517+
assert (
518+
request["grant_type"]
519+
== "urn:ietf:params:oauth:grant-type:token-exchange"
520+
)
521+
assert request["subject_token"] == "ababababab"
522+
assert (
523+
request["subject_token_type"]
524+
== "urn:ietf:params:oauth:token-type:access_token"
525+
)
526+
527+
assert request.verify()
528+
529+
530+
class TestTokenExchangeResponse(object):
531+
def test_init(self):
532+
response = TokenExchangeResponse(
533+
access_token="bababababa",
534+
issued_token_type="urn:ietf:params:oauth:token-type:access_token",
535+
token_type="Bearer",
536+
expires_in=60
537+
)
538+
assert (
539+
response["issued_token_type"]
540+
== "urn:ietf:params:oauth:token-type:access_token"
541+
)
542+
assert response["access_token"] == "bababababa"
543+
assert response["token_type"] == "Bearer"
544+
assert response["expires_in"] == 60
545+
546+
assert response.verify()
547+
548+
508549
class TestResponseMessage_error(object):
509550
def test_error_message(self):
510551
err = ResponseMessage(error="invalid_request",

0 commit comments

Comments
 (0)