Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
# is set with the environment varibale for sp_name. This method is compatible with
# both cases.
def _process_sp_name(sp_name):
from azure.cli.core.util import is_guid
return sp_name if is_guid(sp_name) else 'http://{}'.format(sp_name)
return sp_name


class AzureKubernetesServiceScenarioTest(ScenarioTest):
Expand Down Expand Up @@ -493,7 +492,7 @@ def generate_user_assigned_identity_resource_id(self, resource_group):
resource_group, identity_name)).get_output_in_json()
return identity.get("id")


# reset the count so in replay mode the random names will start with 0
self.test_resources_count = 0
# kwargs for string formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def create_resource(self, name, **kwargs):
pass

if self.live_test or self.test_class_instance.in_recording:
sp_name = name
sp_name = self.result['appId']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

name is now only displayName of the app. It can no longer be used as an identifier for the service principal (#19892).

sp_password = self.result.get("password") or GraphClientPasswordReplacer.PWD_REPLACEMENT
else:
sp_name = MOCK_GUID
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
# is set with the environment varibale for sp_name. This method is compatible with
# both cases.
def _process_sp_name(sp_name):
from azure.cli.core.util import is_guid
return sp_name if is_guid(sp_name) else 'http://{}'.format(sp_name)
return sp_name


class AzureKubernetesServiceScenarioTest(ScenarioTest):
Expand Down Expand Up @@ -820,7 +819,7 @@ def test_aks_create_and_update_with_managed_nat_gateway_outbound(self, resource_

update_cmd = 'aks update --resource-group={resource_group} --name={name} ' \
'--nat-gateway-managed-outbound-ip-count=2 ' \
'--nat-gateway-idle-timeout=30 '
'--nat-gateway-idle-timeout=30 '
self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('networkProfile.outboundType', 'managedNATGateway'),
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# --------------------------------------------------------------------------------------------

import os
import unittest
from unittest import mock

from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)
Expand All @@ -17,6 +18,7 @@ class ManagedCassandraScenarioTest(ScenarioTest):

# pylint: disable=line-too-long
# pylint: disable=broad-except
@unittest.skip('Cannot record due to https://github.com/Azure/azure-cli/issues/22174')
@ResourceGroupPreparer(name_prefix='cli_managed_cassandra')
def test_managed_cassandra_cluster_without_datacenters(self, resource_group):

Expand All @@ -39,6 +41,7 @@ def test_managed_cassandra_cluster_without_datacenters(self, resource_group):
print(e)

# pylint: disable=broad-except
@unittest.skip('Cannot record due to https://github.com/Azure/azure-cli/issues/22174')
@ResourceGroupPreparer(name_prefix='cli_managed_cassandra')
@AllowLargeResponse()
def test_managed_cassandra_verify_lists(self, resource_group):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# --------------------------------------------------------------------------------------------

# pylint: disable=too-many-lines
import unittest

from azure.cli.testsdk import JMESPathCheck, ScenarioTest, ResourceGroupPreparer, KeyVaultPreparer
from knack.util import CLIError
Expand Down Expand Up @@ -1464,6 +1465,7 @@ def test_cosmosdb_table_resource_throughput(self, resource_group):
db_througput_update = self.cmd('az cosmosdb table throughput update -g {rg} -a {acc} -n {tb_name} --throughput {tp2}').get_output_in_json()
assert db_througput_update["resource"]["throughput"] == tp2

@unittest.skip('Cannot record due to https://github.com/Azure/azure-cli/issues/22174')
@ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_key_vault_key_uri')
@KeyVaultPreparer(name_prefix='cli', name_len=15, location='eastus2', additional_params='--enable-purge-protection')
def test_cosmosdb_key_vault_key_uri(self, resource_group, key_vault):
Expand All @@ -1485,6 +1487,7 @@ def test_cosmosdb_key_vault_key_uri(self, resource_group, key_vault):

assert cmk_output["keyVaultKeyUri"] == key_uri

@unittest.skip('Cannot record due to https://github.com/Azure/azure-cli/issues/22174')
@ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_managed_service_identity')
@KeyVaultPreparer(name_prefix='cli', name_len=15, location='eastus2', additional_params='--enable-purge-protection')
def test_cosmosdb_managed_service_identity(self, resource_group, key_vault):
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=too-many-statements

import unittest
from unittest import mock

from azure.cli.testsdk import ResourceGroupPreparer, ScenarioTest, StorageAccountPreparer
Expand Down Expand Up @@ -428,6 +428,7 @@ def test_iot_hub(self, resource_group, resource_group_location, storage_account)
self.check('properties.enableDataResidency', True)])
self.cmd('az iot hub delete -n {}'.format(dr_hub_name))

@unittest.skip('Will be recorded in https://github.com/Azure/azure-cli/pull/22262')
@AllowLargeResponse()
@ResourceGroupPreparer(location='westus2')
@StorageAccountPreparer()
Expand Down Expand Up @@ -640,7 +641,7 @@ def test_identity_hub(self, resource_group, resource_group_location, storage_acc
self.exists('userAssignedIdentities."{0}"'.format(user_identity_1)),
self.exists('userAssignedIdentities."{0}"'.format(user_identity_2)),
self.exists('userAssignedIdentities."{0}"'.format(user_identity_3))])

# assign (system) re-add system identity
self.cmd('iot hub identity assign -n {0} -g {1} --system'.format(identity_hub, rg),
checks=[
Expand Down Expand Up @@ -688,6 +689,7 @@ def test_identity_hub(self, resource_group, resource_group_location, storage_acc
self.check('userAssignedIdentities', None),
self.check('type', IdentityType.none.value)])

@unittest.skip('Will be recorded in https://github.com/Azure/azure-cli/pull/22262')
@AllowLargeResponse()
@ResourceGroupPreparer(location='westus2')
@StorageAccountPreparer()
Expand Down Expand Up @@ -759,13 +761,13 @@ def test_hub_file_upload(self, resource_group, resource_group_location, storage_
assert not updated_hub['properties']['storageEndpoints']['$default']['authenticationType']
assert storage_cs_pattern in updated_hub['properties']['storageEndpoints']['$default']['connectionString']
assert updated_hub['properties']['storageEndpoints']['$default']['containerName'] == containerName

updated_hub = self.cmd('iot hub update -n {0} -g {1} --fsa {2}'
.format(hub, rg, key_based_auth)).get_output_in_json()
assert updated_hub['properties']['storageEndpoints']['$default']['authenticationType'] == key_based_auth
assert storage_cs_pattern in updated_hub['properties']['storageEndpoints']['$default']['connectionString']
assert updated_hub['properties']['storageEndpoints']['$default']['containerName'] == containerName


# Change to identity-based (with no identity) - fail
self.cmd('iot hub update -n {0} -g {1} --fsa identitybased'.format(hub, rg), expect_failure=True)
Expand Down Expand Up @@ -805,7 +807,7 @@ def test_hub_file_upload(self, resource_group, resource_group_location, storage_

# change to user-identity - fail
updated_hub = self.cmd('iot hub update -n {0} -g {1} --fsi /test/user/identity'.format(hub, rg), expect_failure=True)

# add a user identity, assign access to storage account
with mock.patch('azure.cli.command_modules.role.custom._gen_guid', side_effect=self.create_guid):
self.cmd('role assignment create --role "{0}" --assignee "{1}" --scope "{2}"'.format(storage_role, user_identity_id, storage_id))
Expand Down
8 changes: 1 addition & 7 deletions src/azure-cli/azure/cli/command_modules/keyvault/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.x509 import load_pem_x509_certificate

from msrestazure.azure_exceptions import CloudError

from knack.log import get_logger
from knack.util import CLIError

Expand Down Expand Up @@ -679,7 +677,7 @@ def create_vault(cmd, client, # pylint: disable=too-many-locals, too-many-state
VaultProperties = cmd.get_models('VaultProperties', resource_type=ResourceType.MGMT_KEYVAULT)

profile = Profile(cli_ctx=cmd.cli_ctx)
cred, _, tenant_id = profile.get_login_credentials(
_, _, tenant_id = profile.get_login_credentials(
resource=cmd.cli_ctx.cloud.endpoints.active_directory_graph_resource_id)

graph_client = graph_client_factory(cmd.cli_ctx)
Expand Down Expand Up @@ -896,12 +894,8 @@ def update_hsm(cmd, instance,

def _object_id_args_helper(cli_ctx, object_id, spn, upn):
if not object_id:
from azure.cli.core._profile import Profile
from azure.cli.command_modules.role import graph_client_factory

profile = Profile(cli_ctx=cli_ctx)
cred, _, tenant_id = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.active_directory_graph_resource_id)
graph_client = graph_client_factory(cli_ctx)
object_id = _get_object_id(graph_client, spn=spn, upn=upn)
if not object_id:
Expand Down
Loading