Skip to content

Commit

Permalink
Removing the duplicate command "az iot hub show-connection-string" (#65)
Browse files Browse the repository at this point in the history
* removing the duplicate command

* update the return key of show-connection-string commands
  • Loading branch information
anusapan authored and YingXue committed Mar 7, 2019
1 parent 5a7f3b2 commit 9f051e5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 28 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release History
* Added support for edge offline commands.
* Upgrade service Sdk to 2018-08-30-preview.
* Added --set-parent and --add-children to device-identity create to support edge offline feature.
* BREAKING CHANGES: The commands "az iot hub show-connection-string", "az iot hub device-identity show-connection-string" and "az iot hub module-identity show-connection-string" will no longer return the output with key "cs".

0.6.1
+++++++++++++++
Expand Down
5 changes: 0 additions & 5 deletions azext_iot/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,6 @@
az iot hub query -n {iothub_name} -q "select * from devices.modules where devices.deviceId = '{device_id}'"
"""

helps['iot hub show-connection-string'] = """
type: command
short-summary: Show a target IoT Hub Connection String.
"""

helps['iot hub configuration'] = """
type: group
short-summary: Manage IoT device configurations at scale
Expand Down
2 changes: 0 additions & 2 deletions azext_iot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def load_command_table(self, _):
cmd_group.command('monitor-events', 'iot_hub_monitor_events')
cmd_group.command('monitor-feedback', 'iot_hub_monitor_feedback')

cmd_group.command('show-connection-string', 'iot_get_hub_connection_string')

with self.command_group('iot hub device-identity', command_type=iothub_ops) as cmd_group:
cmd_group.command('create', 'iot_device_create')
cmd_group.command('show', 'iot_device_show')
Expand Down
6 changes: 4 additions & 2 deletions azext_iot/operations/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ def _build_device_or_module_connection_string(device, key_type='primary', module
raise CLIError('Unable to form target connection string')


# Introducing breaking changes by removing this command as same command exist in core-cli.
# Only removing the command and keeping command defination for further references.
def iot_get_hub_connection_string(cmd, hub_name, policy_name='iothubowner', key_type='primary',
resource_group_name=None):
result = {}
Expand All @@ -974,7 +976,7 @@ def iot_get_device_connection_string(cmd, device_id, hub_name=None, key_type='pr
result = {}
device = iot_device_show(cmd, device_id,
hub_name=hub_name, resource_group_name=resource_group_name, login=login)
result['cs'] = _build_device_or_module_connection_string(device, key_type)
result['connectionString'] = _build_device_or_module_connection_string(device, key_type)
return result


Expand All @@ -983,7 +985,7 @@ def iot_get_module_connection_string(cmd, device_id, module_id, hub_name=None, k
result = {}
module = iot_device_module_show(cmd, device_id, module_id,
resource_group_name=resource_group_name, hub_name=hub_name, login=login)
result['cs'] = _build_device_or_module_connection_string(None, key_type, module)
result['connectionString'] = _build_device_or_module_connection_string(None, key_type, module)
return result


Expand Down
25 changes: 6 additions & 19 deletions azext_iot/tests/test_iot_ext_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@ def tearDown(self):
self._remove_entities()

def test_hub(self):
hub_policy = "iothubowner"

hub_conn_str_pattern = r'^HostName={}\.azure-devices\.net;SharedAccessKeyName={};SharedAccessKey='.format(
LIVE_HUB, hub_policy)

self.cmd('iot hub show-connection-string -n {} -g {}'.format(LIVE_HUB, LIVE_RG), checks=[
self.check_pattern('cs', hub_conn_str_pattern)
])
self.cmd('iot hub show-connection-string -n {} -g {} --kt {}'.format(LIVE_HUB, LIVE_RG, 'secondary'), checks=[
self.check_pattern('cs', hub_conn_str_pattern)
])
self.cmd('iot hub show-connection-string -n {} -g {} --kt {} --pn doesnotexist'.format(LIVE_HUB, LIVE_RG, 'secondary'),
expect_failure=True)

self.cmd('az iot hub generate-sas-token -n {} -g {}'.format(LIVE_HUB, LIVE_RG), checks=[
self.exists('sas')
Expand Down Expand Up @@ -369,15 +356,15 @@ def test_hub_devices(self):

self.cmd('iot hub device-identity show-connection-string -d {} -n {} -g {}'
.format(edge_device_ids[0], LIVE_HUB, LIVE_RG),
checks=[self.check_pattern('cs', sym_conn_str_pattern)])
checks=[self.check_pattern('connectionString', sym_conn_str_pattern)])

self.cmd('iot hub device-identity show-connection-string -d {} -n {} -g {} --kt {}'
.format(edge_device_ids[0], LIVE_HUB, LIVE_RG, 'secondary'),
checks=[self.check_pattern('cs', sym_conn_str_pattern)])
checks=[self.check_pattern('connectionString', sym_conn_str_pattern)])

self.cmd('iot hub device-identity show-connection-string -d {} -n {} -g {}'
.format(device_ids[2], LIVE_HUB, LIVE_RG),
checks=[self.check_pattern('cs', cer_conn_str_pattern)])
checks=[self.check_pattern('connectionString', cer_conn_str_pattern)])

self.cmd('iot hub generate-sas-token -n {} -g {} -d {}'.format(LIVE_HUB, LIVE_RG, edge_device_ids[0]), checks=[
self.exists('sas')
Expand Down Expand Up @@ -663,16 +650,16 @@ def test_hub_modules(self):
LIVE_HUB, edge_device_ids[0], module_ids[0])
self.cmd('iot hub module-identity show-connection-string -d {} -n {} -g {} -m {}'
.format(edge_device_ids[0], LIVE_HUB, LIVE_RG, module_ids[0]),
checks=[self.check_pattern('cs', mod_sym_conn_str_pattern)])
checks=[self.check_pattern('connectionString', mod_sym_conn_str_pattern)])

# With connection string
self.cmd('iot hub module-identity show-connection-string -d {} --login {} -m {}'
.format(edge_device_ids[0], LIVE_HUB_CS, module_ids[0]),
checks=[self.check_pattern('cs', mod_sym_conn_str_pattern)])
checks=[self.check_pattern('connectionString', mod_sym_conn_str_pattern)])

self.cmd('iot hub module-identity show-connection-string -d {} -n {} -g {} -m {} --kt {}'
.format(edge_device_ids[0], LIVE_HUB, LIVE_RG, module_ids[0], "secondary"),
checks=[self.check_pattern('cs', mod_sym_conn_str_pattern)])
checks=[self.check_pattern('connectionString', mod_sym_conn_str_pattern)])

for i in module_ids:
if module_ids.index(i) == (len(module_ids) - 1):
Expand Down

0 comments on commit 9f051e5

Please sign in to comment.