pull from master

This commit is contained in:
d98762625 2018-12-07 13:20:54 +00:00
commit 18f6ab451d
34 changed files with 2164 additions and 1798 deletions

View file

@ -658,7 +658,7 @@ WWFkYSBZYWRh\r
assert.strictEqual(
chef.JSONBeautify("{\"key\" : \"value\"}").toString(),
`{
\\t"key": "value"
"key": "value"
}`);
}),

View file

@ -0,0 +1,179 @@
/**
* CSV tests.
*
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
const EXAMPLE_CSV = `A,B,C,D,E,F\r
1,2,3,4,5,6\r
",",;,',"""",,\r
"""hello""","a""1","multi\r
line",,,end\r
`;
TestRegister.addTests([
{
name: "CSV to JSON: Array of dictionaries",
input: EXAMPLE_CSV,
expectedOutput: JSON.stringify([
{
"A": "1",
"B": "2",
"C": "3",
"D": "4",
"E": "5",
"F": "6"
},
{
"A": ",",
"B": ";",
"C": "'",
"D": "\"",
"E": "",
"F": ""
},
{
"A": "\"hello\"",
"B": "a\"1",
"C": "multi\r\nline",
"D": "",
"E": "",
"F": "end"
}
], null, 4),
recipeConfig: [
{
op: "CSV to JSON",
args: [",", "\r\n", "Array of dictionaries"],
}
],
},
{
name: "CSV to JSON: Array of arrays",
input: EXAMPLE_CSV,
expectedOutput: JSON.stringify([
[
"A",
"B",
"C",
"D",
"E",
"F"
],
[
"1",
"2",
"3",
"4",
"5",
"6"
],
[
",",
";",
"'",
"\"",
"",
""
],
[
"\"hello\"",
"a\"1",
"multi\r\nline",
"",
"",
"end"
]
], null, 4),
recipeConfig: [
{
op: "CSV to JSON",
args: [",", "\r\n", "Array of arrays"],
}
],
},
{
name: "JSON to CSV: Array of dictionaries",
input: JSON.stringify([
{
"A": "1",
"B": "2",
"C": "3",
"D": "4",
"E": "5",
"F": "6"
},
{
"A": ",",
"B": ";",
"C": "'",
"D": "\"",
"E": "",
"F": ""
},
{
"A": "\"hello\"",
"B": "a\"1",
"C": "multi\r\nline",
"D": "",
"E": "",
"F": "end"
}
]),
expectedOutput: EXAMPLE_CSV,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\r\n"],
}
],
},
{
name: "JSON to CSV: Array of arrays",
input: JSON.stringify([
[
"A",
"B",
"C",
"D",
"E",
"F"
],
[
"1",
"2",
"3",
"4",
"5",
"6"
],
[
",",
";",
"'",
"\"",
"",
""
],
[
"\"hello\"",
"a\"1",
"multi\r\nline",
"",
"",
"end"
]
]),
expectedOutput: EXAMPLE_CSV,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\r\n"],
}
],
},
]);

View file

@ -220,6 +220,39 @@ TestRegister.addTests([
}
],
},
{
name: "Citrix CTX1 Encode",
input: "Password1",
expectedOutput: "PFFAJEDBOHECJEDBODEGIMCJPOFLJKDPKLAO",
recipeConfig: [
{
"op": "Citrix CTX1 Encode",
"args": []
}
],
},
{
name: "Citrix CTX1 Decode: normal",
input: "PFFAJEDBOHECJEDBODEGIMCJPOFLJKDPKLAO",
expectedOutput: "Password1",
recipeConfig: [
{
"op": "Citrix CTX1 Decode",
"args": []
}
],
},
{
name: "Citrix CTX1 Decode: invalid length",
input: "PFFAJEDBOHECJEDBODEGIMCJPOFLJKDPKLA",
expectedOutput: "Incorrect hash length",
recipeConfig: [
{
"op": "Citrix CTX1 Decode",
"args": []
}
],
},
{
name: "Vigenère Encode: no input",
input: "",

View file

@ -0,0 +1,122 @@
/**
* JSONBeautify tests.
*
* @author Phillip Nordwall [Phillip.Nordwall@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
TestRegister.addTests([
{
name: "JSON Beautify: space, ''",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: space, number",
input: "42",
expectedOutput: "42",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: space, string",
input: "\"string\"",
expectedOutput: "\"string\"",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: space, boolean",
input: "false",
expectedOutput: "false",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: space, emptyList",
input: "[]",
expectedOutput: "[]",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: space, list",
input: "[2,1]",
expectedOutput: "[\n 2,\n 1\n]",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: tab, list",
input: "[2,1]",
expectedOutput: "[\n\t2,\n\t1\n]",
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", false],
},
],
},
{
name: "JSON Beautify: space, object",
input: "{\"second\":2,\"first\":3}",
expectedOutput: "{\n \"second\": 2,\n \"first\": 3\n}",
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
},
],
},
{
name: "JSON Beautify: tab, nested",
input: "[2,{\"second\":2,\"first\":3,\"beginning\":{\"j\":\"3\",\"i\":[2,3,false]}},1,2,3]",
expectedOutput: "[\n\t2,\n\t{\n\t\t\"second\": 2,\n\t\t\"first\": 3,\n\t\t\"beginning\": {\n\t\t\t\"j\": \"3\",\n\t\t\t\"i\": [\n\t\t\t\t2,\n\t\t\t\t3,\n\t\t\t\tfalse\n\t\t\t]\n\t\t}\n\t},\n\t1,\n\t2,\n\t3\n]",
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", false],
},
],
},
{
name: "JSON Beautify: tab, nested, sorted",
input: "[2,{\"second\":2,\"first\":3,\"beginning\":{\"j\":\"3\",\"i\":[2,3,false]}},1,2,3]",
expectedOutput: "[\n\t2,\n\t{\n\t\t\"beginning\": {\n\t\t\t\"i\": [\n\t\t\t\t2,\n\t\t\t\t3,\n\t\t\t\tfalse\n\t\t\t],\n\t\t\t\"j\": \"3\"\n\t\t},\n\t\t\"first\": 3,\n\t\t\"second\": 2\n\t},\n\t1,\n\t2,\n\t3\n]",
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", true],
},
],
},
]);

View file

@ -0,0 +1,111 @@
/**
* JSONMinify tests.
*
* @author Phillip Nordwall [Phillip.Nordwall@gmail.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../TestRegister";
TestRegister.addTests([
{
name: "JSON Minify: ''",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: number",
input: "42",
expectedOutput: "42",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: number",
input: "4.2",
expectedOutput: "4.2",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: string",
input: "\"string\"",
expectedOutput: "\"string\"",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: boolean",
input: "false",
expectedOutput: "false",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: emptyList",
input: "[\n \n \t]",
expectedOutput: "[]",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: list",
input: "[2,\n \t1]",
expectedOutput: "[2,1]",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: object",
input: "{\n \"second\": 2,\n \"first\": 3\n}",
expectedOutput: "{\"second\":2,\"first\":3}",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "JSON Minify: tab, nested",
input: "[\n\t2,\n\t{\n\t\t\"second\": 2,\n\t\t\"first\": 3,\n\t\t\"beginning\": {\n\t\t\t\"j\": \"3\",\n\t\t\t\"i\": [\n\t\t\t\t2,\n\t\t\t\t3,\n\t\t\t\tfalse\n\t\t\t]\n\t\t}\n\t},\n\t1,\n\t2,\n\t3\n]",
expectedOutput: "[2,{\"second\":2,\"first\":3,\"beginning\":{\"j\":\"3\",\"i\":[2,3,false]}},1,2,3]",
recipeConfig: [
{
op: "JSON Minify",
args: [],
},
],
},
]);