mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Refactor SSH Configuration workflow (#28122)
* initial copy from other #28004 * pr feedback * grr
This commit is contained in:
@@ -346,80 +346,6 @@ module('Unit | Model | secret-engine', function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
module('saveCA', function () {
|
||||
test('does not call endpoint if type != ssh', async function (assert) {
|
||||
assert.expect(1);
|
||||
const model = this.store.createRecord('secret-engine', {
|
||||
type: 'not-ssh',
|
||||
});
|
||||
const saveSpy = sinon.spy(model, 'save');
|
||||
await model.saveCA({});
|
||||
assert.ok(saveSpy.notCalled, 'save not called');
|
||||
});
|
||||
test('calls save with correct params', async function (assert) {
|
||||
assert.expect(4);
|
||||
const model = this.store.createRecord('secret-engine', {
|
||||
type: 'ssh',
|
||||
privateKey: 'private-key',
|
||||
publicKey: 'public-key',
|
||||
generateSigningKey: true,
|
||||
});
|
||||
const saveStub = sinon.stub(model, 'save').callsFake((params) => {
|
||||
assert.deepEqual(
|
||||
params,
|
||||
{
|
||||
adapterOptions: {
|
||||
options: {},
|
||||
apiPath: 'config/ca',
|
||||
attrsToSend: ['privateKey', 'publicKey', 'generateSigningKey'],
|
||||
},
|
||||
},
|
||||
'send correct params to save'
|
||||
);
|
||||
return;
|
||||
});
|
||||
|
||||
await model.saveCA({});
|
||||
assert.strictEqual(model.privateKey, 'private-key', 'value exists before save');
|
||||
assert.strictEqual(model.publicKey, 'public-key', 'value exists before save');
|
||||
assert.true(model.generateSigningKey, 'value true before save');
|
||||
|
||||
saveStub.restore();
|
||||
});
|
||||
test('sets properties when isDelete', async function (assert) {
|
||||
assert.expect(7);
|
||||
const model = this.store.createRecord('secret-engine', {
|
||||
type: 'ssh',
|
||||
privateKey: 'private-key',
|
||||
publicKey: 'public-key',
|
||||
generateSigningKey: true,
|
||||
});
|
||||
const saveStub = sinon.stub(model, 'save').callsFake((params) => {
|
||||
assert.deepEqual(
|
||||
params,
|
||||
{
|
||||
adapterOptions: {
|
||||
options: { isDelete: true },
|
||||
apiPath: 'config/ca',
|
||||
attrsToSend: ['privateKey', 'publicKey', 'generateSigningKey'],
|
||||
},
|
||||
},
|
||||
'send correct params to save'
|
||||
);
|
||||
return;
|
||||
});
|
||||
assert.strictEqual(model.privateKey, 'private-key', 'value exists before save');
|
||||
assert.strictEqual(model.publicKey, 'public-key', 'value exists before save');
|
||||
assert.true(model.generateSigningKey, 'value true before save');
|
||||
|
||||
await model.saveCA({ isDelete: true });
|
||||
assert.strictEqual(model.privateKey, null, 'value null after save');
|
||||
assert.strictEqual(model.publicKey, null, 'value null after save');
|
||||
assert.false(model.generateSigningKey, 'value false after save');
|
||||
saveStub.restore();
|
||||
});
|
||||
});
|
||||
|
||||
module('saveZeroAddressConfig', function () {
|
||||
test('calls save with correct params', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
Reference in New Issue
Block a user