mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
* manual cherry pick to deal with all the merge things * changelog * test fixes * Update 28148.txt * fix tests failures after main merge * fix test failures after main merge * Add Access Type and conditionally render WIF fields (#28149) * initial work. * remove access_type * better no model logic well kind of * rollback attrs * remove defaults * stopping point * wip changing back to sidebranch * hustling shuffling and serializing * some of the component test coverage * disable acces type if editing * test coverage * hide max retries that sneaky bugger * cleanup * cleanup * Update root-config.js * remove flash message check, locally passes great but on ci flaky * clean up * thank you chelsea * test clean up per enterprise vs community * address pr comments * welp a miss add * UI (sidebranch) WIF Issuer field (#28187) * Add type declaration files for aws config models * use updated task syntax for save method on configure-aws * fix types on edit route * fetch issuer on configure edit page if aws + enterprise * track issuer within configure-aws component * add placeholder support on form-field * Add warning if issuer changed from previous value or could not be read * cleanup * preliminary tests * dont use while loop so we can test the modal * tests * cleanup * fix tests * remove extra tracked value and duplicate changed attrs check * modal footer --------- Co-authored-by: Angel Garbarino <argarbarino@gmail.com> * Display issuer on Configuration details (#28209) * display issuer on configuration details * workflow complete, now on to testing * handle issuer things * fix all the broken tests things * add test coveragE: * cleanup * rename model/adapter * Update configure-aws.ts * Update aws-configuration-test.js * 90 percent there for pr comments * last one for tonight * a few more because why not * hasDirtyAttributes fixes * revert back to previous noRead->queryIssuerError --------- Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
142 lines
4.4 KiB
JavaScript
142 lines
4.4 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 | secret engine', function (hooks) {
|
|
setupTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
const storeStub = {
|
|
serializerFor() {
|
|
return {
|
|
serializeIntoHash() {},
|
|
};
|
|
},
|
|
};
|
|
const type = {
|
|
modelName: 'secret-engine',
|
|
};
|
|
|
|
test('Empty query', function (assert) {
|
|
assert.expect(1);
|
|
this.server.get('/sys/internal/ui/mounts', () => {
|
|
assert.ok('query calls the correct url');
|
|
return {};
|
|
});
|
|
const adapter = this.owner.lookup('adapter:secret-engine');
|
|
adapter['query'](storeStub, type, {});
|
|
});
|
|
test('Query with a path', function (assert) {
|
|
assert.expect(1);
|
|
this.server.get('/sys/internal/ui/mounts/foo', () => {
|
|
assert.ok('query calls the correct url');
|
|
return {};
|
|
});
|
|
const adapter = this.owner.lookup('adapter:secret-engine');
|
|
adapter['query'](storeStub, type, { path: 'foo' });
|
|
});
|
|
|
|
test('Query with nested path', function (assert) {
|
|
assert.expect(1);
|
|
this.server.get('/sys/internal/ui/mounts/foo/bar/baz', () => {
|
|
assert.ok('query calls the correct url');
|
|
return {};
|
|
});
|
|
const adapter = this.owner.lookup('adapter:secret-engine');
|
|
adapter['query'](storeStub, type, { path: 'foo/bar/baz' });
|
|
});
|
|
|
|
module('WIF secret engines', function (hooks) {
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
});
|
|
|
|
test('it should make request to correct endpoint when creating new record', async function (assert) {
|
|
assert.expect(1);
|
|
this.server.post('/sys/mounts/aws-wif', (schema, req) => {
|
|
assert.deepEqual(
|
|
JSON.parse(req.requestBody),
|
|
{
|
|
path: 'aws-wif',
|
|
type: 'aws',
|
|
config: { id: 'aws-wif', identity_token_key: 'test-key', listing_visibility: 'hidden' },
|
|
},
|
|
'Correct payload is sent when adding aws secret engine with identity_token_key set'
|
|
);
|
|
return {};
|
|
});
|
|
const mountData = {
|
|
id: 'aws-wif',
|
|
path: 'aws-wif',
|
|
type: 'aws',
|
|
config: this.store.createRecord('mount-config', {
|
|
identityTokenKey: 'test-key',
|
|
}),
|
|
uuid: 'f1739f9d-dfc0-83c8-011f-ec17103a06c2',
|
|
};
|
|
const record = this.store.createRecord('secret-engine', mountData);
|
|
await record.save();
|
|
});
|
|
|
|
test('it should not send identity_token_key if not set', async function (assert) {
|
|
assert.expect(1);
|
|
this.server.post('/sys/mounts/aws-wif', (schema, req) => {
|
|
assert.deepEqual(
|
|
JSON.parse(req.requestBody),
|
|
{
|
|
path: 'aws-wif',
|
|
type: 'aws',
|
|
config: { id: 'aws-wif', max_lease_ttl: '125h', listing_visibility: 'hidden' },
|
|
},
|
|
'Correct payload is sent when adding aws secret engine with no identity_token_key set'
|
|
);
|
|
return {};
|
|
});
|
|
const mountData = {
|
|
id: 'aws-wif',
|
|
path: 'aws-wif',
|
|
type: 'aws',
|
|
config: this.store.createRecord('mount-config', {
|
|
maxLeaseTtl: '125h',
|
|
}),
|
|
uuid: 'f1739f9d-dfc0-83c8-011f-ec17103a06c2',
|
|
};
|
|
const record = this.store.createRecord('secret-engine', mountData);
|
|
await record.save();
|
|
});
|
|
|
|
test('it should not send identity_token_key if set on a non-WIF secret engine', async function (assert) {
|
|
assert.expect(1);
|
|
this.server.post('/sys/mounts/cubbyhole-test', (schema, req) => {
|
|
assert.deepEqual(
|
|
JSON.parse(req.requestBody),
|
|
{
|
|
path: 'cubbyhole-test',
|
|
type: 'cubbyhole',
|
|
config: { id: 'cubbyhole-test', max_lease_ttl: '125h', listing_visibility: 'hidden' },
|
|
},
|
|
'Correct payload is sent when sending a non-wif secret engine with identity_token_key accidentally set'
|
|
);
|
|
return {};
|
|
});
|
|
const mountData = {
|
|
id: 'cubbyhole-test',
|
|
path: 'cubbyhole-test',
|
|
type: 'cubbyhole',
|
|
config: this.store.createRecord('mount-config', {
|
|
maxLeaseTtl: '125h',
|
|
identity_token_key: 'test-key',
|
|
}),
|
|
uuid: 'f1739f9d-dfc0-83c8-011f-ec17103a06c4',
|
|
};
|
|
const record = this.store.createRecord('secret-engine', mountData);
|
|
await record.save();
|
|
});
|
|
});
|
|
});
|