Skip to content

Commit

Permalink
tests: missing client_id on OIDC authorization page
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Sep 13, 2024
1 parent 5149b96 commit 001d635
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion canaille/oidc/endpoints/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def authorize():
request.form.to_dict(flat=False),
)

client = Backend.instance.get(models.Client, client_id=request.args["client_id"])
client = Backend.instance.get(
models.Client, client_id=request.args.get("client_id")
)
user = current_user()

if response := authorize_guards(client):
Expand Down
17 changes: 17 additions & 0 deletions tests/oidc/test_authorization_code_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,3 +763,20 @@ def test_locked_account(
)

assert "access_token" not in res.json


def test_missing_client_id(
testclient, logged_user, client, keypair, trusted_client, backend
):
"""Missing client_id should raise a 400 error."""

res = testclient.get(
"/oauth/authorize",
params=dict(
response_type="code",
scope="openid profile email groups address phone",
nonce="somenonce",
),
status=400,
)
res.mustcontain("client_id parameter is missing.")

0 comments on commit 001d635

Please sign in to comment.