Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Drop Track 1 SDK authentication support #29631

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Aug 1, 2024

Related command

Description
Close #20460

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

Copy link

azure-client-tools-bot-prd bot commented Aug 1, 2024

❌AzureCLI-FullTest
🔄acr
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄acs
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄advisor
🔄latest
🔄3.11
🔄ams
🔄latest
🔄3.11
🔄apim
🔄latest
🔄3.11
🔄appconfig
🔄latest
🔄3.11
🔄appservice
🔄latest
🔄3.11
🔄aro
🔄latest
🔄3.11
🔄backup
🔄latest
🔄3.11
🔄batch
🔄latest
🔄3.11
🔄batchai
🔄latest
🔄3.11
🔄billing
🔄latest
🔄3.11
🔄botservice
🔄latest
🔄3.11
🔄cdn
🔄latest
🔄3.11
🔄cloud
🔄latest
🔄3.11
🔄cognitiveservices
🔄latest
🔄3.11
🔄compute_recommender
🔄latest
🔄3.11
🔄config
🔄latest
🔄3.11
🔄configure
🔄latest
🔄3.11
🔄consumption
🔄latest
🔄3.11
🔄container
🔄latest
🔄3.11
🔄containerapp
🔄latest
🔄3.11
❌core
❌2018-03-01-hybrid
❌3.11
Type Test Case Error Message Line
Failed test_get_login_credentials self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140538053403536'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials(self, get_user_credential_mock):
        cli = DummyCli()
        # setup
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                             'MSI-DEV-INC', self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # action
        cred, subscription_id, 
 = profile.get_login_credentials()
        get_user_credential_mock.assert_called_with(self.user1)
    
        # verify
        self.assertEqual(subscription_id, test_subscription_id)
    
        # verify the cred.get_token()
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:904: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7fd190b82c90>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:882
Failed test_get_login_credentials_aux_subscriptions self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_subscriptions>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140538053405328'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_subscriptions(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription1 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription1, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
    
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_subscriptions=[test_subscription_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:931: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7fd190ab1f10>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:906
Failed test_get_login_credentials_aux_tenants self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_tenants>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140538053406928'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_tenants(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # test only input aux_tenants
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_tenants=[test_tenant_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:960: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7fd190ab2950>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:935
Failed test_get_login_credentials_msi_system_assigned self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_system_assigned>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_system_assigned(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'systemAssignedIdentity'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSI', self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user,
                                                     [msi_subscription],
                                                     True)
        profile.set_subscriptions(consolidated)
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:986: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7fd192375610>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:971
Failed test_get_login_credentials_msi_user_assigned_with_client_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_client_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_client_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'userAssignedIdentity'
        test_client_id = '12345678-38d6-4fb2-bad9-b7b93a3e8888'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSIClient-{}'.format(test_client_id), self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user, [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1008: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7fd19236f250>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:995
Failed test_get_login_credentials_msi_user_assigned_with_object_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_object_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_object_id(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_object_id = '12345678-38d6-4fb2-bad9-b7b93a3e9999'
        msi_subscription = SubscriptionStub('/subscriptions/12345678-1bf0-4dda-aec3-cb9272f09590',
                                            'MSIObject-{}'.format(test_object_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1032: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7fd190c08350>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1018
Failed test_get_login_credentials_msi_user_assigned_with_res_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_res_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_res_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_res_id = ('/subscriptions/{}/resourceGroups/r1/providers/Microsoft.ManagedIdentity/'
                       'userAssignedIdentities/id1').format(test_subscription_id)
        msi_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                            'MSIResource-{}'.format(test_res_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1056: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7fd19236f210>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1042
❌3.9
Type Test Case Error Message Line
Failed test_get_login_credentials self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140691343301552'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials(self, get_user_credential_mock):
        cli = DummyCli()
        # setup
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                             'MSI-DEV-INC', self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # action
        cred, subscription_id, 
 = profile.get_login_credentials()
        get_user_credential_mock.assert_called_with(self.user1)
    
        # verify
        self.assertEqual(subscription_id, test_subscription_id)
    
        # verify the cred.get_token()
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:904: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff5417e5a90>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:882
Failed test_get_login_credentials_aux_subscriptions self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_subscriptions>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140691343301840'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_subscriptions(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription1 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription1, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
    
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_subscriptions=[test_subscription_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:931: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff5417e6c40>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:906
Failed test_get_login_credentials_aux_tenants self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_tenants>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140691343302128'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_tenants(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # test only input aux_tenants
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_tenants=[test_tenant_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:960: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff5417e5e80>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:935
Failed test_get_login_credentials_msi_system_assigned self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_system_assigned>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_system_assigned(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'systemAssignedIdentity'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSI', self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user,
                                                     [msi_subscription],
                                                     True)
        profile.set_subscriptions(consolidated)
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:986: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff541792190>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:971
Failed test_get_login_credentials_msi_user_assigned_with_client_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_client_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_client_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'userAssignedIdentity'
        test_client_id = '12345678-38d6-4fb2-bad9-b7b93a3e8888'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSIClient-{}'.format(test_client_id), self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user, [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1008: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff541793280>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:995
Failed test_get_login_credentials_msi_user_assigned_with_object_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_object_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_object_id(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_object_id = '12345678-38d6-4fb2-bad9-b7b93a3e9999'
        msi_subscription = SubscriptionStub('/subscriptions/12345678-1bf0-4dda-aec3-cb9272f09590',
                                            'MSIObject-{}'.format(test_object_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1032: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff541792430>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1018
Failed test_get_login_credentials_msi_user_assigned_with_res_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_res_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_res_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_res_id = ('/subscriptions/{}/resourceGroups/r1/providers/Microsoft.ManagedIdentity/'
                       'userAssignedIdentities/id1').format(test_subscription_id)
        msi_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                            'MSIResource-{}'.format(test_res_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1056: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff541795550>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1042
❌2020-09-01-hybrid
❌3.11
Type Test Case Error Message Line
Failed test_get_login_credentials self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140371966260176'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials(self, get_user_credential_mock):
        cli = DummyCli()
        # setup
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                             'MSI-DEV-INC', self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # action
        cred, subscription_id, 
 = profile.get_login_credentials()
        get_user_credential_mock.assert_called_with(self.user1)
    
        # verify
        self.assertEqual(subscription_id, test_subscription_id)
    
        # verify the cred.get_token()
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:904: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7faae54d1290>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:882
Failed test_get_login_credentials_aux_subscriptions self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_subscriptions>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140371966248656'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_subscriptions(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription1 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription1, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
    
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_subscriptions=[test_subscription_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:931: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7faae53c8490>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:906
Failed test_get_login_credentials_aux_tenants self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_tenants>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140371966313616'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_tenants(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # test only input aux_tenants
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_tenants=[test_tenant_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:960: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7faae53d1190>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:935
Failed test_get_login_credentials_msi_system_assigned self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_system_assigned>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_system_assigned(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'systemAssignedIdentity'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSI', self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user,
                                                     [msi_subscription],
                                                     True)
        profile.set_subscriptions(consolidated)
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:986: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7faae6c7b410>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:971
Failed test_get_login_credentials_msi_user_assigned_with_client_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_client_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_client_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'userAssignedIdentity'
        test_client_id = '12345678-38d6-4fb2-bad9-b7b93a3e8888'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSIClient-{}'.format(test_client_id), self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user, [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1008: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7faae6c7b410>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:995
Failed test_get_login_credentials_msi_user_assigned_with_object_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_object_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_object_id(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_object_id = '12345678-38d6-4fb2-bad9-b7b93a3e9999'
        msi_subscription = SubscriptionStub('/subscriptions/12345678-1bf0-4dda-aec3-cb9272f09590',
                                            'MSIObject-{}'.format(test_object_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1032: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7faae6c7b410>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1018
Failed test_get_login_credentials_msi_user_assigned_with_res_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_res_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_res_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_res_id = ('/subscriptions/{}/resourceGroups/r1/providers/Microsoft.ManagedIdentity/'
                       'userAssignedIdentities/id1').format(test_subscription_id)
        msi_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                            'MSIResource-{}'.format(test_res_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1056: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7faae6c7b410>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1042
❌3.9
Type Test Case Error Message Line
Failed test_get_login_credentials self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140699436179168'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials(self, get_user_credential_mock):
        cli = DummyCli()
        # setup
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                             'MSI-DEV-INC', self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # action
        cred, subscription_id, 
 = profile.get_login_credentials()
        get_user_credential_mock.assert_called_with(self.user1)
    
        # verify
        self.assertEqual(subscription_id, test_subscription_id)
    
        # verify the cred.get_token()
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:904: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff723ddfc40>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:882
Failed test_get_login_credentials_aux_subscriptions self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_subscriptions>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140699436273728'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_subscriptions(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription1 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription1, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
    
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_subscriptions=[test_subscription_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:931: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff723ddee50>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:906
Failed test_get_login_credentials_aux_tenants self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_aux_tenants>
get_user_credential_mock = <MagicMock name='get_user_credential' id='140699436257632'>

    @mock.patch('azure.cli.core.auth.identity.Identity.get_user_credential', return_value=credential_mock)
    def test_get_login_credentials_aux_tenants(self, get_user_credential_mock):
        cli = DummyCli()
    
        storage_mock = {'subscriptions': None}
        profile = Profile(cli_ctx=cli, storage=storage_mock)
        test_subscription_id1 = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_subscription_id2 = '12345678-1bf0-4dda-aec3-cb9272f09591'
        test_tenant_id1 = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_tenant_id2 = '12345678-38d6-4fb2-bad9-b7b93a3e4321'
        test_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id1),
                                             'MSI-DEV-INC', self.state1, test_tenant_id1)
        test_subscription2 = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id2),
                                              'MSI-DEV-INC2', self.state1, test_tenant_id2)
        consolidated = profile.normalize_properties(self.user1,
                                                     [test_subscription, test_subscription2],
                                                     False, None, None)
        profile.set_subscriptions(consolidated)
        # test only input aux_tenants
        cred, subscription_id, 
 = profile.get_login_credentials(subscription_id=test_subscription_id1,
                                                                 aux_tenants=[test_tenant_id2])
    
        self.assertEqual(subscription_id, test_subscription_id1)
    
>       token = cred.get_token()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:960: 
                                       _ 

self = <azure.cli.core.auth.credential_adaptor.CredentialAdaptor object at 0x7ff723ddef40>
scopes = None, kwargs = {}

    def get_token(self, *scopes, **kwargs):
        """Get an access token from the main credential."""
        logger.debug("CredentialAdaptor.get_token: scopes=%r, kwargs=%r", scopes, kwargs)
    
        # SDK azure-keyvault-keys 4.5.0b5 passes tenant_id as kwargs, but we don't support tenant_id for now,
        # so discard it.
        kwargs.pop('tenant_id', None)
    
        scopes = _normalize_scopes(scopes)
>       return self._credential.get_token(scopes, **kwargs)
E       TypeError: azure.cli.core.tests.test_profile.CredentialMock.get_token() argument after 
 must be an iterable, not NoneType

src/azure-cli-core/azure/cli/core/auth/credential_adaptor.py:38: TypeError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:935
Failed test_get_login_credentials_msi_system_assigned self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_system_assigned>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_system_assigned(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'systemAssignedIdentity'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSI', self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user,
                                                     [msi_subscription],
                                                     True)
        profile.set_subscriptions(consolidated)
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:986: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff723d8b520>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:971
Failed test_get_login_credentials_msi_user_assigned_with_client_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_client_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_client_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_tenant_id = '12345678-38d6-4fb2-bad9-b7b93a3e1234'
        test_user = 'userAssignedIdentity'
        test_client_id = '12345678-38d6-4fb2-bad9-b7b93a3e8888'
        msi_subscription = SubscriptionStub('/subscriptions/' + test_subscription_id, 'MSIClient-{}'.format(test_client_id), self.state1, test_tenant_id)
        consolidated = profile.normalize_properties(test_user, [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1008: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff723d89640>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:995
Failed test_get_login_credentials_msi_user_assigned_with_object_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_object_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_object_id(self):
    
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_object_id = '12345678-38d6-4fb2-bad9-b7b93a3e9999'
        msi_subscription = SubscriptionStub('/subscriptions/12345678-1bf0-4dda-aec3-cb9272f09590',
                                            'MSIObject-{}'.format(test_object_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1032: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff723d89760>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1018
Failed test_get_login_credentials_msi_user_assigned_with_res_id self = <azure.cli.core.tests.test_profile.TestProfile testMethod=test_get_login_credentials_msi_user_assigned_with_res_id>

    @mock.patch('azure.cli.core.auth.adal_authentication.MSIAuthenticationWrapper', MSRestAzureAuthStub)
    def test_get_login_credentials_msi_user_assigned_with_res_id(self):
        # setup an existing msi subscription
        profile = Profile(cli_ctx=DummyCli(), storage={'subscriptions': None})
        test_subscription_id = '12345678-1bf0-4dda-aec3-cb9272f09590'
        test_res_id = ('/subscriptions/{}/resourceGroups/r1/providers/Microsoft.ManagedIdentity/'
                       'userAssignedIdentities/id1').format(test_subscription_id)
        msi_subscription = SubscriptionStub('/subscriptions/{}'.format(test_subscription_id),
                                            'MSIResource-{}'.format(test_res_id),
                                            self.state1, '12345678-38d6-4fb2-bad9-b7b93a3e1234')
        consolidated = profile.normalize_properties('userAssignedIdentity', [msi_subscription], True)
        profile.set_subscriptions(consolidated, secondary_key_name='name')
    
>       cred, subscription_id, 
 = profile.get_login_credentials()

src/azure-cli-core/azure/cli/core/tests/test_profile.py:1056: 
                                       _ 

self = <azure.cli.core._profile.Profile object at 0x7ff723d89880>
client_id = None, subscription_id = None, aux_subscriptions = None
aux_tenants = None

    def get_login_credentials(self, client_id=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None):
        """Get a CredentialAdaptor instance to be used with both Track 1 and Track 2 SDKs.
    
        :param client_id:
        :param subscription_id:
        :param aux_subscriptions:
        :param aux_tenants:
        """
        if aux_tenants and aux_subscriptions:
            raise CLIError("Please specify only one of aux_subscriptions and aux_tenants, not both")
    
        account = self.get_subscription(subscription_id)
    
        managed_identity_type, managed_identity_id = Profile._try_parse_msi_account_name(account)
    
        # Cloud Shell is just a system assignment managed identity
        if in_cloud_console() and account[_USER_ENTITY].get(_CLOUD_SHELL_ID):
            managed_identity_type = MsiAccountTypes.system_assigned
    
        if managed_identity_type is None:
            # user and service principal
            external_tenants = []
            if aux_tenants:
                external_tenants = [tenant for tenant in aux_tenants if tenant != account[_TENANT_ID]]
            if aux_subscriptions:
                ext_subs = [aux_sub for aux_sub in aux_subscriptions if aux_sub != subscription_id]
                for ext_sub in ext_subs:
                    sub = self.get_subscription(ext_sub)
                    if sub[_TENANT_ID] != account[_TENANT_ID]:
                        external_tenants.append(sub[_TENANT_ID])
    
            credential = self._create_credential(account, client_id=client_id)
            external_credentials = []
            for external_tenant in external_tenants:
                external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id))
            from azure.cli.core.auth.credential_adaptor import CredentialAdaptor
            cred = CredentialAdaptor(credential, auxiliary_credentials=external_credentials)
        else:
            # managed identity
            # TODO: Migrate MSIAuthentication to MSAL
>           cred = MsiAccountTypes.msi_auth_factory(managed_identity_type, managed_identity_id, resource)
E           NameError: name 'resource' is not defined

src/azure-cli-core/azure/cli/core/_profile.py:371: NameError
src/azure-cli-core/azure/cli/core/tests/test_profile.py:1042
🔄latest
🔄3.11
🔄cosmosdb
🔄latest
🔄3.11
🔄databoxedge
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
❌dla
❌latest
❌3.11
Type Test Case Error Message Line
Failed test_adla_account_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f99f4f86f10>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f99f5103f10>
command = 'dls account create -g cli_test_adla_mgmt000001 -n cliadls000003 -l eastus2 --disable-encryption'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:302: 
                                        
env/lib/python3.11/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:127: in exception_handler
    return handle_exception(ex)
                                        

ex = AttributeError("'CredentialAdaptor' object has no attribute 'signed_session'")
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception AttributeError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.dla.tests.latest.test_dla_commands.DataLakeAnalyticsScenarioTest testMethod=test_adla_account_mgmt>
resource_group = 'cli_test_adla_mgmt000001'
storage_account_info = ('cliwasb000002', 'veryFakedStorageAccountKey==')

    @ResourceGroupPreparer(name_prefix='cli_test_adla_mgmt')
    @StorageAccountPreparer(name_prefix='cliwasb', length=12, sku='Standard_GRS')
    def test_adla_account_mgmt(self, resource_group, storage_account_info):
    
        self.kwargs.update({
            'dls1': self.create_random_name('cliadls', 12),
            'dls2': self.create_random_name('cliadls', 12),
            'dla': self.create_random_name('cliadla', 12),
            'wasb': storage_account_info[0],
            'wasb_key': storage_account_info[1],
            'loc': 'eastus2',
            # compute policy variables
            'user_policy': 'pycliuserpolicy',
            'user_oid': '181c08fa-7ac8-48a6-a869-342ab74566a4',  # azureclitest
            'group_policy': 'pycligrouppolicy',
            'group_oid': 'f0bec09f-45a4-4c58-ac5b-cf0516d7bc68'  # AzureSDKTeam
        })
    
        # create ADLS accounts
>       self.cmd('dls account create -g {rg} -n {dls1} -l {loc} --disable-encryption')

src/azure-cli/azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:342: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:176: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:251: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:314: in in_process_execute
    raise ex.exception
env/lib/python3.11/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:664: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:731: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:701: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:334: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:121: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/dls/custom.py:82: in create_adls_account
    return client.create(resource_group_name, account_name, create_params).result()
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:318: in create
    raw_result = self.create_initial(
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:272: in create_initial
    response = self.client.send(
env/lib/python3.11/site-packages/msrest/service_client.py:336: in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
env/lib/python3.11/site-packages/msrest/pipeline/init.py:197: in run
    return first_node.send(pipeline_request, **kwargs)  # type: ignore
env/lib/python3.11/site-packages/msrest/pipeline/init.py:150: in send
    response = self.next.send(request, **kwargs)
 
 
 
 
 
 
 
                                 

self = <msrest.pipeline.requests.RequestsCredentialsPolicy object at 0x7f99f5fe55d0>
request = <msrest.pipeline.Request object at 0x7f99f4194950>
kwargs = {'stream': False}
session = <requests.sessions.Session object at 0x7f99f4193b90>

    def send(self, request, **kwargs):
        session = request.context.session
        try:
>           self._creds.signed_session(session)
E           AttributeError: 'CredentialAdaptor' object has no attribute 'signed_session'

env/lib/python3.11/site-packages/msrest/pipeline/requests.py:65: AttributeError
azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:322
Failed test_adla_catalog_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f99f4dbed50>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f99f5116310>
command = 'dls account create -g cli_test_adla_catalog_mgmt000001 -n cliadls000002 -l eastus2 --disable-encryption'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:302: 
                                        
env/lib/python3.11/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:127: in exception_handler
    return handle_exception(ex)
                                        

ex = AttributeError("'CredentialAdaptor' object has no attribute 'signed_session'")
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception AttributeError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.dla.tests.latest.test_dla_commands.DataLakeAnalyticsScenarioTest testMethod=test_adla_catalog_mgmt>
resource_group = 'cli_test_adla_catalog_mgmt000001'

    @ResourceGroupPreparer(name_prefix='cli_test_adla_catalog_mgmt')
    def test_adla_catalog_mgmt(self, resource_group):
    
        self.kwargs.update({
            'dls': self.create_random_name('cliadls', 24),
            'dla': self.create_random_name('cliadla', 24),
            'loc': 'eastus2',
    
            # define catalog item names
            'db': 'catalog_item_1',
            'table': 'catalog_item_2',
            'tvf': 'catalog_item_3',
            'proc': 'catalog_item_4',
            'cred': 'catalog_item_5',
            'cred_username': 'catalog_item_6',
            'cred_pwd': 'catalog_item_7',
            'view': 'catalog_item_8'
        })
    
        # create ADLS accounts
>       self.cmd('dls account create -g {rg} -n {dls} -l {loc} --disable-encryption')

src/azure-cli/azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:43: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:176: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:251: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:314: in in_process_execute
    raise ex.exception
env/lib/python3.11/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:664: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:731: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:701: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:334: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:121: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/dls/custom.py:82: in create_adls_account
    return client.create(resource_group_name, account_name, create_params).result()
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:318: in create
    raw_result = self.create_initial(
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:272: in create_initial
    response = self.client.send(
env/lib/python3.11/site-packages/msrest/service_client.py:336: in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
env/lib/python3.11/site-packages/msrest/pipeline/init.py:197: in run
    return first_node.send(pipeline_request, **kwargs)  # type: ignore
env/lib/python3.11/site-packages/msrest/pipeline/init.py:150: in send
    response = self.next.send(request, **kwargs)
 
 
 
 
 
 
 
                                 

self = <msrest.pipeline.requests.RequestsCredentialsPolicy object at 0x7f99f4c25210>
request = <msrest.pipeline.Request object at 0x7f99f418dad0>
kwargs = {'stream': False}
session = <requests.sessions.Session object at 0x7f99f418c9d0>

    def send(self, request, **kwargs):
        session = request.context.session
        try:
>           self._creds.signed_session(session)
E           AttributeError: 'CredentialAdaptor' object has no attribute 'signed_session'

env/lib/python3.11/site-packages/msrest/pipeline/requests.py:65: AttributeError
azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:22
Failed test_adla_job_mgmt self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f99f4d2bf90>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f99f51336d0>
command = 'dls account create -g cli_test_adla_job_mgmt000001 -n cliadls000002 -l eastus2 --disable-encryption'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:302: 
                                        
env/lib/python3.11/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:127: in exception_handler
    return handle_exception(ex)
                                        

ex = AttributeError("'CredentialAdaptor' object has no attribute 'signed_session'")
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception AttributeError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.dla.tests.latest.test_dla_commands.DataLakeAnalyticsScenarioTest testMethod=test_adla_job_mgmt>
resource_group = 'cli_test_adla_job_mgmt000001'

    @ResourceGroupPreparer(name_prefix='cli_test_adla_job_mgmt')
    def test_adla_job_mgmt(self, resource_group):
    
        self.kwargs.update({
            'dls': self.create_random_name('cliadls', 24),
            'dla': self.create_random_name('cliadla', 24),
            'loc': 'eastus2',
            # job relation ship variables
            'pipeline_id': '3f9a237a-325e-4ec8-9e10-60222a71354d',
            'pipeline_name': 'py_pipeline_name',
            'pipeline_uri': 'https://begoldsm.contoso.com/jobs',
            'recurrence_id': '58cab1f7-fe29-46ce-89ab-628a1e09c5bf',
            'recurrence_name': 'py_recurrence_name',
            'run_id': 'a3f300fc-4496-40ad-b76d-7696e3723b77'
        })
    
        # create ADLS accounts
>       self.cmd('dls account create -g {rg} -n {dls} -l {loc} --disable-encryption')

src/azure-cli/azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:242: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:176: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:251: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:314: in in_process_execute
    raise ex.exception
env/lib/python3.11/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:664: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:731: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:701: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:334: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:121: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/dls/custom.py:82: in create_adls_account
    return client.create(resource_group_name, account_name, create_params).result()
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:318: in create
    raw_result = self.create_initial(
src/azure-cli/azure/cli/command_modules/dls/vendored_sdks/azure_mgmt_datalake_store/operations/accounts_operations.py:272: in create_initial
    response = self.client.send(
env/lib/python3.11/site-packages/msrest/service_client.py:336: in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
env/lib/python3.11/site-packages/msrest/pipeline/init.py:197: in run
    return first_node.send(pipeline_request, **kwargs)  # type: ignore
env/lib/python3.11/site-packages/msrest/pipeline/init.py:150: in send
    response = self.next.send(request, **kwargs)
 
 
 
 
 
 
 
                                 

self = <msrest.pipeline.requests.RequestsCredentialsPolicy object at 0x7f99f4d46dd0>
request = <msrest.pipeline.Request object at 0x7f99f41843d0>
kwargs = {'stream': False}
session = <requests.sessions.Session object at 0x7f99f4177150>

    def send(self, request, **kwargs):
        session = request.context.session
        try:
>           self._creds.signed_session(session)
E           AttributeError: 'CredentialAdaptor' object has no attribute 'signed_session'

env/lib/python3.11/site-packages/msrest/pipeline/requests.py:65: AttributeError
azure/cli/command_modules/dla/tests/latest/test_dla_commands.py:224
🔄dls
🔄latest
🔄3.11
🔄dms
🔄latest
🔄3.11
🔄eventgrid
🔄latest
🔄3.11
🔄eventhubs
🔄latest
🔄3.11
🔄feedback
🔄latest
🔄3.11
🔄find
🔄latest
🔄3.11
🔄hdinsight
🔄latest
🔄3.11
🔄identity
🔄latest
🔄3.11
🔄iot
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄keyvault
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄kusto
🔄latest
🔄3.11
🔄lab
🔄latest
🔄3.11
🔄managedservices
🔄latest
🔄3.11
🔄maps
🔄latest
🔄3.11
️✔️marketplaceordering
️✔️latest
️✔️3.11
🔄monitor
🔄latest
🔄3.11
🔄mysql
🔄latest
🔄3.11
🔄netappfiles
🔄latest
🔄3.11
❌network
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
❌latest
❌3.11
Type Test Case Error Message Line
Failed test_private_endpoint_connection_kusto_cluster self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f733bcff0d0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f733c23ad10>
command = 'kusto cluster create -l eastus -n clikusto000002 -g cli_test_kusto_pe000001 --sku Standard_D11_v2'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0

src/azure-cli-testsdk/azure/cli/testsdk/base.py:302: 
                                        
env/lib/python3.11/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
src/azure-cli-core/azure/cli/core/init.py:127: in exception_handler
    return handle_exception(ex)
                                        

ex = AttributeError("'CredentialAdaptor' object has no attribute 'signed_session'")
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception AttributeError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.network.tests.latest.test_private_endpoint_commands.NetworkPrivateLinkKustoClusterScenarioTest testMethod=test_private_endpoint_connection_kusto_cluster>
resource_group = 'cli_test_kusto_pe000001'

    @ResourceGroupPreparer(name_prefix='cli_test_kusto_pe')
    def test_private_endpoint_connection_kusto_cluster(self, resource_group):
        self.kwargs.update({
            'acc': self.create_random_name('clikusto', 12),
            'loc': 'eastus',
            'rg': resource_group,
            'vnet': self.create_random_name('cli-vnet-', 24),
            'subnet': self.create_random_name('cli-subnet-', 24),
            'pe': self.create_random_name('cli-pe-', 24),
            'pe_connection': self.create_random_name('cli-pec-', 24),
            'sku': 'Standard_D11_v2'
        })
    
        # Prepare kusto cluster and network
>       account = self.cmd('az kusto cluster create -l {loc} -n {acc} -g {rg} --sku {sku}').get_output_in_json()

src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:1108: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:176: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:251: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:314: in in_process_execute
    raise ex.exception
env/lib/python3.11/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
src/azure-cli-core/azure/cli/core/commands/init.py:664: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:731: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
src/azure-cli-core/azure/cli/core/commands/init.py:701: in run_job
    result = cmd_copy(params)
src/azure-cli-core/azure/cli/core/commands/init.py:334: in call
    return self.handler(*args, **kwargs)
src/azure-cli-core/azure/cli/core/commands/command_operation.py:121: in handler
    return op(**command_args)
src/azure-cli/azure/cli/command_modules/kusto/custom.py:60: in cluster_create
    return sdk_no_wait(no_wait,
src/azure-cli-core/azure/cli/core/util.py:710: in sdk_no_wait
    return func(*args, **kwargs)
env/lib/python3.11/site-packages/azure/mgmt/kusto/operations/clusters_operations.py:182: in create_or_update
    raw_result = self.create_or_update_initial(
env/lib/python3.11/site-packages/azure/mgmt/kusto/operations/clusters_operations.py:137: in create_or_update_initial
    response = self.client.send(request, stream=False, **operation_config)
env/lib/python3.11/site-packages/msrest/service_client.py:336: in send
    pipeline_response = self.config.pipeline.run(request, **kwargs)
env/lib/python3.11/site-packages/msrest/pipeline/init.py:197: in run
    return first_node.send(pipeline_request, **kwargs)  # type: ignore
env/lib/python3.11/site-packages/msrest/pipeline/init.py:150: in send
    response = self.next.send(request, **kwargs)
 
 
 
 
 
 
 
                                 

self = <msrest.pipeline.requests.RequestsCredentialsPolicy object at 0x7f733be47310>
request = <msrest.pipeline.Request object at 0x7f733be4c790>
kwargs = {'operation_config': {}, 'stream': False}
session = <requests.sessions.Session object at 0x7f733be474d0>

    def send(self, request, **kwargs):
        session = request.context.session
        try:
>           self._creds.signed_session(session)
E           AttributeError: 'CredentialAdaptor' object has no attribute 'signed_session'

env/lib/python3.11/site-packages/msrest/pipeline/requests.py:65: AttributeError
azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:1093
Failed test_private_link_resource_kusto_cluster The error message is too long, please check the pipeline log for details. azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py:1079
🔄policyinsights
🔄latest
🔄3.11
🔄privatedns
🔄latest
🔄3.11
🔄profile
🔄latest
🔄3.11
🔄rdbms
🔄latest
🔄3.11
🔄redis
🔄latest
🔄3.11
🔄relay
🔄latest
🔄3.11
🔄resource
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄role
🔄latest
🔄3.11
🔄search
🔄latest
🔄3.11
🔄security
🔄latest
🔄3.11
🔄servicebus
🔄latest
🔄3.11
🔄serviceconnector
🔄latest
🔄3.11
🔄servicefabric
🔄latest
🔄3.11
🔄signalr
🔄latest
🔄3.11
🔄sql
🔄latest
🔄3.11
🔄sqlvm
🔄latest
🔄3.11
🔄storage
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄synapse
🔄latest
🔄3.11
🔄telemetry
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11
🔄util
🔄latest
🔄3.11
🔄vm
️✔️2018-03-01-hybrid
️✔️3.11
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.11
️✔️3.9
🔄latest
🔄3.11

Copy link

azure-client-tools-bot-prd bot commented Aug 1, 2024

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Aug 1, 2024

Core

@@ -97,6 +97,7 @@ def scopes_to_resource(scopes):


def _normalize_scopes(scopes):
# TODO: Drop this function
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is to support very old Track 2 SDKs that doesn't comply with the current authentication interface. We should consider dropping their support as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Core CLI core infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop Track 1 Azure SDK support
2 participants