Skip to content

Commit f91b018

Browse files
duzumakidopry
authored andcommitted
Add incorrect client id test
1 parent 338b082 commit f91b018

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
@@ -136,3 +136,25 @@ def test_device_polling_interval_can_be_changed(self):
136136
"device_code": "abc",
137137
"interval": 10,
138138
}
139+
140+
def test_incorrect_client_id_sent(self):
141+
"""
142+
Ensure the correct error is returned when an invalid client is sent
143+
"""
144+
request_data: dict[str, str] = {
145+
"client_id": "client_id_that_does_not_exist",
146+
}
147+
request_as_x_www_form_urlencoded: str = urlencode(request_data)
148+
149+
response: django.http.response.JsonResponse = self.client.post(
150+
reverse("oauth2_provider:device-authorization"),
151+
data=request_as_x_www_form_urlencoded,
152+
content_type="application/x-www-form-urlencoded",
153+
)
154+
155+
assert response.status_code == 400
156+
157+
assert response.json() == {
158+
"error": "invalid_request",
159+
"error_description": "Invalid client_id parameter value.",
160+
}

0 commit comments

Comments
 (0)