mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
add more wrapper tests for node api
This commit is contained in:
parent
a5d58071cd
commit
ffb65d8ea1
1 changed files with 57 additions and 18 deletions
|
@ -5,6 +5,9 @@
|
||||||
*
|
*
|
||||||
* Test node api operations
|
* Test node api operations
|
||||||
*
|
*
|
||||||
|
* Aim of these tests is to ensure each arg type is
|
||||||
|
* handled correctly by the wrapper.
|
||||||
|
*
|
||||||
* @author d98762625 [d98762625@gmail.com]
|
* @author d98762625 [d98762625@gmail.com]
|
||||||
* @copyright Crown Copyright 2018
|
* @copyright Crown Copyright 2018
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
|
@ -12,17 +15,18 @@
|
||||||
|
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import it from "../assertionHandler";
|
import it from "../assertionHandler";
|
||||||
import Utils from "../../../src/core/Utils";
|
|
||||||
// import chef from "../../../src/node/index";
|
|
||||||
// import OperationError from "../../../src/core/errors/OperationError";
|
|
||||||
// import SyncDish from "../../../src/node/SyncDish";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ADD,
|
ADD,
|
||||||
addLineNumbers,
|
addLineNumbers,
|
||||||
adler32Checksum,
|
adler32Checksum,
|
||||||
AESDecrypt,
|
AESDecrypt,
|
||||||
AESEncrypt,
|
affineCipherDecode,
|
||||||
|
affineCipherEncode,
|
||||||
|
bifidCipherEncode,
|
||||||
|
bitShiftRight,
|
||||||
|
cartesianProduct,
|
||||||
|
CSSMinify,
|
||||||
} from "../../../src/node/index";
|
} from "../../../src/node/index";
|
||||||
import TestRegister from "../../TestRegister";
|
import TestRegister from "../../TestRegister";
|
||||||
|
|
||||||
|
@ -63,21 +67,56 @@ TestRegister.addApiTests([
|
||||||
assert.equal(result.toString(), "a slightly longer sampleinput?");
|
assert.equal(result.toString(), "a slightly longer sampleinput?");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("AES encrypt: toggleString and options", () => {
|
it("AffineCipherDecode: number input", () => {
|
||||||
const result = AESEncrypt("something", {
|
const result = affineCipherDecode("some input", {
|
||||||
key: {
|
a: 7,
|
||||||
string: "a key that is long enuff",
|
b: 4
|
||||||
option: "utf8",
|
|
||||||
},
|
|
||||||
iv: {
|
|
||||||
string: "another iv",
|
|
||||||
option: "utf8",
|
|
||||||
},
|
|
||||||
mode: "ECB",
|
|
||||||
output: "Raw",
|
|
||||||
});
|
});
|
||||||
|
assert.strictEqual(result.toString(), "cuqa ifjgr");
|
||||||
|
}),
|
||||||
|
|
||||||
assert.equal(result.toString(), "Ä)\u0005DSa;F£nÐ");
|
it("affineCipherEncode: number input", () => {
|
||||||
|
const result = affineCipherEncode("some input", {
|
||||||
|
a: 11,
|
||||||
|
b: 6
|
||||||
|
});
|
||||||
|
assert.strictEqual(result.toString(), "weiy qtpsh");
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("bifid cipher encode: string option", () => {
|
||||||
|
const result = bifidCipherEncode("some input", {
|
||||||
|
keyword: "mykeyword",
|
||||||
|
});
|
||||||
|
assert.strictEqual(result.toString(), "nmhs zmsdo");
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("bitShiftRight: number and option", () => {
|
||||||
|
const result = bitShiftRight("some bits to shift", {
|
||||||
|
type: "Arithmetic shift",
|
||||||
|
amount: 1,
|
||||||
|
});
|
||||||
|
assert.strictEqual(result.toString(), "9762\u001014:9\u0010:7\u00109443:");
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("cartesianProduct: binary string", () => {
|
||||||
|
const result = cartesianProduct("1:2\\n\\n3:4", {
|
||||||
|
itemDelimiter: ":",
|
||||||
|
});
|
||||||
|
assert.strictEqual(result.toString(), "(1,3):(1,4):(2,3):(2,4)");
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("CSS minify: boolean", () => {
|
||||||
|
const input = `header {
|
||||||
|
// comment
|
||||||
|
width: 100%;
|
||||||
|
color: white;
|
||||||
|
}`;
|
||||||
|
const result = CSSMinify(input, {
|
||||||
|
preserveComments: true,
|
||||||
|
});
|
||||||
|
assert.strictEqual(result.toString(), "header {// comment width: 100%;color: white;}");
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue