@@ -196,6 +196,8 @@ def _test_username_password(self,
196
196
azure_region = azure_region , # Regional endpoint does not support ROPC.
197
197
# Here we just use it to test a regional app won't break ROPC.
198
198
client_credential = client_secret )
199
+ self .assertEqual (
200
+ self .app .get_accounts (username = username ), [], "Cache starts empty" )
199
201
result = self .app .acquire_token_by_username_password (
200
202
username , password , scopes = scope )
201
203
self .assertLoosely (result )
@@ -204,6 +206,9 @@ def _test_username_password(self,
204
206
username = username , # Our implementation works even when "profile" scope was not requested, or when profile claims is unavailable in B2C
205
207
)
206
208
209
+ @unittest .skipIf (
210
+ os .getenv ("TRAVIS" ), # It is set when running on TravisCI or Github Actions
211
+ "Although it is doable, we still choose to skip device flow to save time" )
207
212
def _test_device_flow (
208
213
self , client_id = None , authority = None , scope = None , ** ignored ):
209
214
assert client_id and authority and scope
@@ -229,6 +234,7 @@ def _test_device_flow(
229
234
logger .info (
230
235
"%s obtained tokens: %s" , self .id (), json .dumps (result , indent = 4 ))
231
236
237
+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
232
238
def _test_acquire_token_interactive (
233
239
self , client_id = None , authority = None , scope = None , port = None ,
234
240
username = None , lab_name = None ,
@@ -289,7 +295,6 @@ def test_ssh_cert_for_service_principal(self):
289
295
result .get ("error" ), result .get ("error_description" )))
290
296
self .assertEqual ("ssh-cert" , result ["token_type" ])
291
297
292
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
293
298
def test_ssh_cert_for_user_should_work_with_any_account (self ):
294
299
result = self ._test_acquire_token_interactive (
295
300
client_id = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" , # Azure CLI is one
@@ -524,8 +529,8 @@ def tearDownClass(cls):
524
529
cls .session .close ()
525
530
526
531
@classmethod
527
- def get_lab_app_object (cls , ** query ): # https://msidlab.com/swagger/index.html
528
- url = "https://msidlab.com/api/app"
532
+ def get_lab_app_object (cls , client_id = None , ** query ): # https://msidlab.com/swagger/index.html
533
+ url = "https://msidlab.com/api/app/{}" . format ( client_id or "" )
529
534
resp = cls .session .get (url , params = query )
530
535
result = resp .json ()[0 ]
531
536
result ["scopes" ] = [ # Raw data has extra space, such as "s1, s2"
@@ -561,6 +566,7 @@ def get_lab_user(cls, **query): # https://docs.msidlab.com/labapi/userapi.html
561
566
"scope" : scope ,
562
567
}
563
568
569
+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
564
570
def _test_acquire_token_by_auth_code (
565
571
self , client_id = None , authority = None , port = None , scope = None ,
566
572
** ignored ):
@@ -583,6 +589,7 @@ def _test_acquire_token_by_auth_code(
583
589
error_description = result .get ("error_description" )))
584
590
self .assertCacheWorksForUser (result , scope , username = None )
585
591
592
+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
586
593
def _test_acquire_token_by_auth_code_flow (
587
594
self , client_id = None , authority = None , port = None , scope = None ,
588
595
username = None , lab_name = None ,
@@ -723,11 +730,9 @@ def test_adfs2019_fed_user(self):
723
730
self .skipTest ("MEX endpoint in our test environment tends to fail" )
724
731
raise
725
732
726
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
727
733
def test_cloud_acquire_token_interactive (self ):
728
734
self ._test_acquire_token_interactive (** self .get_lab_user (usertype = "cloud" ))
729
735
730
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
731
736
def test_msa_pt_app_signin_via_organizations_authority_without_login_hint (self ):
732
737
"""There is/was an upstream bug. See test case full docstring for the details.
733
738
@@ -751,7 +756,6 @@ def test_ropc_adfs2019_onprem(self):
751
756
config ["password" ] = self .get_lab_user_secret (config ["lab_name" ])
752
757
self ._test_username_password (** config )
753
758
754
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
755
759
def test_adfs2019_onprem_acquire_token_by_auth_code (self ):
756
760
"""When prompted, you can manually login using this account:
757
761
@@ -765,7 +769,6 @@ def test_adfs2019_onprem_acquire_token_by_auth_code(self):
765
769
config ["port" ] = 8080
766
770
self ._test_acquire_token_by_auth_code (** config )
767
771
768
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
769
772
def test_adfs2019_onprem_acquire_token_by_auth_code_flow (self ):
770
773
config = self .get_lab_user (usertype = "onprem" , federationProvider = "ADFSv2019" )
771
774
self ._test_acquire_token_by_auth_code_flow (** dict (
@@ -775,7 +778,6 @@ def test_adfs2019_onprem_acquire_token_by_auth_code_flow(self):
775
778
port = 8080 ,
776
779
))
777
780
778
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
779
781
def test_adfs2019_onprem_acquire_token_interactive (self ):
780
782
config = self .get_lab_user (usertype = "onprem" , federationProvider = "ADFSv2019" )
781
783
self ._test_acquire_token_interactive (** dict (
@@ -846,7 +848,6 @@ def _build_b2c_authority(self, policy):
846
848
base = "https://msidlabb2c.b2clogin.com/msidlabb2c.onmicrosoft.com"
847
849
return base + "/" + policy # We do not support base + "?p=" + policy
848
850
849
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
850
851
def test_b2c_acquire_token_by_auth_code (self ):
851
852
"""
852
853
When prompted, you can manually login using this account:
@@ -863,7 +864,6 @@ def test_b2c_acquire_token_by_auth_code(self):
863
864
scope = config ["scopes" ],
864
865
)
865
866
866
- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
867
867
def test_b2c_acquire_token_by_auth_code_flow (self ):
868
868
self ._test_acquire_token_by_auth_code_flow (** dict (
869
869
self .get_lab_user (usertype = "b2c" , b2cprovider = "local" ),
0 commit comments