5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-09 16:16:55 +00:00

Fix wildcard for K/V v2 and Cubbyhole. Add more tests

This commit is contained in:
Lemme 2021-07-27 23:49:58 -04:00
parent 6c9a25ff52
commit a729d0aca1
2 changed files with 27 additions and 1 deletions

View file

@ -226,6 +226,14 @@ describe('integration', () => {
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 () => {
mockInput('/secret-kv1/foobar fookv1');
@ -256,6 +264,17 @@ describe('integration', () => {
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 () => {
mockInput(`
/cubbyhole/test foo ;

View file

@ -41,7 +41,11 @@ async function getSecrets(secretRequests, client) {
if (selector == wildcard) {
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) {
let newRequest = Object.assign({},secretRequest);
newRequest.selector = key;
@ -74,6 +78,9 @@ async function getSecrets(secretRequests, client) {
cachedResponse
});
//DEBUG
//console.log("After", newRequest, value);
// used cachedResponse for first entry in wildcard list and set to true for the rest
cachedResponse = true;
}