mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 09:16:17 -04:00
Bring up to date with master
This commit is contained in:
commit
dd5038c15b
25 changed files with 2265 additions and 2202 deletions
|
@ -49,9 +49,11 @@ import "./tests/Hash";
|
|||
import "./tests/HaversineDistance";
|
||||
import "./tests/Hexdump";
|
||||
import "./tests/Image";
|
||||
import "./tests/IndexOfCoincidence";
|
||||
import "./tests/Jump";
|
||||
import "./tests/JSONBeautify";
|
||||
import "./tests/JSONMinify";
|
||||
import "./tests/JSONtoCSV";
|
||||
import "./tests/JWTDecode";
|
||||
import "./tests/JWTSign";
|
||||
import "./tests/JWTVerify";
|
||||
|
|
22
tests/operations/tests/IndexOfCoincidence.mjs
Normal file
22
tests/operations/tests/IndexOfCoincidence.mjs
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Index of Coincidence tests.
|
||||
*
|
||||
* @author George O [georgeomnet+cyberchef@gmail.com]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../TestRegister";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Index of Coincidence",
|
||||
input: "Hello world, this is a test to determine the correct IC value.",
|
||||
expectedMatch: /^Index of Coincidence: 0\.07142857142857142\nNormalized: 1\.857142857142857/,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Index of Coincidence",
|
||||
"args": []
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
93
tests/operations/tests/JSONtoCSV.mjs
Normal file
93
tests/operations/tests/JSONtoCSV.mjs
Normal file
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* JSON to CSV tests.
|
||||
*
|
||||
* @author mshwed [m@ttshwed.com]
|
||||
*
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../TestRegister";
|
||||
|
||||
const EXPECTED_CSV_SINGLE = "a,b,c\r\n1,2,3\r\n";
|
||||
const EXPECTED_CSV_MULTIPLE = "a,b,c\r\n1,2,3\r\n1,2,3\r\n";
|
||||
const EXPECTED_CSV_EMPTY = "\r\n\r\n";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "JSON to CSV: strings as values",
|
||||
input: JSON.stringify({a: "1", b: "2", c: "3"}),
|
||||
expectedOutput: EXPECTED_CSV_SINGLE,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: numbers as values",
|
||||
input: JSON.stringify({a: 1, b: 2, c: 3}),
|
||||
expectedOutput: EXPECTED_CSV_SINGLE,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: numbers and strings as values",
|
||||
input: JSON.stringify({a: 1, b: "2", c: 3}),
|
||||
expectedOutput: EXPECTED_CSV_SINGLE,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: JSON as an array",
|
||||
input: JSON.stringify([{a: 1, b: "2", c: 3}]),
|
||||
expectedOutput: EXPECTED_CSV_SINGLE,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: multiple JSON values in an array",
|
||||
input: JSON.stringify([{a: 1, b: "2", c: 3}, {a: 1, b: "2", c: 3}]),
|
||||
expectedOutput: EXPECTED_CSV_MULTIPLE,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: empty JSON",
|
||||
input: JSON.stringify({}),
|
||||
expectedOutput: EXPECTED_CSV_EMPTY,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: empty JSON in array",
|
||||
input: JSON.stringify([{}]),
|
||||
expectedOutput: EXPECTED_CSV_EMPTY,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue