mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-09 08:06:55 +00:00
add tests for custom engines
This commit is contained in:
parent
f38072a263
commit
44e1f881f2
5 changed files with 58 additions and 0 deletions
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
|
|
@ -130,6 +130,14 @@ jobs:
|
|||
test altSecret ;
|
||||
test altSecret | NAMED_ALTSECRET ;
|
||||
nested/test otherAltSecret ;
|
||||
- name: use vault action (using cubbyhole engine)
|
||||
uses: ./
|
||||
with:
|
||||
url: http://localhost:${{ job.services.vault.ports[8200] }}
|
||||
token: testtoken
|
||||
secrets: |
|
||||
/cubbyhole/test foo ;
|
||||
/cubbyhole/test zip | NAMED_CUBBYSECRET ;
|
||||
- name: verify
|
||||
run: npm run test:e2e
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ async function exportSecrets() {
|
|||
let body;
|
||||
if (responseCache.has(requestPath)) {
|
||||
body = responseCache.get(requestPath);
|
||||
core.debug('ℹ using cached response');
|
||||
} else {
|
||||
const result = await got(requestPath, requestOptions);
|
||||
body = result.body;
|
||||
|
|
|
|||
|
|
@ -171,4 +171,40 @@ describe('integration', () => {
|
|||
|
||||
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERCUSTOMSECRET');
|
||||
});
|
||||
|
||||
describe('generic engines', () => {
|
||||
beforeAll(async () => {
|
||||
await got(`${vaultUrl}/v1/cubbyhole/test`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': 'testtoken',
|
||||
},
|
||||
json: {
|
||||
foo: "bar",
|
||||
zip: "zap"
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('supports cubbyhole', async () => {
|
||||
mockInput('/cubbyhole/test foo');
|
||||
|
||||
await exportSecrets();
|
||||
|
||||
expect(core.exportVariable).toBeCalledWith('FOO', 'bar');
|
||||
});
|
||||
|
||||
it('caches responses', async () => {
|
||||
mockInput(`
|
||||
/cubbyhole/test foo ;
|
||||
/cubbyhole/test zip`);
|
||||
|
||||
await exportSecrets();
|
||||
|
||||
expect(core.debug).toBeCalledWith('ℹ using cached response');
|
||||
|
||||
expect(core.exportVariable).toBeCalledWith('FOO', 'bar');
|
||||
expect(core.exportVariable).toBeCalledWith('ZIP', 'zap');
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@ describe('e2e', () => {
|
|||
expect(process.env.ALTSECRET).toBe("CUSTOMSECRET");
|
||||
expect(process.env.NAMED_ALTSECRET).toBe("CUSTOMSECRET");
|
||||
expect(process.env.OTHERALTSECRET).toBe("OTHERCUSTOMSECRET");
|
||||
expect(process.env.FOO).toBe("bar");
|
||||
expect(process.env.NAMED_CUBBYSECRET).toBe("zap");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,6 +64,17 @@ const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;
|
|||
otherAltSecret: 'OTHERCUSTOMSECRET',
|
||||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/cubbyhole/test`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': 'testtoken',
|
||||
},
|
||||
json: {
|
||||
foo: 'bar',
|
||||
zip: 'zap',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
process.exit(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue