Skip to content

Commit

Permalink
fix (#14808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip authored Mar 31, 2022
1 parent 2e37771 commit b7f834c
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 @@ -114,11 +114,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 @@ -144,7 +143,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 b7f834c

Please sign in to comment.