mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
WIP: start testing ops with various arg types. AESENCRYPT result encoding error
This commit is contained in:
parent
fc1b8917a8
commit
a5d58071cd
4 changed files with 120 additions and 5 deletions
83
test/tests/nodeApi/ops.mjs
Normal file
83
test/tests/nodeApi/ops.mjs
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* eslint no-console: 0 */
|
||||
|
||||
/**
|
||||
* nodeApi.js
|
||||
*
|
||||
* Test node api operations
|
||||
*
|
||||
* @author d98762625 [d98762625@gmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import assert from "assert";
|
||||
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 {
|
||||
ADD,
|
||||
addLineNumbers,
|
||||
adler32Checksum,
|
||||
AESDecrypt,
|
||||
AESEncrypt,
|
||||
} from "../../../src/node/index";
|
||||
import TestRegister from "../../TestRegister";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
|
||||
it("ADD: toggleString argument", () => {
|
||||
const result = ADD("sample input", {
|
||||
key: {
|
||||
string: "some key",
|
||||
option: "Hex"
|
||||
}
|
||||
});
|
||||
assert.equal(result.toString(), "aO[^ZS\u000eW\\^cb");
|
||||
}),
|
||||
|
||||
it("addLineNumbers: No arguments", () => {
|
||||
const result = addLineNumbers("sample input");
|
||||
assert.equal(result.toString(), "1 sample input");
|
||||
}),
|
||||
|
||||
it("adler32Checksum: No args", () => {
|
||||
const result = adler32Checksum("sample input");
|
||||
assert.equal(result.toString(), "1f2304d3");
|
||||
}),
|
||||
|
||||
it("AES decrypt: toggleString and option", () => {
|
||||
const result = AESDecrypt("812c34ae6af353244a63c6ce23b7c34286b60be28ea4645523d4494700e7", {
|
||||
key: {
|
||||
string: "some longer key1",
|
||||
option: "utf8",
|
||||
},
|
||||
iv: {
|
||||
string: "some iv",
|
||||
option: "utf8",
|
||||
},
|
||||
mode: "OFB",
|
||||
});
|
||||
assert.equal(result.toString(), "a slightly longer sampleinput?");
|
||||
}),
|
||||
|
||||
it("AES encrypt: toggleString and options", () => {
|
||||
const result = AESEncrypt("something", {
|
||||
key: {
|
||||
string: "a key that is long enuff",
|
||||
option: "utf8",
|
||||
},
|
||||
iv: {
|
||||
string: "another iv",
|
||||
option: "utf8",
|
||||
},
|
||||
mode: "ECB",
|
||||
output: "Raw",
|
||||
});
|
||||
|
||||
assert.equal(result.toString(), "Ä)\u0005DSa;F£nÐ");
|
||||
})
|
||||
]);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue