Skip to content

Commit

Permalink
tests: use lists of strings for Token.scope and AuthorizationCode.scope
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Nov 23, 2023
1 parent 7494800 commit c19199b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
10 changes: 4 additions & 6 deletions tests/oidc/commands/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ def test_clean_command(testclient, backend, client, user):
subject=user,
redirect_uri="https://foo.bar/callback",
response_type="code",
scope="openid profile",
scope=["openid", "profile"],
nonce="nonce",
issue_date=datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0),
lifetime=3600,
challenge="challenge",
challenge_method="method",
revokation="",
)
valid_code.save()
expired_code = models.AuthorizationCode(
Expand All @@ -29,7 +28,7 @@ def test_clean_command(testclient, backend, client, user):
subject=user,
redirect_uri="https://foo.bar/callback",
response_type="code",
scope="openid profile",
scope=["openid", "profile"],
nonce="nonce",
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
Expand All @@ -38,7 +37,6 @@ def test_clean_command(testclient, backend, client, user):
lifetime=3600,
challenge="challenge",
challenge_method="method",
revokation="",
)
expired_code.save()

Expand All @@ -48,7 +46,7 @@ def test_clean_command(testclient, backend, client, user):
client=client,
subject=user,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
),
Expand All @@ -61,7 +59,7 @@ def test_clean_command(testclient, backend, client, user):
client=client,
subject=user,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
- datetime.timedelta(days=1)
Expand Down
5 changes: 2 additions & 3 deletions tests/oidc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ def authorization(testclient, user, client, backend):
subject=user,
redirect_uri="https://foo.bar/callback",
response_type="code",
scope="openid profile",
scope=["openid", "profile"],
nonce="nonce",
issue_date=datetime.datetime(2020, 1, 1, tzinfo=datetime.timezone.utc),
lifetime=3600,
challenge="challenge",
challenge_method="method",
revokation="",
)
a.save()
yield a
Expand All @@ -144,7 +143,7 @@ def token(testclient, client, user, backend):
subject=user,
token_type=None,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=datetime.datetime.now(datetime.timezone.utc),
lifetime=3600,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/oidc/test_token_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_token_list_pagination(testclient, logged_admin, client):
subject=logged_admin,
type=None,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
),
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_token_list_search(testclient, logged_admin, client):
subject=logged_admin,
type=None,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
),
Expand All @@ -95,7 +95,7 @@ def test_token_list_search(testclient, logged_admin, client):
subject=logged_admin,
type=None,
refresh_token=gen_salt(48),
scope="openid profile",
scope=["openid", "profile"],
issue_date=(
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0)
),
Expand Down
4 changes: 2 additions & 2 deletions tests/oidc/test_userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_userinfo(testclient, token, user, foo_group):


def test_generate_user_standard_claims_with_default_config(testclient, backend, user):
user.preferred_language = ["fr"]
user.preferred_language = "fr"

data = generate_user_claims(user, STANDARD_CLAIMS, DEFAULT_JWT_MAPPING)

Expand Down Expand Up @@ -294,7 +294,7 @@ def test_custom_config_format_claim_is_well_formated(testclient, backend, user):
def test_claim_is_omitted_if_empty(testclient, backend, user):
# According to https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
# it's better to not insert a null or empty string value
user.emails = ""
user.emails = []
user.save()

data = generate_user_claims(user, STANDARD_CLAIMS, DEFAULT_JWT_MAPPING)
Expand Down

0 comments on commit c19199b

Please sign in to comment.