Skip to content

Commit 0df26f7

Browse files
Ajit Navasaretjprescott
authored andcommitted
ServiceBus: Added validator for rights (#9886)
* added validator for rigths * fixed logic * updated history
1 parent a641b75 commit 0df26f7

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/azure-cli/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Release History
3535
* Fixed issue #8775 : Cannot create hybrid connection with disabled client authroization
3636
* Added parameter "--requires-transport-security" to az relay wcfrelay create
3737

38+
**Servicebus**
39+
40+
* Fix for issue #5824 - added validation for parameter --rights of authorizationrule commands
41+
3842
**Storage**
3943

4044
* Enable Files AADDS for storage account update.

src/azure-cli/azure/cli/command_modules/servicebus/_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def load_arguments_sb(self, _):
1515
from azure.cli.command_modules.servicebus._validators import _validate_auto_delete_on_idle, \
1616
_validate_duplicate_detection_history_time_window, \
1717
_validate_default_message_time_to_live, \
18-
_validate_lock_duration, validate_partner_namespace, validate_premiumsku_capacity, validate_target_namespace
18+
_validate_lock_duration, validate_partner_namespace, validate_premiumsku_capacity, validate_target_namespace, validate_rights
1919

2020
from knack.arguments import CLIArgumentType
2121
from azure.mgmt.servicebus.models import SkuName, AccessRights, KeyType, FilterType
22-
rights_arg_type = CLIArgumentType(options_list=['--rights'], nargs='+', arg_type=get_enum_type(AccessRights), help='Space-separated list of Authorization rule rights')
22+
rights_arg_type = CLIArgumentType(options_list=['--rights'], nargs='+', arg_type=get_enum_type(AccessRights), validator=validate_rights, help='Space-separated list of Authorization rule rights')
2323
key_arg_type = CLIArgumentType(options_list=['--key'], arg_type=get_enum_type(KeyType), help='specifies Primary or Secondary key needs to be reset')
2424
keyvalue_arg_type = CLIArgumentType(options_list=['--key-value'], help='Optional, if the key value provided, is set for KeyType or autogenerated Key value set for keyType.')
2525

src/azure-cli/azure/cli/command_modules/servicebus/_validators.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ def validate_subnet(cmd, namespace):
116116
else:
117117
raise CLIError('incorrect usage: [--subnet ID | --subnet NAME --vnet-name NAME]')
118118
delattr(namespace, 'vnet_name')
119+
120+
121+
def validate_rights(namespace):
122+
if 'Manage' in namespace.rights:
123+
if 'Listen' not in namespace.rights or 'Send' not in namespace.rights:
124+
raise CLIError('Error : Assigning \'Manage\' to --rights requires \'Listen\' and \'Send\' to be included with. e.g. --rights Manage Send Listen')

0 commit comments

Comments
 (0)