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

{AppConfig} Fix #13498958: Fix errors with az appconfig revision list when using customized fields #21419

Merged
merged 6 commits into from
Feb 25, 2022
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
1 change: 1 addition & 0 deletions scripts/ci/credscan/CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_azconfig_json_content_type.yaml",
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_azconfig_key_validation.yaml",
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_azconfig_kv.yaml",
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_azconfig_kv_revision_list.yaml",
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_azconfig_public_network_access.yaml",
"src\\azure-cli\\azure\\cli\\command_modules\\appconfig\\tests\\latest\\recordings\\test_resolve_keyvault.yaml"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,16 @@ def list_revision(cmd,
label = prep_label_filter_for_url_encoding(label)

try:
query_fields = None
if fields:
query_fields = []
for field in fields:
query_fields.append(field.name.lower())

revisions_iterable = azconfig_client.list_revisions(key_filter=key,
label_filter=label,
accept_datetime=datetime,
fields=fields)
fields=query_fields)
pratiksanglikar marked this conversation as resolved.
Show resolved Hide resolved
retrieved_revisions = []
count = 0

Expand Down

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.

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.

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.

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.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,85 @@ def test_resolve_keyvault(self, key_vault, resource_group):
assert len(exported_kvs) == 1
assert exported_kvs[secret_name] == secret_value

@AllowLargeResponse()
@ResourceGroupPreparer(parameter_name_for_location='location')
def test_azconfig_kv_revision_list(self, resource_group, location):
config_store_name = self.create_random_name(prefix='KVRevisionTest', length=24)

location = 'eastus'
sku = 'standard'
self.kwargs.update({
'config_store_name': config_store_name,
'rg_loc': location,
'rg': resource_group,
'sku': sku
})
_create_config_store(self, self.kwargs)

entry_key = "Color"
entry_label = 'v1.0.0'

self.kwargs.update({
'key': entry_key,
'label': entry_label
})

# add a new key-value entry
self.cmd('appconfig kv set -n {config_store_name} --key {key} --label {label} -y',
checks=[self.check('contentType', ""),
self.check('key', entry_key),
self.check('value', ""),
self.check('label', entry_label)])

# edit a key-value entry
updated_entry_value = "Green"
entry_content_type = "text"

self.kwargs.update({
'value': updated_entry_value,
'content_type': entry_content_type
})

self.cmd(
'appconfig kv set -n {config_store_name} --key {key} --value {value} --content-type {content_type} --label {label} -y',
checks=[self.check('contentType', entry_content_type),
self.check('key', entry_key),
self.check('value', updated_entry_value),
self.check('label', entry_label)])

# add a new label
updated_label = 'newlabel'
self.kwargs.update({
'label': updated_label
})

self.cmd(
'appconfig kv set -n {config_store_name} --key {key} --value {value} --content-type {content_type} --label {label} -y',
checks=[self.check('contentType', entry_content_type),
self.check('key', entry_key),
self.check('value', updated_entry_value),
self.check('label', updated_label)])

revisions = self.cmd('appconfig revision list -n {config_store_name} --key {key} --label * --top 2 --fields content_type etag label last_modified value').get_output_in_json()
assert len(revisions) == 2

assert revisions[0]['content_type'] == 'text'
assert revisions[1]['content_type'] == 'text'
assert revisions[0]['label'] == 'newlabel'
assert revisions[1]['label'] == 'v1.0.0'
assert revisions[0]['value'] == 'Green'
assert revisions[1]['value'] == 'Green'
assert revisions[0]['last_modified'] is not None
assert revisions[1]['last_modified'] is not None
assert revisions[1]['etag'] is not None
pratiksanglikar marked this conversation as resolved.
Show resolved Hide resolved
assert revisions[0]['etag'] is not None
assert 'key' not in revisions[0]
assert 'key' not in revisions[1]
assert 'locked' not in revisions[0]
assert 'locked' not in revisions[1]
assert 'tags' not in revisions[0]
assert 'tags' not in revisions[1]


class AppConfigImportExportScenarioTest(ScenarioTest):

Expand Down