From 0a6b6ce790024f477ac4acddf33be0f6662b3fa3 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 31 Jan 2024 11:36:48 -0700 Subject: [PATCH 1/7] wip need to address testing but want to test something quick on 1.13 --- ui/lib/kv/addon/components/kv-data-fields.hbs | 2 +- ui/lib/kv/addon/components/kv-data-fields.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ui/lib/kv/addon/components/kv-data-fields.hbs b/ui/lib/kv/addon/components/kv-data-fields.hbs index 7f7a26db3ce4..aa520676b511 100644 --- a/ui/lib/kv/addon/components/kv-data-fields.hbs +++ b/ui/lib/kv/addon/components/kv-data-fields.hbs @@ -15,7 +15,7 @@ {{#if @showJson}} Date: Wed, 31 Jan 2024 12:08:18 -0700 Subject: [PATCH 2/7] add test coverage --- .../kv/kv-v2-workflow-edge-cases-test.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js index 87de5a20d715..948ec45e63ba 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js @@ -302,6 +302,42 @@ module('Acceptance | kv-v2 workflow | edge cases', function (hooks) { assert.dom(FORM.toggleJson).isChecked(); assert.false(codemirror().getValue().includes('*'), 'Values are not obscured on edit view'); }); + + test('viewing advanced secret data versions displays the correct version data', async function (assert) { + assert.expect(2); + const obscuredDataV1 = `{ + "foo1": { + "name": "********" + } +}`; + const obscuredDataV2 = `{ + "foo2": { + "name": "********" + } +}`; + + await visit(`/vault/secrets/${this.backend}/kv/create`); + await fillIn(FORM.inputByAttr('path'), 'complex_version_test'); + + await click(FORM.toggleJson); + codemirror().setValue('{ "foo1": { "name": "bar1" } }'); + await click(FORM.saveBtn); + + // Create another version + await click(PAGE.detail.createNewVersion); + codemirror().setValue('{ "foo2": { "name": "bar2" } }'); + await click(FORM.saveBtn); + + // View the first version and make sure it changes + await click(PAGE.detail.versionDropdown); + await click(`${PAGE.detail.version(1)} a`); + assert.strictEqual(codemirror().getValue(), obscuredDataV1, 'Version one data is displayed'); + + await click(PAGE.detail.versionDropdown); + await click(`${PAGE.detail.version(2)} a`); + assert.strictEqual(codemirror().getValue(), obscuredDataV2, 'Version two data is displayed'); + }); + test('does not register as advanced when value includes {', async function (assert) { await visit(`/vault/secrets/${this.backend}/kv/create`); await fillIn(FORM.inputByAttr('path'), 'not-advanced'); From 313513bcdd3bc2d3ad24660f3ffc9066cee5e30a Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 31 Jan 2024 12:14:15 -0700 Subject: [PATCH 3/7] changelog --- changelog/25152.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/25152.txt diff --git a/changelog/25152.txt b/changelog/25152.txt new file mode 100644 index 000000000000..7a89d5fc8289 --- /dev/null +++ b/changelog/25152.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Update the KV secret data when you change the version you're viewing of a nested secret. +``` \ No newline at end of file From 0fcca292fe4562e98765e79ac2dab39fcbd9e7d0 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 31 Jan 2024 12:20:24 -0700 Subject: [PATCH 4/7] update test comment --- .../secrets/backend/kv/kv-v2-workflow-edge-cases-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js index 948ec45e63ba..1c6d868eabec 100644 --- a/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js +++ b/ui/tests/acceptance/secrets/backend/kv/kv-v2-workflow-edge-cases-test.js @@ -328,11 +328,12 @@ module('Acceptance | kv-v2 workflow | edge cases', function (hooks) { codemirror().setValue('{ "foo2": { "name": "bar2" } }'); await click(FORM.saveBtn); - // View the first version and make sure it changes + // View the first version and make sure the secret data is correct await click(PAGE.detail.versionDropdown); await click(`${PAGE.detail.version(1)} a`); assert.strictEqual(codemirror().getValue(), obscuredDataV1, 'Version one data is displayed'); + // Navigate back the second version and make sure the secret data is correct await click(PAGE.detail.versionDropdown); await click(`${PAGE.detail.version(2)} a`); assert.strictEqual(codemirror().getValue(), obscuredDataV2, 'Version two data is displayed'); From 0e2a6460625a1161a1108689095d375ae38f7a91 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 31 Jan 2024 14:21:50 -0700 Subject: [PATCH 5/7] rename getter --- ui/lib/kv/addon/components/kv-data-fields.hbs | 11 +++++++++-- ui/lib/kv/addon/components/kv-data-fields.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/lib/kv/addon/components/kv-data-fields.hbs b/ui/lib/kv/addon/components/kv-data-fields.hbs index aa520676b511..8c659c1fb466 100644 --- a/ui/lib/kv/addon/components/kv-data-fields.hbs +++ b/ui/lib/kv/addon/components/kv-data-fields.hbs @@ -15,7 +15,7 @@ {{#if @showJson}} - + {{else}} diff --git a/ui/lib/kv/addon/components/kv-data-fields.js b/ui/lib/kv/addon/components/kv-data-fields.js index 3a4faf05c144..071cbe39ac10 100644 --- a/ui/lib/kv/addon/components/kv-data-fields.js +++ b/ui/lib/kv/addon/components/kv-data-fields.js @@ -30,7 +30,7 @@ import { stringify } from 'core/helpers/stringify'; export default class KvDataFields extends Component { @tracked lintingErrors; - get secretDataForCodeMirror() { + get stringifiedSecretData() { return this.args.secret?.secretData ? stringify([this.args.secret.secretData], {}) : '{ "": "" }'; } From 0adba991d24d0fdc619b2079148b32e62f52e210 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Wed, 31 Jan 2024 14:25:02 -0700 Subject: [PATCH 6/7] Update kv-data-fields.hbs revert accidental next step --- ui/lib/kv/addon/components/kv-data-fields.hbs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/lib/kv/addon/components/kv-data-fields.hbs b/ui/lib/kv/addon/components/kv-data-fields.hbs index 8c659c1fb466..16b00f6ee44d 100644 --- a/ui/lib/kv/addon/components/kv-data-fields.hbs +++ b/ui/lib/kv/addon/components/kv-data-fields.hbs @@ -36,8 +36,7 @@ -{{/if}} \ No newline at end of file +{{/if}} From 03e9fe4147d2f3111fcdbf8cb0f6b2d2e9d1df3c Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Thu, 1 Feb 2024 12:06:03 -0700 Subject: [PATCH 7/7] linting things --- ui/lib/kv/addon/components/kv-data-fields.hbs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ui/lib/kv/addon/components/kv-data-fields.hbs b/ui/lib/kv/addon/components/kv-data-fields.hbs index 16b00f6ee44d..ba3003825b35 100644 --- a/ui/lib/kv/addon/components/kv-data-fields.hbs +++ b/ui/lib/kv/addon/components/kv-data-fields.hbs @@ -34,13 +34,7 @@ {{else if (eq @type "details")}} {{#each-in @secret.secretData as |key value|}} - + {{else}} @@ -53,4 +47,4 @@ @onChange={{fn (mut @secret.secretData)}} @isMasked={{true}} /> -{{/if}} +{{/if}} \ No newline at end of file