@@ -58,6 +58,12 @@ def assertLoosely(self, response, assertion=None,
58
58
59
59
def assertCacheWorksForUser (
60
60
self , result_from_wire , scope , username = None , data = None ):
61
+ logger .debug (
62
+ "%s: cache = %s, id_token_claims = %s" ,
63
+ self .id (),
64
+ json .dumps (self .app .token_cache ._cache , indent = 4 ),
65
+ json .dumps (result_from_wire .get ("id_token_claims" ), indent = 4 ),
66
+ )
61
67
# You can filter by predefined username, or let end user to choose one
62
68
accounts = self .app .get_accounts (username = username )
63
69
self .assertNotEqual (0 , len (accounts ))
@@ -164,12 +170,6 @@ def _test_acquire_token_interactive(
164
170
</ol></body></html>""" .format (id = self .id (), username_uri = username_uri ),
165
171
data = data or {},
166
172
)
167
- logger .debug (
168
- "%s: cache = %s, id_token_claims = %s" ,
169
- self .id (),
170
- json .dumps (self .app .token_cache ._cache , indent = 4 ),
171
- json .dumps (result .get ("id_token_claims" ), indent = 4 ),
172
- )
173
173
self .assertIn (
174
174
"access_token" , result ,
175
175
"{error}: {error_description}" .format (
@@ -401,7 +401,10 @@ def tearDownClass(cls):
401
401
def get_lab_app_object (cls , ** query ): # https://msidlab.com/swagger/index.html
402
402
url = "https://msidlab.com/api/app"
403
403
resp = cls .session .get (url , params = query )
404
- return resp .json ()[0 ]
404
+ result = resp .json ()[0 ]
405
+ result ["scopes" ] = [ # Raw data has extra space, such as "s1, s2"
406
+ s .strip () for s in result ["defaultScopes" ].split (',' )]
407
+ return result
405
408
406
409
@classmethod
407
410
def get_lab_user_secret (cls , lab_name = "msidlab4" ):
@@ -698,7 +701,7 @@ def test_b2c_acquire_token_by_auth_code(self):
698
701
authority = self ._build_b2c_authority ("B2C_1_SignInPolicy" ),
699
702
client_id = config ["appId" ],
700
703
port = 3843 , # Lab defines 4 of them: [3843, 4584, 4843, 60000]
701
- scope = config ["defaultScopes" ]. split ( ',' ) ,
704
+ scope = config ["scopes" ] ,
702
705
)
703
706
704
707
@unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
@@ -708,7 +711,7 @@ def test_b2c_acquire_token_by_auth_code_flow(self):
708
711
authority = self ._build_b2c_authority ("B2C_1_SignInPolicy" ),
709
712
client_id = config ["appId" ],
710
713
port = 3843 , # Lab defines 4 of them: [3843, 4584, 4843, 60000]
711
- scope = config ["defaultScopes" ]. split ( ',' ) ,
714
+ scope = config ["scopes" ] ,
712
715
username_uri = "https://msidlab.com/api/user?usertype=b2c&b2cprovider=local" ,
713
716
)
714
717
@@ -719,7 +722,7 @@ def test_b2c_acquire_token_by_ropc(self):
719
722
client_id = config ["appId" ],
720
723
721
724
password = self .get_lab_user_secret ("msidlabb2c" ),
722
- scope = config ["defaultScopes" ]. split ( ',' ) ,
725
+ scope = config ["scopes" ] ,
723
726
)
724
727
725
728
0 commit comments