@@ -536,6 +536,7 @@ def test_login_in_cloud_shell(self, cloud_shell_credential_mock, create_subscrip
536536
537537 @mock .patch ('requests.get' , autospec = True )
538538 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
539+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
539540 def test_login_with_mi_system_assigned (self , create_subscription_client_mock , mock_get ):
540541 mock_subscription_client = mock .MagicMock ()
541542 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -569,6 +570,7 @@ def test_login_with_mi_system_assigned(self, create_subscription_client_mock, mo
569570
570571 @mock .patch ('requests.get' , autospec = True )
571572 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
573+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
572574 def test_login_with_mi_no_subscriptions (self , create_subscription_client_mock , mock_get ):
573575 mock_subscription_client = mock .MagicMock ()
574576 mock_subscription_client .subscriptions .list .return_value = []
@@ -604,6 +606,7 @@ def test_login_with_mi_no_subscriptions(self, create_subscription_client_mock, m
604606
605607 @mock .patch ('requests.get' , autospec = True )
606608 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
609+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
607610 def test_login_with_mi_user_assigned_client_id (self , create_subscription_client_mock , mock_get ):
608611 mock_subscription_client = mock .MagicMock ()
609612 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -651,6 +654,7 @@ def test_login_with_mi_user_assigned_client_id(self, create_subscription_client_
651654
652655 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , autospec = True )
653656 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
657+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
654658 def test_login_with_mi_user_assigned_object_id (self , create_subscription_client_mock ,
655659 mock_msi_auth ):
656660 mock_subscription_client = mock .MagicMock ()
@@ -699,6 +703,7 @@ def set_token(self):
699703
700704 @mock .patch ('requests.get' , autospec = True )
701705 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
706+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
702707 def test_login_with_mi_user_assigned_resource_id (self , create_subscription_client_mock ,
703708 mock_get ):
704709
@@ -740,7 +745,6 @@ def test_login_with_mi_user_assigned_resource_id(self, create_subscription_clien
740745
741746 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
742747 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
743- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
744748 def test_login_with_mi_system_assigned_msal (self , create_subscription_client_mock ):
745749 mock_subscription_client = mock .MagicMock ()
746750 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -768,7 +772,6 @@ def test_login_with_mi_system_assigned_msal(self, create_subscription_client_moc
768772
769773 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
770774 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
771- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
772775 def test_login_with_mi_system_assigned_no_subscriptions_msal (self , create_subscription_client_mock ):
773776 mock_subscription_client = mock .MagicMock ()
774777 mock_subscription_client .subscriptions .list .return_value = []
@@ -798,7 +801,6 @@ def test_login_with_mi_system_assigned_no_subscriptions_msal(self, create_subscr
798801
799802 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
800803 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
801- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
802804 def test_login_with_mi_user_assigned_client_id_msal (self , create_subscription_client_mock ):
803805 mock_subscription_client = mock .MagicMock ()
804806 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -827,7 +829,6 @@ def test_login_with_mi_user_assigned_client_id_msal(self, create_subscription_cl
827829
828830 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
829831 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
830- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
831832 def test_login_with_mi_user_assigned_object_id_msal (self , create_subscription_client_mock ):
832833 mock_subscription_client = mock .MagicMock ()
833834 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -851,7 +852,6 @@ def test_login_with_mi_user_assigned_object_id_msal(self, create_subscription_cl
851852
852853 @mock .patch ('azure.cli.core._profile.SubscriptionFinder._create_subscription_client' , autospec = True )
853854 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
854- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
855855 def test_login_with_mi_user_assigned_resource_id_msal (self , create_subscription_client_mock ):
856856 mock_subscription_client = mock .MagicMock ()
857857 mock_subscription_client .subscriptions .list .return_value = [deepcopy (self .subscription1_raw )]
@@ -1218,6 +1218,7 @@ def test_get_login_credentials_aux_tenants(self, get_user_credential_mock):
12181218 aux_tenants = [test_tenant_id2 ])
12191219
12201220 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , MSRestAzureAuthStub )
1221+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
12211222 def test_get_login_credentials_mi_system_assigned (self ):
12221223 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
12231224 consolidated = profile ._normalize_properties ('systemAssignedIdentity' ,
@@ -1237,6 +1238,7 @@ def test_get_login_credentials_mi_system_assigned(self):
12371238 self .assertTrue (cred .token_read_count )
12381239
12391240 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , MSRestAzureAuthStub )
1241+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
12401242 def test_get_login_credentials_mi_user_assigned_with_client_id (self ):
12411243 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
12421244 test_client_id = '12345678-38d6-4fb2-bad9-b7b93a3e8888'
@@ -1258,6 +1260,7 @@ def test_get_login_credentials_mi_user_assigned_with_client_id(self):
12581260 self .assertTrue (cred .client_id , test_client_id )
12591261
12601262 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , MSRestAzureAuthStub )
1263+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
12611264 def test_get_login_credentials_mi_user_assigned_with_object_id (self ):
12621265 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
12631266 test_object_id = '12345678-38d6-4fb2-bad9-b7b93a3e9999'
@@ -1279,6 +1282,7 @@ def test_get_login_credentials_mi_user_assigned_with_object_id(self):
12791282 self .assertTrue (cred .object_id , test_object_id )
12801283
12811284 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , MSRestAzureAuthStub )
1285+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
12821286 def test_get_login_credentials_mi_user_assigned_with_res_id (self ):
12831287 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
12841288 test_res_id = ('/subscriptions/{}/resourceGroups/r1/providers/Microsoft.ManagedIdentity/'
@@ -1301,7 +1305,6 @@ def test_get_login_credentials_mi_user_assigned_with_res_id(self):
13011305 self .assertTrue (cred .msi_res_id , test_res_id )
13021306
13031307 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1304- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
13051308 def test_get_login_credentials_mi_system_assigned_msal (self ):
13061309 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
13071310 consolidated = profile ._normalize_properties ('systemAssignedIdentity' ,
@@ -1318,7 +1321,6 @@ def test_get_login_credentials_mi_system_assigned_msal(self):
13181321 assert cred ._credential .resource_id is None
13191322
13201323 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1321- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
13221324 def test_get_login_credentials_mi_user_assigned_client_id_msal (self ):
13231325 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
13241326 consolidated = profile ._normalize_properties (
@@ -1337,7 +1339,6 @@ def test_get_login_credentials_mi_user_assigned_client_id_msal(self):
13371339 assert cred ._credential .resource_id is None
13381340
13391341 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1340- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
13411342 def test_get_login_credentials_mi_user_assigned_object_id_msal (self ):
13421343 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
13431344 consolidated = profile ._normalize_properties (
@@ -1356,7 +1357,6 @@ def test_get_login_credentials_mi_user_assigned_object_id_msal(self):
13561357 assert cred ._credential .resource_id is None
13571358
13581359 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1359- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
13601360 def test_get_login_credentials_mi_user_assigned_resource_id_msal (self ):
13611361 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
13621362 consolidated = profile ._normalize_properties (
@@ -1463,6 +1463,7 @@ def test_get_raw_token_for_sp(self, get_service_principal_credential_mock):
14631463 self .assertEqual (tenant , self .tenant_id )
14641464
14651465 @mock .patch ('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper' , autospec = True )
1466+ @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'false' })
14661467 def test_get_raw_token_mi_system_assigned (self , mock_msi_auth ):
14671468 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
14681469 consolidated = profile ._normalize_properties ('systemAssignedIdentity' ,
@@ -1502,7 +1503,6 @@ def mi_auth_factory(*args, **kwargs):
15021503
15031504 @mock .patch ('azure.cli.core.auth.util._now_timestamp' , new = _now_timestamp_mock )
15041505 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1505- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
15061506 def test_get_raw_token_mi_system_assigned_msal (self ):
15071507 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
15081508 consolidated = profile ._normalize_properties ('systemAssignedIdentity' ,
@@ -1537,7 +1537,6 @@ def test_get_raw_token_mi_system_assigned_msal(self):
15371537
15381538 @mock .patch ('azure.cli.core.auth.util._now_timestamp' , new = _now_timestamp_mock )
15391539 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1540- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
15411540 def test_get_raw_token_mi_user_assigned_client_id_msal (self ):
15421541 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
15431542 consolidated = profile ._normalize_properties (
@@ -1569,7 +1568,6 @@ def test_get_raw_token_mi_user_assigned_client_id_msal(self):
15691568
15701569 @mock .patch ('azure.cli.core.auth.util._now_timestamp' , new = _now_timestamp_mock )
15711570 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1572- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
15731571 def test_get_raw_token_mi_user_assigned_object_id_msal (self ):
15741572 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
15751573 consolidated = profile ._normalize_properties (
@@ -1601,7 +1599,6 @@ def test_get_raw_token_mi_user_assigned_object_id_msal(self):
16011599
16021600 @mock .patch ('azure.cli.core.auth.util._now_timestamp' , new = _now_timestamp_mock )
16031601 @mock .patch ('azure.cli.core.auth.msal_credentials.ManagedIdentityCredential' , ManagedIdentityCredentialStub )
1604- @mock .patch .dict ('os.environ' , {'AZURE_CORE_USE_MSAL_MANAGED_IDENTITY' : 'true' })
16051602 def test_get_raw_token_mi_user_assigned_resource_id_msal (self ):
16061603 profile = Profile (cli_ctx = DummyCli (), storage = {'subscriptions' : None })
16071604 consolidated = profile ._normalize_properties (
0 commit comments