Skip to content

Commit

Permalink
backport-fix (#14815)
Browse files Browse the repository at this point in the history
* fix

* Update mount-backend-form.js
  • Loading branch information
Monkeychip committed Mar 31, 2022
1 parent 0681894 commit cbb26e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions ui/app/components/mount-backend-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ export default Component.extend({
}

let changedAttrKeys = Object.keys(mountModel.changedAttributes());
const updatesConfig =
mountModel.isV2KV &&
(changedAttrKeys.includes('casRequired') ||
changedAttrKeys.includes('deleteVersionAfter') ||
changedAttrKeys.includes('maxVersions'));
let updatesConfig =
changedAttrKeys.includes('casRequired') ||
changedAttrKeys.includes('deleteVersionAfter') ||
changedAttrKeys.includes('maxVersions');

try {
yield mountModel.save();
Expand All @@ -142,7 +141,8 @@ export default Component.extend({
}
return;
}
if (updatesConfig && !capabilities.get('canUpdate')) {
// mountModel must be after the save
if (mountModel.isV2KV && updatesConfig && !capabilities.get('canUpdate')) {
// config error is not thrown from secret-engine adapter, so handling here
this.flashMessages.warning(
'You do not have access to the config endpoint. The secret engine was mounted, but the configuration settings were not saved.'
Expand Down
11 changes: 6 additions & 5 deletions ui/tests/acceptance/settings/mount-secret-backend-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { currentRouteName, settled, find } from '@ember/test-helpers';
import { currentRouteName, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { create } from 'ember-cli-page-object';
Expand Down Expand Up @@ -131,10 +131,11 @@ module('Acceptance | settings/mount-secret-backend', function (hooks) {
await mountSecrets.selectType('kv');
await mountSecrets.next().path(enginePath).setMaxVersion(101).submit();
await settled();
assert.ok(
find('[data-test-flash-message]').textContent.trim(),
`You do not have access to the config endpoint. The secret engine was mounted, but the configuration settings were not saved.`
);
assert
.dom('[data-test-flash-message]')
.containsText(
`You do not have access to the config endpoint. The secret engine was mounted, but the configuration settings were not saved.`
);
await configPage.visit({ backend: enginePath });
await settled();
assert.dom('[data-test-row-value="Maximum number of versions"]').hasText('Not set');
Expand Down

0 comments on commit cbb26e3

Please sign in to comment.