mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-08 23:56:55 +00:00
add test case for special chars
This commit is contained in:
parent
dc4f72debb
commit
83200f4fb1
4 changed files with 36 additions and 0 deletions
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
|
|
@ -153,6 +153,16 @@ jobs:
|
|||
my-secret/test altSecret | NAMED_ALTSECRET ;
|
||||
my-secret/nested/test otherAltSecret ;
|
||||
|
||||
- name: Test Vault Action (default KV V2)
|
||||
uses: ./
|
||||
id: kv-secrets
|
||||
with:
|
||||
url: http://localhost:8200
|
||||
token: testtoken
|
||||
secrets: |
|
||||
secret/data/specialchars secret ;
|
||||
secret/data/specialchars secret | SPECIAL_CHARS_SECRET ;
|
||||
|
||||
- name: Test Vault Action (cubbyhole)
|
||||
uses: ./
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
describe('e2e', () => {
|
||||
it('verify', () => {
|
||||
expect(process.env.SECRET).toBe("SUPERSECRET");
|
||||
expect(process.env.SPECIAL_CHARS_SECRET).toBe("abc$xyz");
|
||||
expect(process.env.NAMED_SECRET).toBe("SUPERSECRET");
|
||||
expect(process.env.OTHERSECRET).toBe("OTHERSUPERSECRET");
|
||||
expect(process.env.OTHER_SECRET_OUTPUT).toBe("OTHERSUPERSECRET");
|
||||
|
|
|
|||
|
|
@ -24,6 +24,18 @@ const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.V
|
|||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/secret/data/specialchars`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': vaultToken,
|
||||
},
|
||||
json: {
|
||||
data: {
|
||||
secret: 'abc$xyz',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/secret/data/nested/test`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,19 @@ describe('exportSecrets', () => {
|
|||
expect(core.setOutput).toBeCalledWith('key', '1');
|
||||
});
|
||||
|
||||
it('special chars secret retrieval', async () => {
|
||||
const secret = 'abc$xyz';
|
||||
mockInput('test key');
|
||||
mockVaultData({
|
||||
key: secret
|
||||
});
|
||||
|
||||
await exportSecrets();
|
||||
|
||||
expect(core.exportVariable).toBeCalledWith('KEY', secret);
|
||||
expect(core.setOutput).toBeCalledWith('key', secret);
|
||||
});
|
||||
|
||||
it('encoded secret retrieval', async () => {
|
||||
mockInput('test key');
|
||||
mockVaultData({
|
||||
|
|
|
|||
Loading…
Reference in a new issue