Merge branch 'master' into time-difference

This commit is contained in:
tomgond 2025-05-19 21:18:53 +03:00 committed by GitHub
commit 568849fece
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 20048 additions and 4028 deletions

View file

@ -11,15 +11,14 @@
* @license Apache-2.0
*/
import {
setLongTestFailure,
logTestReport,
} from "../lib/utils.mjs";
import { setLongTestFailure, logTestReport } from "../lib/utils.mjs";
import TestRegister from "../lib/TestRegister.mjs";
import "./tests/AESKeyWrap.mjs";
import "./tests/AlternatingCaps.mjs";
import "./tests/AvroToJSON.mjs";
import "./tests/BaconCipher.mjs";
import "./tests/Base32.mjs";
import "./tests/Base45.mjs";
import "./tests/Base58.mjs";
import "./tests/Base62.mjs";
@ -30,6 +29,7 @@ import "./tests/BCD.mjs";
import "./tests/BitwiseOp.mjs";
import "./tests/BLAKE2b.mjs";
import "./tests/BLAKE2s.mjs";
import "./tests/BLAKE3.mjs";
import "./tests/Bombe.mjs";
import "./tests/BSON.mjs";
import "./tests/ByteRepr.mjs";
@ -44,7 +44,6 @@ import "./tests/ChaCha.mjs";
import "./tests/ChangeIPFormat.mjs";
import "./tests/CharEnc.mjs";
import "./tests/Charts.mjs";
import "./tests/Checksum.mjs";
import "./tests/Ciphers.mjs";
import "./tests/CipherSaber2.mjs";
import "./tests/CMAC.mjs";
@ -54,21 +53,26 @@ import "./tests/Comment.mjs";
import "./tests/Compress.mjs";
import "./tests/ConditionalJump.mjs";
import "./tests/ConvertCoordinateFormat.mjs";
import "./tests/ConvertLeetSpeak.mjs";
import "./tests/ConvertToNATOAlphabet.mjs";
import "./tests/CRCChecksum.mjs";
import "./tests/Crypt.mjs";
import "./tests/CSV.mjs";
import "./tests/DateTime.mjs";
import "./tests/DefangIP.mjs";
import "./tests/DropNthBytes.mjs";
import "./tests/ECDSA.mjs";
import "./tests/ELFInfo.mjs";
import "./tests/Enigma.mjs";
import "./tests/ExtractEmailAddresses.mjs";
import "./tests/ExtractHashes.mjs";
import "./tests/ExtractIPAddresses.mjs";
import "./tests/Float.mjs";
import "./tests/FileTree.mjs";
import "./tests/FletcherChecksum.mjs";
import "./tests/Fork.mjs";
import "./tests/FromDecimal.mjs";
import "./tests/GenerateAllChecksums.mjs";
import "./tests/GenerateAllHashes.mjs";
import "./tests/GenerateDeBruijnSequence.mjs";
import "./tests/GetAllCasings.mjs";
@ -86,6 +90,7 @@ import "./tests/IndexOfCoincidence.mjs";
import "./tests/JA3Fingerprint.mjs";
import "./tests/JA4.mjs";
import "./tests/JA3SFingerprint.mjs";
import "./tests/Jsonata.mjs";
import "./tests/JSONBeautify.mjs";
import "./tests/JSONMinify.mjs";
import "./tests/JSONtoCSV.mjs";
@ -102,6 +107,8 @@ import "./tests/LZNT1Decompress.mjs";
import "./tests/LZString.mjs";
import "./tests/Magic.mjs";
import "./tests/Media.mjs";
import "./tests/MIMEDecoding.mjs";
import "./tests/Modhex.mjs";
import "./tests/MorseCode.mjs";
import "./tests/MS.mjs";
import "./tests/MultipleBombe.mjs";
@ -115,11 +122,13 @@ import "./tests/ParseObjectIDTimestamp.mjs";
import "./tests/ParseQRCode.mjs";
import "./tests/ParseSSHHostKey.mjs";
import "./tests/ParseTCP.mjs";
import "./tests/ParseTLSRecord.mjs";
import "./tests/ParseTLV.mjs";
import "./tests/ParseUDP.mjs";
import "./tests/PEMtoHex.mjs";
import "./tests/PGP.mjs";
import "./tests/PHP.mjs";
import "./tests/PHPSerialize.mjs";
import "./tests/PowerSet.mjs";
import "./tests/Protobuf.mjs";
import "./tests/PubKeyFromCert.mjs";
@ -139,18 +148,35 @@ import "./tests/SetIntersection.mjs";
import "./tests/SetUnion.mjs";
import "./tests/Shuffle.mjs";
import "./tests/SIGABA.mjs";
import "./tests/SM2.mjs";
import "./tests/SM4.mjs";
// import "./tests/SplitColourChannels.mjs"; // Cannot test operations that use the File type yet
import "./tests/StrUtils.mjs";
import "./tests/StripIPv4Header.mjs";
import "./tests/StripTCPHeader.mjs";
import "./tests/StripUDPHeader.mjs";
import "./tests/Subsection.mjs";
import "./tests/SwapCase.mjs";
import "./tests/SymmetricDifference.mjs";
import "./tests/TakeNthBytes.mjs";
import "./tests/Template.mjs";
import "./tests/TextEncodingBruteForce.mjs";
import "./tests/ToFromInsensitiveRegex.mjs";
import "./tests/TranslateDateTimeFormat.mjs";
import "./tests/Typex.mjs";
import "./tests/UnescapeString.mjs";
import "./tests/Unicode.mjs";
import "./tests/URLEncodeDecode.mjs";
import "./tests/RSA.mjs";
import "./tests/CBOREncode.mjs";
import "./tests/CBORDecode.mjs";
import "./tests/JA3Fingerprint.mjs";
import "./tests/JA3SFingerprint.mjs";
import "./tests/HASSH.mjs";
import "./tests/JSONtoYAML.mjs";
// Cannot test operations that use the File type yet
// import "./tests/SplitColourChannels.mjs";
import "./tests/YARA.mjs";
import "./tests/ParseCSR.mjs";
import "./tests/XXTEA.mjs";
@ -159,14 +185,14 @@ const testStatus = {
allTestsPassing: true,
counts: {
total: 0,
}
},
};
setLongTestFailure();
const logOpsTestReport = logTestReport.bind(null, testStatus);
(async function() {
(async function () {
const results = await TestRegister.runTests();
logOpsTestReport(results);
})();

View file

@ -0,0 +1,19 @@
/* @author sw5678
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "AlternatingCaps: Basic Example",
"input": "Hello, world!",
"expectedOutput": "hElLo, WoRlD!",
"recipeConfig": [
{
"op": "Alternating Caps",
"args": []
},
],
}
]);

View file

@ -0,0 +1,55 @@
/**
* BLAKE3 tests.
* @author xumptex [xumptex@outlook.fr]
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "BLAKE3: 8 - Hello world",
input: "Hello world",
expectedOutput: "e7e6fb7d2869d109",
recipeConfig: [
{ "op": "BLAKE3",
"args": [8, ""] }
]
},
{
name: "BLAKE3: 16 - Hello world 2",
input: "Hello world 2",
expectedOutput: "2a3df5fe5f0d3fcdd995fc203c7f7c52",
recipeConfig: [
{ "op": "BLAKE3",
"args": [16, ""] }
]
},
{
name: "BLAKE3: 32 - Hello world",
input: "Hello world",
expectedOutput: "e7e6fb7d2869d109b62cdb1227208d4016cdaa0af6603d95223c6a698137d945",
recipeConfig: [
{ "op": "BLAKE3",
"args": [32, ""] }
]
},
{
name: "BLAKE3: Key Test",
input: "Hello world",
expectedOutput: "59dd23ac9d025690",
recipeConfig: [
{ "op": "BLAKE3",
"args": [8, "ThiskeyisexactlythirtytwoBytesLo"] }
]
},
{
name: "BLAKE3: Key Test 2",
input: "Hello world",
expectedOutput: "c8302c9634c1da42",
recipeConfig: [
{ "op": "BLAKE3",
"args": [8, "ThiskeyisexactlythirtytwoByteslo"] }
]
}
]);

View file

@ -0,0 +1,176 @@
/**
* Base32 Tests
*
* @author Peter C-S [petercs@purelymail.com]
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import {ALPHABET_OPTIONS} from "../../../src/core/lib/Base32.mjs";
// Example Standard Base32 Tests
const STANDARD_INP = "HELLO BASE32";
const STANDARD_OUT = "JBCUYTCPEBBECU2FGMZA====";
// Example Hex Extended Base32 Tests
const EXTENDED_INP = "HELLO BASE32 EXTENDED";
const EXTENDED_OUT = "912KOJ2F41142KQ56CP20HAOAH2KSH258G======";
// All Bytes
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
const ALL_BYTES_EXTENDED_OUT = "000G40O40K30E209185GO38E1S8124GJ2GAHC5OO34D1M70T3OFI08924CI2A9H750KIKAPC5KN2UC1H68PJ8D9M6SS3IEHR7GUJSFQ085146H258P3KGIAA9D64QJIFA18L4KQKALB5EM2PB9DLONAUBTG62OJ3CHIMCPR8D5L6MR3DDPNN0SBIEDQ7ATJNF1SNKURSFLV7V041GA1O91C6GU48J2KBHI6OT3SGI699754LIQBPH6CQJEE9R7KVK2GQ58T4KMJAFA59LALQPBDELUOB3CLJMIQRDDTON6TBNF5TNQVS1GE2OF2CBHM7P34SLIUCPN7CVK6HQB9T9LEMQVCDJMMRRJETTNV0S7HE7P75SRJUHQFATFMERRNFU3OV5SVKUNRFFU7PVBTVPVFUVS======";
const ALL_BYTES_STANDARD_OUT = "AAAQEAYEAUDAOCAJBIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYPSAIJCEMSCKJRHFAUSUKZMFUXC6MBRGIZTINJWG44DSOR3HQ6T4P2AIFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLJNVYXK6L5QGCYTDMRSWMZ3INFVGW3DNNZXXA4LSON2HK5TXPB4XU634PV7H7AEBQKBYJBMGQ6EITCULRSGY5D4QSGJJHFEVS2LZRGM2TOOJ3HU7UCQ2FI5EUWTKPKFJVKV2ZLNOV6YLDMVTWS23NN5YXG5LXPF5X274BQOCYPCMLRWHZDE4VS6MZXHM7UGR2LJ5JVOW27MNTWW33TO55X7A4HROHZHF43T6R2PK5PWO33XP6DY7F47U6X3PP6HZ7L57Z7P674======";
TestRegister.addTests([
{
name: "To Base32 Standard: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[0].value],
},
],
},
{
name: "To Base32 Hex Extended: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[1].value],
},
],
},
{
name: "From Base32 Standard: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[0].value, false],
},
],
},
{
name: "From Base32 Hex Extended: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[1].value, false],
},
],
},
{
name: "To Base32 Standard: " + STANDARD_INP,
input: STANDARD_INP,
expectedOutput: STANDARD_OUT,
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[0].value],
},
],
},
{
name: "To Base32 Hex Extended: " + EXTENDED_INP,
input: EXTENDED_INP,
expectedOutput: EXTENDED_OUT,
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[1].value],
},
],
},
{
name: "From Base32 Standard: " + STANDARD_OUT,
input: STANDARD_OUT,
expectedOutput: STANDARD_INP,
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[0].value, false],
},
],
},
{
name: "From Base32 Hex Extended: " + EXTENDED_OUT,
input: EXTENDED_OUT,
expectedOutput: EXTENDED_INP,
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[1].value, false],
},
],
},
{
name: "To Base32 Hex Standard: All Bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES_STANDARD_OUT,
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[0].value],
},
],
},
{
name: "To Base32 Hex Extended: All Bytes",
input: ALL_BYTES,
expectedOutput: ALL_BYTES_EXTENDED_OUT,
recipeConfig: [
{
op: "To Base32",
args: [ALPHABET_OPTIONS[1].value],
},
],
},
{
name: "From Base32 Hex Standard: All Bytes",
input: ALL_BYTES_STANDARD_OUT,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[0].value, false],
},
],
},
{
name: "From Base32 Hex Extended: All Bytes",
input: ALL_BYTES_EXTENDED_OUT,
expectedOutput: ALL_BYTES,
recipeConfig: [
{
op: "From Base32",
args: [ALPHABET_OPTIONS[1].value, false],
},
],
},
]);

File diff suppressed because it is too large Load diff

View file

@ -1,241 +0,0 @@
/**
* Checksum tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const BASIC_STRING = "The ships hung in the sky in much the same way that bricks don't.";
const UTF8_STR = "ნუ პანიკას";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "CRC-8: nothing",
input: "",
expectedOutput: "00",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8"]
}
]
},
{
name: "CRC-8: default check",
input: "123456789",
expectedOutput: "f4",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8"]
}
]
},
{
name: "CRC-8: CDMA2000",
input: "123456789",
expectedOutput: "da",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/CDMA2000"]
}
]
},
{
name: "CRC-8: DARC",
input: "123456789",
expectedOutput: "15",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/DARC"]
}
]
},
{
name: "CRC-8: DVB-S2",
input: "123456789",
expectedOutput: "bc",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/DVB-S2"]
}
]
},
{
name: "CRC-8: EBU",
input: "123456789",
expectedOutput: "97",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/EBU"]
}
]
},
{
name: "CRC-8: I-CODE",
input: "123456789",
expectedOutput: "7e",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/I-CODE"]
}
]
},
{
name: "CRC-8: ITU",
input: "123456789",
expectedOutput: "a1",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/ITU"]
}
]
},
{
name: "CRC-8: MAXIM",
input: "123456789",
expectedOutput: "a1",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/MAXIM"]
}
]
},
{
name: "CRC-8: ROHC",
input: "123456789",
expectedOutput: "d0",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/ROHC"]
}
]
},
{
name: "CRC-8: WCDMA",
input: "123456789",
expectedOutput: "25",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/WCDMA"]
}
]
},
{
name: "CRC-16: nothing",
input: "",
expectedOutput: "0000",
recipeConfig: [
{
"op": "CRC-16 Checksum",
"args": []
}
]
},
{
name: "CRC-16: basic string",
input: BASIC_STRING,
expectedOutput: "0c70",
recipeConfig: [
{
"op": "CRC-16 Checksum",
"args": []
}
]
},
{
name: "CRC-16: UTF-8",
input: UTF8_STR,
expectedOutput: "dcf6",
recipeConfig: [
{
"op": "CRC-16 Checksum",
"args": []
}
]
},
{
name: "CRC-16: all bytes",
input: ALL_BYTES,
expectedOutput: "bad3",
recipeConfig: [
{
"op": "CRC-16 Checksum",
"args": []
}
]
},
{
name: "CRC-32: nothing",
input: "",
expectedOutput: "00000000",
recipeConfig: [
{
"op": "CRC-32 Checksum",
"args": []
}
]
},
{
name: "CRC-32: basic string",
input: BASIC_STRING,
expectedOutput: "bf4b739c",
recipeConfig: [
{
"op": "CRC-32 Checksum",
"args": []
}
]
},
{
name: "CRC-32: UTF-8",
input: UTF8_STR,
expectedOutput: "87553290",
recipeConfig: [
{
"op": "CRC-32 Checksum",
"args": []
}
]
},
{
name: "CRC-32: all bytes",
input: ALL_BYTES,
expectedOutput: "29058c73",
recipeConfig: [
{
"op": "CRC-32 Checksum",
"args": []
}
]
}
]);

View file

@ -528,4 +528,15 @@ TestRegister.addTests([
}
],
},
{
name: "Rail Fence Cipher Encode: Normal with Offset with Spaces",
input: "No one expects the spanish Inquisition.",
expectedOutput: " e n ut.ooeepcstesaihIqiiinNnxthpsnso",
recipeConfig: [
{
"op": "Rail Fence Cipher Encode",
"args": [3, 2]
}
],
},
]);

View file

@ -0,0 +1,55 @@
/**
* @author bartblaze []
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Convert to Leet Speak: basic text",
input: "leet",
expectedOutput: "l337",
recipeConfig: [
{
op: "Convert Leet Speak",
args: ["To Leet Speak"]
}
]
},
{
name: "Convert from Leet Speak: basic leet",
input: "l337",
expectedOutput: "leet",
recipeConfig: [
{
op: "Convert Leet Speak",
args: ["From Leet Speak"]
}
]
},
{
name: "Convert to Leet Speak: basic text, keep case",
input: "HELLO",
expectedOutput: "H3LL0",
recipeConfig: [
{
op: "Convert Leet Speak",
args: ["To Leet Speak"]
}
]
},
{
name: "Convert from Leet Speak: basic leet, keep case",
input: "H3LL0",
expectedOutput: "HeLLo",
recipeConfig: [
{
op: "Convert Leet Speak",
args: ["From Leet Speak"]
}
]
}
]);

View file

@ -580,8 +580,7 @@ Tag: a8f04c4d93bbef82bef61a103371aef9`,
input: "",
expectedOutput: `Invalid key length: 0 bytes
DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 bits).`,
DES uses a key length of 8 bytes (64 bits).`,
recipeConfig: [
{
"op": "DES Encrypt",
@ -674,8 +673,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
input: "",
expectedOutput: `Invalid key length: 0 bytes
Triple DES uses a key length of 24 bytes (192 bits).
DES uses a key length of 8 bytes (64 bits).`,
Triple DES uses a key length of 24 bytes (192 bits).`,
recipeConfig: [
{
"op": "Triple DES Encrypt",
@ -1300,8 +1298,7 @@ The following algorithms will be used based on the size of the key:
input: "",
expectedOutput: `Invalid key length: 0 bytes
DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 bits).`,
DES uses a key length of 8 bytes (64 bits).`,
recipeConfig: [
{
"op": "DES Decrypt",
@ -1394,8 +1391,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
input: "",
expectedOutput: `Invalid key length: 0 bytes
Triple DES uses a key length of 24 bytes (192 bits).
DES uses a key length of 8 bytes (64 bits).`,
Triple DES uses a key length of 24 bytes (192 bits).`,
recipeConfig: [
{
"op": "Triple DES Decrypt",
@ -1579,19 +1575,31 @@ DES uses a key length of 8 bytes (64 bits).`,
from Crypto.Cipher import Blowfish
import binascii
input_data = b"The quick brown fox jumps over the lazy dog."
# Blowfish cipher parameters - key, mode, iv, segment_size, nonce
key = binascii.unhexlify("0011223344556677")
iv = binascii.unhexlify("0000000000000000")
mode = Blowfish.MODE_CBC
kwargs = {}
iv = binascii.unhexlify("ffeeddccbbaa9988")
if mode in [Blowfish.MODE_CBC, Blowfish.MODE_CFB, Blowfish.MODE_OFB]:
kwargs = {"iv": iv}
if mode == Blowfish.MODE_CFB:
kwargs["segment_size"] = 64
if mode == Blowfish.MODE_CTR:
nonce = binascii.unhexlify("0000000000000000")
nonce = nonce[:7]
kwargs["nonce"] = nonce
cipher = Blowfish.new(key, mode, **kwargs)
# Input data and padding
input_data = b"The quick brown fox jumps over the lazy dog."
if mode == Blowfish.MODE_ECB or mode == Blowfish.MODE_CBC:
padding_len = 8-(len(input_data) & 7)
for i in range(padding_len):
input_data += bytes([padding_len])
cipher = Blowfish.new(key, mode) # set iv, nonce, segment_size etc. here
# Encrypted text
cipher_text = cipher.encrypt(input_data)
cipher_text = binascii.hexlify(cipher_text).decode("UTF-8")
print("Encrypted: {}".format(cipher_text))

View file

@ -0,0 +1,123 @@
/**
* @author Oshawk [oshawk@protonmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
/**
* Drop nth bytes tests
*/
TestRegister.addTests([
{
name: "Drop nth bytes: Nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Drop nth bytes: Nothing (apply to each line)",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Drop nth bytes: Basic single line",
input: "0123456789",
expectedOutput: "1235679",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Drop nth bytes: Basic single line (apply to each line)",
input: "0123456789",
expectedOutput: "1235679",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Drop nth bytes: Complex single line",
input: "0123456789",
expectedOutput: "01234678",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 5, false],
},
],
},
{
name: "Drop nth bytes: Complex single line (apply to each line)",
input: "0123456789",
expectedOutput: "01234678",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 5, true],
},
],
},
{
name: "Drop nth bytes: Basic multi line",
input: "01234\n56789",
expectedOutput: "123\n5689",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Drop nth bytes: Basic multi line (apply to each line)",
input: "01234\n56789",
expectedOutput: "123\n678",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Drop nth bytes: Complex multi line",
input: "01234\n56789",
expectedOutput: "012345679",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 5, false],
},
],
},
{
name: "Drop nth bytes: Complex multi line (apply to each line)",
input: "012345\n6789ab",
expectedOutput: "01234\n6789a",
recipeConfig: [
{
op: "Drop nth bytes",
args: [4, 5, true],
},
],
}
]);

View file

@ -6,7 +6,10 @@
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import { ASCII_TEXT } from "../../samples/Ciphers.mjs";
import {ALL_BYTES, ASCII_TEXT, UTF8_TEXT} from "../../samples/Ciphers.mjs";
const SOME_HEX_BYTES = "cdb23f958e018418621d9e489b7bba0f0c481f604eba2eb1ea35e38f99490cc0";
const SOME_BASE64_BYTES = "zbI/lY4BhBhiHZ5Im3u6DwxIH2BOui6x6jXjj5lJDMA=";
const P256 = {
// openssl ecparam -name prime256v1 -genkey -noout -out p256.priv.key
@ -104,7 +107,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "MD5", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "MD5", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -119,7 +122,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-1", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-1", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -134,7 +137,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -149,7 +152,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-384", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-384", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -164,7 +167,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-512", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-512", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -179,7 +182,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -194,7 +197,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-384", P384.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-384", P384.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -209,7 +212,7 @@ TestRegister.addTests([
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-512", P521.publicKey, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-512", P521.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -246,7 +249,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -257,7 +260,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -268,7 +271,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -279,7 +282,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -290,7 +293,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -301,7 +304,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT]
"args": ["Auto", "SHA-256", P256.publicKey, ASCII_TEXT, "Raw"]
}
]
},
@ -312,7 +315,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.privateKeyPkcs1, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-256", P256.privateKeyPkcs1, ASCII_TEXT, "Raw"]
}
]
},
@ -323,7 +326,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", PEM_PUB_RSA512, ASCII_TEXT]
"args": ["ASN.1 HEX", "SHA-256", PEM_PUB_RSA512, ASCII_TEXT, "Raw"]
}
]
},
@ -460,5 +463,73 @@ TestRegister.addTests([
"args": ["Auto", "Raw JSON"]
}
]
},
{
name: "ECDSA Sign/Verify: P-256 with SHA256 UTF8",
input: UTF8_TEXT,
expectedOutput: "Verified OK",
recipeConfig: [
{
"op": "ECDSA Sign",
"args": [P256.privateKeyPkcs1, "SHA-256", "ASN.1 HEX"]
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, UTF8_TEXT, "Raw"]
}
]
},
{
name: "ECDSA Sign/Verify: P-256 with SHA256 bytes raw",
input: ALL_BYTES,
expectedOutput: "Verified OK",
recipeConfig: [
{
"op": "ECDSA Sign",
"args": [P256.privateKeyPkcs1, "SHA-256", "ASN.1 HEX"]
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, ALL_BYTES, "Raw"]
}
]
},
{
name: "ECDSA Sign/Verify: P-256 with SHA256 bytes hex",
input: SOME_HEX_BYTES,
expectedOutput: "Verified OK",
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "ECDSA Sign",
"args": [P256.privateKeyPkcs1, "SHA-256", "ASN.1 HEX"]
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, SOME_HEX_BYTES, "Hex"]
}
]
},
{
name: "ECDSA Sign/Verify: P-256 with SHA256 bytes Base64",
input: SOME_BASE64_BYTES,
expectedOutput: "Verified OK",
recipeConfig: [
{
"op": "From Base64",
"args": ["A-Za-z0-9+/=", true]
},
{
"op": "ECDSA Sign",
"args": [P256.privateKeyPkcs1, "SHA-256", "ASN.1 HEX"]
},
{
"op": "ECDSA Verify",
"args": ["ASN.1 HEX", "SHA-256", P256.publicKey, SOME_BASE64_BYTES, "Base64"]
}
]
}
]);

View file

@ -0,0 +1,133 @@
/**
* ExtractIPAddresses tests.
*
* @author gchqdev365 [gchqdev365@outlook.com]
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "ExtractIPAddress All Zeros",
input: "0.0.0.0",
expectedOutput: "0.0.0.0",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress All 10s",
input: "10.10.10.10",
expectedOutput: "10.10.10.10",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress All 10s",
input: "100.100.100.100",
expectedOutput: "100.100.100.100",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress 255s",
input: "255.255.255.255",
expectedOutput: "255.255.255.255",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress double digits",
input: "10.10.10.10 25.25.25.25 99.99.99.99",
expectedOutput: "10.10.10.10\n25.25.25.25\n99.99.99.99",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress 256 in middle",
input: "255.256.255.255 255.255.256.255",
expectedOutput: "",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress 256 at each end",
input: "256.255.255.255 255.255.255.256",
expectedOutput: "",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress silly example",
input: "710.65.0.456",
expectedOutput: "",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress longer dotted decimal",
input: "1.2.3.4.5.6.7.8",
expectedOutput: "1.2.3.4\n5.6.7.8",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress octal valid",
input: "01.01.01.01 0123.0123.0123.0123 0377.0377.0377.0377",
expectedOutput: "01.01.01.01\n0123.0123.0123.0123\n0377.0377.0377.0377",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
{
name: "ExtractIPAddress octal invalid",
input: "0378.01.01.01 03.0377.2.3",
expectedOutput: "",
recipeConfig: [
{
"op": "Extract IP addresses",
"args": [true, true, false, false, false, false]
},
],
},
]);

View file

@ -0,0 +1,805 @@
/**
* GenerateAllChecksums tests.
*
* @author r4mos [2k95ljkhg@mozmail.com]
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const CHECK_STRING = "123456789";
TestRegister.addTests([
{
name: "Full generate all checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-3/GSM: 4
CRC-3/ROHC: 6
CRC-4/G-704: 7
CRC-4/INTERLAKEN: b
CRC-4/ITU: 7
CRC-5/EPC: 00
CRC-5/EPC-C1G2: 00
CRC-5/G-704: 07
CRC-5/ITU: 07
CRC-5/USB: 19
CRC-6/CDMA2000-A: 0d
CRC-6/CDMA2000-B: 3b
CRC-6/DARC: 26
CRC-6/G-704: 06
CRC-6/GSM: 13
CRC-6/ITU: 06
CRC-7/MMC: 75
CRC-7/ROHC: 53
CRC-7/UMTS: 61
CRC-8: f4
CRC-8/8H2F: df
CRC-8/AES: 97
CRC-8/AUTOSAR: df
CRC-8/BLUETOOTH: 26
CRC-8/CDMA2000: da
CRC-8/DARC: 15
CRC-8/DVB-S2: bc
CRC-8/EBU: 97
CRC-8/GSM-A: 37
CRC-8/GSM-B: 94
CRC-8/HITAG: b4
CRC-8/I-432-1: a1
CRC-8/I-CODE: 7e
CRC-8/ITU: a1
CRC-8/LTE: ea
CRC-8/MAXIM: a1
CRC-8/MAXIM-DOW: a1
CRC-8/MIFARE-MAD: 99
CRC-8/NRSC-5: f7
CRC-8/OPENSAFETY: 3e
CRC-8/ROHC: d0
CRC-8/SAE-J1850: 4b
CRC-8/SAE-J1850-ZERO: 37
CRC-8/SMBUS: f4
CRC-8/TECH-3250: 97
CRC-8/WCDMA: 25
Fletcher-8: 0c
CRC-10/ATM: 199
CRC-10/CDMA2000: 233
CRC-10/GSM: 12a
CRC-10/I-610: 199
CRC-11/FLEXRAY: 5a3
CRC-11/UMTS: 061
CRC-12/3GPP: daf
CRC-12/CDMA2000: d4d
CRC-12/DECT: f5b
CRC-12/GSM: b34
CRC-12/UMTS: daf
CRC-13/BBC: 04fa
CRC-14/DARC: 082d
CRC-14/GSM: 30ae
CRC-15/CAN: 059e
CRC-15/MPT1327: 2566
CRC-16: bb3d
CRC-16/A: bf05
CRC-16/ACORN: 31c3
CRC-16/ARC: bb3d
CRC-16/AUG-CCITT: e5cc
CRC-16/AUTOSAR: 29b1
CRC-16/B: 906e
CRC-16/BLUETOOTH: 2189
CRC-16/BUYPASS: fee8
CRC-16/CCITT: 2189
CRC-16/CCITT-FALSE: 29b1
CRC-16/CCITT-TRUE: 2189
CRC-16/CCITT-ZERO: 31c3
CRC-16/CDMA2000: 4c06
CRC-16/CMS: aee7
CRC-16/DARC: d64e
CRC-16/DDS-110: 9ecf
CRC-16/DECT-R: 007e
CRC-16/DECT-X: 007f
CRC-16/DNP: ea82
CRC-16/EN-13757: c2b7
CRC-16/EPC: d64e
CRC-16/EPC-C1G2: d64e
CRC-16/GENIBUS: d64e
CRC-16/GSM: ce3c
CRC-16/I-CODE: d64e
CRC-16/IBM: bb3d
CRC-16/IBM-3740: 29b1
CRC-16/IBM-SDLC: 906e
CRC-16/IEC-61158-2: a819
CRC-16/ISO-HDLC: 906e
CRC-16/ISO-IEC-14443-3-A: bf05
CRC-16/ISO-IEC-14443-3-B: 906e
CRC-16/KERMIT: 2189
CRC-16/LHA: bb3d
CRC-16/LJ1200: bdf4
CRC-16/LTE: 31c3
CRC-16/M17: 772b
CRC-16/MAXIM: 44c2
CRC-16/MAXIM-DOW: 44c2
CRC-16/MCRF4XX: 6f91
CRC-16/MODBUS: 4b37
CRC-16/NRSC-5: a066
CRC-16/OPENSAFETY-A: 5d38
CRC-16/OPENSAFETY-B: 20fe
CRC-16/PROFIBUS: a819
CRC-16/RIELLO: 63d0
CRC-16/SPI-FUJITSU: e5cc
CRC-16/T10-DIF: d0db
CRC-16/TELEDISK: 0fb3
CRC-16/TMS37157: 26b1
CRC-16/UMTS: fee8
CRC-16/USB: b4c8
CRC-16/V-41-LSB: 2189
CRC-16/V-41-MSB: 31c3
CRC-16/VERIFONE: fee8
CRC-16/X-25: 906e
CRC-16/XMODEM: 31c3
CRC-16/ZMODEM: 31c3
Fletcher-16: 1ede
CRC-17/CAN-FD: 04f03
CRC-21/CAN-FD: 0ed841
CRC-24/BLE: c25a56
CRC-24/FLEXRAY-A: 7979bd
CRC-24/FLEXRAY-B: 1f23b8
CRC-24/INTERLAKEN: b4f3e6
CRC-24/LTE-A: cde703
CRC-24/LTE-B: 23ef52
CRC-24/OPENPGP: 21cf02
CRC-24/OS-9: 200fa5
CRC-30/CDMA: 04c34abf
CRC-31/PHILIPS: 0ce9e46c
Adler-32: 091e01de
CRC-32: cbf43926
CRC-32/AAL5: fc891918
CRC-32/ADCCP: cbf43926
CRC-32/AIXM: 3010bf7f
CRC-32/AUTOSAR: 1697d06a
CRC-32/BASE91-C: e3069283
CRC-32/BASE91-D: 87315576
CRC-32/BZIP2: fc891918
CRC-32/C: e3069283
CRC-32/CASTAGNOLI: e3069283
CRC-32/CD-ROM-EDC: 6ec2edc4
CRC-32/CKSUM: 765e7680
CRC-32/D: 87315576
CRC-32/DECT-B: fc891918
CRC-32/INTERLAKEN: e3069283
CRC-32/ISCSI: e3069283
CRC-32/ISO-HDLC: cbf43926
CRC-32/JAMCRC: 340bc6d9
CRC-32/MEF: d2c22f51
CRC-32/MPEG-2: 0376e6e7
CRC-32/NVME: e3069283
CRC-32/PKZIP: cbf43926
CRC-32/POSIX: 765e7680
CRC-32/Q: 3010bf7f
CRC-32/SATA: cf72afe8
CRC-32/V-42: cbf43926
CRC-32/XFER: bd0be338
CRC-32/XZ: cbf43926
Fletcher-32: df09d509
CRC-40/GSM: d4164fc646
CRC-64/ECMA-182: 6c40df5f0b497347
CRC-64/GO-ECMA: 995dc9bbdf1939fa
CRC-64/GO-ISO: b90956c775a41001
CRC-64/MS: 75d4b74f024eceea
CRC-64/NVME: ae8b14860a799888
CRC-64/REDIS: e9c6d914c4b8d9ca
CRC-64/WE: 62ec59e3f1a4f00a
CRC-64/XZ: 995dc9bbdf1939fa
Fletcher-64: 0d0803376c6a689f
CRC-82/DARC: 09ea83f625023801fd612
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["All", true]
}
]
},
{
name: "Full generate all checksums without name",
input: CHECK_STRING,
expectedOutput: `4
6
7
b
7
00
00
07
07
19
0d
3b
26
06
13
06
75
53
61
f4
df
97
df
26
da
15
bc
97
37
94
b4
a1
7e
a1
ea
a1
a1
99
f7
3e
d0
4b
37
f4
97
25
0c
199
233
12a
199
5a3
061
daf
d4d
f5b
b34
daf
04fa
082d
30ae
059e
2566
bb3d
bf05
31c3
bb3d
e5cc
29b1
906e
2189
fee8
2189
29b1
2189
31c3
4c06
aee7
d64e
9ecf
007e
007f
ea82
c2b7
d64e
d64e
d64e
ce3c
d64e
bb3d
29b1
906e
a819
906e
bf05
906e
2189
bb3d
bdf4
31c3
772b
44c2
44c2
6f91
4b37
a066
5d38
20fe
a819
63d0
e5cc
d0db
0fb3
26b1
fee8
b4c8
2189
31c3
fee8
906e
31c3
31c3
1ede
04f03
0ed841
c25a56
7979bd
1f23b8
b4f3e6
cde703
23ef52
21cf02
200fa5
04c34abf
0ce9e46c
091e01de
cbf43926
fc891918
cbf43926
3010bf7f
1697d06a
e3069283
87315576
fc891918
e3069283
e3069283
6ec2edc4
765e7680
87315576
fc891918
e3069283
e3069283
cbf43926
340bc6d9
d2c22f51
0376e6e7
e3069283
cbf43926
765e7680
3010bf7f
cf72afe8
cbf43926
bd0be338
cbf43926
df09d509
d4164fc646
6c40df5f0b497347
995dc9bbdf1939fa
b90956c775a41001
75d4b74f024eceea
ae8b14860a799888
e9c6d914c4b8d9ca
62ec59e3f1a4f00a
995dc9bbdf1939fa
0d0803376c6a689f
09ea83f625023801fd612
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["All", false]
}
]
},
{
name: "Full generate 3 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-3/GSM: 4
CRC-3/ROHC: 6
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["3", true]
}
]
},
{
name: "Full generate 4 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-4/G-704: 7
CRC-4/INTERLAKEN: b
CRC-4/ITU: 7
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["4", true]
}
]
},
{
name: "Full generate 5 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-5/EPC: 00
CRC-5/EPC-C1G2: 00
CRC-5/G-704: 07
CRC-5/ITU: 07
CRC-5/USB: 19
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["5", true]
}
]
},
{
name: "Full generate 6 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-6/CDMA2000-A: 0d
CRC-6/CDMA2000-B: 3b
CRC-6/DARC: 26
CRC-6/G-704: 06
CRC-6/GSM: 13
CRC-6/ITU: 06
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["6", true]
}
]
},
{
name: "Full generate 7 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-7/MMC: 75
CRC-7/ROHC: 53
CRC-7/UMTS: 61
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["7", true]
}
]
},
{
name: "Full generate 8 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-8: f4
CRC-8/8H2F: df
CRC-8/AES: 97
CRC-8/AUTOSAR: df
CRC-8/BLUETOOTH: 26
CRC-8/CDMA2000: da
CRC-8/DARC: 15
CRC-8/DVB-S2: bc
CRC-8/EBU: 97
CRC-8/GSM-A: 37
CRC-8/GSM-B: 94
CRC-8/HITAG: b4
CRC-8/I-432-1: a1
CRC-8/I-CODE: 7e
CRC-8/ITU: a1
CRC-8/LTE: ea
CRC-8/MAXIM: a1
CRC-8/MAXIM-DOW: a1
CRC-8/MIFARE-MAD: 99
CRC-8/NRSC-5: f7
CRC-8/OPENSAFETY: 3e
CRC-8/ROHC: d0
CRC-8/SAE-J1850: 4b
CRC-8/SAE-J1850-ZERO: 37
CRC-8/SMBUS: f4
CRC-8/TECH-3250: 97
CRC-8/WCDMA: 25
Fletcher-8: 0c
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["8", true]
}
]
},
{
name: "Full generate 10 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-10/ATM: 199
CRC-10/CDMA2000: 233
CRC-10/GSM: 12a
CRC-10/I-610: 199
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["10", true]
}
]
},
{
name: "Full generate 11 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-11/FLEXRAY: 5a3
CRC-11/UMTS: 061
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["11", true]
}
]
},
{
name: "Full generate 12 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-12/3GPP: daf
CRC-12/CDMA2000: d4d
CRC-12/DECT: f5b
CRC-12/GSM: b34
CRC-12/UMTS: daf
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["12", true]
}
]
},
{
name: "Full generate 13 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-13/BBC: 04fa
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["13", true]
}
]
},
{
name: "Full generate 14 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-14/DARC: 082d
CRC-14/GSM: 30ae
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["14", true]
}
]
},
{
name: "Full generate 15 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-15/CAN: 059e
CRC-15/MPT1327: 2566
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["15", true]
}
]
},
{
name: "Full generate 16 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-16: bb3d
CRC-16/A: bf05
CRC-16/ACORN: 31c3
CRC-16/ARC: bb3d
CRC-16/AUG-CCITT: e5cc
CRC-16/AUTOSAR: 29b1
CRC-16/B: 906e
CRC-16/BLUETOOTH: 2189
CRC-16/BUYPASS: fee8
CRC-16/CCITT: 2189
CRC-16/CCITT-FALSE: 29b1
CRC-16/CCITT-TRUE: 2189
CRC-16/CCITT-ZERO: 31c3
CRC-16/CDMA2000: 4c06
CRC-16/CMS: aee7
CRC-16/DARC: d64e
CRC-16/DDS-110: 9ecf
CRC-16/DECT-R: 007e
CRC-16/DECT-X: 007f
CRC-16/DNP: ea82
CRC-16/EN-13757: c2b7
CRC-16/EPC: d64e
CRC-16/EPC-C1G2: d64e
CRC-16/GENIBUS: d64e
CRC-16/GSM: ce3c
CRC-16/I-CODE: d64e
CRC-16/IBM: bb3d
CRC-16/IBM-3740: 29b1
CRC-16/IBM-SDLC: 906e
CRC-16/IEC-61158-2: a819
CRC-16/ISO-HDLC: 906e
CRC-16/ISO-IEC-14443-3-A: bf05
CRC-16/ISO-IEC-14443-3-B: 906e
CRC-16/KERMIT: 2189
CRC-16/LHA: bb3d
CRC-16/LJ1200: bdf4
CRC-16/LTE: 31c3
CRC-16/M17: 772b
CRC-16/MAXIM: 44c2
CRC-16/MAXIM-DOW: 44c2
CRC-16/MCRF4XX: 6f91
CRC-16/MODBUS: 4b37
CRC-16/NRSC-5: a066
CRC-16/OPENSAFETY-A: 5d38
CRC-16/OPENSAFETY-B: 20fe
CRC-16/PROFIBUS: a819
CRC-16/RIELLO: 63d0
CRC-16/SPI-FUJITSU: e5cc
CRC-16/T10-DIF: d0db
CRC-16/TELEDISK: 0fb3
CRC-16/TMS37157: 26b1
CRC-16/UMTS: fee8
CRC-16/USB: b4c8
CRC-16/V-41-LSB: 2189
CRC-16/V-41-MSB: 31c3
CRC-16/VERIFONE: fee8
CRC-16/X-25: 906e
CRC-16/XMODEM: 31c3
CRC-16/ZMODEM: 31c3
Fletcher-16: 1ede
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["16", true]
}
]
},
{
name: "Full generate 17 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-17/CAN-FD: 04f03
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["17", true]
}
]
},
{
name: "Full generate 21 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-21/CAN-FD: 0ed841
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["21", true]
}
]
},
{
name: "Full generate 24 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-24/BLE: c25a56
CRC-24/FLEXRAY-A: 7979bd
CRC-24/FLEXRAY-B: 1f23b8
CRC-24/INTERLAKEN: b4f3e6
CRC-24/LTE-A: cde703
CRC-24/LTE-B: 23ef52
CRC-24/OPENPGP: 21cf02
CRC-24/OS-9: 200fa5
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["24", true]
}
]
},
{
name: "Full generate 30 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-30/CDMA: 04c34abf
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["30", true]
}
]
},
{
name: "Full generate 31 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-31/PHILIPS: 0ce9e46c
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["31", true]
}
]
},
{
name: "Full generate 32 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `Adler-32: 091e01de
CRC-32: cbf43926
CRC-32/AAL5: fc891918
CRC-32/ADCCP: cbf43926
CRC-32/AIXM: 3010bf7f
CRC-32/AUTOSAR: 1697d06a
CRC-32/BASE91-C: e3069283
CRC-32/BASE91-D: 87315576
CRC-32/BZIP2: fc891918
CRC-32/C: e3069283
CRC-32/CASTAGNOLI: e3069283
CRC-32/CD-ROM-EDC: 6ec2edc4
CRC-32/CKSUM: 765e7680
CRC-32/D: 87315576
CRC-32/DECT-B: fc891918
CRC-32/INTERLAKEN: e3069283
CRC-32/ISCSI: e3069283
CRC-32/ISO-HDLC: cbf43926
CRC-32/JAMCRC: 340bc6d9
CRC-32/MEF: d2c22f51
CRC-32/MPEG-2: 0376e6e7
CRC-32/NVME: e3069283
CRC-32/PKZIP: cbf43926
CRC-32/POSIX: 765e7680
CRC-32/Q: 3010bf7f
CRC-32/SATA: cf72afe8
CRC-32/V-42: cbf43926
CRC-32/XFER: bd0be338
CRC-32/XZ: cbf43926
Fletcher-32: df09d509
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["32", true]
}
]
},
{
name: "Full generate 40 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-40/GSM: d4164fc646
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["40", true]
}
]
},
{
name: "Full generate 64 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-64/ECMA-182: 6c40df5f0b497347
CRC-64/GO-ECMA: 995dc9bbdf1939fa
CRC-64/GO-ISO: b90956c775a41001
CRC-64/MS: 75d4b74f024eceea
CRC-64/NVME: ae8b14860a799888
CRC-64/REDIS: e9c6d914c4b8d9ca
CRC-64/WE: 62ec59e3f1a4f00a
CRC-64/XZ: 995dc9bbdf1939fa
Fletcher-64: 0d0803376c6a689f
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["64", true]
}
]
},
{
name: "Full generate 82 bits checksums with name",
input: CHECK_STRING,
expectedOutput: `CRC-82/DARC: 09ea83f625023801fd612
`,
recipeConfig: [
{
"op": "Generate all checksums",
"args": ["82", true]
}
]
}
]);

View file

@ -54,16 +54,6 @@ LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
NT Hash: 0CB6948805F797BF2A82807973B89537
SSDEEP: 3:Hn:Hn
CTPH: A:E:E
Checksums:
Fletcher-8: 3d
Fletcher-16: 5dc1
Fletcher-32: 3f5cd9e7
Fletcher-64: 7473657474736574
Adler-32: 045d01c1
CRC-8: b9
CRC-16: f82e
CRC-32: d87f7e0c
`,
recipeConfig: [
{

View file

@ -0,0 +1,63 @@
/**
* IPv6Transition tests.
*
* @author jb30795
*
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "IPv6 Transition: IPv4 to IPv6",
input: "198.51.100.7",
expectedOutput: "6to4: 2002:c633:6407::/48\nIPv4 Mapped: ::ffff:c633:6407\nIPv4 Translated: ::ffff:0:c633:6407\nNat 64: 64:ff9b::c633:6407",
recipeConfig: [
{
op: "IPv6 Transition Addresses",
args: [true, false],
},
],
}, {
name: "IPv6 Transition: IPv4 /24 Range to IPv6",
input: "198.51.100.0/24",
expectedOutput: "6to4: 2002:c633:6400::/40\nIPv4 Mapped: ::ffff:c633:6400/120\nIPv4 Translated: ::ffff:0:c633:6400/120\nNat 64: 64:ff9b::c633:6400/120",
recipeConfig: [
{
op: "IPv6 Transition Addresses",
args: [false, false],
},
],
}, {
name: "IPv6 Transition: IPv4 to IPv6 Remove headers",
input: "198.51.100.7",
expectedOutput: "2002:c633:6407::/48\n::ffff:c633:6407\n::ffff:0:c633:6407\n64:ff9b::c633:6407",
recipeConfig: [
{
op: "IPv6 Transition Addresses",
args: [true, true],
},
],
}, {
name: "IPv6 Transition: IPv6 to IPv4",
input: "64:ff9b::c633:6407",
expectedOutput: "IPv4: 198.51.100.7",
recipeConfig: [
{
op: "IPv6 Transition Addresses",
args: [true, false],
},
],
}, {
name: "IPv6 Transition: MAC to EUI-64",
input: "a1:b2:c3:d4:e5:f6",
expectedOutput: "EUI-64 Interface ID: a3b2:c3ff:fed4:e5f6",
recipeConfig: [
{
op: "IPv6 Transition Addresses",
args: [true, false],
},
],
},
]);

View file

@ -0,0 +1,41 @@
/**
* YAML tests.
*
* @author ccarpo [ccarpo@gmx.net]
*
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const EXAMPLE_YAML = `number: 3\nplain: string\nblock: |\n two\n lines`;
const EXAMPLE_JSON = `{ "number": 3, "plain": "string" }`;
TestRegister.addTests([
{
name: "YAML to JSON",
input: EXAMPLE_YAML,
expectedOutput: JSON.stringify({
"number": 3,
"plain": "string",
"block": "two\nlines\n"
}, null, 4),
recipeConfig: [
{
op: "YAML to JSON",
args: [],
}
],
},
{
name: "JSON to YAML",
input: EXAMPLE_JSON,
expectedOutput: `number: 3\nplain: string\n`,
recipeConfig: [
{
op: "JSON to YAML",
args: [],
}
],
},
]);

View file

@ -44,7 +44,18 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [hsKey, "HS256"],
args: [hsKey, "HS256", "{}"],
}
],
},
{
name: "JWT Sign: HS256 with custom header",
input: inputObject,
expectedOutput: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImN1c3RvbS5rZXkifQ.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.kXln8btJburfRlND8IDZAQ8NZGFFZhvHyooHa6N9za8",
recipeConfig: [
{
op: "JWT Sign",
args: [hsKey, "HS256", `{"kid":"custom.key"}`],
}
],
},
@ -55,7 +66,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [hsKey, "HS384"],
args: [hsKey, "HS384", "{}"],
}
],
},
@ -66,7 +77,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [hsKey, "HS512"],
args: [hsKey, "HS512", "{}"],
}
],
},
@ -77,7 +88,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [esKey, "ES256"],
args: [esKey, "ES256", "{}"],
},
{
op: "JWT Decode",
@ -92,7 +103,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [esKey, "ES384"],
args: [esKey, "ES384", "{}"],
},
{
op: "JWT Decode",
@ -107,7 +118,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [esKey, "ES512"],
args: [esKey, "ES512", "{}"],
},
{
op: "JWT Decode",
@ -122,7 +133,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [rsKey, "RS256"],
args: [rsKey, "RS256", "{}"],
},
{
op: "JWT Decode",
@ -137,7 +148,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [rsKey, "RS384"],
args: [rsKey, "RS384", "{}"],
},
{
op: "JWT Decode",
@ -152,7 +163,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JWT Sign",
args: [esKey, "RS512"],
args: [esKey, "RS512", "{}"],
},
{
op: "JWT Decode",

View file

@ -0,0 +1,551 @@
/**
* Jsonata Query tests.
*
* @author Jon King [jon@ajarsoftware.com]
*
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const INPUT_JSON_OBJECT_WITH_ARRAYS = `{
"FirstName": "Fred",
"Surname": "Smith",
"Age": 28,
"Address": {
"Street": "Hursley Park",
"City": "Winchester",
"Postcode": "SO21 2JN"
},
"Phone": [
{
"type": "home",
"number": "0203 544 1234"
},
{
"type": "office",
"number": "01962 001234"
},
{
"type": "office",
"number": "01962 001235"
},
{
"type": "mobile",
"number": "077 7700 1234"
}
],
"Email": [
{
"type": "work",
"address": ["fred.smith@my-work.com", "fsmith@my-work.com"]
},
{
"type": "home",
"address": ["freddy@my-social.com", "frederic.smith@very-serious.com"]
}
],
"Other": {
"Over 18 ?": true,
"Misc": null,
"Alternative.Address": {
"Street": "Brick Lane",
"City": "London",
"Postcode": "E1 6RF"
}
}
}`;
const INPUT_ARRAY_OF_OBJECTS = `[
{ "ref": [ 1,2 ] },
{ "ref": [ 3,4 ] }
]`;
const INPUT_NUMBER_ARRAY = `{
"Numbers": [1, 2.4, 3.5, 10, 20.9, 30]
}`;
TestRegister.addTests([
{
name: "Jsonata: Returns a JSON string (double quoted)",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"Smith"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Surname"],
},
],
},
{
name: "Jsonata: Returns a JSON number",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: "28",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Age"],
},
],
},
{
name: "Jsonata: Field references are separated by '.'",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"Winchester"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Address.City"],
},
],
},
{
name: "Jsonata: Matched the path and returns the null value",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: "null",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Other.Misc"],
},
],
},
{
name: "Jsonata: Path not found. Returns nothing",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '""',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Other.DoesntExist"],
},
],
},
{
name: "Jsonata: Field references containing whitespace or reserved tokens can be enclosed in backticks",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Other.`Over 18 ?`"],
},
],
},
{
name: "Jsonata: Returns the first item (an object)",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '{"type":"home","number":"0203 544 1234"}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[0]"],
},
],
},
{
name: "Jsonata: Returns the second item",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '{"type":"office","number":"01962 001234"}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[1]"],
},
],
},
{
name: "Jsonata: Returns the last item",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '{"type":"mobile","number":"077 7700 1234"}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[-1]"],
},
],
},
{
name: "Jsonata: Negative indexed count from the end",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '{"type":"office","number":"01962 001235"}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[-2]"],
},
],
},
{
name: "Jsonata: Doesn't exist - returns nothing",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '""',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[8]"],
},
],
},
{
name: "Jsonata: Selects the number field in the first item",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"0203 544 1234"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[0].number"],
},
],
},
{
name: "Jsonata: No index is given to Phone so it selects all of them (the whole array), then it selects all the number fields for each of them",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput:
'["0203 544 1234","01962 001234","01962 001235","077 7700 1234"]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone.number"],
},
],
},
{
name: "Jsonata: Might expect it to just return the first number, but it returns the first number of each of the items selected by Phone",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput:
'["0203 544 1234","01962 001234","01962 001235","077 7700 1234"]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone.number[0]"],
},
],
},
{
name: "Jsonata: Applies the index to the array returned by Phone.number.",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"0203 544 1234"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["(Phone.number)[0]"],
},
],
},
{
name: "Jsonata: Returns a range of items by creating an array of indexes",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput:
'[{"type":"home","number":"0203 544 1234"},{"type":"office","number":"01962 001234"}]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[[0..1]]"],
},
],
},
// Predicates
{
name: "Jsonata: Select the Phone items that have a type field that equals 'mobile'",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '{"type":"mobile","number":"077 7700 1234"}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[type='mobile']"],
},
],
},
{
name: "Jsonata: Select the mobile phone number",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"077 7700 1234"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[type='mobile'].number"],
},
],
},
{
name: "Jsonata: Select the office phone numbers - there are two of them",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '["01962 001234","01962 001235"]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Phone[type='office'].number"],
},
],
},
// Wildcards
{
name: "Jsonata: Select the values of all the fields of 'Address'",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '["Hursley Park","Winchester","SO21 2JN"]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Address.*"],
},
],
},
{
name: "Jsonata: Select the 'Postcode' value of any child object",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"SO21 2JN"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["*.Postcode"],
},
],
},
{
name: "Jsonata: Select all Postcode values, regardless of how deeply nested they are in the structure",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '["SO21 2JN","E1 6RF"]',
recipeConfig: [
{
op: "Jsonata Query",
args: ["**.Postcode"],
},
],
},
// String Expressions
{
name: "Jsonata: Concatenate 'FirstName' followed by space followed by 'Surname'",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"Fred Smith"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["FirstName & ' ' & Surname"],
},
],
},
{
name: "Jsonata: Concatenates the 'Street' and 'City' from the 'Address' object with a comma separator",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"Hursley Park, Winchester"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["Address.(Street & ', ' & City)"],
},
],
},
{
name: "Jsonata: Casts the operands to strings, if necessary",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: '"50true"',
recipeConfig: [
{
op: "Jsonata Query",
args: ["5&0&true"],
},
],
},
// Numeric Expressions
{
name: "Jsonata: Addition",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "3.4",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] + Numbers[1]"],
},
],
},
{
name: "Jsonata: Subtraction",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "-19.9",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] - Numbers[4]"],
},
],
},
{
name: "Jsonata: Multiplication",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "30",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] * Numbers[5]"],
},
],
},
{
name: "Jsonata: Division",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "0.04784688995215311",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] / Numbers[4]"],
},
],
},
{
name: "Jsonata: Modulus",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "3.5",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[2] % Numbers[5]"],
},
],
},
{
name: "Jsonata: Equality",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "false",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] = Numbers[5]"],
},
],
},
{
name: "Jsonata: Inequality",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] != Numbers[4]"],
},
],
},
{
name: "Jsonata: Less than",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] < Numbers[4]"],
},
],
},
{
name: "Jsonata: Less than or equal to",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] <= Numbers[4]"],
},
],
},
{
name: "Jsonata: Greater than",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "false",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[0] > Numbers[4]"],
},
],
},
{
name: "Jsonata: Greater than or equal to",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "false",
recipeConfig: [
{
op: "Jsonata Query",
args: ["Numbers[2] >= Numbers[4]"],
},
],
},
{
name: "Jsonata: Value is contained in",
input: INPUT_JSON_OBJECT_WITH_ARRAYS,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ['"01962 001234" in Phone.number'],
},
],
},
// Boolean Expressions
{
name: "Jsonata: and",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["(Numbers[2] != 0) and (Numbers[5] != Numbers[1])"],
},
],
},
{
name: "Jsonata: or",
input: INPUT_NUMBER_ARRAY,
expectedOutput: "true",
recipeConfig: [
{
op: "Jsonata Query",
args: ["(Numbers[2] != 0) or (Numbers[5] = Numbers[1])"],
},
],
},
// Array tests
{
name: "Jsonata: $ at the start of an expression refers to the entire input document, subscripting it with 0 selects the first item",
input: INPUT_ARRAY_OF_OBJECTS,
expectedOutput: '{"ref":[1,2]}',
recipeConfig: [
{
op: "Jsonata Query",
args: ["$[0]"],
},
],
},
{
name: "Jsonata: .ref here returns the entire internal array",
input: INPUT_ARRAY_OF_OBJECTS,
expectedOutput: "[1,2]",
recipeConfig: [
{
op: "Jsonata Query",
args: ["$[0].ref"],
},
],
},
{
name: "Jsonata: returns element on first position of the internal array",
input: INPUT_ARRAY_OF_OBJECTS,
expectedOutput: "1",
recipeConfig: [
{
op: "Jsonata Query",
args: ["$[0].ref[0]"],
},
],
},
{
name: "Jsonata: $.field_reference flattens the result into a single array",
input: INPUT_ARRAY_OF_OBJECTS,
expectedOutput: "[1,2,3,4]",
recipeConfig: [
{
op: "Jsonata Query",
args: ["$.ref"],
},
],
},
]);

View file

@ -2,11 +2,392 @@
* From Decimal tests
*
* @author n1073645 [n1073645@gmail.com]
* @author k3ach [k3ach@proton.me]
* @copyright Crown Copyright 2020
* @licence Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const testCases = [
{
radix: 2,
input: "01",
checksum: "1",
checkdigit: "1",
}, {
radix: 2,
input: "001111",
checksum: "0",
checkdigit: "0",
}, {
radix: 2,
input: "00011101",
checksum: "0",
checkdigit: "0",
}, {
radix: 2,
input: "0100101101",
checksum: "1",
checkdigit: "1",
}, {
radix: 4,
input: "0123",
checksum: "1",
checkdigit: "1",
}, {
radix: 4,
input: "130100",
checksum: "2",
checkdigit: "2",
}, {
radix: 4,
input: "32020313",
checksum: "3",
checkdigit: "0",
}, {
radix: 4,
input: "302233210112",
checksum: "3",
checkdigit: "0",
}, {
radix: 6,
input: "012345",
checksum: "4",
checkdigit: "4",
}, {
radix: 6,
input: "134255",
checksum: "2",
checkdigit: "4",
}, {
radix: 6,
input: "15021453",
checksum: "5",
checkdigit: "4",
}, {
radix: 6,
input: "211450230513",
checksum: "3",
checkdigit: "1",
}, {
radix: 8,
input: "01234567",
checksum: "2",
checkdigit: "2",
}, {
radix: 8,
input: "340624",
checksum: "0",
checkdigit: "4",
}, {
radix: 8,
input: "07260247",
checksum: "3",
checkdigit: "3",
}, {
radix: 8,
input: "026742114675",
checksum: "7",
checkdigit: "1",
}, {
radix: 10,
input: "0123456789",
checksum: "7",
checkdigit: "7",
}, {
radix: 10,
input: "468543",
checksum: "7",
checkdigit: "4",
}, {
radix: 10,
input: "59377601",
checksum: "5",
checkdigit: "6",
}, {
radix: 10,
input: "013909981254",
checksum: "1",
checkdigit: "3",
}, {
radix: 12,
input: "0123456789ab",
checksum: "3",
checkdigit: "3",
}, {
radix: 12,
input: "284685",
checksum: "0",
checkdigit: "6",
}, {
radix: 12,
input: "951a2661",
checksum: "0",
checkdigit: "8",
}, {
radix: 12,
input: "898202676387",
checksum: "b",
checkdigit: "9",
}, {
radix: 14,
input: "0123456789abcd",
checksum: "a",
checkdigit: "a",
}, {
radix: 14,
input: "33db25",
checksum: "0",
checkdigit: "d",
}, {
radix: 14,
input: "0b4ac128",
checksum: "b",
checkdigit: "3",
}, {
radix: 14,
input: "3d1c6d16160d",
checksum: "3",
checkdigit: "c",
}, {
radix: 16,
input: "0123456789abcdef",
checksum: "4",
checkdigit: "4",
}, {
radix: 16,
input: "e1fe64",
checksum: "b",
checkdigit: "6",
}, {
radix: 16,
input: "241a5dcd",
checksum: "1",
checkdigit: "9",
}, {
radix: 16,
input: "1fea740e0e1f",
checksum: "7",
checkdigit: "4",
}, {
radix: 18,
input: "0123456789abcdefgh",
checksum: "d",
checkdigit: "d",
}, {
radix: 18,
input: "995dgf",
checksum: "9",
checkdigit: "1",
}, {
radix: 18,
input: "9f80h32h",
checksum: "1",
checkdigit: "0",
}, {
radix: 18,
input: "5f9428e493g4",
checksum: "8",
checkdigit: "c",
}, {
radix: 20,
input: "0123456789abcdefghij",
checksum: "5",
checkdigit: "5",
}, {
radix: 20,
input: "918jci",
checksum: "h",
checkdigit: "d",
}, {
radix: 20,
input: "jab7j50d",
checksum: "g",
checkdigit: "j",
}, {
radix: 20,
input: "c56fe85eb6gg",
checksum: "g",
checkdigit: "5",
}, {
radix: 22,
input: "0123456789abcdefghijkl",
checksum: "g",
checkdigit: "g",
}, {
radix: 22,
input: "de57le",
checksum: "5",
checkdigit: "l",
}, {
radix: 22,
input: "e3fg6dfc",
checksum: "f",
checkdigit: "d",
}, {
radix: 22,
input: "1f8l80ai4kbg",
checksum: "l",
checkdigit: "f",
}, {
radix: 24,
input: "0123456789abcdefghijklmn",
checksum: "6",
checkdigit: "6",
}, {
radix: 24,
input: "agne7d",
checksum: "4",
checkdigit: "f",
}, {
radix: 24,
input: "1l4d9cf4",
checksum: "d",
checkdigit: "c",
}, {
radix: 24,
input: "blc1j09i3296",
checksum: "8",
checkdigit: "7",
}, {
radix: 26,
input: "0123456789abcdefghijklmnop",
checksum: "j",
checkdigit: "j",
}, {
radix: 26,
input: "82n9op",
checksum: "i",
checkdigit: "2",
}, {
radix: 26,
input: "e9cddn70",
checksum: "9",
checkdigit: "i",
}, {
radix: 26,
input: "ck0ep419knom",
checksum: "p",
checkdigit: "g",
}, {
radix: 28,
input: "0123456789abcdefghijklmnopqr",
checksum: "7",
checkdigit: "7",
}, {
radix: 28,
input: "a6hnoo",
checksum: "h",
checkdigit: "9",
}, {
radix: 28,
input: "lblc7kh0",
checksum: "a",
checkdigit: "f",
}, {
radix: 28,
input: "64k5piod3lmf",
checksum: "0",
checkdigit: "p",
}, {
radix: 30,
input: "0123456789abcdefghijklmnopqrst",
checksum: "m",
checkdigit: "m",
}, {
radix: 30,
input: "t69j7d",
checksum: "9",
checkdigit: "s",
}, {
radix: 30,
input: "p54o9ig3",
checksum: "a",
checkdigit: "o",
}, {
radix: 30,
input: "gc1njrt55030",
checksum: "6",
checkdigit: "1",
}, {
radix: 32,
input: "0123456789abcdefghijklmnopqrstuv",
checksum: "8",
checkdigit: "8",
}, {
radix: 32,
input: "rdou19",
checksum: "u",
checkdigit: "3",
}, {
radix: 32,
input: "ighj0pc7",
checksum: "3",
checkdigit: "8",
}, {
radix: 32,
input: "op4nn5fvjsrs",
checksum: "g",
checkdigit: "j",
}, {
radix: 34,
input: "0123456789abcdefghijklmnopqrstuvwx",
checksum: "p",
checkdigit: "p",
}, {
radix: 34,
input: "nvftj5",
checksum: "b",
checkdigit: "f",
}, {
radix: 34,
input: "u9v9g162",
checksum: "j",
checkdigit: "b",
}, {
radix: 34,
input: "o5gqg5d7gjh9",
checksum: "5",
checkdigit: "q",
}, {
radix: 36,
input: "0123456789abcdefghijklmnopqrstuvwxyz",
checksum: "9",
checkdigit: "9",
}, {
radix: 36,
input: "29zehu",
checksum: "i",
checkdigit: "j",
}, {
radix: 36,
input: "1snmikbu",
checksum: "s",
checkdigit: "v",
}, {
radix: 36,
input: "jpkar545q7gb",
checksum: "3",
checkdigit: "d",
},
];
testCases.forEach(element => {
TestRegister.addTests([
{
name: "Luhn Checksum Mod " + element.radix + " on " + element.input,
input: element.input,
expectedOutput: "Checksum: " + element.checksum + "\nCheckdigit: " + element.checkdigit + "\nLuhn Validated String: " + element.input + element.checkdigit,
recipeConfig: [
{
op: "Luhn Checksum",
args: [element.radix]
},
],
},
]);
});
TestRegister.addTests([
{
name: "Luhn Checksum on standard data",
@ -15,7 +396,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Luhn Checksum",
args: []
args: [10]
},
],
},
@ -26,7 +407,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Luhn Checksum",
args: []
args: [10]
},
],
},
@ -37,18 +418,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Luhn Checksum",
args: []
},
],
},
{
name: "Luhn Checksum on invalid data",
input: "35641709b012469",
expectedOutput: "Character: b is not a digit.",
recipeConfig: [
{
op: "Luhn Checksum",
args: []
args: [10]
},
],
},
@ -59,8 +429,8 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Luhn Checksum",
args: []
args: [10]
},
],
}
},
]);

View file

@ -0,0 +1,89 @@
/**
* MIME Header Decoding tests
*
* @author mshwed [m@ttshwed.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Encoded comments",
input: "(=?ISO-8859-1?Q?a?=)",
expectedOutput: "(a)",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "Encoded adjacent comments whitespace",
input: "(=?ISO-8859-1?Q?a?= b)",
expectedOutput: "(a b)",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "Encoded adjacent single whitespace ignored",
input: "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
expectedOutput: "(ab)",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "Encoded adjacent double whitespace ignored",
input: "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
expectedOutput: "(ab)",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "Encoded adjacent CRLF whitespace ignored",
input: "(=?ISO-8859-1?Q?a?=\r\n =?ISO-8859-1?Q?b?=)",
expectedOutput: "(ab)",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "UTF-8 Encodings Multiple Headers",
input: "=?utf-8?q?=C3=89ric?= <eric@example.org>, =?utf-8?q?Ana=C3=AFs?= <anais@example.org>",
expectedOutput: "Éric <eric@example.org>, Anaïs <anais@example.org>",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
},
{
name: "ISO Decoding",
input: "From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>\nTo: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>\nCC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>\nSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\n=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=",
expectedOutput: "From: Keith Moore <moore@cs.utk.edu>\nTo: Keld Jørn Simonsen <keld@dkuug.dk>\nCC: André Pirard <PIRARD@vm1.ulg.ac.be>\nSubject: If you can read this you understand the example.",
recipeConfig: [
{
"op": "MIME Decoding",
"args": []
}
]
}
]);

View file

@ -0,0 +1,150 @@
/**
* Modhex operation tests.
* @author linuxgemini [ilteris@asenkron.com.tr]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "ASCII to Modhex stream",
input: "aberystwyth",
expectedOutput: "hbhdhgidikieifiiikifhj",
recipeConfig: [
{
"op": "To Modhex",
"args": [
"None",
0
]
},
]
},
{
name: "ASCII to Modhex with colon deliminator",
input: "aberystwyth",
expectedOutput: "hb:hd:hg:id:ik:ie:if:ii:ik:if:hj",
recipeConfig: [
{
"op": "To Modhex",
"args": [
"Colon",
0
]
}
]
},
{
name: "Modhex stream to UTF-8",
input: "uhkgkbuhkgkbugltlkugltkc",
expectedOutput: "救救孩子",
recipeConfig: [
{
"op": "From Modhex",
"args": [
"Auto"
]
}
]
},
{
name: "Mixed case Modhex stream to UTF-8",
input: "uhKGkbUHkgkBUGltlkugltkc",
expectedOutput: "救救孩子",
recipeConfig: [
{
"op": "From Modhex",
"args": [
"Auto"
]
}
]
},
{
name: "Mutiline Modhex with comma to ASCII (Auto Mode)",
input: "fk,dc,ie,hb,ii,dc,ht,ik,ie,hg,hr,hh,dc,ie,hk,\n\
if,if,hk,hu,hi,dc,hk,hu,dc,if,hj,hg,dc,he,id,\n\
hv,if,he,hj,dc,hv,hh,dc,if,hj,hg,dc,if,hj,hk,\n\
ie,dc,hh,hk,hi,dc,if,id,hg,hg,dr,dc,ie,if,hb,\n\
id,ih,hk,hu,hi,dc,if,hv,dc,hf,hg,hb,if,hj,dr,\n\
dc,hl,ig,ie,if,dc,hd,hg,he,hb,ig,ie,hg,dc,fk,\n\
dc,he,hv,ig,hr,hf,hu,di,if,dc,ht,hb,hn,hg,dc,\n\
ig,ic,dc,ht,ik,dc,ht,hk,hu,hf,dc,ii,hj,hk,he,\n\
hj,dc,hv,hh,dc,if,hj,hg,dc,hh,hk,hi,ie,dc,fk,\n\
dc,ii,hv,ig,hr,hf,dc,he,hj,hv,hv,ie,hg,du",
expectedOutput: "I saw myself sitting in the crotch of the this fig tree, starving to death, just because I couldn't make up my mind which of the figs I would choose.",
recipeConfig: [
{
"op": "From Modhex",
"args": [
"Auto"
]
}
]
},
{
name: "Mutiline Modhex with percent to ASCII (Percent Mode)",
input: "fk%dc%ie%hb%ii%dc%ht%ik%ie%hg%hr%hh%dc%ie%hk%\n\
if%if%hk%hu%hi%dc%hk%hu%dc%if%hj%hg%dc%he%id%\n\
hv%if%he%hj%dc%hv%hh%dc%if%hj%hg%dc%if%hj%hk%\n\
ie%dc%hh%hk%hi%dc%if%id%hg%hg%dr%dc%ie%if%hb%\n\
id%ih%hk%hu%hi%dc%if%hv%dc%hf%hg%hb%if%hj%dr%\n\
dc%hl%ig%ie%if%dc%hd%hg%he%hb%ig%ie%hg%dc%fk%\n\
dc%he%hv%ig%hr%hf%hu%di%if%dc%ht%hb%hn%hg%dc%\n\
ig%ic%dc%ht%ik%dc%ht%hk%hu%hf%dc%ii%hj%hk%he%\n\
hj%dc%hv%hh%dc%if%hj%hg%dc%hh%hk%hi%ie%dc%fk%\n\
dc%ii%hv%ig%hr%hf%dc%he%hj%hv%hv%ie%hg%du",
expectedOutput: "I saw myself sitting in the crotch of the this fig tree, starving to death, just because I couldn't make up my mind which of the figs I would choose.",
recipeConfig: [
{
"op": "From Modhex",
"args": [
"Percent"
]
}
]
},
{
name: "Mutiline Modhex with semicolon to ASCII (Semi-colon Mode)",
input: "fk;dc;ie;hb;ii;dc;ht;ik;ie;hg;hr;hh;dc;ie;hk;\n\
if;if;hk;hu;hi;dc;hk;hu;dc;if;hj;hg;dc;he;id;\n\
hv;if;he;hj;dc;hv;hh;dc;if;hj;hg;dc;if;hj;hk;\n\
ie;dc;hh;hk;hi;dc;if;id;hg;hg;dr;dc;ie;if;hb;\n\
id;ih;hk;hu;hi;dc;if;hv;dc;hf;hg;hb;if;hj;dr;\n\
dc;hl;ig;ie;if;dc;hd;hg;he;hb;ig;ie;hg;dc;fk;\n\
dc;he;hv;ig;hr;hf;hu;di;if;dc;ht;hb;hn;hg;dc;\n\
ig;ic;dc;ht;ik;dc;ht;hk;hu;hf;dc;ii;hj;hk;he;\n\
hj;dc;hv;hh;dc;if;hj;hg;dc;hh;hk;hi;ie;dc;fk;\n\
dc;ii;hv;ig;hr;hf;dc;he;hj;hv;hv;ie;hg;du",
expectedOutput: "I saw myself sitting in the crotch of the this fig tree, starving to death, just because I couldn't make up my mind which of the figs I would choose.",
recipeConfig: [
{
"op": "From Modhex",
"args": [
"Semi-colon"
]
}
]
},
{
name: "ASCII to Modhex with comma and line breaks",
input: "aberystwyth",
expectedOutput: "hb,hd,hg,id,\nik,ie,if,ii,\nik,if,hj",
recipeConfig: [
{
"op": "To Modhex",
"args": [
"Comma",
4
]
}
]
},
]);

View file

@ -11,12 +11,12 @@ import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Generate HOTP",
input: "12345678901234567890",
expectedOutput: "URI: otpauth://hotp/OTPAuthentication?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ\n\nPassword: 755224",
input: "JBSWY3DPEHPK3PXP",
expectedOutput: `URI: otpauth://hotp/?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760`,
recipeConfig: [
{
op: "Generate HOTP",
args: ["", 32, 6, 0],
args: ["", 6, 0], // [Name, Code length, Counter]
},
],
},

View file

@ -0,0 +1,112 @@
/**
* PHP Serialization tests.
*
* @author brun0ne [brunonblok@gmail.com]
*
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "PHP Serialize empty array",
input: "[]",
expectedOutput: "a:0:{}",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize empty object",
input: "{}",
expectedOutput: "a:0:{}",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize null",
input: "null",
expectedOutput: "N;",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize integer",
input: "10",
expectedOutput: "i:10;",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize float",
input: "14.523",
expectedOutput: "d:14.523;",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize boolean",
input: "[true, false]",
expectedOutput: "a:2:{i:0;b:1;i:1;b:0;}",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize string",
input: "\"Test string to serialize\"",
expectedOutput: "s:24:\"Test string to serialize\";",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize object",
input: "{\"a\": 10,\"0\": {\"ab\": true}}",
expectedOutput: "a:2:{s:1:\"0\";a:1:{s:2:\"ab\";b:1;}s:1:\"a\";i:10;}",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
},
{
name: "PHP Serialize array",
input: "[1,\"abc\",true,{\"x\":1,\"y\":2}]",
expectedOutput: "a:4:{i:0;i:1;i:1;s:3:\"abc\";i:2;b:1;i:3;a:2:{s:1:\"x\";i:1;s:1:\"y\";i:2;}}",
recipeConfig: [
{
op: "PHP Serialize",
args: []
}
]
}
]);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,331 @@
/**
* Parse X.509 CRL tests.
*
* @author robinsandhu
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const IN_CRL_PEM_RSA = `-----BEGIN X509 CRL-----
MIID7jCCAdYCAQEwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCVUsxDzANBgNV
BAgMBkxvbmRvbjELMAkGA1UECgwCQkIxFTATBgNVBAMMDFRlc3QgUm9vdCBDQRcN
MjQwODI1MTE0OTEwWhcNMjQwOTI0MTE0OTEwWjA1MDMCAhAAFw0yNDA4MjUwMzIz
MDhaMB4wCgYDVR0VBAMKAQYwEAYDVR0XBAkGByqGSM44AgOgggEnMIIBIzAJBgNV
HRIEAjAAMH0GA1UdIwR2MHSAFLjJrf2oUFTVhW40i0xgL7BJtodGoUakRDBCMQsw
CQYDVQQGEwJVSzEPMA0GA1UECAwGTG9uZG9uMQswCQYDVQQKDAJCQjEVMBMGA1UE
AwwMVGVzdCBSb290IENBghQ3XUv2vXwRfMxGGv/XLywm+B5LPTAtBgNVHS4EJjAk
MCKgIKAehhxodHRwOi8vZXhhbXBsZS5jb20vZGVsdGEtY3JsMFsGA1UdHwRUMFIw
IaAfoB2GG2h0dHA6Ly9leGFtcGxlLmNvbS9mdWxsLWNybDAhoB+gHYYbbGRhcDov
L2V4YW1wbGUuY29tL2Z1bGwtY3JsMAqgCKAGhwR/AAABMAsGA1UdFAQEAgIePDAN
BgkqhkiG9w0BAQsFAAOCAgEAAxsr+9nELUVWhFekwy6GsqH8xOf6EqGjRaEdX49W
mB40m2VajOkK8UHGoVyZzoDI2r/c8OPXUtbpK0fpvEl3SZU5j/C8JbZaZFFrEGeH
fSEqdVHFjohpawNcG41Qs+YT21TBqH1hD5yVI7gjVvfKICRfxDpl5oGClxBCVOSV
gVtLbe9q44uCBJ1kUkoc9Vz47Hv7JyckgqVXkORWHt2SFNALxlMEzOEQTpuC5Kcb
4i7hTCUF+kpkIvr02LJImq0Aaqzs6cC/DcdJiRPPyfaN8fQryFv76gg9i8zZcb6c
W42rvumiyw+7nnZfmq53webr5fCHaXhZk47ASOJD6GC5cX9rje1qGRgULXRhqcvK
n319s2iXj3FStDDorKGgsCV2zYmotX17ExB98CcCgBE52zMtRZilwhOGeh8mx3qT
l0W2B8uKKAq5BMmiziSBzQt700JPiruURZXbQ1fH1n7pKP6wGEh2e9TfQMlN20hE
I+CMt+1bG0Bpt5AfiwE8UykQ/WvpVxdJrgj0JM0yA37KfC8XD+cmavJ5/grorbj3
t0zBdK7bl+Y45VU/5/mX5ZR3O3ea1RclPM3hKMREfPneOlpan6r3dVwFqEN/TeTu
46vuDeKaEr3yJkOFfy0lSYPhPhzhU5vDR5ibxqvwxZNznI2AdTnZLEf8LRqnTVo1
qx0=
-----END X509 CRL-----`;
const OUT_CRL_PEM_RSA = `Certificate Revocation List (CRL):
Version: 2 (0x1)
Signature Algorithm: SHA256withRSA
Issuer:
C = UK
ST = London
O = BB
CN = Test Root CA
Last Update: Sun, 25 Aug 2024 11:49:10 GMT
Next Update: Tue, 24 Sep 2024 11:49:10 GMT
CRL extensions:
2.5.29.46:
Unsupported CRL extension. Try openssl CLI.
X509v3 Authority Key Identifier:
keyid:B8:C9:AD:FD:A8:50:54:D5:85:6E:34:8B:4C:60:2F:B0:49:B6:87:46
DirName:/C=UK/ST=London/O=BB/CN=Test Root CA
serial:37:5D:4B:F6:BD:7C:11:7C:CC:46:1A:FF:D7:2F:2C:26:F8:1E:4B:3D
X509v3 CRL Distribution Points:
Full Name:
URI:http://example.com/full-crl
Full Name:
URI:ldap://example.com/full-crl
Full Name:
IP:127.0.0.1
X509v3 CRL Number:
1E3C
issuerAltName:
Unsupported CRL extension. Try openssl CLI.
Revoked Certificates:
Serial Number: 1000
Revocation Date: Sun, 25 Aug 2024 03:23:08 GMT
CRL entry extensions:
X509v3 CRL Reason Code:
Certificate Hold
Hold Instruction Code:
Hold Instruction Reject
Signature Value:
03:1b:2b:fb:d9:c4:2d:45:56:84:57:a4:c3:2e:86:b2:a1:fc:
c4:e7:fa:12:a1:a3:45:a1:1d:5f:8f:56:98:1e:34:9b:65:5a:
8c:e9:0a:f1:41:c6:a1:5c:99:ce:80:c8:da:bf:dc:f0:e3:d7:
52:d6:e9:2b:47:e9:bc:49:77:49:95:39:8f:f0:bc:25:b6:5a:
64:51:6b:10:67:87:7d:21:2a:75:51:c5:8e:88:69:6b:03:5c:
1b:8d:50:b3:e6:13:db:54:c1:a8:7d:61:0f:9c:95:23:b8:23:
56:f7:ca:20:24:5f:c4:3a:65:e6:81:82:97:10:42:54:e4:95:
81:5b:4b:6d:ef:6a:e3:8b:82:04:9d:64:52:4a:1c:f5:5c:f8:
ec:7b:fb:27:27:24:82:a5:57:90:e4:56:1e:dd:92:14:d0:0b:
c6:53:04:cc:e1:10:4e:9b:82:e4:a7:1b:e2:2e:e1:4c:25:05:
fa:4a:64:22:fa:f4:d8:b2:48:9a:ad:00:6a:ac:ec:e9:c0:bf:
0d:c7:49:89:13:cf:c9:f6:8d:f1:f4:2b:c8:5b:fb:ea:08:3d:
8b:cc:d9:71:be:9c:5b:8d:ab:be:e9:a2:cb:0f:bb:9e:76:5f:
9a:ae:77:c1:e6:eb:e5:f0:87:69:78:59:93:8e:c0:48:e2:43:
e8:60:b9:71:7f:6b:8d:ed:6a:19:18:14:2d:74:61:a9:cb:ca:
9f:7d:7d:b3:68:97:8f:71:52:b4:30:e8:ac:a1:a0:b0:25:76:
cd:89:a8:b5:7d:7b:13:10:7d:f0:27:02:80:11:39:db:33:2d:
45:98:a5:c2:13:86:7a:1f:26:c7:7a:93:97:45:b6:07:cb:8a:
28:0a:b9:04:c9:a2:ce:24:81:cd:0b:7b:d3:42:4f:8a:bb:94:
45:95:db:43:57:c7:d6:7e:e9:28:fe:b0:18:48:76:7b:d4:df:
40:c9:4d:db:48:44:23:e0:8c:b7:ed:5b:1b:40:69:b7:90:1f:
8b:01:3c:53:29:10:fd:6b:e9:57:17:49:ae:08:f4:24:cd:32:
03:7e:ca:7c:2f:17:0f:e7:26:6a:f2:79:fe:0a:e8:ad:b8:f7:
b7:4c:c1:74:ae:db:97:e6:38:e5:55:3f:e7:f9:97:e5:94:77:
3b:77:9a:d5:17:25:3c:cd:e1:28:c4:44:7c:f9:de:3a:5a:5a:
9f:aa:f7:75:5c:05:a8:43:7f:4d:e4:ee:e3:ab:ee:0d:e2:9a:
12:bd:f2:26:43:85:7f:2d:25:49:83:e1:3e:1c:e1:53:9b:c3:
47:98:9b:c6:ab:f0:c5:93:73:9c:8d:80:75:39:d9:2c:47:fc:
2d:1a:a7:4d:5a:35:ab:1d`;
const IN_CRL_PEM_RSA_CRL_REASON_AND_INVALIDITY_DATE = `-----BEGIN X509 CRL-----
MIID9jCCAd4CAQEwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCVUsxDzANBgNV
BAgMBkxvbmRvbjELMAkGA1UECgwCQkIxFTATBgNVBAMMDFRlc3QgUm9vdCBDQRcN
MjQwODI1MTIwODU2WhcNMjQwOTI0MTIwODU2WjA9MDsCAhAAFw0yNDA4MjUxMjA4
NDhaMCYwCgYDVR0VBAMKAQEwGAYDVR0YBBEYDzIwMjQwODI1MDAwMDAwWqCCAScw
ggEjMAkGA1UdEgQCMAAwfQYDVR0jBHYwdIAUuMmt/ahQVNWFbjSLTGAvsEm2h0ah
RqREMEIxCzAJBgNVBAYTAlVLMQ8wDQYDVQQIDAZMb25kb24xCzAJBgNVBAoMAkJC
MRUwEwYDVQQDDAxUZXN0IFJvb3QgQ0GCFDddS/a9fBF8zEYa/9cvLCb4Hks9MC0G
A1UdLgQmMCQwIqAgoB6GHGh0dHA6Ly9leGFtcGxlLmNvbS9kZWx0YS1jcmwwWwYD
VR0fBFQwUjAhoB+gHYYbaHR0cDovL2V4YW1wbGUuY29tL2Z1bGwtY3JsMCGgH6Ad
hhtsZGFwOi8vZXhhbXBsZS5jb20vZnVsbC1jcmwwCqAIoAaHBH8AAAEwCwYDVR0U
BAQCAh49MA0GCSqGSIb3DQEBCwUAA4ICAQByLp7JWQmB1NhlLACH6zFOe31yCTVy
xJQtgujtSri1LNu6IwzBGsKBQIl3ucwMxPvoZzlujNLmshUT3nSogV0/5n1q0Gyj
5Yiz2iw8mmKJLmGZ9Oz3QoGxgFww0/0x/VwRHuS2hw+A7JB8tO/2nW3oTclvS55l
R+VtkDjUN58+Yl2SQksvb3qD6bHHJTCaP7Dskls0fdBIoYIDvZejrTYSSzTX/Kw4
735P0GBMhj7zVF8azGz2PFpSISg4huJMyp7EDKZf2c2dnkuwmEUlPQEBLX25j/Il
81OxfVVFja+wUagaGtjEPGy5gsU8zFwkWhjaD5PGBbZvnT+EDsOtJPU7Ot/sBHfz
XqUtMrfmz/S/GsQ+QCpnBvarBy9QYuk9M0ePBGy33CUQpjPULxuJJVAHxNoetHCv
7udng2Pi4D8vDNfzbMwHt7HurMo0CsSju+cL4rnIfsz02RrD9WC84KxBLWkqC7Hi
IKGIpF740Yc4BliVE1HDaOKyI6FEft5asj3OgXwmBw7pVlxSNWACaA2vOFkdN/V5
XZZjVJdRJxkgEfCvsJVenFp8ND6gmJmWum7tqM5ytmiXjPtejsPpVq4IclG+Yhnr
tFQ9TDEuCrNsRIGGGDodyXq1+kGXY0w8RqGEb7J4Og/M6r4LMAKPkO7e0nEibTqX
d2igvR2e5p+yKw==
-----END X509 CRL-----`;
const OUT_CRL_PEM_RSA_CRL_REASON_AND_INVALIDITY_DATE = `Certificate Revocation List (CRL):
Version: 2 (0x1)
Signature Algorithm: SHA256withRSA
Issuer:
C = UK
ST = London
O = BB
CN = Test Root CA
Last Update: Sun, 25 Aug 2024 12:08:56 GMT
Next Update: Tue, 24 Sep 2024 12:08:56 GMT
CRL extensions:
2.5.29.46:
Unsupported CRL extension. Try openssl CLI.
X509v3 Authority Key Identifier:
keyid:B8:C9:AD:FD:A8:50:54:D5:85:6E:34:8B:4C:60:2F:B0:49:B6:87:46
DirName:/C=UK/ST=London/O=BB/CN=Test Root CA
serial:37:5D:4B:F6:BD:7C:11:7C:CC:46:1A:FF:D7:2F:2C:26:F8:1E:4B:3D
X509v3 CRL Distribution Points:
Full Name:
URI:http://example.com/full-crl
Full Name:
URI:ldap://example.com/full-crl
Full Name:
IP:127.0.0.1
X509v3 CRL Number:
1E3D
issuerAltName:
Unsupported CRL extension. Try openssl CLI.
Revoked Certificates:
Serial Number: 1000
Revocation Date: Sun, 25 Aug 2024 12:08:48 GMT
CRL entry extensions:
X509v3 CRL Reason Code:
Key Compromise
Invalidity Date:
Sun, 25 Aug 2024 00:00:00 GMT
Signature Value:
72:2e:9e:c9:59:09:81:d4:d8:65:2c:00:87:eb:31:4e:7b:7d:
72:09:35:72:c4:94:2d:82:e8:ed:4a:b8:b5:2c:db:ba:23:0c:
c1:1a:c2:81:40:89:77:b9:cc:0c:c4:fb:e8:67:39:6e:8c:d2:
e6:b2:15:13:de:74:a8:81:5d:3f:e6:7d:6a:d0:6c:a3:e5:88:
b3:da:2c:3c:9a:62:89:2e:61:99:f4:ec:f7:42:81:b1:80:5c:
30:d3:fd:31:fd:5c:11:1e:e4:b6:87:0f:80:ec:90:7c:b4:ef:
f6:9d:6d:e8:4d:c9:6f:4b:9e:65:47:e5:6d:90:38:d4:37:9f:
3e:62:5d:92:42:4b:2f:6f:7a:83:e9:b1:c7:25:30:9a:3f:b0:
ec:92:5b:34:7d:d0:48:a1:82:03:bd:97:a3:ad:36:12:4b:34:
d7:fc:ac:38:ef:7e:4f:d0:60:4c:86:3e:f3:54:5f:1a:cc:6c:
f6:3c:5a:52:21:28:38:86:e2:4c:ca:9e:c4:0c:a6:5f:d9:cd:
9d:9e:4b:b0:98:45:25:3d:01:01:2d:7d:b9:8f:f2:25:f3:53:
b1:7d:55:45:8d:af:b0:51:a8:1a:1a:d8:c4:3c:6c:b9:82:c5:
3c:cc:5c:24:5a:18:da:0f:93:c6:05:b6:6f:9d:3f:84:0e:c3:
ad:24:f5:3b:3a:df:ec:04:77:f3:5e:a5:2d:32:b7:e6:cf:f4:
bf:1a:c4:3e:40:2a:67:06:f6:ab:07:2f:50:62:e9:3d:33:47:
8f:04:6c:b7:dc:25:10:a6:33:d4:2f:1b:89:25:50:07:c4:da:
1e:b4:70:af:ee:e7:67:83:63:e2:e0:3f:2f:0c:d7:f3:6c:cc:
07:b7:b1:ee:ac:ca:34:0a:c4:a3:bb:e7:0b:e2:b9:c8:7e:cc:
f4:d9:1a:c3:f5:60:bc:e0:ac:41:2d:69:2a:0b:b1:e2:20:a1:
88:a4:5e:f8:d1:87:38:06:58:95:13:51:c3:68:e2:b2:23:a1:
44:7e:de:5a:b2:3d:ce:81:7c:26:07:0e:e9:56:5c:52:35:60:
02:68:0d:af:38:59:1d:37:f5:79:5d:96:63:54:97:51:27:19:
20:11:f0:af:b0:95:5e:9c:5a:7c:34:3e:a0:98:99:96:ba:6e:
ed:a8:ce:72:b6:68:97:8c:fb:5e:8e:c3:e9:56:ae:08:72:51:
be:62:19:eb:b4:54:3d:4c:31:2e:0a:b3:6c:44:81:86:18:3a:
1d:c9:7a:b5:fa:41:97:63:4c:3c:46:a1:84:6f:b2:78:3a:0f:
cc:ea:be:0b:30:02:8f:90:ee:de:d2:71:22:6d:3a:97:77:68:
a0:bd:1d:9e:e6:9f:b2:2b`;
const IN_CRL_PEM_RSA_CRL_EXTENSIONS = `-----BEGIN X509 CRL-----
MIIE0DCCArgCAQEwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCVUsxDzANBgNV
BAgMBkxvbmRvbjELMAkGA1UECgwCQkIxFTATBgNVBAMMDFRlc3QgUm9vdCBDQRcN
MjQwODI1MTIzNzEwWhcNMjQwOTI0MTIzNzEwWjA9MDsCAhAAFw0yNDA4MjUxMjA4
NDhaMCYwCgYDVR0VBAMKAQEwGAYDVR0YBBEYDzIwMjQwODI1MDAwMDAwWqCCAgEw
ggH9MIHiBgNVHRIEgdowgdegFAYEKgMEBaAMFgpDdXN0b21OYW1lgQ5jYUBleGFt
cGxlLmNvbYYSaHR0cDovL2V4YW1wbGUuY29tgg5jYS5leGFtcGxlLmNvbYcEwKgB
AaSBhDCBgTELMAkGA1UEBhMCVVMxFTATBgNVBAgMDEV4YW1wbGVTdGF0ZTEUMBIG
A1UEBwwLRXhhbXBsZUNpdHkxEzARBgNVBAoMCkV4YW1wbGVPcmcxFDASBgNVBAsM
C0V4YW1wbGVVbml0MRowGAYDVQQDDBFFeGFtcGxlQ29tbW9uTmFtZTB9BgNVHSME
djB0gBS4ya39qFBU1YVuNItMYC+wSbaHRqFGpEQwQjELMAkGA1UEBhMCVUsxDzAN
BgNVBAgMBkxvbmRvbjELMAkGA1UECgwCQkIxFTATBgNVBAMMDFRlc3QgUm9vdCBD
QYIUN11L9r18EXzMRhr/1y8sJvgeSz0wLQYDVR0uBCYwJDAioCCgHoYcaHR0cDov
L2V4YW1wbGUuY29tL2RlbHRhLWNybDBbBgNVHR8EVDBSMCGgH6AdhhtodHRwOi8v
ZXhhbXBsZS5jb20vZnVsbC1jcmwwIaAfoB2GG2xkYXA6Ly9leGFtcGxlLmNvbS9m
dWxsLWNybDAKoAigBocEfwAAATALBgNVHRQEBAICHkIwDQYJKoZIhvcNAQELBQAD
ggIBAF/9L4aGmId2igw7+MfDxokevIJkJX/MkmHpXBl1b4hL85FGD7OPCmn47VzC
Wejlc/AQB7mWyUugvrVEq/FiCO8a8Fieyjw5uCYz0eiNnuvHVRGM2mOEkiA0I/rn
F5AFB1YfCFGXPyRkXNRbOBE91mhOzh1H9PX2qVnj5l3KsPE/7YuteacR0TkfkRJa
BXLic+5F/CCV/J/iYR7LncuLUlhBfsosG/ucHL70EytlfX6CBWY3kBbmj7nd497T
QG392+m9xp7MIsJAS+3qEzwJAfni6zUV0fWh/ucOl8BIjHEh97VqI3+8yzhdXfkF
2gkfpkqJQY0+5OO1VSRYTlQNld3QjN/VVJjatfHyaXfPCx4VEKW1kWYo+0zxO4SL
SB/+S/o99bCeNy1MXqEvy5HoDwFHePXGsAEPHWPdj7EWm7g9T/Fl1iSR6hpohvDD
K4LaGdVhzvCraLIh8H7XW3KztvZvDQejYQAgADW0UO0rFHJ1XXhKYSqXNGnfDt+3
cRpt2XxSxt5HJtHlatiI25PuBMNWV2Zod4RHB/8UEvs1KC7dcwkAiCEY+E3o/zkC
rdZ/8XtNf5a4WSN/D7pPsfsO6SE+7lxkJ+UQcZLXAz8b5ArPTlWt2HdJIBEVs25K
FAkizyldhnAcNHFk7XN94eTLNeD6hUbFL9pNHiSmKu5A9YW0
-----END X509 CRL-----`;
const OUT_CRL_PEM_RSA_CRL_EXTENSIONS = `Certificate Revocation List (CRL):
Version: 2 (0x1)
Signature Algorithm: SHA256withRSA
Issuer:
C = UK
ST = London
O = BB
CN = Test Root CA
Last Update: Sun, 25 Aug 2024 12:37:10 GMT
Next Update: Tue, 24 Sep 2024 12:37:10 GMT
CRL extensions:
2.5.29.46:
Unsupported CRL extension. Try openssl CLI.
X509v3 Authority Key Identifier:
keyid:B8:C9:AD:FD:A8:50:54:D5:85:6E:34:8B:4C:60:2F:B0:49:B6:87:46
DirName:/C=UK/ST=London/O=BB/CN=Test Root CA
serial:37:5D:4B:F6:BD:7C:11:7C:CC:46:1A:FF:D7:2F:2C:26:F8:1E:4B:3D
X509v3 CRL Distribution Points:
Full Name:
URI:http://example.com/full-crl
Full Name:
URI:ldap://example.com/full-crl
Full Name:
IP:127.0.0.1
X509v3 CRL Number:
1E42
X509v3 Issuer Alternative Name:
OtherName:1.2.3.4.5::CustomName
EMAIL:ca@example.com
URI:http://example.com
DNS:ca.example.com
IP:192.168.1.1
DIR:/C=US/ST=ExampleState/L=ExampleCity/O=ExampleOrg/OU=ExampleUnit/CN=ExampleCommonName
Revoked Certificates:
Serial Number: 1000
Revocation Date: Sun, 25 Aug 2024 12:08:48 GMT
CRL entry extensions:
X509v3 CRL Reason Code:
Key Compromise
Invalidity Date:
Sun, 25 Aug 2024 00:00:00 GMT
Signature Value:
5f:fd:2f:86:86:98:87:76:8a:0c:3b:f8:c7:c3:c6:89:1e:bc:
82:64:25:7f:cc:92:61:e9:5c:19:75:6f:88:4b:f3:91:46:0f:
b3:8f:0a:69:f8:ed:5c:c2:59:e8:e5:73:f0:10:07:b9:96:c9:
4b:a0:be:b5:44:ab:f1:62:08:ef:1a:f0:58:9e:ca:3c:39:b8:
26:33:d1:e8:8d:9e:eb:c7:55:11:8c:da:63:84:92:20:34:23:
fa:e7:17:90:05:07:56:1f:08:51:97:3f:24:64:5c:d4:5b:38:
11:3d:d6:68:4e:ce:1d:47:f4:f5:f6:a9:59:e3:e6:5d:ca:b0:
f1:3f:ed:8b:ad:79:a7:11:d1:39:1f:91:12:5a:05:72:e2:73:
ee:45:fc:20:95:fc:9f:e2:61:1e:cb:9d:cb:8b:52:58:41:7e:
ca:2c:1b:fb:9c:1c:be:f4:13:2b:65:7d:7e:82:05:66:37:90:
16:e6:8f:b9:dd:e3:de:d3:40:6d:fd:db:e9:bd:c6:9e:cc:22:
c2:40:4b:ed:ea:13:3c:09:01:f9:e2:eb:35:15:d1:f5:a1:fe:
e7:0e:97:c0:48:8c:71:21:f7:b5:6a:23:7f:bc:cb:38:5d:5d:
f9:05:da:09:1f:a6:4a:89:41:8d:3e:e4:e3:b5:55:24:58:4e:
54:0d:95:dd:d0:8c:df:d5:54:98:da:b5:f1:f2:69:77:cf:0b:
1e:15:10:a5:b5:91:66:28:fb:4c:f1:3b:84:8b:48:1f:fe:4b:
fa:3d:f5:b0:9e:37:2d:4c:5e:a1:2f:cb:91:e8:0f:01:47:78:
f5:c6:b0:01:0f:1d:63:dd:8f:b1:16:9b:b8:3d:4f:f1:65:d6:
24:91:ea:1a:68:86:f0:c3:2b:82:da:19:d5:61:ce:f0:ab:68:
b2:21:f0:7e:d7:5b:72:b3:b6:f6:6f:0d:07:a3:61:00:20:00:
35:b4:50:ed:2b:14:72:75:5d:78:4a:61:2a:97:34:69:df:0e:
df:b7:71:1a:6d:d9:7c:52:c6:de:47:26:d1:e5:6a:d8:88:db:
93:ee:04:c3:56:57:66:68:77:84:47:07:ff:14:12:fb:35:28:
2e:dd:73:09:00:88:21:18:f8:4d:e8:ff:39:02:ad:d6:7f:f1:
7b:4d:7f:96:b8:59:23:7f:0f:ba:4f:b1:fb:0e:e9:21:3e:ee:
5c:64:27:e5:10:71:92:d7:03:3f:1b:e4:0a:cf:4e:55:ad:d8:
77:49:20:11:15:b3:6e:4a:14:09:22:cf:29:5d:86:70:1c:34:
71:64:ed:73:7d:e1:e4:cb:35:e0:fa:85:46:c5:2f:da:4d:1e:
24:a6:2a:ee:40:f5:85:b4`;
TestRegister.addTests([
{
name: "Parse X.509 CRL: Example PEM encoded CRL with RSA signature",
input: IN_CRL_PEM_RSA,
expectedOutput: OUT_CRL_PEM_RSA,
recipeConfig: [
{
"op": "Parse X.509 CRL",
"args": ["PEM"]
}
]
},
{
name: "Parse X.509 CRL: Example PEM encoded CRL with RSA signature, CRL Reason and Invalidity Date",
input: IN_CRL_PEM_RSA_CRL_REASON_AND_INVALIDITY_DATE,
expectedOutput: OUT_CRL_PEM_RSA_CRL_REASON_AND_INVALIDITY_DATE,
recipeConfig: [
{
"op": "Parse X.509 CRL",
"args": ["PEM"]
}
]
},
{
name: "Parse X.509 CRL: Example PEM encoded CRL with RSA signature and CRL Extensions",
input: IN_CRL_PEM_RSA_CRL_EXTENSIONS,
expectedOutput: OUT_CRL_PEM_RSA_CRL_EXTENSIONS,
recipeConfig: [
{
"op": "Parse X.509 CRL",
"args": ["PEM"]
}
]
},
]);

View file

@ -135,10 +135,21 @@ TestRegister.addTests([
},
],
},
{
name: "ROT13: no shift amount",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
recipeConfig: [
{
op: "ROT13",
args: [true, true, true, 0]
},
],
},
{
name: "ROT13: normal",
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
expectedOutput: "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt.",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt. 3456789012",
recipeConfig: [
{
op: "ROT13",
@ -146,10 +157,21 @@ TestRegister.addTests([
},
],
},
{
name: "ROT13: negative shift amount",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt. 7890123456",
recipeConfig: [
{
op: "ROT13",
args: [true, true, true, -13]
},
],
},
{
name: "ROT13: full loop",
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog.",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 6789012345",
recipeConfig: [
{
op: "ROT13",
@ -157,10 +179,21 @@ TestRegister.addTests([
},
],
},
{
name: "ROT13: full loop (negative shift amount)",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 4567890123",
recipeConfig: [
{
op: "ROT13",
args: [true, true, true, -26]
},
],
},
{
name: "ROT13: lowercase only",
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
expectedOutput: "Tur Qhvpx Bebja Fbk Jhzcrq Oire Tur Lnml Dbt.",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "Tur Qhvpx Bebja Fbk Jhzcrq Oire Tur Lnml Dbt. 0123456789",
recipeConfig: [
{
op: "ROT13",
@ -170,8 +203,8 @@ TestRegister.addTests([
},
{
name: "ROT13: uppercase only",
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
expectedOutput: "Ghe Duick Orown Sox Wumped Bver Ghe Yazy Qog.",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "Ghe Duick Orown Sox Wumped Bver Ghe Yazy Qog. 0123456789",
recipeConfig: [
{
op: "ROT13",
@ -179,6 +212,50 @@ TestRegister.addTests([
},
],
},
{
name: "ROT13: numbers only",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 5678901234",
recipeConfig: [
{
op: "ROT13",
args: [false, false, true, 5]
},
],
},
{
name: "ROT13: numbers only (negative shift amount)",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 5678901234",
recipeConfig: [
{
op: "ROT13",
args: [false, false, true, 5]
},
],
},
{
name: "ROT13: numbers only loop",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
recipeConfig: [
{
op: "ROT13",
args: [false, false, true, 10]
},
],
},
{
name: "ROT13: numbers only loop (negative shift amount)",
input: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog. 0123456789",
recipeConfig: [
{
op: "ROT13",
args: [false, false, true, -10]
},
],
},
{
name: "ROT47: nothing",
input: "",

View file

@ -0,0 +1,135 @@
/**
* SM2 Tests
*
* @author flakjacket95 [dflack95@gmail.com]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
/* Plaintexts */
const SMALL_PLAIN = "I am a small plaintext";
const LARGE_PLAIN = "I am a larger plaintext, that will require the encryption KDF to generate a much larger key to properly encrypt me";
/* Test Key Parameters */
const PUBLIC_X = "f7d903cab7925066c31150a92b31e548e63f954f92d01eaa0271fb2a336baef8";
const PUBLIC_Y = "fb0c45e410ef7a6cdae724e6a78dbff52562e97ede009e762b667d9b14adea6c";
const PRIVATE_K = "e74a72505084c3269aa9b696d603e3e08c74c6740212c11a31e26cdfe08bdf6a";
const CURVE = "sm2p256v1";
/* Decryption Test Ciphertext*/
const CIPHERTEXT_1 = "9a31bc0adb4677cdc4141479e3949572a55c3e6fb52094721f741c2bd2e179aaa87be6263bc1be602e473be3d5de5dce97f8248948b3a7e15f9f67f64aef21575e0c05e6171870a10ff9ab778dbef24267ad90e1a9d47d68f757d57c4816612e9829f804025dea05a511cda39371c22a2828f976f72e";
const CIPHERTEXT_2 = "d3647d68568a2e7a4f8e843286be7bf2b4d80256697d19a73df306ae1a7e6d0364d942e23d2340606e7a2502a838b132f9242587b2ea7e4c207e87242eea8cae68f5ff4da2a95a7f6d350608ae5b6777e1d925bf9c560087af84aba7befba713130106ddb4082d803811bca3864594722f3198d58257fe4ba37f4aa540adf4cb0568bddd2d8140ad3030deea0a87e3198655cc4d22bfc3d73b1c4afec2ff15d68c8d1298d97132cace922ee8a4e41ca288a7e748b77ca94aa81dc283439923ae7939e00898e16fe5111fbe1d928d152b216a";
const CIPHERTEXT_3 = "5f340eeb4398fa8950ee3408d0e3fe34bf7728c9fdb060c94b916891b5c693610274160b52a7132a2bf16ad5cdb57d1e00da2f3ddbd55350729aa9c268b53e40c05ccce9912daa14406e8c132e389484e69757350be25351755dcc6c25c94b3c1a448b2cf8c2017582125eb6cf782055b199a875e966";
const CIPHERTEXT_4 = "0649bac46c3f9fd7fb3b2be4bff27414d634651efd02ca67d8c802bbc5468e77d035c39b581d6b56227f5d87c0b4efbea5032c0761139295ae194b9f1fce698f2f4b51d89fa5554171a1aad2e61fe9de89831aec472ecc5ab178ebf4d2230c1fb94fca03e536b87b9eba6db71ba9939260a08ffd230ca86cb45cf754854222364231bdb8b873791d63ad57a4b3fa5b6375388dc879373f5f1be9051bc5072a8afbec5b7b034e4907aa5bb4b6b1f50e725d09cb6a02e07ce20263005f6c9157ce05d3ea739d231d4f09396fb72aa680884d78";
TestRegister.addTests([
{
name: "SM2 Decrypt: Small Input; Format One",
input: CIPHERTEXT_1,
expectedOutput: SMALL_PLAIN,
recipeConfig: [
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C3C2", CURVE]
}
]
},
{
name: "SM2 Decrypt: Large Input; Format One",
input: CIPHERTEXT_2,
expectedOutput: LARGE_PLAIN,
recipeConfig: [
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C3C2", CURVE]
}
]
},
{
name: "SM2 Decrypt: Small Input; Format Two",
input: CIPHERTEXT_3,
expectedOutput: SMALL_PLAIN,
recipeConfig: [
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C2C3", CURVE]
}
]
},
{
name: "SM2 Decrypt: Large Input; Format Two",
input: CIPHERTEXT_4,
expectedOutput: LARGE_PLAIN,
recipeConfig: [
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C2C3", CURVE]
}
]
},
{
name: "SM2 Encrypt And Decrypt: Small Input; Format One",
input: SMALL_PLAIN,
expectedOutput: SMALL_PLAIN,
recipeConfig: [
{
"op": "SM2 Encrypt",
"args": [PUBLIC_X, PUBLIC_Y, "C1C3C2", CURVE],
},
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C3C2", CURVE]
}
]
},
{
name: "SM2 Encrypt And Decrypt: Large Input; Format One",
input: LARGE_PLAIN,
expectedOutput: LARGE_PLAIN,
recipeConfig: [
{
"op": "SM2 Encrypt",
"args": [PUBLIC_X, PUBLIC_Y, "C1C3C2", CURVE],
},
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C3C2", CURVE]
}
]
},
{
name: "SM2 Encrypt And Decrypt: Small Input; Format Two",
input: SMALL_PLAIN,
expectedOutput: SMALL_PLAIN,
recipeConfig: [
{
"op": "SM2 Encrypt",
"args": [PUBLIC_X, PUBLIC_Y, "C1C2C3", CURVE],
},
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C2C2", CURVE]
}
]
},
{
name: "SM2 Encrypt And Decrypt: Large Input; Format Two",
input: LARGE_PLAIN,
expectedOutput: LARGE_PLAIN,
recipeConfig: [
{
"op": "SM2 Encrypt",
"args": [PUBLIC_X, PUBLIC_Y, "C1C2C3", CURVE],
},
{
"op": "SM2 Decrypt",
"args": [PRIVATE_K, "C1C2C3", CURVE]
}
]
},
]);

View file

@ -0,0 +1,126 @@
/**
* Strip IPv4 header tests.
*
* @author c65722 []
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Strip IPv4 header: No options, No payload",
input: "450000140005400080060000c0a80001c0a80002",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip IPv4 header: No options, Payload",
input: "450000140005400080060000c0a80001c0a80002ffffffffffffffff",
expectedOutput: "ffffffffffffffff",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip IPv4 header: Options, No payload",
input: "460000140005400080060000c0a80001c0a8000207000000",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip IPv4 header: Options, Payload",
input: "460000140005400080060000c0a80001c0a8000207000000ffffffffffffffff",
expectedOutput: "ffffffffffffffff",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip IPv4 header: Input length lesss than minimum header length",
input: "450000140005400080060000c0a80001c0a800",
expectedOutput: "Input length is less than minimum IPv4 header length",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip IPv4 header: Input length less than IHL",
input: "460000140005400080060000c0a80001c0a80000",
expectedOutput: "Input length is less than IHL",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip IPv4 header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
}
]);

View file

@ -0,0 +1,126 @@
/**
* Strip TCP header tests.
*
* @author c65722 []
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Strip TCP header: No options, No payload",
input: "7f900050000fa4b2000cb2a45010bff100000000",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip TCP header: No options, Payload",
input: "7f900050000fa4b2000cb2a45010bff100000000ffffffffffffffff",
expectedOutput: "ffffffffffffffff",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip TCP header: Options, No payload",
input: "7f900050000fa4b2000cb2a47010bff100000000020405b404020000",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip TCP header: Options, Payload",
input: "7f900050000fa4b2000cb2a47010bff100000000020405b404020000ffffffffffffffff",
expectedOutput: "ffffffffffffffff",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip TCP header: Input length less than minimum header length",
input: "7f900050000fa4b2000cb2a45010bff1000000",
expectedOutput: "Need at least 20 bytes for a TCP Header",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip TCP header: Input length less than data offset",
input: "7f900050000fa4b2000cb2a47010bff100000000",
expectedOutput: "Input length is less than data offset",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip TCP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
}
]);

View file

@ -0,0 +1,69 @@
/**
* Strip UDP header tests.
*
* @author c65722 []
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Strip UDP header: No payload",
input: "8111003500000000",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip UDP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip UDP header: Payload",
input: "8111003500080000ffffffffffffffff",
expectedOutput: "ffffffffffffffff",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip UDP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
},
{
name: "Strip UDP header: Input length less than header length",
input: "81110035000000",
expectedOutput: "Need 8 bytes for a UDP Header",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Strip UDP header",
args: [],
},
{
op: "To Hex",
args: ["None", 0]
}
]
}
]);

View file

@ -0,0 +1,123 @@
/**
* @author Oshawk [oshawk@protonmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
/**
* Take nth bytes tests
*/
TestRegister.addTests([
{
name: "Take nth bytes: Nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Take nth bytes: Nothing (apply to each line)",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Take nth bytes: Basic single line",
input: "0123456789",
expectedOutput: "048",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Take nth bytes: Basic single line (apply to each line)",
input: "0123456789",
expectedOutput: "048",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Take nth bytes: Complex single line",
input: "0123456789",
expectedOutput: "59",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 5, false],
},
],
},
{
name: "Take nth bytes: Complex single line (apply to each line)",
input: "0123456789",
expectedOutput: "59",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 5, true],
},
],
},
{
name: "Take nth bytes: Basic multi line",
input: "01234\n56789",
expectedOutput: "047",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, false],
},
],
},
{
name: "Take nth bytes: Basic multi line (apply to each line)",
input: "01234\n56789",
expectedOutput: "04\n59",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 0, true],
},
],
},
{
name: "Take nth bytes: Complex multi line",
input: "01234\n56789",
expectedOutput: "\n8",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 5, false],
},
],
},
{
name: "Take nth bytes: Complex multi line (apply to each line)",
input: "012345\n6789ab",
expectedOutput: "5\nb",
recipeConfig: [
{
op: "Take nth bytes",
args: [4, 5, true],
},
],
}
]);

View file

@ -0,0 +1,53 @@
/**
* @author kendallgoto [k@kgo.to]
* @copyright Crown Copyright 2025
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Template: Simple Print",
"input": "{}",
"expectedOutput": "Hello, world!",
"recipeConfig": [
{
"op": "Template",
"args": ["Hello, world!"]
}
]
},
{
"name": "Template: Print Basic Variables",
"input": "{\"one\": 1, \"two\": 2}",
"expectedOutput": "1 2",
"recipeConfig": [
{
"op": "Template",
"args": ["{{ one }} {{ two }}"]
}
]
},
{
"name": "Template: Partials",
"input": "{\"users\":[{\"name\":\"Someone\",\"age\":25},{\"name\":\"Someone Else\",\"age\":32}]}",
"expectedOutput": "Name: Someone\nAge: 25\n\nName: Someone Else\nAge: 32\n\n",
"recipeConfig": [
{
"op": "Template",
"args": ["{{#*inline \"user\"}}\nName: {{ name }}\nAge: {{ age }}\n{{/inline}}\n{{#each users}}\n{{> user}}\n\n{{/each}}"]
}
]
},
{
"name": "Template: Disallow XSS",
"input": "{\"test\": \"<script></script>\"}",
"expectedOutput": "<script></script>&lt;script&gt;&lt;/script&gt;",
"recipeConfig": [
{
"op": "Template",
"args": ["<script></script>{{ test }}"]
}
]
}
]);

View file

@ -0,0 +1,92 @@
/**
* URLEncode and URLDecode tests.
*
* @author es45411 [135977478+es45411@users.noreply.github.com]
*
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
// URL Decode
{
name: "URLDecode: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "URL Decode",
args: [],
},
],
},
{
name: "URLDecode: spaces without special chars",
input: "Hello%20world%21",
expectedOutput: "Hello world!",
recipeConfig: [
{
op: "URL Decode",
args: [],
},
],
},
{
name: "URLDecode: spaces with special chars",
input: "Hello%20world!",
expectedOutput: "Hello world!",
recipeConfig: [
{
op: "URL Decode",
args: [],
},
],
},
{
name: "URLDecode: decode plus as space",
input: "Hello%20world!",
expectedOutput: "Hello world!",
recipeConfig: [
{
op: "URL Decode",
args: [],
},
],
},
// URL Encode
{
name: "URLEncode: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "URL Encode",
args: [],
},
],
},
{
name: "URLEncode: spaces without special chars",
input: "Hello world!",
expectedOutput: "Hello%20world!",
recipeConfig: [
{
op: "URL Encode",
args: [],
},
],
},
{
name: "URLEncode: spaces with special chars",
input: "Hello world!",
expectedOutput: "Hello%20world%21",
recipeConfig: [
{
op: "URL Encode",
args: [true],
},
],
},
]);

View file

@ -0,0 +1,120 @@
/**
* Checksum tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const BASIC_STRING = "The ships hung in the sky in much the same way that bricks don't.";
const UTF8_STR = "ნუ პანიკას";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
TestRegister.addTests([
{
name: "XOR Checksum (1): nothing",
input: "",
expectedOutput: "00",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [1]
}
]
},
{
name: "XOR Checksum (1): basic string",
input: BASIC_STRING,
expectedOutput: "08",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [1]
}
]
},
{
name: "XOR Checksum (1): UTF-8",
input: UTF8_STR,
expectedOutput: "df",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [1]
}
]
},
{
name: "XOR Checksum (1): all bytes",
input: ALL_BYTES,
expectedOutput: "00",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [1]
}
]
},
{
name: "XOR Checksum (4): nothing",
input: "",
expectedOutput: "00000000",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [4]
}
]
},
{
name: "XOR Checksum (4): basic string",
input: BASIC_STRING,
expectedOutput: "4918421b",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [4]
}
]
},
{
name: "XOR Checksum (4): UTF-8",
input: UTF8_STR,
expectedOutput: "83a424dc",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [4]
}
]
},
{
name: "XOR Checksum (4): all bytes",
input: ALL_BYTES,
expectedOutput: "00000000",
recipeConfig: [
{
"op": "XOR Checksum",
"args": [4]
}
]
},
]);