mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-04-11 22:50:05 +00:00
fix secrets stored in JSON format (#473)
* fix secrets stored in JSON format * add more tests * fix lint and pass token to build * add test cases * add debug * fix ordering of build steps * fix test string format * update test check * fix test string format * final cleanup * remove comment * remove unused var assignment * simplify more * simplify code and add more comments
This commit is contained in:
parent
e926631bb2
commit
b138504969
7 changed files with 153 additions and 6 deletions
|
|
@ -10,5 +10,11 @@ describe('e2e', () => {
|
|||
expect(process.env.FOO).toBe("bar");
|
||||
expect(process.env.NAMED_CUBBYSECRET).toBe("zap");
|
||||
expect(process.env.SUBSEQUENT_TEST_SECRET).toBe("SUBSEQUENT_TEST_SECRET");
|
||||
expect(process.env.JSONSTRING).toBe('{"x":1,"y":"qux"}');
|
||||
expect(process.env.JSONSTRINGMULTILINE).toBe('{"x": 1, "y": "q\\nux"}');
|
||||
|
||||
let result = JSON.stringify('{"x":1,"y":"qux"}');
|
||||
result = result.substring(1, result.length - 1);
|
||||
expect(process.env.JSONDATA).toBe(result);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ const got = require('got');
|
|||
const vaultUrl = `${process.env.VAULT_HOST}:${process.env.VAULT_PORT}`;
|
||||
const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.VAULT_TOKEN}` : "testtoken";
|
||||
|
||||
const jsonStringMultiline = '{"x": 1, "y": "q\\nux"}';
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// Verify Connection
|
||||
|
|
@ -36,6 +38,44 @@ const vaultToken = `${process.env.VAULT_TOKEN}` === undefined ? `${process.env.V
|
|||
}
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/secret/data/test-json-string`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': vaultToken,
|
||||
},
|
||||
json: {
|
||||
data: {
|
||||
// this is stored in Vault as a string
|
||||
jsonString: '{"x":1,"y":"qux"}',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/secret/data/test-json-data`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': vaultToken,
|
||||
},
|
||||
json: {
|
||||
data: {
|
||||
// this is stored in Vault as a map
|
||||
jsonData: {"x":1,"y":"qux"},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/secret/data/test-json-string-multiline`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Vault-Token': vaultToken,
|
||||
},
|
||||
json: {
|
||||
data: {
|
||||
jsonStringMultiline,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await got(`http://${vaultUrl}/v1/sys/mounts/my-secret`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue