vault/ui/tests/unit/adapters/pki/config-test.js
claire bontempo 5e5e61b5a8
UI: add pki cluster config parameters (#20724)
* add config directory, rename crl and urls models

* fix imports

* add cluster config fields to edit form

* reorder url save

* update tests

* add to details page

* add details test;

* fix adapter name

* fix cluster adapter test name

* combine adapter tests

* update imports

* fix git diff

* move crl and urls adapters to config folder

* add config file

* woops add config adapter

* final renaming!!

* fix imports after naming to base

* add cluster to beforeModel hook

* hide help text

* maybe you should write tests that actually pass, claire

* seriously claire its embarrassing
2023-05-23 15:24:53 -07:00

69 lines
1.9 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'vault/tests/helpers';
import { setupMirage } from 'ember-cli-mirage/test-support';
module('Unit | Adapter | pki/config', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
hooks.beforeEach(async function () {
this.store = this.owner.lookup('service:store');
this.backend = 'pki-engine';
});
const testHelper = (test) => {
test('it should make request to correct endpoint on update', async function (assert) {
assert.expect(1);
this.server.post(`/${this.backend}/config/${this.endpoint}`, () => {
assert.ok(true, `request made to POST config/${this.endpoint} endpoint on update`);
});
this.store.pushPayload(`pki/config/${this.endpoint}`, {
modelName: `pki/config/${this.endpoint}`,
id: this.backend,
});
const model = this.store.peekRecord(`pki/config/${this.endpoint}`, this.backend);
await model.save();
});
test('it should make request to correct endpoint on find', async function (assert) {
assert.expect(1);
this.server.get(`/${this.backend}/config/${this.endpoint}`, () => {
assert.ok(true, `request is made to GET /config/${this.endpoint} endpoint on find`);
return { data: { id: this.backend } };
});
this.store.findRecord(`pki/config/${this.endpoint}`, this.backend);
});
};
module('cluster', function (hooks) {
hooks.beforeEach(async function () {
this.endpoint = 'cluster';
});
testHelper(test);
});
module('urls', function (hooks) {
hooks.beforeEach(async function () {
this.endpoint = 'urls';
});
testHelper(test);
});
module('crl', function (hooks) {
hooks.beforeEach(async function () {
this.endpoint = 'crl';
});
testHelper(test);
});
});