Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions src/aro/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.14
++++++
* Migrate Disk Encryption Set validation from the Compute SDK to AAZ.

1.0.13
++++++
* Add support for hosted control plane clusters via `az aro hcp` and its subcommands.
Expand Down
8 changes: 5 additions & 3 deletions src/aro/azext_aro/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ def validate_disk_encryption_set(cmd, namespace):
f"Invalid --disk-encryption-set '{namespace.disk_encryption_set}', has to be a resource ID.")

desid = parse_resource_id(namespace.disk_encryption_set)
compute_client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_COMPUTE)
from azure.cli.command_modules.vm.aaz.latest.disk_encryption_set import Show
try:
compute_client.disk_encryption_sets.get(resource_group_name=desid['resource_group'],
disk_encryption_set_name=desid['name'])
Show(cli_ctx=cmd.cli_ctx)(command_args={
'resource_group': desid['resource_group'],
'disk_encryption_set_name': desid['name']
})
except HttpResponseError as err:
raise InvalidArgumentValueError(
f"Invalid --disk-encryption-set, error when getting '{namespace.disk_encryption_set}':"
Expand Down
27 changes: 15 additions & 12 deletions src/aro/azext_aro/tests/latest/standard/unit/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,48 +275,51 @@ def test_validate_cluster_resource_group(get_mgmt_service_client_mock, test_desc
None
),
(
"should not raise any exception when compute_client.disk_encryption_sets.get() not raises CludError exception",
"should not raise any exception when the AAZ disk encryption set show command succeeds",
Mock(cli_ctx=None),
Mock(disk_encryption_set="something different than None"),
True,
Mock(),
None,
{"resource_group": None, "name": None}
{"resource_group": "des-resource-group", "name": "des-name"}
)
]


@pytest.mark.parametrize(
"test_description, cmd_mock, namespace, is_valid_resource_id_return_value, compute_client_mock, expected_exception, parse_resource_id_mock_return_value",
"test_description, cmd_mock, namespace, is_valid_resource_id_return_value, show_mock, expected_exception, parse_resource_id_mock_return_value",
test_validate_disk_encryption_set_data,
ids=[i[0] for i in test_validate_disk_encryption_set_data]
)
@patch('azext_aro._validators.get_mgmt_service_client')
@patch('azure.cli.command_modules.vm.aaz.latest.disk_encryption_set.Show')
@patch('azext_aro._validators.parse_resource_id')
@patch('azext_aro._validators.is_valid_resource_id')
def test_validate_disk_encryption_set(
# Mocks:
is_valid_resource_id_mock,
parse_resource_id_mock,
get_mgmt_service_client_mock,

# Test cases parameters:
aaz_show_mock,
test_description, cmd_mock, namespace, is_valid_resource_id_return_value,
compute_client_mock, expected_exception, parse_resource_id_mock_return_value
show_mock, expected_exception, parse_resource_id_mock_return_value
):
is_valid_resource_id_mock.return_value = is_valid_resource_id_return_value
parse_resource_id_mock.return_value = parse_resource_id_mock_return_value

if compute_client_mock is not None:
compute_client_mock.get.return_value = None
get_mgmt_service_client_mock.return_value = compute_client_mock
if show_mock is not None:
aaz_show_mock.return_value = show_mock

if expected_exception is None:
validate_disk_encryption_set(cmd_mock, namespace)
else:
with pytest.raises(expected_exception):
validate_disk_encryption_set(cmd_mock, namespace)

if show_mock is not None:
aaz_show_mock.assert_called_once_with(cli_ctx=cmd_mock.cli_ctx)
show_mock.assert_called_once_with(command_args={
'resource_group': 'des-resource-group',
'disk_encryption_set_name': 'des-name'
})


test_validate_domain_data = [
(
Expand Down
2 changes: 1 addition & 1 deletion src/aro/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '1.0.13'
VERSION = '1.0.14'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading