mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-09 16:26:14 +00:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
module('Unit | Adapter | pki/key', function (hooks) {
|
|
setupTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.secretMountPath = this.owner.lookup('service:secret-mount-path');
|
|
this.backend = 'pki-test';
|
|
this.secretMountPath.currentPath = this.backend;
|
|
this.data = {
|
|
key_id: '724862ff-6438-bad0-b598-77a6c7f4e934',
|
|
key_type: 'ec',
|
|
key_name: 'test-key',
|
|
key_bits: '256',
|
|
};
|
|
});
|
|
|
|
hooks.afterEach(function () {
|
|
this.server.shutdown();
|
|
});
|
|
|
|
test('it should make request to correct endpoint on query', async function (assert) {
|
|
assert.expect(1);
|
|
const { key_id, ...otherAttrs } = this.data; // excludes key_id from key_info data
|
|
const key_info = { [key_id]: { ...otherAttrs } };
|
|
this.server.get(`${this.backend}/keys`, (schema, req) => {
|
|
assert.strictEqual(req.queryParams.list, 'true', 'request is made to correct endpoint on query');
|
|
return { data: { keys: [key_id], key_info } };
|
|
});
|
|
|
|
this.store.query('pki/key', { backend: this.backend });
|
|
});
|
|
|
|
test('it should make request to correct endpoint on queryRecord', async function (assert) {
|
|
assert.expect(1);
|
|
|
|
this.server.get(`${this.backend}/key/${this.data.key_id}`, () => {
|
|
assert.ok(true, 'request is made to correct endpoint on query record');
|
|
return { data: this.data };
|
|
});
|
|
|
|
this.store.queryRecord('pki/key', { backend: this.backend, id: this.data.key_id });
|
|
});
|
|
|
|
test('it should make request to correct endpoint on delete', async function (assert) {
|
|
assert.expect(1);
|
|
this.store.pushPayload('pki/key', { modelName: 'pki/key', ...this.data });
|
|
this.server.get(`${this.backend}/key/${this.data.key_id}`, () => ({ data: this.data }));
|
|
this.server.delete(`${this.backend}/key/${this.data.key_id}`, () => {
|
|
assert.ok(true, 'request made to correct endpoint on delete');
|
|
});
|
|
|
|
const model = await this.store.queryRecord('pki/key', { backend: this.backend, id: this.data.key_id });
|
|
await model.destroyRecord();
|
|
});
|
|
});
|