mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-04-16 16:55:45 +00:00
Add ability to export Vault Token (#127)
* Add export Vault Token * Set correct condition for default value * Add test for exportToken Fix key with dash * Restore index.js
This commit is contained in:
parent
307c9ae581
commit
2f76ad395b
7 changed files with 66 additions and 15 deletions
|
|
@ -178,6 +178,12 @@ describe('exportSecrets', () => {
|
|||
}
|
||||
}
|
||||
|
||||
function mockExportToken(doExport) {
|
||||
when(core.getInput)
|
||||
.calledWith('exportToken')
|
||||
.mockReturnValueOnce(doExport);
|
||||
}
|
||||
|
||||
it('simple secret retrieval', async () => {
|
||||
mockInput('test key');
|
||||
mockVaultData({
|
||||
|
|
@ -257,4 +263,35 @@ describe('exportSecrets', () => {
|
|||
expect(core.exportVariable).toBeCalledWith('KEY__VALUE', '1');
|
||||
expect(core.setOutput).toBeCalledWith('key__value', '1');
|
||||
});
|
||||
|
||||
it('export Vault token', async () => {
|
||||
mockInput('test key');
|
||||
mockVaultData({
|
||||
key: 1
|
||||
});
|
||||
mockExportToken("true")
|
||||
|
||||
await exportSecrets();
|
||||
|
||||
expect(core.exportVariable).toBeCalledTimes(2);
|
||||
|
||||
expect(core.exportVariable).toBeCalledWith('VAULT_TOKEN', 'EXAMPLE');
|
||||
expect(core.exportVariable).toBeCalledWith('KEY', '1');
|
||||
expect(core.setOutput).toBeCalledWith('key', '1');
|
||||
});
|
||||
|
||||
it('not export Vault token', async () => {
|
||||
mockInput('test key');
|
||||
mockVaultData({
|
||||
key: 1
|
||||
});
|
||||
mockExportToken("false")
|
||||
|
||||
await exportSecrets();
|
||||
|
||||
expect(core.exportVariable).toBeCalledTimes(1);
|
||||
|
||||
expect(core.exportVariable).toBeCalledWith('KEY', '1');
|
||||
expect(core.setOutput).toBeCalledWith('key', '1');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue