mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
fixes mount backend success message (#19072)
This commit is contained in:
@@ -127,7 +127,7 @@ export default class MountBackendForm extends Component {
|
|||||||
}
|
}
|
||||||
this.flashMessages.success(
|
this.flashMessages.success(
|
||||||
`Successfully mounted the ${type} ${
|
`Successfully mounted the ${type} ${
|
||||||
this.mountType === 'secret' ? 'secrets engine' : 'auth method'
|
this.args.mountType === 'secret' ? 'secrets engine' : 'auth method'
|
||||||
} at ${path}.`
|
} at ${path}.`
|
||||||
);
|
);
|
||||||
yield this.args.onMountSuccess(type, path);
|
yield this.args.onMountSuccess(type, path);
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ module('Integration | Component | mount backend form', function (hooks) {
|
|||||||
setupMirage(hooks);
|
setupMirage(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.owner.lookup('service:flash-messages').registerTypes(['success', 'danger']);
|
this.flashMessages = this.owner.lookup('service:flash-messages');
|
||||||
|
this.flashMessages.registerTypes(['success', 'danger']);
|
||||||
|
this.flashSuccessSpy = sinon.spy(this.flashMessages, 'success');
|
||||||
this.store = this.owner.lookup('service:store');
|
this.store = this.owner.lookup('service:store');
|
||||||
this.server.post('/sys/capabilities-self', allowAllCapabilitiesStub());
|
this.server.post('/sys/capabilities-self', allowAllCapabilitiesStub());
|
||||||
this.server.post('/sys/auth/foo', noopStub());
|
this.server.post('/sys/auth/foo', noopStub());
|
||||||
@@ -81,21 +83,27 @@ module('Integration | Component | mount backend form', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('it calls mount success', async function (assert) {
|
test('it calls mount success', async function (assert) {
|
||||||
assert.expect(2);
|
assert.expect(3);
|
||||||
|
|
||||||
this.server.post('/sys/auth/foo', () => {
|
this.server.post('/sys/auth/foo', () => {
|
||||||
assert.ok(true, 'it calls enable on an auth method');
|
assert.ok(true, 'it calls enable on an auth method');
|
||||||
return [204, { 'Content-Type': 'application/json' }];
|
return [204, { 'Content-Type': 'application/json' }];
|
||||||
});
|
});
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
this.set('onMountSuccess', spy);
|
this.set('onMountSuccess', spy);
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
|
hbs`<MountBackendForm @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
|
||||||
);
|
);
|
||||||
await component.mount('approle', 'foo');
|
await component.mount('approle', 'foo');
|
||||||
|
|
||||||
later(() => cancelTimers(), 50);
|
later(() => cancelTimers(), 50);
|
||||||
await settled();
|
await settled();
|
||||||
|
|
||||||
assert.ok(spy.calledOnce, 'calls the passed success method');
|
assert.ok(spy.calledOnce, 'calls the passed success method');
|
||||||
|
assert.ok(
|
||||||
|
this.flashSuccessSpy.calledWith('Successfully mounted the approle auth method at foo.'),
|
||||||
|
'Renders correct flash message'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -146,22 +154,28 @@ module('Integration | Component | mount backend form', function (hooks) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('it calls mount success', async function (assert) {
|
test('it calls mount success', async function (assert) {
|
||||||
assert.expect(2);
|
assert.expect(3);
|
||||||
|
|
||||||
this.server.post('/sys/mounts/foo', () => {
|
this.server.post('/sys/mounts/foo', () => {
|
||||||
assert.ok(true, 'it calls enable on an secrets engine');
|
assert.ok(true, 'it calls enable on an secrets engine');
|
||||||
return [204, { 'Content-Type': 'application/json' }];
|
return [204, { 'Content-Type': 'application/json' }];
|
||||||
});
|
});
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
this.set('onMountSuccess', spy);
|
this.set('onMountSuccess', spy);
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
|
hbs`<MountBackendForm @mountType="secret" @mountModel={{this.model}} @onMountSuccess={{this.onMountSuccess}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
await component.mount('ssh', 'foo');
|
await component.mount('ssh', 'foo');
|
||||||
|
|
||||||
later(() => cancelTimers(), 50);
|
later(() => cancelTimers(), 50);
|
||||||
await settled();
|
await settled();
|
||||||
|
|
||||||
assert.ok(spy.calledOnce, 'calls the passed success method');
|
assert.ok(spy.calledOnce, 'calls the passed success method');
|
||||||
|
assert.ok(
|
||||||
|
this.flashSuccessSpy.calledWith('Successfully mounted the ssh secrets engine at foo.'),
|
||||||
|
'Renders correct flash message'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user