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:
parent
1d767e3957
commit
93d64baa8a
4 changed files with 35 additions and 0 deletions
11
.github/actions/nested-vault-action/action.yml
vendored
Normal file
11
.github/actions/nested-vault-action/action.yml
vendored
Normal 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;
|
||||||
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
|
|
@ -174,6 +174,17 @@ jobs:
|
||||||
/cubbyhole/test foo ;
|
/cubbyhole/test foo ;
|
||||||
/cubbyhole/test zip | NAMED_CUBBYSECRET ;
|
/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
|
- name: Verify Vault Action Outputs
|
||||||
run: npm run test:e2e
|
run: npm run test:e2e
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,6 @@ describe('e2e', () => {
|
||||||
expect(process.env.OTHERALTSECRET).toBe("OTHERCUSTOMSECRET");
|
expect(process.env.OTHERALTSECRET).toBe("OTHERCUSTOMSECRET");
|
||||||
expect(process.env.FOO).toBe("bar");
|
expect(process.env.FOO).toBe("bar");
|
||||||
expect(process.env.NAMED_CUBBYSECRET).toBe("zap");
|
expect(process.env.NAMED_CUBBYSECRET).toBe("zap");
|
||||||
|
expect(process.env.NESTED_VAULT_ACTION_SECRET).toBe("NESTED_VAULT_ACTION_SECRET");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,18 @@ const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.V
|
||||||
zip: 'zap',
|
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) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue