mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 16:26:16 -04:00
make chef.help emulate search function in UI. Didnt extract search logic from web as it is fairly entwined.
This commit is contained in:
parent
3466f4e452
commit
63a23e4dcc
5 changed files with 80 additions and 30 deletions
|
@ -115,12 +115,12 @@ TestRegister.addApiTests([
|
|||
|
||||
it("chef.help: should describe a operation", () => {
|
||||
const result = chef.help("tripleDESDecrypt");
|
||||
assert.strictEqual(result.name, "Triple DES Decrypt");
|
||||
assert.strictEqual(result.module, "Ciphers");
|
||||
assert.strictEqual(result.inputType, "string");
|
||||
assert.strictEqual(result.outputType, "string");
|
||||
assert.strictEqual(result.description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.");
|
||||
assert.strictEqual(result.args.length, 5);
|
||||
assert.strictEqual(result[0].name, "Triple DES Decrypt");
|
||||
assert.strictEqual(result[0].module, "Ciphers");
|
||||
assert.strictEqual(result[0].inputType, "string");
|
||||
assert.strictEqual(result[0].outputType, "string");
|
||||
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.");
|
||||
assert.strictEqual(result[0].args.length, 5);
|
||||
}),
|
||||
|
||||
it("chef.help: null for invalid operation", () => {
|
||||
|
@ -130,8 +130,29 @@ TestRegister.addApiTests([
|
|||
|
||||
it("chef.help: takes a wrapped operation as input", () => {
|
||||
const result = chef.help(chef.toBase32);
|
||||
assert.strictEqual(result.name, "To Base32");
|
||||
assert.strictEqual(result.module, "Default");
|
||||
assert.strictEqual(result[0].name, "To Base32");
|
||||
assert.strictEqual(result[0].module, "Default");
|
||||
}),
|
||||
|
||||
it("chef.help: returns multiple results", () => {
|
||||
const result = chef.help("base 64");
|
||||
assert.strictEqual(result.length, 8);
|
||||
}),
|
||||
|
||||
it("chef.help: looks in description for matches too", () => {
|
||||
// string only in one operation's description.
|
||||
const result = chef.help("Converts a unit of data to another format.");
|
||||
assert.strictEqual(result.length, 1);
|
||||
assert.strictEqual(result[0].name, "Convert data units");
|
||||
}),
|
||||
|
||||
it("chef.help: lists name matches before desc matches", () => {
|
||||
const result = chef.help("MD5");
|
||||
assert.ok(result[0].name.includes("MD5"));
|
||||
assert.strictEqual(result[1].name.includes("MD5"), false);
|
||||
assert.strictEqual(result[2].name.includes("MD5"), false);
|
||||
assert.ok(result[1].description.includes("MD5"));
|
||||
assert.ok(result[2].description.includes("MD5"));
|
||||
}),
|
||||
|
||||
it("chef.bake: should exist", () => {
|
||||
|
|
|
@ -512,7 +512,7 @@ Top Drawer`, {
|
|||
const expected = "{\"dataLength\":43,\"percentages\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13.953488372093023,0,0,0,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.3255813953488373,4.651162790697675,2.3255813953488373,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,2.3255813953488373,0,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,2.3255813953488373,0,4.651162790697675,0,9.30232558139535,2.3255813953488373,0,6.976744186046512,2.3255813953488373,0,2.3255813953488373,0,0,6.976744186046512,9.30232558139535,0,0,4.651162790697675,2.3255813953488373,6.976744186046512,4.651162790697675,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"distribution\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,2,0,4,1,0,3,1,0,1,0,0,3,4,0,0,2,1,3,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"bytesRepresented\":22}";
|
||||
assert.strictEqual(result.toString(), expected);
|
||||
}),
|
||||
|
||||
|
||||
it("From base", () => {
|
||||
assert.strictEqual(chef.fromBase("11", {radix: 13}).toString(), "14");
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue