Skip to content
Closed
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
4 changes: 4 additions & 0 deletions src/authV2/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.1
++++++
* Fix excluded paths parsing in `az webapp auth update` command.

1.0.0
++++++
* Update module documentation.
Expand Down
12 changes: 10 additions & 2 deletions src/authV2/azext_authV2/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,16 @@ def update_auth_settings_v2(cmd, resource_group_name, name, set_string=None, ena
if excluded_paths is not None:
if "globalValidation" not in existing_auth.keys():
existing_auth["globalValidation"] = {}
excluded_paths_list_string = excluded_paths[1:-1]
existing_auth["globalValidation"]["excludedPaths"] = excluded_paths_list_string.split(",")
try:
parsed = json.loads(excluded_paths)
if isinstance(parsed, list):
excluded_paths_list = parsed
else:
excluded_paths_list = [parsed] if parsed else []
except json.JSONDecodeError:
excluded_paths_list = excluded_paths.split(",")

existing_auth["globalValidation"]["excludedPaths"] = excluded_paths_list

existing_auth = update_http_settings_in_auth_settings(existing_auth, require_https,
proxy_convention, proxy_custom_host_header,
Expand Down
1,800 changes: 1,478 additions & 322 deletions src/authV2/azext_authV2/tests/latest/recordings/test_authV2_auth.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

72 changes: 68 additions & 4 deletions src/authV2/azext_authV2/tests/latest/test_authV2_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class Authv2ScenarioTest(ScenarioTest):

@ResourceGroupPreparer(name_prefix='cli_test_authV2')
@AllowLargeResponse()
def test_authV2_clientsecret_param_combinations(self, resource_group):
webapp_name = self.create_random_name('webapp-authentication-test', 40)
plan_name = self.create_random_name('webapp-authentication-plan', 40)
Expand All @@ -29,13 +30,17 @@ def test_authV2_clientsecret_param_combinations(self, resource_group):

# testing show command for newly created app and initial fields
self.cmd('webapp auth show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('properties', {})
JMESPathCheck('properties.platform.enabled', False)
])

# upgrade to v2 before using v2 commands
self.cmd('webapp auth config-version upgrade -g {} -n {}'.format(resource_group, webapp_name))

# # update and verify
self.cmd('webapp auth update -g {} -n {} --enabled true --runtime-version 1.2.8'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('platform', "{'enabled': True, 'runtimeVersion': '1.2.8'}")
JMESPathCheck('platform.enabled', True),
JMESPathCheck('platform.runtimeVersion', '1.2.8')
])

with self.assertRaisesRegex(ArgumentUsageError, 'Usage Error: --client-secret and --client-secret-setting-name cannot both be '
Expand Down Expand Up @@ -79,6 +84,7 @@ def test_authV2_clientsecret_param_combinations(self, resource_group):
.format(resource_group, webapp_name))

@ResourceGroupPreparer(name_prefix='cli_test_authV2')
@AllowLargeResponse()
def test_authV2_auth(self, resource_group):
webapp_name = self.create_random_name('webapp-authentication-test', 40)
plan_name = self.create_random_name('webapp-authentication-plan', 40)
Expand All @@ -92,17 +98,21 @@ def test_authV2_auth(self, resource_group):

# testing show command for newly created app and initial fields
self.cmd('webapp auth show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('properties', {})
JMESPathCheck('properties.platform.enabled', False)
])

self.cmd('webapp auth config-version upgrade -g {} -n {}'.format(resource_group, webapp_name))

# # update and verify
self.cmd('webapp auth update -g {} -n {} --enabled true --runtime-version 1.2.8'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('platform', "{'enabled': True, 'runtimeVersion': '1.2.8'}")
JMESPathCheck('platform.enabled', True),
JMESPathCheck('platform.runtimeVersion', '1.2.8')
])


@ResourceGroupPreparer(name_prefix='cli_test_authV2')
@AllowLargeResponse()
def test_authV2_authclassic(self, resource_group):
webapp_name = self.create_random_name('webapp-authentication-test', 40)
plan_name = self.create_random_name('webapp-authentication-plan', 40)
Expand Down Expand Up @@ -154,3 +164,57 @@ def test_authV2_authclassic(self, resource_group):
JMESPathCheck('facebookAppId', 'facebook_id')]).get_output_in_json()

self.assertIn('https://audience1', result['allowedAudiences'])

@ResourceGroupPreparer(name_prefix='cli_test_authV2')
@AllowLargeResponse()
def test_authV2_excluded_paths_parsing(self, resource_group):
webapp_name = self.create_random_name('webapp-authentication-test', 40)
plan_name = self.create_random_name('webapp-authentication-plan', 40)
self.cmd(
'appservice plan create -g {} -n {} --sku S1'.format(resource_group, plan_name))
self.cmd(
'webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan_name))
self.cmd('webapp auth config-version show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('configVersion', 'v1')
])

self.cmd('webapp auth show -g {} -n {}'.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('properties.platform.enabled', False)
])
self.cmd('webapp auth config-version upgrade -g {} -n {}'.format(resource_group, webapp_name))

# # update and verify
# test single path
self.cmd('webapp auth update -g {} -n {} --enabled true --excluded-paths "/health"'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('platform.enabled', True),
JMESPathCheck('globalValidation.excludedPaths[0]', '/health')
])

# test multiple comma separated paths
self.cmd('webapp auth update -g {} -n {} --excluded-paths "/health,/status,/metrics"'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('globalValidation.excludedPaths[0]', '/health'),
JMESPathCheck('globalValidation.excludedPaths[1]', '/status'),
JMESPathCheck('globalValidation.excludedPaths[2]', '/metrics')
])

# test JSON array format
self.cmd('webapp auth update -g {} -n {} --excluded-paths \'["/api/health", "/api/status"]\''
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('globalValidation.excludedPaths[0]', '/api/health'),
JMESPathCheck('globalValidation.excludedPaths[1]', '/api/status')
])

# test paths with special characters
self.cmd('webapp auth update -g {} -n {} --excluded-paths "/api/v1/health,/webhook/callback"'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('globalValidation.excludedPaths[0]', '/api/v1/health'),
JMESPathCheck('globalValidation.excludedPaths[1]', '/webhook/callback')
])

# test single path without leading slash
self.cmd('webapp auth update -g {} -n {} --excluded-paths "public"'
.format(resource_group, webapp_name)).assert_with_checks([
JMESPathCheck('globalValidation.excludedPaths[0]', 'public')
])
2 changes: 1 addition & 1 deletion src/authV2/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '1.0.0'
VERSION = '1.0.1'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading