@@ -257,6 +257,8 @@ def test_pre_auth_default_redirect(self):
257257 Test for default redirect uri if omitted from query string with response_type: code
258258 """
259259 self .client .login (username = "test_user" , password = "123456" )
260+ self .application .redirect_uris = "http://localhost"
261+ self .application .save ()
260262
261263 query_data = {
262264 "client_id" : self .application .client_id ,
@@ -269,6 +271,21 @@ def test_pre_auth_default_redirect(self):
269271 form = response .context ["form" ]
270272 self .assertEqual (form ["redirect_uri" ].value (), "http://localhost" )
271273
274+ def test_pre_auth_missing_redirect (self ):
275+ """
276+ Test response if redirect_uri is missing and multiple URIs are registered.
277+ @see https://datatracker.ietf.org/doc/html/rfc6749#section-3.1.2.3
278+ """
279+ self .client .login (username = "test_user" , password = "123456" )
280+
281+ query_data = {
282+ "client_id" : self .application .client_id ,
283+ "response_type" : "code" ,
284+ }
285+
286+ response = self .client .get (reverse ("oauth2_provider:authorize" ), data = query_data )
287+ self .assertEqual (response .status_code , 400 )
288+
272289 def test_pre_auth_forbibben_redirect (self ):
273290 """
274291 Test error when passing a forbidden redirect_uri in query string with response_type: code
@@ -293,6 +310,7 @@ def test_pre_auth_wrong_response_type(self):
293310 query_data = {
294311 "client_id" : self .application .client_id ,
295312 "response_type" : "WRONG" ,
313+ "redirect_uri" : "http://example.org" ,
296314 }
297315
298316 response = self .client .get (reverse ("oauth2_provider:authorize" ), data = query_data )
0 commit comments