@@ -132,10 +132,9 @@ def _test_username_password(self,
132132 result = self .app .acquire_token_by_username_password (
133133 username , password , scopes = scope )
134134 self .assertLoosely (result )
135- # self.assertEqual(None, result.get("error"), str(result))
136135 self .assertCacheWorksForUser (
137136 result , scope ,
138- username = username if ".b2clogin.com" not in authority else None ,
137+ username = username , # Our implementation works even when "profile" scope was not requested, or when profile claims is unavailable in B2C
139138 )
140139
141140 def _test_device_flow (
@@ -554,11 +553,13 @@ def _test_acquire_token_obo(self, config_pca, config_cca):
554553 # Assuming you already did that (which is not shown in this test case),
555554 # the following part shows one of the ways to obtain an AT from cache.
556555 username = cca_result .get ("id_token_claims" , {}).get ("preferred_username" )
557- self .assertEqual (config_cca ["username" ], username )
558- if username : # A precaution so that we won't use other user's token
559- account = cca .get_accounts (username = username )[0 ]
560- result = cca .acquire_token_silent (config_cca ["scope" ], account )
561- self .assertEqual (cca_result ["access_token" ], result ["access_token" ])
556+ if username : # It means CCA have requested an IDT w/ "profile" scope
557+ self .assertEqual (config_cca ["username" ], username )
558+ accounts = cca .get_accounts (username = username )
559+ assert len (accounts ) == 1 , "App is expected to partition token cache per user"
560+ account = accounts [0 ]
561+ result = cca .acquire_token_silent (config_cca ["scope" ], account )
562+ self .assertEqual (cca_result ["access_token" ], result ["access_token" ])
562563
563564 def _test_acquire_token_by_client_secret (
564565 self , client_id = None , client_secret = None , authority = None , scope = None ,
0 commit comments