diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebcb2bc..9ecf4d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,9 +77,9 @@ jobs: vaultUrl: http://localhost:${{ job.services.vault.ports[8200] }} vaultToken: testtoken keys: | - test a ; - test a | NAMED_TOKEN ; - nested/test e ; + test secret ; + test secret | NAMED_SECRET ; + nested/test otherSecret ; - name: verify run: npm run test:e2e diff --git a/action.test.js b/action.test.js index c2d740d..32de246 100644 --- a/action.test.js +++ b/action.test.js @@ -105,7 +105,7 @@ describe('exportSecrets', () => { await exportSecrets(); - expect(core.exportVariable).toBeCalledWith('KEY', 1); + expect(core.exportVariable).toBeCalledWith('KEY', '1'); }); it('mapped key retrieval', async () => { @@ -116,6 +116,6 @@ describe('exportSecrets', () => { await exportSecrets(); - expect(core.exportVariable).toBeCalledWith('TEST_NAME', 1); + expect(core.exportVariable).toBeCalledWith('TEST_NAME', '1'); }); }); \ No newline at end of file diff --git a/e2e/e2e.test.js b/e2e/e2e.test.js index d0bd673..f5bfd47 100644 --- a/e2e/e2e.test.js +++ b/e2e/e2e.test.js @@ -1,7 +1,7 @@ describe('e2e', () => { it('verify', () => { - expect(process.env.A).toBe("1"); - expect(process.env.NAMED_TOKEN).toBe("1"); - expect(process.env.E).toBe("4"); + expect(process.env.SECRET).toBe("SUPERSECRET"); + expect(process.env.NAMED_SECRET).toBe("SUPERSECRET"); + expect(process.env.OTHERSECRET).toBe("OTHERSUPERSECRET"); }); }); \ No newline at end of file diff --git a/e2e/setup.js b/e2e/setup.js index c6a01cd..5ca354c 100644 --- a/e2e/setup.js +++ b/e2e/setup.js @@ -16,9 +16,7 @@ const got = require('got'); }, body: { data: { - a: 1, - b: 2, - c: 3, + secret: "SUPERSECRET", }, }, json: true, @@ -31,9 +29,7 @@ const got = require('got'); }, body: { data: { - e: 4, - f: 5, - g: 6, + otherSecret: "OTHERSUPERSECRET", }, }, json: true, diff --git a/integration/integration.test.js b/integration/integration.test.js index 80a266b..c1d12b3 100644 --- a/integration/integration.test.js +++ b/integration/integration.test.js @@ -1,4 +1,5 @@ jest.mock('@actions/core'); +jest.mock('@actions/core/lib/command'); const core = require('@actions/core'); const got = require('got'); @@ -23,9 +24,7 @@ describe('integration', () => { }, body: { data: { - a: 1, - b: 2, - c: 3, + secret: "SUPERSECRET", }, }, json: true, @@ -38,9 +37,7 @@ describe('integration', () => { }, body: { data: { - e: 4, - f: 5, - g: 6, + otherSecret: "OTHERSUPERSECRET", }, }, json: true, @@ -66,26 +63,26 @@ describe('integration', () => { } it('get simple secret', async () => { - mockInput('test a') + mockInput('test secret') await exportSecrets(); - expect(core.exportSecret).toBeCalledWith('A', 1); + expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET'); }); it('re-map secret', async () => { - mockInput('test a | TEST_KEY') + mockInput('test secret | TEST_KEY') await exportSecrets(); - expect(core.exportSecret).toBeCalledWith('TEST_KEY', 1); + expect(core.exportVariable).toBeCalledWith('TEST_KEY', 'SUPERSECRET'); }); it('get nested secret', async () => { - mockInput('nested/test e') + mockInput('nested/test otherSecret') await exportSecrets(); - expect(core.exportSecret).toBeCalledWith('E', 4); + expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERSUPERSECRET'); }); }); \ No newline at end of file