mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
UI: Fix toast message text when deleting a kv v2 secret (#28093)
* VAULT-29995 fix flash grabbing status from state * add test * add changelog * add test for destroyed copy
This commit is contained in:
3
changelog/28093.txt
Normal file
3
changelog/28093.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
ui: fixes toast (flash) alert message saying "created" when deleting a kv v2 secret
|
||||
```
|
||||
@@ -108,7 +108,8 @@ export default class KvSecretDetails extends Component {
|
||||
const { secret } = this.args;
|
||||
try {
|
||||
await secret.destroyRecord({ adapterOptions: { deleteType: type, deleteVersions: this.version } });
|
||||
this.flashMessages.success(`Successfully ${secret.state} Version ${this.version} of ${secret.path}.`);
|
||||
const verb = type.includes('delete') ? 'deleted' : 'destroyed';
|
||||
this.flashMessages.success(`Successfully ${verb} Version ${this.version} of ${secret.path}.`);
|
||||
this.refreshRoute();
|
||||
} catch (err) {
|
||||
const verb = type.includes('delete') ? 'deleting' : 'destroying';
|
||||
|
||||
@@ -13,6 +13,7 @@ import { clearRecords, deleteLatestCmd, writeVersionedSecret } from 'vault/tests
|
||||
import { setupControlGroup } from 'vault/tests/helpers/control-groups';
|
||||
import { click, currentURL, visit } from '@ember/test-helpers';
|
||||
import { PAGE } from 'vault/tests/helpers/kv/kv-selectors';
|
||||
import sinon from 'sinon';
|
||||
|
||||
const ALL_DELETE_ACTIONS = ['delete', 'destroy', 'undelete'];
|
||||
const assertDeleteActions = (assert, expected = ['delete', 'destroy']) => {
|
||||
@@ -65,7 +66,8 @@ module('Acceptance | kv-v2 workflow | delete, undelete, destroy', function (hook
|
||||
return;
|
||||
});
|
||||
test('can delete and undelete the latest secret version (a)', async function (assert) {
|
||||
assert.expect(17);
|
||||
assert.expect(18);
|
||||
const flashSuccess = sinon.spy(this.owner.lookup('service:flash-messages'), 'success');
|
||||
// go to secret details
|
||||
await visit(`/vault/secrets/${this.backend}/kv/${this.secretPath}/details`);
|
||||
// correct toolbar options & details show
|
||||
@@ -78,6 +80,10 @@ module('Acceptance | kv-v2 workflow | delete, undelete, destroy', function (hook
|
||||
assert.dom(PAGE.detail.deleteOptionLatest).isNotDisabled('delete latest option is selectable');
|
||||
await click(PAGE.detail.deleteOptionLatest);
|
||||
await click(PAGE.detail.deleteConfirm);
|
||||
const expected = `Successfully deleted Version 4 of ${this.secretPath}.`;
|
||||
const [actual] = flashSuccess.lastCall.args;
|
||||
assert.strictEqual(actual, expected, 'renders correct flash message');
|
||||
|
||||
// details update accordingly
|
||||
assert
|
||||
.dom(PAGE.emptyStateTitle)
|
||||
@@ -123,7 +129,8 @@ module('Acceptance | kv-v2 workflow | delete, undelete, destroy', function (hook
|
||||
assertDeleteActions(assert, ['delete', 'destroy']);
|
||||
});
|
||||
test('can destroy a secret version (a)', async function (assert) {
|
||||
assert.expect(9);
|
||||
assert.expect(10);
|
||||
const flashSuccess = sinon.spy(this.owner.lookup('service:flash-messages'), 'success');
|
||||
// go to secret details
|
||||
await visit(`/vault/secrets/${this.backend}/kv/${this.secretPath}/details?version=3`);
|
||||
// correct toolbar options show
|
||||
@@ -132,6 +139,9 @@ module('Acceptance | kv-v2 workflow | delete, undelete, destroy', function (hook
|
||||
await click(PAGE.detail.destroy);
|
||||
assert.dom(PAGE.detail.deleteModalTitle).includesText('Destroy version?', 'modal has correct title');
|
||||
await click(PAGE.detail.deleteConfirm);
|
||||
const expected = `Successfully destroyed Version 3 of ${this.secretPath}.`;
|
||||
const [actual] = flashSuccess.lastCall.args;
|
||||
assert.strictEqual(actual, expected, 'renders correct flash message');
|
||||
// details update accordingly
|
||||
assert
|
||||
.dom(PAGE.emptyStateTitle)
|
||||
|
||||
Reference in New Issue
Block a user