Reverting fix on KV 2 for duplicate paths (#12008)

* revert changes

* changelog

* add test coverage for max versions
This commit is contained in:
Angel Garbarino 2021-07-07 11:50:00 -06:00 committed by GitHub
parent 0bc339a2f8
commit 5fe59a685b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 15 deletions

3
changelog/12008.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:bug-fix
ui: Revert fix for PR [11423](https://github.com/hashicorp/vault/pull/11423).
```

View file

@ -248,13 +248,6 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
secretData.set(secretData.pathAttr, key); secretData.set(secretData.pathAttr, key);
} }
if (this.mode === 'create') {
key = JSON.stringify({
backend: secret.backend,
id: key,
});
}
return secretData return secretData
.save() .save()
.then(() => { .then(() => {
@ -376,14 +369,8 @@ export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
return; return;
} }
this.persistKey(key => { this.persistKey(() => {
let secretKey; this.transitionToRoute(SHOW_ROUTE, this.model.path || this.model.id);
try {
secretKey = JSON.parse(key).id;
} catch (error) {
secretKey = key;
}
this.transitionToRoute(SHOW_ROUTE, secretKey);
}); });
}, },

View file

@ -64,6 +64,29 @@ module('Acceptance | secrets/secret/create', function(hooks) {
assert.ok(showPage.editIsPresent, 'shows the edit button'); assert.ok(showPage.editIsPresent, 'shows the edit button');
}); });
test('it can create a secret with a non default max version', async function(assert) {
let enginePath = `kv-${new Date().getTime()}`;
let secretPath = 'maxVersions';
let maxVersions = 101;
await mountSecrets.visit();
await mountSecrets.enable('kv', enginePath);
await click('[data-test-secret-create="true"]');
await fillIn('[data-test-secret-path="true"]', secretPath);
await fillIn('[data-test-input="maxVersions"]', maxVersions);
await fillIn('[data-test-secret-key]', 'key');
await click('[data-test-secret-save]');
await settled();
await click('[data-test-secret-edit="true"]');
await settled();
let savedMaxVersions = document.querySelector('[data-test-input="maxVersions"]').value;
assert.equal(
maxVersions,
savedMaxVersions,
'max_version displays the saved number set when creating the secret'
);
});
test('it disables save when validation errors occur', async function(assert) { test('it disables save when validation errors occur', async function(assert) {
let enginePath = `kv-${new Date().getTime()}`; let enginePath = `kv-${new Date().getTime()}`;
await mountSecrets.visit(); await mountSecrets.visit();