5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-07 15:16:56 +00:00

final cleanup

This commit is contained in:
JM Faircloth 2023-07-05 12:58:41 -05:00
parent 1a47f33407
commit 4ef647191c
3 changed files with 1 additions and 56 deletions

View file

@ -17,16 +17,4 @@ describe('e2e', () => {
result = result.substring(1, result.length - 1); result = result.substring(1, result.length - 1);
expect(process.env.JSONDATA).toBe(result); expect(process.env.JSONDATA).toBe(result);
}); });
it('verify jsonstring', () => {
expect(process.env.JSONSTRING).toBe('{"x":1,"y":"qux"}');
});
it('verify jsonstringmultiline', () => {
expect(process.env.JSONSTRINGMULTILINE).toBe('{"x": 1, "y": "q\\nux"}');
});
it('verify jsondata', () => {
let result = JSON.stringify('{"x":1,"y":"qux"}');
result = result.substring(1, result.length - 1);
expect(process.env.JSONDATA).toBe(result);
});
}); });

View file

@ -1,43 +0,0 @@
// This script is used by the e2e tests in build.yml to test that we can
// successfully parse JSON string data into JS objects
try {
let inputs = [
process.env.JSONSTRING,
process.env.JSONSTRINGMULTILINE,
];
let names = [
"test-json-string",
"test-json-string-multiline",
];
let i = 0;
inputs.forEach(input => {
console.log(`processing: ${names[i]}`)
i++;
input = (input || '').trim();
if (!input) {
throw new Error(`missing input`);
}
// If the string doesn't start with a JSON object character, it is probably
// base64-encoded.
if (!input.startsWith('{')) {
let str = input.replace(/-/g, '+').replace(/_/g, '/');
while (str.length % 4) str += '=';
input = Buffer.from(str, 'base64').toString('utf8');
}
try {
const creds = JSON.parse(input);
console.log('success!')
return creds;
} catch (err) {
throw new Error(`error parsing: ${err}`);
}
})
} catch (error) {
throw new Error(`error in parse.js: ${err}`);
}

View file

@ -107,7 +107,7 @@ async function exportSecrets() {
for (const line of value.replace(/\r/g, '').split('\n')) { for (const line of value.replace(/\r/g, '').split('\n')) {
if (line.length > 0) { if (line.length > 0) {
core.setOutput(line); core.setSecret(line);
} }
} }
if (exportEnv) { if (exportEnv) {