5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-08 15:46:56 +00:00

feat: make secret names less derp for tsts

This commit is contained in:
Richard Simpson 2019-09-20 17:29:13 -05:00
parent 13eebbc4e5
commit b524055d38
No known key found for this signature in database
GPG key ID: 0CECAF50D013D1E2
5 changed files with 19 additions and 26 deletions

View file

@ -77,9 +77,9 @@ jobs:
vaultUrl: http://localhost:${{ job.services.vault.ports[8200] }} vaultUrl: http://localhost:${{ job.services.vault.ports[8200] }}
vaultToken: testtoken vaultToken: testtoken
keys: | keys: |
test a ; test secret ;
test a | NAMED_TOKEN ; test secret | NAMED_SECRET ;
nested/test e ; nested/test otherSecret ;
- name: verify - name: verify
run: npm run test:e2e run: npm run test:e2e

View file

@ -105,7 +105,7 @@ describe('exportSecrets', () => {
await exportSecrets(); await exportSecrets();
expect(core.exportVariable).toBeCalledWith('KEY', 1); expect(core.exportVariable).toBeCalledWith('KEY', '1');
}); });
it('mapped key retrieval', async () => { it('mapped key retrieval', async () => {
@ -116,6 +116,6 @@ describe('exportSecrets', () => {
await exportSecrets(); await exportSecrets();
expect(core.exportVariable).toBeCalledWith('TEST_NAME', 1); expect(core.exportVariable).toBeCalledWith('TEST_NAME', '1');
}); });
}); });

View file

@ -1,7 +1,7 @@
describe('e2e', () => { describe('e2e', () => {
it('verify', () => { it('verify', () => {
expect(process.env.A).toBe("1"); expect(process.env.SECRET).toBe("SUPERSECRET");
expect(process.env.NAMED_TOKEN).toBe("1"); expect(process.env.NAMED_SECRET).toBe("SUPERSECRET");
expect(process.env.E).toBe("4"); expect(process.env.OTHERSECRET).toBe("OTHERSUPERSECRET");
}); });
}); });

View file

@ -16,9 +16,7 @@ const got = require('got');
}, },
body: { body: {
data: { data: {
a: 1, secret: "SUPERSECRET",
b: 2,
c: 3,
}, },
}, },
json: true, json: true,
@ -31,9 +29,7 @@ const got = require('got');
}, },
body: { body: {
data: { data: {
e: 4, otherSecret: "OTHERSUPERSECRET",
f: 5,
g: 6,
}, },
}, },
json: true, json: true,

View file

@ -1,4 +1,5 @@
jest.mock('@actions/core'); jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
const core = require('@actions/core'); const core = require('@actions/core');
const got = require('got'); const got = require('got');
@ -23,9 +24,7 @@ describe('integration', () => {
}, },
body: { body: {
data: { data: {
a: 1, secret: "SUPERSECRET",
b: 2,
c: 3,
}, },
}, },
json: true, json: true,
@ -38,9 +37,7 @@ describe('integration', () => {
}, },
body: { body: {
data: { data: {
e: 4, otherSecret: "OTHERSUPERSECRET",
f: 5,
g: 6,
}, },
}, },
json: true, json: true,
@ -66,26 +63,26 @@ describe('integration', () => {
} }
it('get simple secret', async () => { it('get simple secret', async () => {
mockInput('test a') mockInput('test secret')
await exportSecrets(); await exportSecrets();
expect(core.exportSecret).toBeCalledWith('A', 1); expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
}); });
it('re-map secret', async () => { it('re-map secret', async () => {
mockInput('test a | TEST_KEY') mockInput('test secret | TEST_KEY')
await exportSecrets(); await exportSecrets();
expect(core.exportSecret).toBeCalledWith('TEST_KEY', 1); expect(core.exportVariable).toBeCalledWith('TEST_KEY', 'SUPERSECRET');
}); });
it('get nested secret', async () => { it('get nested secret', async () => {
mockInput('nested/test e') mockInput('nested/test otherSecret')
await exportSecrets(); await exportSecrets();
expect(core.exportSecret).toBeCalledWith('E', 4); expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET');
}); });
}); });