Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APIM] Fixed apim upgrade bug when specifying protocols #18605

Merged
merged 4 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/apim/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def load_arguments(self, _):
c.argument('api_version', arg_group='API', help='Describes the Version of the Api. If you add a version to a non-versioned API, an Original version will be automatically created and will respond on the default URL')
c.argument('api_version_set_id', arg_group='API', help='Describes the Version Set to be used with the API')
c.argument('service_url', arg_group='API', help='Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.')
c.argument('protocols', arg_group='API', arg_type=get_enum_type(API_PROTOCOLS), nargs='+', help='Describes on which protocols the operations in this API can be invoked.')
c.argument('protocols', arg_group='API', arg_type=get_enum_type(API_PROTOCOLS), nargs='+', help='Describes on which protocols(one or more) the operations in this API can be invoked.')
c.argument('api_type', arg_group='API', arg_type=get_enum_type(API_TYPES), help='The type of the API.')
c.argument('subscription_required', arg_group='API', arg_type=get_three_state_flag(), help='If true, the API requires a subscription key on requests.')
c.argument('display_name', arg_group='API', help='Display name of this API.')
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/apim/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def update_apim_api(instance, description=None, subscription_key_header_name=Non
instance.service_url = service_url

if protocols is not None:
instance.protocols = protocols.split(',')
instance.protocols = protocols

if path is not None:
instance.path = path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_apim_core_service(self, resource_group, resource_group_location, storag
'sku_name': 'Developer',
'skucapacity': 1,
'enable_cert': True,
'tags': ["foo=boo"],
'tag': "foo=boo"
})

self.cmd('apim check-name -n {service_name} -o json',
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_apim_core_service(self, resource_group, resource_group_location, storag
'display_name': 'Contoso API',
'path': 'test',
'path2': 'test2',
'protocols': 'https',
'protocol': 'https',
'service_url': 'https://contoso.com',
'subscription_key_header_name': 'header',
'subscription_key_query_param_name': 'query',
Expand Down Expand Up @@ -150,10 +150,11 @@ def test_apim_core_service(self, resource_group, resource_group_location, storag
])

# create api
self.cmd('apim api create -g "{rg}" --service-name "{service_name}" --display-name "{display_name}" --path "{path}" --api-id "{api_id}" --protocols "{protocols}" --service-url "{service_url}" --subscription-key-header-name "{subscription_key_header_name}" --subscription-key-query-param-name "{subscription_key_query_param_name}"', checks=[
self.cmd('apim api create -g "{rg}" --service-name "{service_name}" --display-name "{display_name}" --path "{path}" --api-id "{api_id}" --protocols "{protocol}" --service-url "{service_url}" --subscription-key-header-name "{subscription_key_header_name}" --subscription-key-query-param-name "{subscription_key_query_param_name}"', checks=[
self.check('displayName', '{display_name}'),
self.check('path', '{path}'),
self.check('serviceUrl', '{service_url}')
self.check('serviceUrl', '{service_url}'),
self.check('protocols[0]', '{protocol}')
])

# wait
Expand All @@ -172,8 +173,9 @@ def test_apim_core_service(self, resource_group, resource_group_location, storag
])

# update api
self.cmd('apim api update -g "{rg}" --service-name "{service_name}" --api-id "{api_id}" --description "{description}"', checks=[
self.check('description', '{description}')
self.cmd('apim api update -g "{rg}" --service-name "{service_name}" --api-id "{api_id}" --description "{description}" --protocols {protocol}', checks=[
self.check('description', '{description}'),
self.check('protocols[0]', '{protocol}')
])

# list apis
Expand Down Expand Up @@ -339,12 +341,12 @@ def test_apim_core_service(self, resource_group, resource_group_location, storag
'value': 'testvalue123',
'nv_id': self.create_random_name('az-nv', 12),
'secret': True,
'tags': "foo=baz",
'tag': "foo=baz",
'updatedtestvalue': 'updatedtestvalue123'
})

# create named value
self.cmd('apim nv create -g "{rg}" --service-name "{service_name}" --display-name "{display_name}" --value "{value}" --named-value-id "{nv_id}" --secret "{secret}" --tags "{tags}"', checks=[
self.cmd('apim nv create -g "{rg}" --service-name "{service_name}" --display-name "{display_name}" --value "{value}" --named-value-id "{nv_id}" --secret "{secret}" --tags "{tag}"', checks=[
self.check('displayName', '{display_name}'),
self.check('secret', '{secret}')
])
Expand Down