Skip to content

Commit c58db08

Browse files
committed
added test case for #238
1 parent 27fe47b commit c58db08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

oauth2_provider/tests/test_authorization_code.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,27 @@ def test_code_post_auth_redirection_uri_with_querystring(self):
423423
self.assertIn("http://example.com?foo=bar", response['Location'])
424424
self.assertIn("code=", response['Location'])
425425

426+
def test_code_post_auth_failing_redirection_uri_with_querystring(self):
427+
"""
428+
Test that in case of error the querystring of the redirection uri is preserved
429+
430+
See https://github.com/evonove/django-oauth-toolkit/issues/238
431+
"""
432+
self.client.login(username="test_user", password="123456")
433+
434+
form_data = {
435+
'client_id': self.application.client_id,
436+
'state': 'random_state_string',
437+
'scope': 'read write',
438+
'redirect_uri': 'http://example.com?foo=bar',
439+
'response_type': 'code',
440+
'allow': False,
441+
}
442+
443+
response = self.client.post(reverse('oauth2_provider:authorize'), data=form_data)
444+
self.assertEqual(response.status_code, 302)
445+
self.assertEqual("http://example.com?foo=bar&error=access_denied", response['Location'])
446+
426447
def test_code_post_auth_fails_when_redirect_uri_path_is_invalid(self):
427448
"""
428449
Tests that a redirection uri is matched using scheme + netloc + path

0 commit comments

Comments
 (0)