@@ -330,7 +330,7 @@ def test_oauth_redir_2016(self):
330330 self .assertEqual (qs , qs_expected )
331331
332332 @mock_adfs ("azure" )
333- def test_oauth_redir_azure (self ):
333+ def test_oauth_redir_azure_version_one (self ):
334334 from django_auth_adfs .config import django_settings
335335 settings = deepcopy (django_settings )
336336 del settings .AUTH_ADFS ["SERVER" ]
@@ -355,6 +355,32 @@ def test_oauth_redir_azure(self):
355355 self .assertEqual (redir .path .rstrip ("/" ), '/01234567-89ab-cdef-0123-456789abcdef/oauth2/authorize' )
356356 self .assertEqual (qs , sq_expected )
357357
358+ @mock_adfs ("azure" )
359+ def test_oauth_redir_azure_version_two (self ):
360+ from django_auth_adfs .config import django_settings
361+ settings = deepcopy (django_settings )
362+ del settings .AUTH_ADFS ["SERVER" ]
363+ settings .AUTH_ADFS ["TENANT_ID" ] = "dummy_tenant_id"
364+ settings .AUTH_ADFS ["VERSION" ] = 'v2.0'
365+ with patch ("django_auth_adfs.config.django_settings" , settings ), \
366+ patch ("django_auth_adfs.config.settings" , Settings ()), \
367+ patch ("django_auth_adfs.views.provider_config" , ProviderConfig ()):
368+ response = self .client .get ("/oauth2/login?next=/test/" )
369+ self .assertEqual (response .status_code , 302 )
370+ redir = urlparse (response ["Location" ])
371+ qs = parse_qs (redir .query )
372+ sq_expected = {
373+ 'scope' : ['openid api://your-adfs-RPT-name/.default' ],
374+ 'client_id' : ['your-configured-client-id' ],
375+ 'state' : ['L3Rlc3Qv' ],
376+ 'response_type' : ['code' ],
377+ 'redirect_uri' : ['http://testserver/oauth2/callback' ]
378+ }
379+ self .assertEqual (redir .scheme , 'https' )
380+ self .assertEqual (redir .hostname , 'login.microsoftonline.com' )
381+ self .assertEqual (redir .path .rstrip ("/" ), '/01234567-89ab-cdef-0123-456789abcdef/oauth2/authorize' )
382+ self .assertEqual (qs , sq_expected )
383+
358384 @mock_adfs ("2016" )
359385 def test_inactive_user (self ):
360386 user = User .objects .create (** {
0 commit comments