-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webseal): paste with multilines (#131)
* fix(webseal): paste with multilines * fix * lock * fix * fix * lock * fix * fix * fix * fix * fix
- Loading branch information
Julien Bouquillon
authored
May 16, 2023
1 parent
15e52f5
commit 4191dc4
Showing
12 changed files
with
4,217 additions
and
3,708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ on: | |
|
||
jobs: | ||
build: | ||
|
||
name: ubuntu-latest | ||
name: ubuntu-latest | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
16 changes: 3 additions & 13 deletions
16
.github/workflows/webseal.yml → .github/workflows/webseal-publish.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`toEnv : invalid YAML 1`] = `"some random text"`; | ||
|
||
exports[`toEnv : invalid YAML 2`] = ` | ||
"a=42 | ||
b=43" | ||
`; | ||
|
||
exports[`toEnv : multiple inputs 1`] = ` | ||
"SOME_TOKEN=\\"abcRE6jnuXVj234Y65zfzeUipcdO\\" | ||
SOME_SECRET=\\"-----BEGIN RSA PRIVATE KEY----- | ||
MIIJKAIBAAKCAlkznfzefekBG6MkFlzDVu/C8+c/XABs4HEQNsz61wdKTv9olitl | ||
QcJ6USzSsQNymwjgkWkkGH987z33As6c0VnqXZBeW2RZouctk4P3888cUBmC8AX+ | ||
JvmbEZ3IBic1uXkTY8tyXtvdmzBJClTFMqDBr9bwq975Yosj35lmp+JEFLdOsZT/ | ||
-----END RSA PRIVATE KEY-----\\" | ||
SOME_EMAIL=\\"[email protected], [email protected]\\" | ||
SOME_DB=\\"postgres://user:pass@host:port/db?sslmode=require\\"" | ||
`; | ||
|
||
exports[`toEnv : valid YAML 1`] = ` | ||
"A=\\"42\\" | ||
B=\\"43\\"" | ||
`; | ||
|
||
exports[`toEnv : valid YAML multilines 1`] = ` | ||
"A=\\"42\\" | ||
B=\\"424\\" | ||
C=\\"nlabalbalelkfnzemflkfenz | ||
zekfjbzkmfjbzemfjbzefmze\\"" | ||
`; | ||
|
||
exports[`toEnv : valid YAML quoted 1`] = `"A=\\"blablabla\\""`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { load } from "js-yaml"; | ||
|
||
export const toEnv = (string) => { | ||
try { | ||
const obj = load(string); | ||
if (obj != null && obj.constructor.name === "Object") { | ||
return Object.entries(obj) | ||
.map(([key, value]) => `${key}="${value}"`) | ||
.join("\n"); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
return string; | ||
} | ||
return string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { toEnv } from "./yamlToEnv"; | ||
|
||
const tests = [ | ||
{ | ||
title: "valid YAML", | ||
input: "A: 42\nB: 43", | ||
expected: true, | ||
}, | ||
{ | ||
title: "valid YAML quoted", | ||
input: 'A: "blablabla"', | ||
expected: true, | ||
}, | ||
{ | ||
title: "valid YAML multilines", | ||
input: `A: 42 | ||
B: 424 | ||
C: |- | ||
nlabalbalelkfnzemflkfenz | ||
zekfjbzkmfjbzemfjbzefmze`, | ||
expected: true, | ||
}, | ||
{ | ||
title: "invalid YAML", | ||
input: "some random text", | ||
expected: false, | ||
}, | ||
{ | ||
title: "invalid YAML", | ||
input: "a=42\nb=43", | ||
expected: false, | ||
}, | ||
{ | ||
title: "multiple inputs", | ||
input: ` | ||
SOME_TOKEN: abcRE6jnuXVj234Y65zfzeUipcdO | ||
SOME_SECRET: |- | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIJKAIBAAKCAlkznfzefekBG6MkFlzDVu/C8+c/XABs4HEQNsz61wdKTv9olitl | ||
QcJ6USzSsQNymwjgkWkkGH987z33As6c0VnqXZBeW2RZouctk4P3888cUBmC8AX+ | ||
JvmbEZ3IBic1uXkTY8tyXtvdmzBJClTFMqDBr9bwq975Yosj35lmp+JEFLdOsZT/ | ||
-----END RSA PRIVATE KEY----- | ||
SOME_EMAIL: [email protected], [email protected] | ||
SOME_DB: postgres://user:pass@host:port/db?sslmode=require | ||
`, | ||
expected: true, | ||
}, | ||
]; | ||
|
||
tests.forEach((t) => { | ||
it(`toEnv : ${t.title}`, () => { | ||
expect(toEnv(t.input)).toMatchSnapshot(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.