From 5bafbf49c205cc9ffe39e8da9ddb55fa2bf97e67 Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Thu, 3 Jul 2025 10:41:37 -0700 Subject: [PATCH 1/7] register command group for security-policy waf --- src/alb/HISTORY.rst | 4 ++++ src/alb/azext_alb/custom.py | 8 +++++++- src/alb/setup.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/alb/HISTORY.rst b/src/alb/HISTORY.rst index deccc0d4c54..68318e18b36 100644 --- a/src/alb/HISTORY.rst +++ b/src/alb/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +2.0.1 +++++++ +* Register command group for security-policy waf and add description. + 2.0.0 ++++++ * Upgrade API version to 2025-01-01, introducing Security Policy WAF. diff --git a/src/alb/azext_alb/custom.py b/src/alb/azext_alb/custom.py index a32dde66203..0a1df2c87e0 100644 --- a/src/alb/azext_alb/custom.py +++ b/src/alb/azext_alb/custom.py @@ -9,7 +9,7 @@ # pylint: disable=too-many-statements, protected-access from knack.log import get_logger -from azure.cli.core.aaz import register_command +from azure.cli.core.aaz import register_command, register_command_group, AAZCommandGroup from .aaz.latest.network.alb.association import Create as _AssociationCreate from .aaz.latest.network.alb.security_policy import Create as _SPCreate, Delete as _SPDelete, Update as _SPUpdate @@ -33,6 +33,12 @@ def _build_arguments_schema(cls, *args, **kwargs): return args_schema +@register_command_group("network alb security-policy waf") +class __CMDGroup(AAZCommandGroup): + """Manage and Configure WAF Security Policies for Application Gateway for Containers resource + """ + + @register_command("network alb security-policy waf create") class WafSecurityPolicyCreate(_SPCreate): """Create a Waf SecurityPolicy diff --git a/src/alb/setup.py b/src/alb/setup.py index 013c4171898..d23521e5e12 100644 --- a/src/alb/setup.py +++ b/src/alb/setup.py @@ -10,7 +10,7 @@ # HISTORY.rst entry. -VERSION = '2.0.0' +VERSION = '2.0.1' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From f09bd81b3433619916fdea67f62438ed52da09ed Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Thu, 3 Jul 2025 10:57:58 -0700 Subject: [PATCH 2/7] fix pylint style check --- src/alb/azext_alb/custom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/alb/azext_alb/custom.py b/src/alb/azext_alb/custom.py index 0a1df2c87e0..aee8ac879d5 100644 --- a/src/alb/azext_alb/custom.py +++ b/src/alb/azext_alb/custom.py @@ -7,6 +7,7 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements, protected-access +# pylint: disable=too-few-public-methods from knack.log import get_logger from azure.cli.core.aaz import register_command, register_command_group, AAZCommandGroup From e275593c95f499c52a0f653e7a1451023730680e Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Mon, 7 Jul 2025 15:22:37 -0700 Subject: [PATCH 3/7] modify _help.py instead of custom.py --- src/alb/azext_alb/_help.py | 5 +++++ src/alb/azext_alb/custom.py | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/alb/azext_alb/_help.py b/src/alb/azext_alb/_help.py index 126d5d00714..9e816dda112 100644 --- a/src/alb/azext_alb/_help.py +++ b/src/alb/azext_alb/_help.py @@ -9,3 +9,8 @@ # pylint: disable=too-many-lines from knack.help_files import helps # pylint: disable=unused-import + +helps['network alb security-policy waf'] = """ +type: group +short-summary: Manage and Configure WAF Security Policies for Application Gateway for Containers resource +""" \ No newline at end of file diff --git a/src/alb/azext_alb/custom.py b/src/alb/azext_alb/custom.py index aee8ac879d5..ab3ac38eeab 100644 --- a/src/alb/azext_alb/custom.py +++ b/src/alb/azext_alb/custom.py @@ -10,7 +10,7 @@ # pylint: disable=too-few-public-methods from knack.log import get_logger -from azure.cli.core.aaz import register_command, register_command_group, AAZCommandGroup +from azure.cli.core.aaz import register_command from .aaz.latest.network.alb.association import Create as _AssociationCreate from .aaz.latest.network.alb.security_policy import Create as _SPCreate, Delete as _SPDelete, Update as _SPUpdate @@ -34,12 +34,6 @@ def _build_arguments_schema(cls, *args, **kwargs): return args_schema -@register_command_group("network alb security-policy waf") -class __CMDGroup(AAZCommandGroup): - """Manage and Configure WAF Security Policies for Application Gateway for Containers resource - """ - - @register_command("network alb security-policy waf create") class WafSecurityPolicyCreate(_SPCreate): """Create a Waf SecurityPolicy From e81858771dc1d026be11aab1da1eb24503e8baec Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Mon, 7 Jul 2025 15:23:24 -0700 Subject: [PATCH 4/7] remove redundant comments --- src/alb/azext_alb/custom.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/alb/azext_alb/custom.py b/src/alb/azext_alb/custom.py index ab3ac38eeab..a32dde66203 100644 --- a/src/alb/azext_alb/custom.py +++ b/src/alb/azext_alb/custom.py @@ -7,7 +7,6 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-statements, protected-access -# pylint: disable=too-few-public-methods from knack.log import get_logger from azure.cli.core.aaz import register_command From 84a080648c5c4e3f541d73e86e6039a738083f2b Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Mon, 7 Jul 2025 15:24:57 -0700 Subject: [PATCH 5/7] fix style --- src/alb/azext_alb/_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alb/azext_alb/_help.py b/src/alb/azext_alb/_help.py index 9e816dda112..b47ebb5fb86 100644 --- a/src/alb/azext_alb/_help.py +++ b/src/alb/azext_alb/_help.py @@ -13,4 +13,4 @@ helps['network alb security-policy waf'] = """ type: group short-summary: Manage and Configure WAF Security Policies for Application Gateway for Containers resource -""" \ No newline at end of file +""" From 1ce4ba452eb8d43a52e14dde6681b5e415525999 Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Mon, 7 Jul 2025 20:32:02 -0700 Subject: [PATCH 6/7] fix linter --- src/alb/azext_alb/commands.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/alb/azext_alb/commands.py b/src/alb/azext_alb/commands.py index fc768871325..2a6ba1db193 100644 --- a/src/alb/azext_alb/commands.py +++ b/src/alb/azext_alb/commands.py @@ -15,3 +15,6 @@ def load_command_table(self, _): # pylint: disable=unused-argument self.command_table["network alb security-policy waf create"] = WafSecurityPolicyCreate(loader=self) self.command_table["network alb security-policy waf delete"] = WafSecurityPolicyDelete(loader=self) self.command_table["network alb security-policy waf update"] = WafSecurityPolicyUpdate(loader=self) + + with self.command_group("network alb security-policy waf") as _: + pass From 85d889ba7dbcbd9fcddde93f676d344eb6092717 Mon Sep 17 00:00:00 2001 From: Chengde Xu Date: Wed, 9 Jul 2025 18:30:50 -0700 Subject: [PATCH 7/7] fix tests --- src/alb/azext_alb/tests/latest/test_alb_commands.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/alb/azext_alb/tests/latest/test_alb_commands.py b/src/alb/azext_alb/tests/latest/test_alb_commands.py index 70b42e3f77a..d80cc0d2958 100644 --- a/src/alb/azext_alb/tests/latest/test_alb_commands.py +++ b/src/alb/azext_alb/tests/latest/test_alb_commands.py @@ -21,9 +21,10 @@ TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) class AlbScenario(ScenarioTest): + @live_only() + @ResourceGroupPreparer(name_prefix='cli_record_test_tc_000999990', location="eastus2euap") def test_alb_resources(self): self.kwargs.update({ - 'rg': 'cli_record_test_tc_000999990', 'tc': 'tc1', 'fe': 'fe1', 'aso': 'a1', @@ -32,10 +33,6 @@ def test_alb_resources(self): 'waf_policy': 'waf_policy1', 'sp_waf': 'sp_waf1', }) - - #Works with subscription 668f1741-ef48-4132-bf98-28b3a3d3f257 - # Create Resource group. - self.cmd('group create -n {rg} --location eastus2euap') # Create Traffic Controller tcCount1 = len(self.cmd('network alb list -g {rg}').get_output_in_json())