UI: check path change against all mountable backends (#23749)

* reset path when user clicks back from mount backend form

* update test
This commit is contained in:
claire bontempo
2023-10-20 09:06:43 -07:00
committed by GitHub
parent eca4b4d801
commit 6ac6030cb3
2 changed files with 8 additions and 7 deletions

View File

@@ -9,9 +9,8 @@ import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';
import { waitFor } from '@ember/test-waiters';
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
import { methods } from 'vault/helpers/mountable-auth-methods';
import { isAddonEngine } from 'vault/helpers/mountable-secret-engines';
import { isAddonEngine, allEngines } from 'vault/helpers/mountable-secret-engines';
/**
* @module MountBackendForm
@@ -49,7 +48,9 @@ export default class MountBackendForm extends Component {
const mount = this.args.mountModel;
const currentPath = mount.path;
const mountTypes =
this.args.mountType === 'secret' ? supportedSecretBackends() : methods().map((auth) => auth.type);
this.args.mountType === 'secret'
? allEngines().map((engine) => engine.type)
: methods().map((auth) => auth.type);
// if the current path has not been altered by user,
// change it here to match the new type
if (!currentPath || mountTypes.includes(currentPath)) {

View File

@@ -147,13 +147,13 @@ module('Integration | Component | mount backend form', function (hooks) {
await render(
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
);
await component.selectType('kv');
await component.selectType('azure');
await component.next();
assert.strictEqual(component.pathValue, 'kv', 'sets the value of the type');
assert.strictEqual(component.pathValue, 'azure', 'sets the value of the type');
await component.back();
await component.selectType('ssh');
await component.selectType('nomad');
await component.next();
assert.strictEqual(component.pathValue, 'ssh', 'updates the value of the type');
assert.strictEqual(component.pathValue, 'nomad', 'updates the value of the type');
});
test('it keeps path value if the user has changed it', async function (assert) {