@@ -196,6 +196,8 @@ def _test_username_password(self,
196196 azure_region = azure_region , # Regional endpoint does not support ROPC.
197197 # Here we just use it to test a regional app won't break ROPC.
198198 client_credential = client_secret )
199+ self .assertEqual (
200+ self .app .get_accounts (username = username ), [], "Cache starts empty" )
199201 result = self .app .acquire_token_by_username_password (
200202 username , password , scopes = scope )
201203 self .assertLoosely (result )
@@ -204,6 +206,9 @@ def _test_username_password(self,
204206 username = username , # Our implementation works even when "profile" scope was not requested, or when profile claims is unavailable in B2C
205207 )
206208
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" )
207212 def _test_device_flow (
208213 self , client_id = None , authority = None , scope = None , ** ignored ):
209214 assert client_id and authority and scope
@@ -229,6 +234,7 @@ def _test_device_flow(
229234 logger .info (
230235 "%s obtained tokens: %s" , self .id (), json .dumps (result , indent = 4 ))
231236
237+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
232238 def _test_acquire_token_interactive (
233239 self , client_id = None , authority = None , scope = None , port = None ,
234240 username = None , lab_name = None ,
@@ -289,7 +295,6 @@ def test_ssh_cert_for_service_principal(self):
289295 result .get ("error" ), result .get ("error_description" )))
290296 self .assertEqual ("ssh-cert" , result ["token_type" ])
291297
292- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
293298 def test_ssh_cert_for_user_should_work_with_any_account (self ):
294299 result = self ._test_acquire_token_interactive (
295300 client_id = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" , # Azure CLI is one
@@ -524,8 +529,8 @@ def tearDownClass(cls):
524529 cls .session .close ()
525530
526531 @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 "" )
529534 resp = cls .session .get (url , params = query )
530535 result = resp .json ()[0 ]
531536 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
561566 "scope" : scope ,
562567 }
563568
569+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
564570 def _test_acquire_token_by_auth_code (
565571 self , client_id = None , authority = None , port = None , scope = None ,
566572 ** ignored ):
@@ -583,6 +589,7 @@ def _test_acquire_token_by_auth_code(
583589 error_description = result .get ("error_description" )))
584590 self .assertCacheWorksForUser (result , scope , username = None )
585591
592+ @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
586593 def _test_acquire_token_by_auth_code_flow (
587594 self , client_id = None , authority = None , port = None , scope = None ,
588595 username = None , lab_name = None ,
@@ -723,11 +730,9 @@ def test_adfs2019_fed_user(self):
723730 self .skipTest ("MEX endpoint in our test environment tends to fail" )
724731 raise
725732
726- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
727733 def test_cloud_acquire_token_interactive (self ):
728734 self ._test_acquire_token_interactive (** self .get_lab_user (usertype = "cloud" ))
729735
730- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
731736 def test_msa_pt_app_signin_via_organizations_authority_without_login_hint (self ):
732737 """There is/was an upstream bug. See test case full docstring for the details.
733738
@@ -751,7 +756,6 @@ def test_ropc_adfs2019_onprem(self):
751756 config ["password" ] = self .get_lab_user_secret (config ["lab_name" ])
752757 self ._test_username_password (** config )
753758
754- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
755759 def test_adfs2019_onprem_acquire_token_by_auth_code (self ):
756760 """When prompted, you can manually login using this account:
757761
@@ -765,7 +769,6 @@ def test_adfs2019_onprem_acquire_token_by_auth_code(self):
765769 config ["port" ] = 8080
766770 self ._test_acquire_token_by_auth_code (** config )
767771
768- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
769772 def test_adfs2019_onprem_acquire_token_by_auth_code_flow (self ):
770773 config = self .get_lab_user (usertype = "onprem" , federationProvider = "ADFSv2019" )
771774 self ._test_acquire_token_by_auth_code_flow (** dict (
@@ -775,7 +778,6 @@ def test_adfs2019_onprem_acquire_token_by_auth_code_flow(self):
775778 port = 8080 ,
776779 ))
777780
778- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
779781 def test_adfs2019_onprem_acquire_token_interactive (self ):
780782 config = self .get_lab_user (usertype = "onprem" , federationProvider = "ADFSv2019" )
781783 self ._test_acquire_token_interactive (** dict (
@@ -846,7 +848,6 @@ def _build_b2c_authority(self, policy):
846848 base = "https://msidlabb2c.b2clogin.com/msidlabb2c.onmicrosoft.com"
847849 return base + "/" + policy # We do not support base + "?p=" + policy
848850
849- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
850851 def test_b2c_acquire_token_by_auth_code (self ):
851852 """
852853 When prompted, you can manually login using this account:
@@ -863,7 +864,6 @@ def test_b2c_acquire_token_by_auth_code(self):
863864 scope = config ["scopes" ],
864865 )
865866
866- @unittest .skipIf (os .getenv ("TRAVIS" ), "Browser automation is not yet implemented" )
867867 def test_b2c_acquire_token_by_auth_code_flow (self ):
868868 self ._test_acquire_token_by_auth_code_flow (** dict (
869869 self .get_lab_user (usertype = "b2c" , b2cprovider = "local" ),
0 commit comments