mirror of
https://github.com/gchq/CyberChef
synced 2024-11-14 08:37:07 +00:00
Tidied up UI tests
This commit is contained in:
parent
8e37fec8f8
commit
fb3eceaee0
2 changed files with 26 additions and 51 deletions
|
@ -14,7 +14,8 @@
|
|||
},
|
||||
"desiredCapabilities": {
|
||||
"browserName": "chrome"
|
||||
}
|
||||
},
|
||||
"enable_fail_fast": true
|
||||
},
|
||||
|
||||
"dev": {
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = {
|
|||
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex"]);
|
||||
testOp(browser, "AND", "test input", "4$04 $044", [{ "option": "Hex", "string": "34" }]);
|
||||
testOp(browser, "Add line numbers", "test input", "1 test input");
|
||||
testOp(browser, ["From Hex", "Add Text To Image", "To Base64"], Images.PNG_HEX, Images.PNG_CHEF_B64, ["Chef", "Center", "Middle", 0, 0, 16]);
|
||||
testOp(browser, ["From Hex", "Add Text To Image", "To Base64"], Images.PNG_HEX, Images.PNG_CHEF_B64, [[], ["Chef", "Center", "Middle", 0, 0, 16], []]);
|
||||
testOp(browser, "Adler-32 Checksum", "test input", "16160411");
|
||||
testOp(browser, "Affine Cipher Decode", "test input", "rcqr glnsr", [1, 2]);
|
||||
testOp(browser, "Affine Cipher Encode", "test input", "njln rbfpn", [2, 1]);
|
||||
|
@ -49,8 +49,8 @@ module.exports = {
|
|||
testOp(browser, "Blowfish Encrypt", "test input", "f0fadbd1d90d774f714248cf26b96410", [{"option": "Hex", "string": "1234567801234567"}, {"option": "Hex", "string": "0011223344556677"}, "CBC", "Raw", "Hex"]);
|
||||
testOp(browser, ["From Hex", "Blur Image", "To Base64"], Images.PNG_HEX, Images.PNG_BLUR_B64);
|
||||
// testOp(browser, "Bombe", "test input", "test_output");
|
||||
testOp(browser, "Bzip2 Compress", "test input", "BZh91AY&SYÏ........@..!N. .!.Â.À.3..ß.rE8P.Ï...");
|
||||
testOp(browser, ["From Hex", "Bzip2 Decompress"], "425a68393141592653597b0884b7000003038000008200ce00200021a647a4218013709517c5dc914e14241ec2212dc0", "test_output", [true]);
|
||||
testOp(browser, ["Bzip2 Compress", "To Hex"], "test input", "42 5a 68 39 31 41 59 26 53 59 cf 96 82 1d 00 00 03 91 80 40 00 02 21 4e 00 20 00 21 90 c2 10 c0 88 33 92 8e df 17 72 45 38 50 90 cf 96 82 1d");
|
||||
testOp(browser, ["From Hex", "Bzip2 Decompress"], "425a68393141592653597b0884b7000003038000008200ce00200021a647a4218013709517c5dc914e14241ec2212dc0", "test_output", [[], [true]]);
|
||||
// testOp(browser, "CRC-16 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "CRC-32 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "CRC-8 Checksum", "test input", "test_output");
|
||||
|
@ -379,68 +379,43 @@ module.exports = {
|
|||
* Clears the current recipe and bakes a new operation.
|
||||
*
|
||||
* @param {Browser} browser - Nightwatch client
|
||||
* @param {string|Array<string>} opName - name of operation to be tested, array for pre & post ops
|
||||
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
|
||||
* @param {string} input - input text for test
|
||||
* @param {Array.<string>} args - arguments for test
|
||||
* @param {Array<string>|Array<Array<string>>} args - aarguments, nested if multiple ops
|
||||
*/
|
||||
function bakeOp(browser, opName, input, args=[]) {
|
||||
let recipeConfig;
|
||||
|
||||
let op, recipeConfig;
|
||||
/*
|
||||
* Create recipeConfig as single operation
|
||||
* or wrapped with a pre-op and
|
||||
* possibly a post-op too
|
||||
*/
|
||||
if (typeof(opName) === "string") {
|
||||
op = opName;
|
||||
recipeConfig = JSON.stringify([{
|
||||
"op": opName,
|
||||
"args": args
|
||||
}]);
|
||||
} else if (opName.length === 2) {
|
||||
op = opName[1];
|
||||
recipeConfig = JSON.stringify([{
|
||||
"op": opName[0],
|
||||
"args": []
|
||||
}, {
|
||||
"op": opName[1],
|
||||
"args": args
|
||||
}]);
|
||||
} else if (opName instanceof Array) {
|
||||
recipeConfig = JSON.stringify(
|
||||
opName.map((op, i) => {
|
||||
return {
|
||||
op: op,
|
||||
args: args.length ? args[i] : []
|
||||
};
|
||||
})
|
||||
);
|
||||
} else {
|
||||
op = opName[1];
|
||||
recipeConfig = JSON.stringify([{
|
||||
"op": opName[0],
|
||||
"args": []
|
||||
}, {
|
||||
"op": opName[1],
|
||||
"args": args
|
||||
}, {
|
||||
"op": opName[2],
|
||||
"args": []
|
||||
}]);
|
||||
throw new Error("Invalid operation type. Must be string or array of strings. Received: " + typeof(opName));
|
||||
}
|
||||
|
||||
browser
|
||||
.useCss()
|
||||
.click("#clr-recipe")
|
||||
.click("#clr-io")
|
||||
.perform(function() {
|
||||
console.log("\nCurrent Operation: ", op);
|
||||
})
|
||||
.waitForElementNotPresent("#rec-list li.operation")
|
||||
.expect.element("#input-text").to.have.property("value").that.equals("");
|
||||
|
||||
let currentUrl;
|
||||
browser
|
||||
.urlHash("recipe=" + recipeConfig)
|
||||
// get the current URL
|
||||
.url(function(result) {
|
||||
currentUrl = result;
|
||||
})
|
||||
// and put it out
|
||||
.perform(function() {
|
||||
console.log("Current URL: ", currentUrl.value);
|
||||
console.log(`Current test: ${opName}`);
|
||||
})
|
||||
.urlHash("recipe=" + recipeConfig)
|
||||
.setValue("#input-text", input)
|
||||
.waitForElementPresent("#rec-list li.operation")
|
||||
.expect.element("#input-text").to.have.property("value").that.equals(input);
|
||||
|
@ -458,10 +433,10 @@ function bakeOp(browser, opName, input, args=[]) {
|
|||
* Clears the current recipe and tests a new operation.
|
||||
*
|
||||
* @param {Browser} browser - Nightwatch client
|
||||
* @param {string|Array<string>} opName - name of operation to be tested, array for pre & post ops
|
||||
* @param {string} input - input text for test
|
||||
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
|
||||
* @param {string} input - input text
|
||||
* @param {string} output - expected output
|
||||
* @param {Array.<string>} args - arguments for test
|
||||
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
|
||||
*/
|
||||
function testOp(browser, opName, input, output, args=[]) {
|
||||
|
||||
|
@ -478,14 +453,13 @@ function testOp(browser, opName, input, output, args=[]) {
|
|||
* Clears the current recipe and tests a new operation.
|
||||
*
|
||||
* @param {Browser} browser - Nightwatch client
|
||||
* @param {string} opName - name of operation to be tested
|
||||
* @param {string} input - input text for test
|
||||
* @param {string|Array<string>} opName - name of operation to be tested array for multiple ops
|
||||
* @param {string} input - input text
|
||||
* @param {string} cssSelector - CSS selector for HTML output
|
||||
* @param {string} output - expected output
|
||||
* @param {Array.<string>} args - arguments for test
|
||||
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
|
||||
*/
|
||||
function testOpHtml(browser, opName, input, cssSelector, output, args=[]) {
|
||||
|
||||
bakeOp(browser, opName, input, args);
|
||||
|
||||
if (typeof output === "string") {
|
||||
|
|
Loading…
Reference in a new issue