mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
This commit is contained in:
commit
e4ee0fc397
52 changed files with 6038 additions and 1539 deletions
|
@ -2,7 +2,8 @@ import assert from "assert";
|
|||
import it from "../assertionHandler";
|
||||
import TestRegister from "../../lib/TestRegister";
|
||||
import File from "../../../src/node/File";
|
||||
import {zip} from "../../../src/node/index";
|
||||
import {zip, Dish} from "../../../src/node/index";
|
||||
import { DishBigNumber } from "../../../src/core/dishTranslationTypes/index.mjs";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
it("File: should exist", () => {
|
||||
|
@ -31,4 +32,52 @@ TestRegister.addApiTests([
|
|||
const file = new File([uint8Array], "sample.txt");
|
||||
assert.strictEqual(file.type, "application/unknown");
|
||||
}),
|
||||
|
||||
it("File: should be able to make a dish from it", () => {
|
||||
const uint8Array = new Uint8Array(Buffer.from("hello"));
|
||||
const file = new File([uint8Array], "sample.txt");
|
||||
try {
|
||||
const dish = new Dish(file, 7);
|
||||
assert.ok(dish.valid());
|
||||
} catch (e) {
|
||||
assert.fail(e.message);
|
||||
}
|
||||
}),
|
||||
|
||||
it("File: should allow dish to translate to ArrayBuffer", () => {
|
||||
const uint8Array = new Uint8Array(Buffer.from("hello"));
|
||||
const file = new File([uint8Array], "sample.txt");
|
||||
try {
|
||||
const dish = new Dish(file, 7);
|
||||
assert.ok(dish.value);
|
||||
|
||||
dish.get(4);
|
||||
assert.strictEqual(dish.type, 4);
|
||||
assert.ok(dish.valid());
|
||||
|
||||
} catch (e) {
|
||||
assert.fail(e.message);
|
||||
}
|
||||
}),
|
||||
|
||||
it("File: should allow dish to translate from ArrayBuffer to File", () => {
|
||||
const uint8Array = new Uint8Array(Buffer.from("hello"));
|
||||
const file = new File([uint8Array], "sample.txt");
|
||||
try {
|
||||
const dish = new Dish(file, 7);
|
||||
assert.ok(dish.value);
|
||||
|
||||
// translate to ArrayBuffer
|
||||
dish.get(4);
|
||||
assert.ok(dish.valid());
|
||||
|
||||
// translate back to File
|
||||
dish.get(7);
|
||||
assert.ok(dish.valid());
|
||||
|
||||
} catch (e) {
|
||||
assert.fail(e.message);
|
||||
}
|
||||
})
|
||||
|
||||
]);
|
||||
|
|
|
@ -400,8 +400,8 @@ TestRegister.addApiTests([
|
|||
}),
|
||||
|
||||
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
|
||||
assert.ok(chef.toCharcode.argOptions);
|
||||
assert.deepEqual(chef.unzip.argOptions, {
|
||||
assert.ok(chef.toCharcode.args);
|
||||
assert.deepEqual(chef.unzip.args, {
|
||||
password: {
|
||||
type: "binaryString",
|
||||
value: "",
|
||||
|
@ -414,20 +414,20 @@ TestRegister.addApiTests([
|
|||
}),
|
||||
|
||||
it("Operation arguments: should have key for each argument in operation", () => {
|
||||
assert.ok(chef.convertDistance.argOptions.inputUnits);
|
||||
assert.ok(chef.convertDistance.argOptions.outputUnits);
|
||||
assert.ok(chef.convertDistance.args.inputUnits);
|
||||
assert.ok(chef.convertDistance.args.outputUnits);
|
||||
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.amount.type, "number");
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.amount.value, 1);
|
||||
assert.strictEqual(chef.bitShiftRight.argOptions.type.type, "option");
|
||||
assert.ok(Array.isArray(chef.bitShiftRight.argOptions.type.options));
|
||||
assert.strictEqual(chef.bitShiftRight.args.amount.type, "number");
|
||||
assert.strictEqual(chef.bitShiftRight.args.amount.value, 1);
|
||||
assert.strictEqual(chef.bitShiftRight.args.type.type, "option");
|
||||
assert.ok(Array.isArray(chef.bitShiftRight.args.type.options));
|
||||
|
||||
}),
|
||||
|
||||
it("Operation arguments: should list all options excluding subheadings", () => {
|
||||
// First element (subheading) removed
|
||||
assert.equal(chef.convertDistance.argOptions.inputUnits.options[0], "Nanometres (nm)");
|
||||
assert.equal(chef.defangURL.argOptions.process.options[1], "Only full URLs");
|
||||
assert.equal(chef.convertDistance.args.inputUnits.options[0], "Nanometres (nm)");
|
||||
assert.equal(chef.defangURL.args.process.options[1], "Only full URLs");
|
||||
})
|
||||
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue