diff --git a/src/horizondb/HISTORY.rst b/src/horizondb/HISTORY.rst index db026b51ef5..897e3b67bd0 100644 --- a/src/horizondb/HISTORY.rst +++ b/src/horizondb/HISTORY.rst @@ -3,6 +3,16 @@ Release History =============== +1.0.0b11 +++++++++ +* Require both IPv4 bounds on ``cluster pool firewall-rule create``. Reject invalid + or reversed ranges on create and update, including single-bound updates. +* Show the allowed range when configuring a firewall rule and warn explicitly + when both bounds are ``0.0.0.0`` and the rule allows all Azure resources. +* Correct the pool firewall rule create and update help examples. +* Add ``az horizondb cluster authentication list`` and ``authentication password`` + commands to show, configure, update, and wait for cluster password authentication. + 1.0.0b10 ++++++++ * Add ``az horizondb cluster pool maintenance-event list`` to display the diff --git a/src/horizondb/README.md b/src/horizondb/README.md index 99d4d32e389..daa58cb8f0a 100644 --- a/src/horizondb/README.md +++ b/src/horizondb/README.md @@ -54,6 +54,31 @@ For example, scale the pool's vCores: az horizondb cluster pool update --resource-group example-resource-group --cluster-name example-cluster --name example-pool --v-cores 4 ``` +## Manage cluster authentication + +List the cluster's service-created authentication methods, then inspect the password method: + +```powershell +az horizondb cluster authentication list -g example-resource-group --cluster-name example-cluster +az horizondb cluster authentication password show -g example-resource-group --cluster-name example-cluster +``` + +For initial setup, use `password create` with `--state Enabled` and the administrator login. +Pass `--admin-password` (alias `--administrator-login-password`) **without a value** in a terminal to enter and confirm +the password without echo. An inline password can appear in shell history, process arguments, +or CLI debug logs. Passwords are never returned by these commands. + +```powershell +az horizondb cluster authentication password create -g example-resource-group --cluster-name example-cluster --state Enabled --administrator-login exampleadmin --admin-password +az horizondb cluster authentication password update -g example-resource-group --cluster-name example-cluster --admin-password --no-wait +az horizondb cluster authentication password wait -g example-resource-group --cluster-name example-cluster --updated +``` + +Configuring password authentication requires a compute pool. `password update` +changes only the supplied settings. To disable the method with `--state Disabled`, +first enable Microsoft Entra authentication with a valid tenant. Use `--state Enabled` with a password to +re-enable the method and reset the password. Both create and update accept `--no-wait`. + ## Manage parameter groups Create a parameter group for the cluster's PostgreSQL version, then associate @@ -161,6 +186,14 @@ az horizondb cluster update --resource-group example-resource-group --name examp az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool --name client-access --start-ip-address 203.0.113.10 --end-ip-address 203.0.113.10 ``` +Use `create` for a new rule and supply both ends of the inclusive IPv4 range. +Use `update` to change an existing rule; you can supply just one end of the range +or change the description. Setting both bounds to `0.0.0.0` allows connections +from all Azure resources, not just resources in your subscription. +Neither command changes an individual endpoint. Use `--no-wait` on create, update, +or delete to return after submission; use `firewall-rule wait --created` or +`--deleted` with the same resource group, cluster, pool, and rule name to wait. + ## Included Features ### HorizonDB Cluster Management diff --git a/src/horizondb/azext_horizondb/__init__.py b/src/horizondb/azext_horizondb/__init__.py index 67b72633921..5fd859b60fe 100644 --- a/src/horizondb/azext_horizondb/__init__.py +++ b/src/horizondb/azext_horizondb/__init__.py @@ -18,15 +18,21 @@ def load_command_table(self, args): args=args ) from .aaz.latest.horizondb.cluster.custom import ClusterCreate, ClusterUpdate + from .aaz.latest.horizondb.cluster.authentication.password.custom import PasswordCreate, PasswordUpdate from .aaz.latest.horizondb.cluster.custom_restore import ClusterRestore from .aaz.latest.horizondb.cluster.pool.custom import PoolCreate, PoolUpdate + from .aaz.latest.horizondb.cluster.pool.firewall_rule.custom import FirewallRuleCreate, FirewallRuleUpdate from .aaz.latest.horizondb.cluster.pool.maintenance_event.custom import MaintenanceEventList from .aaz.latest.horizondb.cluster.private_link_resource.custom import PrivateLinkResourceShow self.command_table['horizondb cluster create'] = ClusterCreate(loader=self) self.command_table['horizondb cluster restore'] = ClusterRestore(loader=self) self.command_table['horizondb cluster update'] = ClusterUpdate(loader=self) + self.command_table['horizondb cluster authentication password create'] = PasswordCreate(loader=self) + self.command_table['horizondb cluster authentication password update'] = PasswordUpdate(loader=self) self.command_table['horizondb cluster pool create'] = PoolCreate(loader=self) self.command_table['horizondb cluster pool update'] = PoolUpdate(loader=self) + self.command_table['horizondb cluster pool firewall-rule create'] = FirewallRuleCreate(loader=self) + self.command_table['horizondb cluster pool firewall-rule update'] = FirewallRuleUpdate(loader=self) self.command_table['horizondb cluster pool maintenance-event list'] = MaintenanceEventList(loader=self) self.command_table['horizondb cluster private-link-resource show'] = PrivateLinkResourceShow(loader=self) return self.command_table diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__cmd_group.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__cmd_group.py new file mode 100644 index 00000000000..06f701e5c5f --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "horizondb cluster authentication", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage authentication methods for a HorizonDB cluster. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__init__.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__init__.py new file mode 100644 index 00000000000..d63ae5a6fc9 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._list import * diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/_list.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/_list.py new file mode 100644 index 00000000000..68610fee1eb --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/_list.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "horizondb cluster authentication list", + is_preview=True, +) +class List(AAZCommand): + """List authentication methods for a HorizonDB cluster. + + :example: List cluster authentication methods + az horizondb cluster authentication list --resource-group example-resource-group --cluster-name example-cluster + """ + + _aaz_info = { + "version": "2026-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.horizondb/clusters/{}/authentications", "2026-10-01-preview"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the HorizonDB cluster.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$", + max_length=63, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AuthenticationsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class AuthenticationsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HorizonDb/clusters/{clusterName}/authentications", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "clusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2026-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.state = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__cmd_group.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__cmd_group.py new file mode 100644 index 00000000000..790679678d3 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "horizondb cluster authentication password", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage password authentication settings for a HorizonDB cluster. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__init__.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__init__.py new file mode 100644 index 00000000000..57f3778e840 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_create.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_create.py new file mode 100644 index 00000000000..3a5a3365ec5 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_create.py @@ -0,0 +1,284 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "horizondb cluster authentication password create", + is_preview=True, +) +class Create(AAZCommand): + """Create or replace password authentication settings for a HorizonDB cluster. + + :example: Set up an administrator using a securely prompted password + az horizondb cluster authentication password create --resource-group example-resource-group --cluster-name example-cluster --state Enabled --administrator-login exampleadmin --administrator-login-password + """ + + _aaz_info = { + "version": "2026-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.horizondb/clusters/{}/authentications/passwordmethod", "2026-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the HorizonDB cluster.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$", + max_length=63, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.administrator_login = AAZStrArg( + options=["--administrator-login"], + arg_group="Properties", + help="The PostgreSQL administrator login name. This value is returned in responses after it is set. After it is set, renaming is not supported. Setting the login requires password authentication state to be Enabled in the same request.", + fmt=AAZStrArgFormat( + max_length=63, + min_length=1, + ), + ) + _args_schema.administrator_login_password = AAZPasswordArg( + options=["--admin-password", "--administrator-login-password"], + arg_group="Properties", + help="The PostgreSQL administrator password. Setting the password requires password authentication state to be Enabled in the same request.", + fmt=AAZStrArgFormat( + max_length=128, + min_length=8, + ), + blank=AAZPromptPasswordInput( + msg="Administrator password: ", + confirm=True, + ), + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="The state of PostgreSQL username-and-password authentication.", + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PasswordAuthenticationsCreateOrReplace(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PasswordAuthenticationsCreateOrReplace(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HorizonDb/clusters/{clusterName}/authentications/passwordMethod", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "clusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2026-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("administratorLogin", AAZStrType, ".administrator_login") + properties.set_prop("administratorLoginPassword", AAZStrType, ".administrator_login_password", typ_kwargs={"flags": {"secret": True}}) + properties.set_prop("state", AAZStrType, ".state", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.administrator_login = AAZStrType( + serialized_name="administratorLogin", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.state = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_show.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_show.py new file mode 100644 index 00000000000..4f8a7ccd772 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_show.py @@ -0,0 +1,216 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "horizondb cluster authentication password show", + is_preview=True, +) +class Show(AAZCommand): + """Show password authentication settings for a HorizonDB cluster. + + :example: Show password authentication settings + az horizondb cluster authentication password show --resource-group example-resource-group --cluster-name example-cluster + """ + + _aaz_info = { + "version": "2026-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.horizondb/clusters/{}/authentications/passwordmethod", "2026-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the HorizonDB cluster.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$", + max_length=63, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PasswordAuthenticationsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PasswordAuthenticationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HorizonDb/clusters/{clusterName}/authentications/passwordMethod", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "clusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2026-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.administrator_login = AAZStrType( + serialized_name="administratorLogin", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.state = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_update.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_update.py new file mode 100644 index 00000000000..d738ef29c76 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_update.py @@ -0,0 +1,275 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "horizondb cluster authentication password update", + is_preview=True, +) +class Update(AAZCommand): + """Update password authentication settings for a HorizonDB cluster. + + :example: Reset the administrator password using a secure prompt + az horizondb cluster authentication password update --resource-group example-resource-group --cluster-name example-cluster --administrator-login-password + """ + + _aaz_info = { + "version": "2026-10-01-preview", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.horizondb/clusters/{}/authentications/passwordmethod", "2026-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the HorizonDB cluster.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$", + max_length=63, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.administrator_login_password = AAZPasswordArg( + options=["--admin-password", "--administrator-login-password"], + arg_group="Properties", + help="The PostgreSQL administrator password. Supplying this property resets the configured administrator's password. When password authentication is currently disabled for a cluster that already has an administrator, this property can be combined with state Enabled to re-enable password authentication and reset the password.", + fmt=AAZStrArgFormat( + max_length=128, + min_length=8, + ), + blank=AAZPromptPasswordInput( + msg="Administrator password: ", + confirm=True, + ), + ) + _args_schema.state = AAZStrArg( + options=["--state"], + arg_group="Properties", + help="The target password-authentication state. Enabled can be combined with administratorLoginPassword to re-enable password authentication and reset the password for a cluster that already has an administrator. Disabling password authentication does not remove or modify existing database users or roles. Disabled cannot be combined with administratorLoginPassword.", + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.PasswordAuthenticationsUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class PasswordAuthenticationsUpdate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HorizonDb/clusters/{clusterName}/authentications/passwordMethod", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "clusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2026-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("administratorLoginPassword", AAZStrType, ".administrator_login_password", typ_kwargs={"flags": {"secret": True}}) + properties.set_prop("state", AAZStrType, ".state") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.administrator_login = AAZStrType( + serialized_name="administratorLogin", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.state = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" + + +__all__ = ["Update"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_wait.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_wait.py new file mode 100644 index 00000000000..3da65816ed8 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/_wait.py @@ -0,0 +1,211 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "horizondb cluster authentication password wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.horizondb/clusters/{}/authentications/passwordmethod", "2026-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.cluster_name = AAZStrArg( + options=["--cluster-name"], + help="The name of the HorizonDB cluster.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$", + max_length=63, + min_length=1, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.PasswordAuthenticationsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=False) + return result + + class PasswordAuthenticationsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HorizonDb/clusters/{clusterName}/authentications/passwordMethod", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "clusterName", self.ctx.args.cluster_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2026-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.administrator_login = AAZStrType( + serialized_name="administratorLogin", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.state = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/custom.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/custom.py new file mode 100644 index 00000000000..022e7ccb0c4 --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/authentication/password/custom.py @@ -0,0 +1,85 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core.aaz import has_value +from azure.cli.core.aaz.exceptions import AAZInvalidArgValueError +from azure.cli.core.azclierror import InvalidArgumentValueError + +from ._create import Create +from ._show import Show +from ._update import Update + + +class _PasswordWrite: + _arguments_schema = None + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + schema = super()._build_arguments_schema(*args, **kwargs) + password = schema.administrator_login_password + validate = password._fmt # pylint: disable=protected-access + + def validate_without_echo(ctx, value): + try: + return validate(ctx, value) + except AAZInvalidArgValueError: + # The default AAZ string-length error includes the supplied value. + raise AAZInvalidArgValueError("Password must contain 8 to 128 characters.") from None + + password._fmt = validate_without_echo # pylint: disable=protected-access + return schema + + def _cli_arguments_loader(self): + arguments = super()._cli_arguments_loader() + password = dict(arguments)['administrator_login_password'] + + class LiteralPasswordAction(password.type.settings['action']): + # Do not interpret punctuation or AAZ shorthand in a password. + decode_str = staticmethod(str) + + password.action = LiteralPasswordAction + return arguments + + def _output(self, *args, **kwargs): + if hasattr(self.ctx.vars, 'instance'): + return super()._output(*args, **kwargs) + # A successful async operation can finish without a resource body. + return Show(cli_ctx=self.cli_ctx)(command_args={ + 'subscription': self.ctx.subscription_id, + 'resource_group': self.ctx.args.resource_group.to_serialized_data(), + 'cluster_name': self.ctx.args.cluster_name.to_serialized_data(), + }) + + +class _NoBodyLogging: + def __call__(self, *args, **kwargs): + # CLI's network trace policy otherwise logs the entire request body under --debug. + kwargs['logging_enable'] = False + return super().__call__(*args, **kwargs) + + +class PasswordCreate(_PasswordWrite, Create): + def pre_operations(self): + args = self.ctx.args + credentials_supplied = has_value(args.administrator_login) or has_value(args.administrator_login_password) + if credentials_supplied and args.state != 'Enabled': + raise InvalidArgumentValueError("Setting administrator credentials requires --state Enabled.") + + class PasswordAuthenticationsCreateOrReplace(_NoBodyLogging, Create.PasswordAuthenticationsCreateOrReplace): + pass + + +class PasswordUpdate(_PasswordWrite, Update): + def pre_operations(self): + args = self.ctx.args + if has_value(args.administrator_login_password): + if args.state == 'Disabled': + raise InvalidArgumentValueError("A password reset cannot be combined with --state Disabled.") + elif not has_value(args.state): + raise InvalidArgumentValueError("Specify --state or --administrator-login-password.") + + class PasswordAuthenticationsUpdate(_NoBodyLogging, Update.PasswordAuthenticationsUpdate): + pass diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_create.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_create.py index 72c135078b4..09d72ebb30f 100644 --- a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_create.py +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_create.py @@ -18,8 +18,8 @@ class Create(AAZCommand): """Create a HorizonDB pool firewall rule. - :example: Create or replace a firewall rule on a HorizonDB pool - az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description Allow access from the corporate network + :example: Create a firewall rule on a HorizonDB pool + az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description "Allow access from the corporate network" """ _aaz_info = { @@ -95,6 +95,7 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--end-ip-address"], arg_group="Properties", help="The end IPv4 address of the firewall rule in dotted-decimal notation. This address must be numerically greater than or equal to startIpAddress.", + required=True, fmt=AAZStrArgFormat( pattern="^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$", ), @@ -103,6 +104,7 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--start-ip-address"], arg_group="Properties", help="The start IPv4 address of the firewall rule in dotted-decimal notation.", + required=True, fmt=AAZStrArgFormat( pattern="^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$", ), diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_update.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_update.py index 998c445194e..ae09b6892ae 100644 --- a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_update.py +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/_update.py @@ -19,7 +19,7 @@ class Update(AAZCommand): """Update a HorizonDB pool firewall rule. :example: Update a firewall rule on a HorizonDB pool - az horizon-db cluster pool firewall-rule update --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description Allow access from the corporate network + az horizondb cluster pool firewall-rule update --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --end-ip-address 10.0.0.254 --description "Allow access from the corporate network" """ _aaz_info = { diff --git a/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/custom.py b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/custom.py new file mode 100644 index 00000000000..a3fece05b7d --- /dev/null +++ b/src/horizondb/azext_horizondb/aaz/latest/horizondb/cluster/pool/firewall_rule/custom.py @@ -0,0 +1,43 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from ipaddress import AddressValueError, IPv4Address + +from knack.log import get_logger +from azure.cli.core.azclierror import InvalidArgumentValueError + +from ._create import Create +from ._update import Update + +logger = get_logger(__name__) + + +def _address(value, option): + try: + return IPv4Address(value.to_serialized_data()) + except AddressValueError as exc: + raise InvalidArgumentValueError(f'{option} must be a dotted-decimal IPv4 address.') from exc + + +def _validate_and_warn(properties): + start = _address(properties.start_ip_address, '--start-ip-address') + end = _address(properties.end_ip_address, '--end-ip-address') + if end < start: + raise InvalidArgumentValueError('--end-ip-address must be greater than or equal to --start-ip-address.') + if start.is_unspecified and end.is_unspecified: + logger.warning('Configuring firewall rule to accept connections from all Azure resources...') + else: + logger.warning("Configuring firewall rule to accept connections from '%s' to '%s'...", start, end) + + +class FirewallRuleCreate(Create): + def pre_operations(self): + _validate_and_warn(self.ctx.args) + + +class FirewallRuleUpdate(Update): + def post_instance_update(self, instance): + # A partial update must be checked against the endpoint retained by the GET. + _validate_and_warn(instance.properties) diff --git a/src/horizondb/azext_horizondb/tests/latest/recording_processors.py b/src/horizondb/azext_horizondb/tests/latest/recording_processors.py index 1830e995c73..d8aeac7782e 100644 --- a/src/horizondb/azext_horizondb/tests/latest/recording_processors.py +++ b/src/horizondb/azext_horizondb/tests/latest/recording_processors.py @@ -16,15 +16,15 @@ class ArmOperationResultsRecordingProcessor(RecordingProcessor): @staticmethod def _scrub_uri(uri): parsed = urlsplit(uri) - match = re.search(r'(/operationresults/)([^/]+)', parsed.path, flags=re.IGNORECASE) + match = re.search(r'/(?:operationresults|azureasyncoperation)/([^/]+)', parsed.path, flags=re.IGNORECASE) if not match: return uri - operation = match.group(2) + operation = match.group(1) if not operation.startswith('recorded-operation-'): digest = hashlib.sha256(operation.casefold().encode('utf-8')).hexdigest()[:16] operation = 'recorded-operation-' + digest - path = parsed.path[:match.start(2)] + operation + parsed.path[match.end(2):] + path = parsed.path[:match.start(1)] + operation + parsed.path[match.end(1):] query = [(key, value) for key, value in parse_qsl(parsed.query, keep_blank_values=True) if key.lower() not in {'c', 'h', 's', 't'}] return urlunsplit(parsed._replace(path=path, query=urlencode(query))) @@ -34,6 +34,8 @@ def process_request(self, request): return request def process_response(self, response): + for header in ['x-ms-operation-identifier', 'x-msedge-ref']: + response['headers'].pop(header, None) for header in ['location', 'azure-asyncoperation', 'operation-location']: self.replace_header_fn(response, header, self._scrub_uri) return response diff --git a/src/horizondb/azext_horizondb/tests/latest/recordings/test_horizondb_authentication.yaml b/src/horizondb/azext_horizondb/tests/latest/recordings/test_horizondb_authentication.yaml new file mode 100644 index 00000000000..2204a540699 --- /dev/null +++ b/src/horizondb/azext_horizondb/tests/latest/recordings/test_horizondb_authentication.yaml @@ -0,0 +1,1822 @@ +interactions: +- request: + body: '{"location": "japaneast", "properties": {"backup": {"geoRedundancy": "Disabled", + "retentionDays": 7}, "network": {"publicAccess": "Disabled"}, "postgreSqlVersion": + "17"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + Content-Length: + - '170' + Content-Type: + - application/json + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"postgreSqlVersion":"17","creationMode":"Create","network":{"publicAccess":"Disabled"},"backup":{"geoRedundancy":"Disabled","retentionDays":7},"provisioningState":"Provisioning"},"location":"japaneast","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002","name":"cli-horizondb-000002","type":"Microsoft.HorizonDb/clusters"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '450' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:23:19 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:23:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:24:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:25:22 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:26:23 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:27:24 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:28:25 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"InProgress","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:29:25 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-827583feeee716e1?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d1197959-2f2d-46c6-8bdb-5697bcb093e6","status":"Succeeded","startTime":"2026-11-23T22:23:20.343Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:26 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002?api-version=2026-10-01-preview + response: + body: + string: '{"identity":{"type":"None"},"properties":{"postgreSqlVersion":"17","creationMode":"Create","network":{"publicAccess":"Disabled"},"backup":{"geoRedundancy":"Disabled","retentionDays":7,"earliestRestorePointUtc":"2026-11-23T22:23:23.6105826+00:00"},"aiModelManagement":"Disabled","readWritePool":{},"state":"Ready","provisioningState":"Succeeded"},"location":"japaneast","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002","name":"cli-horizondb-000002","type":"Microsoft.HorizonDb/clusters"}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002?api-version=2026-10-01-preview + response: + body: + string: '{"identity":{"type":"None"},"properties":{"postgreSqlVersion":"17","creationMode":"Create","network":{"publicAccess":"Disabled"},"backup":{"geoRedundancy":"Disabled","retentionDays":7,"earliestRestorePointUtc":"2026-11-23T22:23:23.6105826+00:00"},"aiModelManagement":"Disabled","readWritePool":{},"state":"Ready","provisioningState":"Succeeded"},"location":"japaneast","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002","name":"cli-horizondb-000002","type":"Microsoft.HorizonDb/clusters"}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:29 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster create + Connection: + - keep-alive + ParameterSetName: + - -g -n --location --version --geo-redundancy --public-access + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002?api-version=2026-10-01-preview + response: + body: + string: '{"identity":{"type":"None"},"properties":{"postgreSqlVersion":"17","creationMode":"Create","network":{"publicAccess":"Disabled"},"backup":{"geoRedundancy":"Disabled","retentionDays":7,"earliestRestorePointUtc":"2026-11-23T22:23:23.6105826+00:00"},"aiModelManagement":"Disabled","readWritePool":{},"state":"Ready","provisioningState":"Succeeded"},"location":"japaneast","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002","name":"cli-horizondb-000002","type":"Microsoft.HorizonDb/clusters"}' + headers: + cache-control: + - no-cache + content-length: + - '602' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"computeModel": {"computeGeneration": 1, "computeProcessor": + "Intel", "vCores": 2, "type": "Provisioned"}, "highAvailability": {"mode": "Disabled"}, + "nodeCount": 1}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + Content-Length: + - '181' + Content-Type: + - application/json + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/pools/authpool?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"computeModel":{"type":"Provisioned","computeProcessor":"Intel","computeGeneration":1,"vCores":2},"nodeCount":1,"highAvailability":{"mode":"Disabled"},"state":"Provisioning","provisioningState":"Provisioning"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/pools/authpool","name":"authpool","type":"Microsoft.HorizonDb/clusters/pools"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '467' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:33 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:30:34 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:31:35 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:32:36 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:33:36 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:34:37 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"InProgress","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:35:38 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-b6c901722fc85aba?api-version=2026-10-01-preview + response: + body: + string: '{"name":"dfe276b2-4ab0-4635-a856-c9276a1f161b","status":"Succeeded","startTime":"2026-11-23T22:30:33.853Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --compute-generation --compute-processor --v-cores --node-count + --high-availability-mode + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/pools/authpool?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"computeModel":{"type":"Provisioned","computeProcessor":"Intel","computeGeneration":1,"vCores":2},"nodeCount":1,"highAvailability":{"mode":"Disabled"},"parameterGroup":{"parameterGroupResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/parameterGroups/default_pg17","applyMethod":"PendingReboot","syncStatus":"InSync"},"scheduledMaintenance":{"maintenanceManagementType":"System"},"state":"Ready","provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/pools/authpool","name":"authpool","type":"Microsoft.HorizonDb/clusters/pools"}' + headers: + cache-control: + - no-cache + content-length: + - '750' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:40 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication list + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications?api-version=2026-10-01-preview + response: + body: + string: '{"value":[{"properties":{"state":"Enabled"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"},{"properties":{"state":"Disabled"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/microsoftEntra","name":"microsoftEntra","type":"Microsoft.HorizonDb/clusters/authentications"}]}' + headers: + cache-control: + - no-cache + content-length: + - '630' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:42 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"administratorLogin": "scenarioadmin", "administratorLoginPassword": + "REDACTED-password-1!", "state": "Enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password create + Connection: + - keep-alive + Content-Length: + - '129' + Content-Type: + - application/json + ParameterSetName: + - -g --cluster-name --state --administrator-login --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"state":"Enabled","provisioningState":"Provisioning","administratorLogin":"scenarioadmin"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-d00556d19c9709cf?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '380' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:45 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-d00556d19c9709cf?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --state --administrator-login --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-d00556d19c9709cf?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d6b8652e-1b82-48a8-afeb-d39b69e1cc60","status":"InProgress","startTime":"2026-11-23T22:36:45.897Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --state --administrator-login --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-d00556d19c9709cf?api-version=2026-10-01-preview + response: + body: + string: '{"name":"d6b8652e-1b82-48a8-afeb-d39b69e1cc60","status":"Succeeded","startTime":"2026-11-23T22:36:45.897Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:57 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password create + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --state --administrator-login --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"state":"Enabled","administratorLogin":"scenarioadmin"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:36:57 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password wait + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --custom --timeout + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"state":"Enabled","administratorLogin":"scenarioadmin"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password show + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"state":"Enabled","administratorLogin":"scenarioadmin"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"administratorLoginPassword": "REDACTED-password-1!"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password update + Connection: + - keep-alive + Content-Length: + - '70' + Content-Type: + - application/json + ParameterSetName: + - -g --cluster-name --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-2d2ece5fcd92cae9?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 23 Nov 2026 22:37:05 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-2d2ece5fcd92cae9?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password update + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-2d2ece5fcd92cae9?api-version=2026-10-01-preview + response: + body: + string: '{"name":"a59bee08-a9f0-4658-b16f-53bbaaed1141","status":"InProgress","startTime":"2026-11-23T22:37:05.613Z"}' + headers: + cache-control: + - no-cache + content-length: + - '108' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:05 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password update + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-2d2ece5fcd92cae9?api-version=2026-10-01-preview + response: + body: + string: '{"name":"a59bee08-a9f0-4658-b16f-53bbaaed1141","status":"Succeeded","startTime":"2026-11-23T22:37:05.613Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:16 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster authentication password update + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name --admin-password + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod?api-version=2026-10-01-preview + response: + body: + string: '{"properties":{"state":"Enabled","administratorLogin":"scenarioadmin"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/authentications/passwordMethod","name":"passwordMethod","type":"Microsoft.HorizonDb/clusters/authentications"}' + headers: + cache-control: + - no-cache + content-length: + - '345' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:17 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g --cluster-name -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002/pools/authpool?api-version=2026-10-01-preview + response: + body: + string: '' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-e4b456167f6d98f8?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 23 Nov 2026 22:37:20 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-e4b456167f6d98f8?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool delete + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-e4b456167f6d98f8?api-version=2026-10-01-preview + response: + body: + string: '{"name":"e2af0f54-f8d7-4167-a730-82e0acece35c","status":"InProgress","startTime":"2026-11-23T22:37:21.19Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:37:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool delete + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/azureAsyncOperation/recorded-operation-e4b456167f6d98f8?api-version=2026-10-01-preview + response: + body: + string: '{"name":"e2af0f54-f8d7-4167-a730-82e0acece35c","status":"Succeeded","startTime":"2026-11-23T22:37:21.19Z"}' + headers: + cache-control: + - no-cache + content-length: + - '106' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:38:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster pool delete + Connection: + - keep-alive + ParameterSetName: + - -g --cluster-name -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/japaneast/operationResults/recorded-operation-e4b456167f6d98f8?api-version=2026-10-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 23 Nov 2026 22:38:22 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_horizondb_auth_000001/providers/Microsoft.HorizonDb/clusters/cli-horizondb-000002?api-version=2026-10-01-preview + response: + body: + string: '' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/Japan%20East/azureAsyncOperation/recorded-operation-b935467649d6eb9d?api-version=2026-10-01-preview + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 23 Nov 2026 22:38:25 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/Japan%20East/operationResults/recorded-operation-b935467649d6eb9d?api-version=2026-10-01-preview + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '799' + x-ms-ratelimit-remaining-subscription-global-deletes: + - '11999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/Japan%20East/azureAsyncOperation/recorded-operation-b935467649d6eb9d?api-version=2026-10-01-preview + response: + body: + string: '{"name":"c92be59f-a0e5-4658-bfe4-32bd40dd01c2","status":"InProgress","startTime":"2026-11-23T22:38:25.92Z"}' + headers: + cache-control: + - no-cache + content-length: + - '107' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:38:26 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/Japan%20East/azureAsyncOperation/recorded-operation-b935467649d6eb9d?api-version=2026-10-01-preview + response: + body: + string: '{"name":"c92be59f-a0e5-4658-bfe4-32bd40dd01c2","status":"Succeeded","startTime":"2026-11-23T22:38:25.92Z"}' + headers: + cache-control: + - no-cache + content-length: + - '106' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 23 Nov 2026 22:38:41 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - horizondb cluster delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.93.0 azsdk-python-core/1.39.0 Python/3.13.14 (Windows-11-10.0.26300-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.HorizonDb/locations/Japan%20East/operationResults/recorded-operation-b935467649d6eb9d?api-version=2026-10-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 23 Nov 2026 22:38:42 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + status: + code: 200 + message: OK +version: 1 diff --git a/src/horizondb/azext_horizondb/tests/latest/test_horizondb_authentication_scenario.py b/src/horizondb/azext_horizondb/tests/latest/test_horizondb_authentication_scenario.py new file mode 100644 index 00000000000..fd8dbf854a8 --- /dev/null +++ b/src/horizondb/azext_horizondb/tests/latest/test_horizondb_authentication_scenario.py @@ -0,0 +1,81 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import secrets +from contextlib import ExitStack +from unittest.mock import patch + +from azure.cli.testsdk import ResourceGroupPreparer, ScenarioTest +from azure.cli.testsdk.scenario_tests import AllowLargeResponse + +from .constants import CLUSTER_NAME_MAX_LENGTH, CLUSTER_NAME_PREFIX, JAPANEAST +from .recording_processors import ArmOperationResultsRecordingProcessor + + +class AuthenticationResourceGroupPreparer(ResourceGroupPreparer): + def create_resource(self, name, **kwargs): + args = super().create_resource(name, **kwargs) + if self.dev_setting_name and self.test_class_instance.in_recording: + self.test_class_instance.name_replacer.register_name_pair(self.dev_setting_name, self.moniker) + return args + + +class HorizonDBAuthenticationScenarioTest(ScenarioTest): + + def __init__(self, method_name): + processor = ArmOperationResultsRecordingProcessor() + super().__init__(method_name, recording_processors=[processor], replay_processors=[processor]) + + def setUp(self): + # Without a cassette the test SDK otherwise records even in playback mode. + if self.in_recording and not self.is_live: + self.skipTest('Authentication cassette missing; record explicitly in a disposable subscription.') + super().setUp() + + @AllowLargeResponse() + @AuthenticationResourceGroupPreparer(name_prefix='cli_test_horizondb_auth_', location=JAPANEAST) + def test_horizondb_authentication(self, resource_group): + self.kwargs.update(rg=resource_group, location=JAPANEAST, + cluster=self.create_random_name(CLUSTER_NAME_PREFIX, CLUSTER_NAME_MAX_LENGTH)) + self.cmd('horizondb cluster create -g {rg} -n {cluster} --location {location} ' + '--version 17 --geo-redundancy Disabled --public-access Disabled') + with ExitStack() as cleanup: + cleanup.callback(self.cmd, 'horizondb cluster delete -g {rg} -n {cluster} --yes') + self.cmd('horizondb cluster pool create -g {rg} --cluster-name {cluster} -n authpool ' + '--compute-generation 1 --compute-processor Intel --v-cores 2 ' + '--node-count 1 --high-availability-mode Disabled') + cleanup.callback(self.cmd, 'horizondb cluster pool delete -g {rg} --cluster-name {cluster} -n authpool --yes') + self._check_authentication() + + def _check_authentication(self): + scope = ' -g {rg} --cluster-name {cluster}' + auth = 'horizondb cluster authentication ' + password = auth + 'password ' + self.cmd(auth + 'list' + scope, checks=[ + self.check("[?name=='passwordMethod'] | length(@)", 1), + self.check("[?name=='microsoftEntra'] | length(@)", 1), + ]) + + # Keep the live credential out of command lines and replace it in the VCR traffic. + placeholder = 'REDACTED-password-1!' + secret = 'Aa1!' + secrets.token_hex(24) if self.in_recording else placeholder + self.name_replacer.register_name_pair(secret, placeholder) + with patch('azure.cli.core.aaz._prompt.prompt_pass', return_value=secret): + self.cmd(password + 'create' + scope + ' --state Enabled --administrator-login scenarioadmin ' + '--admin-password') + self.cmd(password + 'wait' + scope + " --custom \"properties.state == 'Enabled'\" --timeout 120") + self.cmd(password + 'show' + scope, checks=[ + self.check('properties.state', 'Enabled'), + self.check('properties.administratorLogin', 'scenarioadmin'), + self.check('contains(keys(properties), `\"administratorLoginPassword\"`)', False), + ]) + # Reset the password without disabling the cluster's only authentication method. + rotated = 'Bb2!' + secrets.token_hex(24) if self.in_recording else placeholder + self.name_replacer.register_name_pair(rotated, placeholder) + with patch('azure.cli.core.aaz._prompt.prompt_pass', return_value=rotated): + self.cmd(password + 'update' + scope + ' --admin-password', checks=[ + self.check('properties.state', 'Enabled'), + self.check('properties.administratorLogin', 'scenarioadmin'), + ]) diff --git a/src/horizondb/azext_horizondb/tests/latest/unittest_authentication.py b/src/horizondb/azext_horizondb/tests/latest/unittest_authentication.py new file mode 100644 index 00000000000..73d40aae34f --- /dev/null +++ b/src/horizondb/azext_horizondb/tests/latest/unittest_authentication.py @@ -0,0 +1,154 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json +from argparse import ArgumentParser +from unittest import TestCase +from unittest.mock import Mock, patch +from uuid import uuid4 + +from azure.cli.core import get_default_cli +from azure.cli.core.azclierror import InvalidArgumentValueError +from azure.core import PipelineClient +from azure.core.pipeline.policies import ContentDecodePolicy +from knack.prompting import NoTTYException + +from azext_horizondb import HorizonDBCommandsLoader + + +class AuthenticationTests(TestCase): + def setUp(self): + prefix = 'horizondb cluster authentication ' + table = HorizonDBCommandsLoader(cli_ctx=get_default_cli()).load_command_table(None) + self.commands = {name[len(prefix):]: cmd for name, cmd in table.items() if name.startswith(prefix)} + self.args = dict(subscription='00000000-0000-0000-0000-000000000001', resource_group='rg', cluster_name='db') + self.client = Mock(wraps=PipelineClient('https://management.azure.com')) + self.client.build_lro_polling = Mock() + client_patch = patch('azure.cli.core.aaz._command_ctx.AAZCommandCtx.get_http_client', return_value=self.client) + client_patch.start() + self.addCleanup(client_patch.stop) + self.url = ('https://management.azure.com/subscriptions/' + self.args['subscription'] + + '/resourceGroups/rg/providers/Microsoft.HorizonDb/clusters/db/authentications') + self.query = '?api-version=2026-10-01-preview' + self.secret = '[' + uuid4().hex + ']' # Include punctuation meaningful to AAZ shorthand. + self.method = {'name': 'passwordMethod', 'properties': { + 'state': 'Enabled', 'provisioningState': 'Succeeded', 'administratorLogin': 'dbadmin', + 'administratorLoginPassword': self.secret, + }} + + @staticmethod + def response(status, data): + response = Mock(context={ContentDecodePolicy.CONTEXT_NAME: data}) + response.http_response.status_code = status + return response + + def run_command(self, name, **kwargs): + return self.commands[name](command_args=dict(self.args, **kwargs)) + + def test_collection_and_password_get(self): + self.assertEqual(set(self.commands), {'list', 'password show', 'password create', 'password update', + 'password wait'}) + entra = {'name': 'microsoftEntra', 'properties': {'state': 'Disabled'}} + next_page = self.url + '?page=2' + self.client.send_request.side_effect = [ + self.response(200, {'value': [self.method], 'nextLink': next_page}), + self.response(200, {'value': [entra]}), + self.response(200, self.method), + ] + methods = list(self.run_command('list')) + self.assertEqual([item['name'] for item in methods], ['passwordMethod', 'microsoftEntra']) + shown = self.run_command('password show') + self.assertEqual(shown['properties'], { + 'administratorLogin': 'dbadmin', 'state': 'Enabled', 'provisioningState': 'Succeeded'}) + self.assertNotIn(self.secret, str(methods)) + requests = [call.kwargs['request'] for call in self.client.send_request.call_args_list] + self.assertEqual([(r.method, r.url) for r in requests], [ + ('GET', self.url + self.query), ('GET', next_page), ('GET', self.url + '/passwordMethod' + self.query)]) + + def password_argument(self, command, *values, option='--admin-password'): + command.load_arguments() + settings = command.arguments['administrator_login_password'].type.settings + self.assertCountEqual(settings['options_list'], ['--admin-password', '--administrator-login-password']) + parser = ArgumentParser() + parser.add_argument(*settings['options_list'], dest='administrator_login_password', + nargs=settings['nargs'], action=settings['action']) + return vars(parser.parse_args([option, *values])) + + def test_no_wait_put_and_sparse_patch(self): + self.client.send_request.return_value = self.response(202, None) + for verb, options, expected in [ + ('create', {'state': 'Enabled', 'administrator_login': 'dbadmin'}, + {'state': 'Enabled', 'administratorLogin': 'dbadmin', 'administratorLoginPassword': self.secret}), + ('update', {}, {'administratorLoginPassword': self.secret}), + ('update', {'state': 'Enabled'}, {'state': 'Enabled', 'administratorLoginPassword': self.secret}), + ('update', {'state': 'Disabled'}, {'state': 'Disabled'})]: + with self.subTest(verb=verb, state=options.get('state')): + name = 'password ' + verb + if 'administratorLoginPassword' in expected: + option = '--administrator-login-password' if verb == 'create' else '--admin-password' + options.update(self.password_argument(self.commands[name], self.secret, option=option)) + self.assertIsNone(self.run_command(name, no_wait=True, **options)) + request = self.client.send_request.call_args.kwargs['request'] + self.assertEqual((request.method, request.url), ( + 'PUT' if verb == 'create' else 'PATCH', self.url + '/passwordMethod' + self.query)) + self.assertEqual(json.loads(request.body), {'properties': expected}) + self.assertFalse(self.client.send_request.call_args.kwargs['logging_enable']) + self.assertTrue(self.client.build_lro_polling.call_args.args[0]) + self.client.build_lro_polling.return_value.run.assert_not_called() + + def test_wait_polls_password_method(self): + pending = {'properties': {'provisioningState': 'Updating'}} + self.client.send_request.side_effect = [self.response(200, pending), self.response(200, self.method)] + with patch('time.sleep') as sleep: + result = self.run_command('password wait', updated=True, created=False, exists=False, deleted=False, + custom=None, interval=1, timeout=2) + self.assertIsNone(result) + sleep.assert_called_once_with(1) + for call in self.client.send_request.call_args_list: + self.assertEqual(call.kwargs['request'].url, self.url + '/passwordMethod' + self.query) + + def test_prompt_is_confirmed_and_optional(self): + self.client.send_request.return_value = self.response(202, None) + with patch('azure.cli.core.aaz._prompt.prompt_pass', return_value=self.secret) as prompt: + self.run_command('password update', state='Disabled', no_wait=True) + prompt.assert_not_called() + options = self.password_argument(self.commands['password update']) + self.run_command('password update', no_wait=True, **options) + self.assertTrue(prompt.call_args.kwargs['confirm']) + request = self.client.send_request.call_args.kwargs['request'] + self.assertEqual(json.loads(request.body)['properties']['administratorLoginPassword'], self.secret) + prompt.side_effect = NoTTYException + with self.assertRaisesRegex(ValueError, 'non-interactive'): + self.run_command('password update', no_wait=True, **options) + + def test_validation_does_not_echo_password_or_contact_service(self): + for verb in ['create', 'update']: + with self.subTest(verb=verb): + for invalid in [self.secret[:7], self.secret * 4]: + with self.assertRaises(InvalidArgumentValueError) as error: + self.run_command('password ' + verb, state='Enabled', administrator_login_password=invalid) + self.assertNotIn(invalid, str(error.exception)) + with self.assertRaisesRegex(InvalidArgumentValueError, '--state'): + self.run_command('password ' + verb, state='Disabled', administrator_login_password=self.secret, + no_wait=True) + self.client.send_request.assert_not_called() + + def test_completed_write_returns_safe_resource_with_or_without_final_body(self): + for verb, body in [('create', self.method), ('update', None)]: + with self.subTest(verb=verb): + self.client.send_request.side_effect = [self.response(202, None), self.response(200, self.method)] + + def build_polling(_no_wait, _session, callback, *_args, final_body=body, **_kwargs): + poller = Mock() + if final_body: + poller.resource.side_effect = lambda: callback(self.response(200, final_body)) + return poller + + self.client.build_lro_polling.side_effect = build_polling + result = self.run_command('password ' + verb, state='Enabled').result() + self.assertEqual(result['properties']['provisioningState'], 'Succeeded') + self.assertNotIn(self.secret, str(result)) + self.assertEqual(self.client.send_request.call_count, 1 if body else 2) + self.client.send_request.reset_mock() diff --git a/src/horizondb/azext_horizondb/tests/latest/unittest_firewall_rule.py b/src/horizondb/azext_horizondb/tests/latest/unittest_firewall_rule.py index 6c04a19b1e9..851ebb323b7 100644 --- a/src/horizondb/azext_horizondb/tests/latest/unittest_firewall_rule.py +++ b/src/horizondb/azext_horizondb/tests/latest/unittest_firewall_rule.py @@ -30,6 +30,12 @@ def setUp(self): 'pool_name': 'test-pool', } + def _name_args(self, command_type, name): + args = dict(self.args, firewall_rule_name=name) + if command_type is Create: + args.update(start_ip_address='203.0.113.10', end_ip_address='203.0.113.10') + return args + def test_accepts_valid_firewall_rule_names(self): for command_type in [Create, Update, Show, Delete, Wait]: schema = command_type.get_arguments_schema() @@ -38,11 +44,55 @@ def test_accepts_valid_firewall_rule_names(self): for name in ['a', 'Allow_Office.1-rule_', 'a' * 80]: with self.subTest(command=command_type.__name__, name=name): command = command_type(loader=self.loader) - args = dict(self.args, firewall_rule_name=name) + args = self._name_args(command_type, name) AAZCommand._handler(command, args) # pylint: disable=protected-access self.assertRegex(name, pattern) self.assertEqual(command.ctx.args.firewall_rule_name.to_serialized_data(), name) + def test_create_validates_ipv4_range_before_request(self): + name = 'horizondb cluster pool firewall-rule create' + command = self.loader.load_command_table(name.split())[name] + for start, end, error in [ + ('2001:db8::1', '203.0.113.10', '--start-ip-address'), + ('203.0.113.10', '256.0.0.1', '--end-ip-address'), + ('203.0.113.10', '203.0.113.9', 'greater than or equal')]: + with self.subTest(start=start, end=end), self.assertRaisesRegex(InvalidArgumentValueError, error): + command(command_args=dict(self.args, firewall_rule_name='office', start_ip_address=start, + end_ip_address=end, no_wait=True)) + + def test_create_warns_about_effective_access(self): + name = 'horizondb cluster pool firewall-rule create' + command = self.loader.load_command_table(name.split())[name] + for end, message in [('0.0.0.0', 'from all Azure resources'), + ('0.0.0.10', "from '0.0.0.0' to '0.0.0.10'")]: + with self.subTest(end=end), patch.object(command, 'FirewallRulesCreateOrReplace'), \ + self.assertLogs(level='WARNING') as logs: + command(command_args=dict(self.args, firewall_rule_name='office', start_ip_address='0.0.0.0', + end_ip_address=end, no_wait=True)) + self.assertIn(message, logs.output[-1]) + + def test_update_validates_merged_range_before_put(self): + name = 'horizondb cluster pool firewall-rule update' + command = self.loader.load_command_table(name.split())[name] + args = dict(self.args, firewall_rule_name='office', end_ip_address='203.0.113.9', no_wait=True) + + def load_existing(): + command.ctx.set_var('instance', {'properties': { + 'startIpAddress': '203.0.113.10', 'endIpAddress': '203.0.113.12', + }}, schema_builder=Update.FirewallRulesGet._build_schema_on_200) # pylint: disable=protected-access + + with patch.object(command, 'FirewallRulesGet') as get, \ + patch.object(command, 'FirewallRulesCreateOrReplace') as put: + get.return_value.side_effect = load_existing + with self.assertRaisesRegex(InvalidArgumentValueError, 'greater than or equal'): + command(command_args=args) + put.assert_not_called() + args['end_ip_address'] = '203.0.113.10' + with self.assertLogs(level='WARNING') as logs: + command(command_args=args) + self.assertIn("from '203.0.113.10' to '203.0.113.10'", logs.output[-1]) + put.assert_called_once() + def test_firewall_rule_name_pattern_rejects_invalid_names(self): for command_type in [Create, Update, Show, Delete, Wait]: schema = command_type.get_arguments_schema() @@ -55,6 +105,6 @@ def test_rejects_firewall_rule_names_longer_than_80_characters(self): for command_type in [Create, Update, Show, Delete, Wait]: with self.subTest(command=command_type.__name__): command = command_type(loader=self.loader) - args = dict(self.args, firewall_rule_name='a' * 81) + args = self._name_args(command_type, 'a' * 81) with self.assertRaises(InvalidArgumentValueError): AAZCommand._handler(command, args) # pylint: disable=protected-access diff --git a/src/horizondb/setup.py b/src/horizondb/setup.py index 879f3bf6ce8..57c1b28282f 100644 --- a/src/horizondb/setup.py +++ b/src/horizondb/setup.py @@ -14,7 +14,7 @@ from distutils import log as logger logger.warn("Wheel is not available, disabling bdist_wheel hook") -VERSION = '1.0.0b10' +VERSION = '1.0.0b11' CLASSIFIERS = [ 'Development Status :: 4 - Beta',