5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-10 00:26:55 +00:00

Test if it's possible to overwrite env var variable in action

This commit is contained in:
Leonardo Villela 2023-04-24 02:15:24 +02:00
parent 1d767e3957
commit 93d64baa8a
4 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,11 @@
name: 'Nested Vault Action'
description: 'A Nested Vault Action to be used in E2E tests'
runs:
using: "composite"
steps:
- uses: ./
with:
url: http://localhost:8200
token: testtoken
secrets: |
secret/data/nested-vault-action secret | NESTED_VAULT_ACTION_SECRET;

View file

@ -174,6 +174,17 @@ jobs:
/cubbyhole/test foo ;
/cubbyhole/test zip | NAMED_CUBBYSECRET ;
- name: Test Vault Action Overwrites Env Vars In Nested Action (part 1/2)
uses: ./
with:
url: http://localhost:8200
token: testtoken
secrets: |
secret/data/test secret | NESTED_VAULT_ACTION_SECRET;
- name: Test Vault Action Overwrites Env Vars In Nested Action (part 2/2)
uses: ./.github/actions/nested-vault-action
- name: Verify Vault Action Outputs
run: npm run test:e2e
env:

View file

@ -9,5 +9,6 @@ describe('e2e', () => {
expect(process.env.OTHERALTSECRET).toBe("OTHERCUSTOMSECRET");
expect(process.env.FOO).toBe("bar");
expect(process.env.NAMED_CUBBYSECRET).toBe("zap");
expect(process.env.NESTED_VAULT_ACTION_SECRET).toBe("NESTED_VAULT_ACTION_SECRET");
});
});

View file

@ -76,6 +76,18 @@ const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.V
zip: 'zap',
},
});
await got(`http://${vaultUrl}/v1/secret/data/nested-vault-action`, {
method: 'POST',
headers: {
'X-Vault-Token': vaultToken,
},
json: {
data: {
secret: 'NESTED_VAULT_ACTION_SECRET',
},
},
});
} catch (error) {
console.log(error);
process.exit(1);