mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-10 00:26:55 +00:00
Fix wildcard for K/V v2 and Cubbyhole. Add more tests
This commit is contained in:
parent
6c9a25ff52
commit
a729d0aca1
2 changed files with 27 additions and 1 deletions
|
|
@ -226,6 +226,14 @@ describe('integration', () => {
|
||||||
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'CUSTOMSECRET');
|
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'CUSTOMSECRET');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('get wildcard nested secret from K/V v1', async () => {
|
||||||
|
mockInput('secret-kv1/nested/test *');
|
||||||
|
|
||||||
|
await exportSecrets();
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET');
|
||||||
|
});
|
||||||
|
|
||||||
it('leading slash kvv1', async () => {
|
it('leading slash kvv1', async () => {
|
||||||
mockInput('/secret-kv1/foobar fookv1');
|
mockInput('/secret-kv1/foobar fookv1');
|
||||||
|
|
||||||
|
|
@ -256,6 +264,17 @@ describe('integration', () => {
|
||||||
expect(core.exportVariable).toBeCalledWith('FOO', 'bar');
|
expect(core.exportVariable).toBeCalledWith('FOO', 'bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('wildcard supports cubbyhole', async () => {
|
||||||
|
mockInput('/cubbyhole/test *');
|
||||||
|
|
||||||
|
await exportSecrets();
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledTimes(2);
|
||||||
|
|
||||||
|
expect(core.exportVariable).toBeCalledWith('FOO', 'bar');
|
||||||
|
expect(core.exportVariable).toBeCalledWith('ZIP', 'zap');
|
||||||
|
});
|
||||||
|
|
||||||
it('caches responses', async () => {
|
it('caches responses', async () => {
|
||||||
mockInput(`
|
mockInput(`
|
||||||
/cubbyhole/test foo ;
|
/cubbyhole/test foo ;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,11 @@ async function getSecrets(secretRequests, client) {
|
||||||
|
|
||||||
if (selector == wildcard) {
|
if (selector == wildcard) {
|
||||||
body = JSON.parse(body);
|
body = JSON.parse(body);
|
||||||
const keys = body.data;
|
let keys = body.data;
|
||||||
|
if (body.data["data"] != undefined) {
|
||||||
|
keys = keys.data;
|
||||||
|
}
|
||||||
|
|
||||||
for (let key in keys) {
|
for (let key in keys) {
|
||||||
let newRequest = Object.assign({},secretRequest);
|
let newRequest = Object.assign({},secretRequest);
|
||||||
newRequest.selector = key;
|
newRequest.selector = key;
|
||||||
|
|
@ -74,6 +78,9 @@ async function getSecrets(secretRequests, client) {
|
||||||
cachedResponse
|
cachedResponse
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//DEBUG
|
||||||
|
//console.log("After", newRequest, value);
|
||||||
|
|
||||||
// used cachedResponse for first entry in wildcard list and set to true for the rest
|
// used cachedResponse for first entry in wildcard list and set to true for the rest
|
||||||
cachedResponse = true;
|
cachedResponse = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue