Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/flask_op/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
}
},
"id_token": {
"class": "oidcop.id_token.IDToken",
"class": "oidcop.token.id_token.IDToken",
"kwargs": {
"default_claims": {
"email": {
Expand Down
35 changes: 24 additions & 11 deletions tests/test_01_session_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from oidcop.session.token import AccessToken
from oidcop.session.token import AuthorizationCode
from oidcop.session.token import IDToken


def test_authorization_code_default():
Expand Down Expand Up @@ -36,23 +37,35 @@ def test_authorization_code_extras():
assert code.resources == ["https://api.example.com"]


def test_dump_load():
code = AuthorizationCode(
value="ABCD",
scope=["openid", "foo", "bar"],
claims={"userinfo": {"given_name": None}},
resources=["https://api.example.com"],
)
def test_dump_load(cls=AuthorizationCode,
kwargs=dict(
value="ABCD",
scope=["openid", "foo", "bar"],
claims={"userinfo": {"given_name": None}},
resources=["https://api.example.com"],
)
):
code = cls(**kwargs)

_item = code.dump()

_new_code = AuthorizationCode().load(_item)

for attr in AuthorizationCode.parameter.keys():
_new_code = cls().load(_item)
for attr in cls.parameter.keys():
val = getattr(code, attr)
if val:
assert val == getattr(_new_code, attr)

def test_dump_load_access_token():
test_dump_load(
cls=AccessToken,
kwargs={}
)

def test_dump_load_idtoken():
test_dump_load(
cls=IDToken,
kwargs={}
)


def test_supports_minting():
code = AuthorizationCode(value="ABCD")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_05_id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ def _mint_code(self, grant, session_id):
)

def _mint_access_token(self, grant, session_id, token_ref):
return grant.mint_token(
access_token = grant.mint_token(
session_id=session_id,
endpoint_context=self.endpoint_context,
token_type="access_token",
token_handler=self.session_manager.token_handler["access_token"],
expires_at=time_sans_frac() + 900, # 15 minutes from now
based_on=token_ref, # Means the token (tok) was used to mint this token
)
return access_token

def _mint_id_token(
self, grant, session_id, token_ref=None, code=None, access_token=None
Expand Down