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:
ZANCO Bertrand 2020-10-01 16:22:10 +02:00 committed by GitHub
parent 307c9ae581
commit 2f76ad395b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 15 deletions

View file

@ -37,7 +37,7 @@ describe('integration', () => {
},
json: {
data: {
otherSecret: 'OTHERSUPERSECRET',
"other-Secret-dash": 'OTHERSUPERSECRET',
},
}
});
@ -100,7 +100,7 @@ describe('integration', () => {
'X-Vault-Token': 'testtoken',
},
json: {
otherSecret: 'OTHERCUSTOMSECRET',
"other-Secret-dash": 'OTHERCUSTOMSECRET',
},
});
});
@ -140,18 +140,18 @@ describe('integration', () => {
});
it('get nested secret', async () => {
mockInput('secret/data/nested/test otherSecret');
mockInput(`secret/data/nested/test "other-Secret-dash"`);
await exportSecrets();
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET');
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERSUPERSECRET');
});
it('get multiple secrets', async () => {
mockInput(`
secret/data/test secret ;
secret/data/test secret | NAMED_SECRET ;
secret/data/nested/test otherSecret ;`);
secret/data/nested/test "other-Secret-dash" ;`);
await exportSecrets();
@ -159,7 +159,7 @@ describe('integration', () => {
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
expect(core.exportVariable).toBeCalledWith('NAMED_SECRET', 'SUPERSECRET');
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET');
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERSUPERSECRET');
});
it('leading slash kvv2', async () => {
@ -179,11 +179,11 @@ describe('integration', () => {
});
it('get nested secret from K/V v1', async () => {
mockInput('secret-kv1/nested/test otherSecret');
mockInput('secret-kv1/nested/test "other-Secret-dash"');
await exportSecrets();
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERCUSTOMSECRET');
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET');
});
it('leading slash kvv1', async () => {