Skip to content

Commit 67dafbf

Browse files
committed
Add incorrect client id test
1 parent 951863f commit 67dafbf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_device.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,25 @@ def test_device_polling_interval_can_be_changed(self):
131131
"device_code": "abc",
132132
"interval": 10,
133133
}
134+
135+
def test_incorrect_client_id_sent(self):
136+
"""
137+
Ensure the correct error is returned when an invalid client is sent
138+
"""
139+
request_data: dict[str, str] = {
140+
"client_id": "client_id_that_does_not_exist",
141+
}
142+
request_as_x_www_form_urlencoded: str = urlencode(request_data)
143+
144+
response: django.http.response.JsonResponse = self.client.post(
145+
reverse("oauth2_provider:device-authorization"),
146+
data=request_as_x_www_form_urlencoded,
147+
content_type="application/x-www-form-urlencoded",
148+
)
149+
150+
assert response.status_code == 400
151+
152+
assert response.json() == {
153+
"error": "invalid_request",
154+
"error_description": "Invalid client_id parameter value.",
155+
}

0 commit comments

Comments
 (0)