2018-09-25 16:28:26 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2018-10-06 03:02:23 +00:00
|
|
|
import apiStub from 'vault/tests/helpers/noop-all-api-requests';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Unit | Adapter | secret-v2', function (hooks) {
|
2018-09-25 16:28:26 +00:00
|
|
|
setupTest(hooks);
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
hooks.beforeEach(function () {
|
2018-10-06 03:02:23 +00:00
|
|
|
this.server = apiStub();
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
hooks.afterEach(function () {
|
2018-10-06 03:02:23 +00:00
|
|
|
this.server.shutdown();
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-10-06 03:02:23 +00:00
|
|
|
[
|
|
|
|
['query', null, {}, { id: '', backend: 'secret' }, 'GET', '/v1/secret/metadata/?list=true'],
|
|
|
|
['queryRecord', null, {}, { id: 'foo', backend: 'secret' }, 'GET', '/v1/secret/metadata/foo'],
|
|
|
|
[
|
|
|
|
'updateRecord',
|
|
|
|
{
|
|
|
|
serializerFor() {
|
|
|
|
return {
|
|
|
|
serializeIntoHash() {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'foo',
|
|
|
|
belongsTo() {
|
|
|
|
return 'secret';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'PUT',
|
|
|
|
'/v1/secret/metadata/foo',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'deleteRecord',
|
|
|
|
{
|
|
|
|
serializerFor() {
|
|
|
|
return {
|
|
|
|
serializeIntoHash() {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: 'foo',
|
|
|
|
belongsTo() {
|
|
|
|
return 'secret';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'DELETE',
|
|
|
|
'/v1/secret/metadata/foo',
|
|
|
|
],
|
|
|
|
].forEach(([adapterMethod, store, type, queryOrSnapshot, expectedHttpVerb, expectedURL]) => {
|
2021-12-17 03:44:29 +00:00
|
|
|
test(`secret-v2: ${adapterMethod}`, function (assert) {
|
2018-10-06 03:02:23 +00:00
|
|
|
let adapter = this.owner.lookup('adapter:secret-v2');
|
|
|
|
adapter[adapterMethod](store, type, queryOrSnapshot);
|
|
|
|
let { url, method } = this.server.handledRequests[0];
|
|
|
|
assert.equal(url, expectedURL, `${adapterMethod} calls the correct url: ${expectedURL}`);
|
|
|
|
assert.equal(
|
|
|
|
method,
|
|
|
|
expectedHttpVerb,
|
|
|
|
`${adapterMethod} uses the correct http verb: ${expectedHttpVerb}`
|
|
|
|
);
|
|
|
|
});
|
2018-09-25 16:28:26 +00:00
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|