mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 06:55:08 -04:00
add all options to argOptions. Add some extra test case for Zip
This commit is contained in:
parent
a1b116d2f5
commit
b48a55bd74
3 changed files with 45 additions and 11 deletions
|
@ -141,9 +141,21 @@ function createArgOptions(op) {
|
||||||
const result = {};
|
const result = {};
|
||||||
op.args.forEach((a) => {
|
op.args.forEach((a) => {
|
||||||
if (a.type === "option" || a.type === "editableOption") {
|
if (a.type === "option" || a.type === "editableOption") {
|
||||||
result[sentenceToCamelCase(a.name)] = removeSubheadingsFromArray(a.value);
|
result[sentenceToCamelCase(a.name)] = {
|
||||||
|
type: a.type,
|
||||||
|
options: removeSubheadingsFromArray(a.value)
|
||||||
|
};
|
||||||
} else if (a.type === "toggleString") {
|
} else if (a.type === "toggleString") {
|
||||||
result[sentenceToCamelCase(a.name)] = removeSubheadingsFromArray(a.toggleValues);
|
result[sentenceToCamelCase(a.name)] = {
|
||||||
|
type: a.type,
|
||||||
|
value: a.value,
|
||||||
|
toggleValues: removeSubheadingsFromArray(a.toggleValues),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
result[sentenceToCamelCase(a.name)] = {
|
||||||
|
type: a.type,
|
||||||
|
value: a.value,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -398,22 +398,33 @@ TestRegister.addApiTests([
|
||||||
|
|
||||||
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
|
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
|
||||||
assert.ok(chef.toCharcode.argOptions);
|
assert.ok(chef.toCharcode.argOptions);
|
||||||
assert.deepEqual(chef.unzip.argOptions, {});
|
assert.deepEqual(chef.unzip.argOptions, {
|
||||||
|
password: {
|
||||||
|
type: "binaryString",
|
||||||
|
value: "",
|
||||||
|
},
|
||||||
|
verifyResult: {
|
||||||
|
type: "boolean",
|
||||||
|
value: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("Operation arguments: should have key for each array-based argument in operation", () => {
|
it("Operation arguments: should have key for each argument in operation", () => {
|
||||||
assert.ok(chef.convertDistance.argOptions.inputUnits);
|
assert.ok(chef.convertDistance.argOptions.inputUnits);
|
||||||
assert.ok(chef.convertDistance.argOptions.outputUnits);
|
assert.ok(chef.convertDistance.argOptions.outputUnits);
|
||||||
|
|
||||||
assert.ok(chef.bitShiftRight.argOptions.type);
|
assert.strictEqual(chef.bitShiftRight.argOptions.amount.type, "number");
|
||||||
// is a number type, so not included.
|
assert.strictEqual(chef.bitShiftRight.argOptions.amount.value, 1);
|
||||||
assert.equal(chef.bitShiftRight.argOptions.amount, undefined);
|
assert.strictEqual(chef.bitShiftRight.argOptions.type.type, "option");
|
||||||
|
assert.ok(Array.isArray(chef.bitShiftRight.argOptions.type.options));
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("Operation arguments: should list all options excluding subheadings", () => {
|
it("Operation arguments: should list all options excluding subheadings", () => {
|
||||||
// First element (subheading) removed
|
// First element (subheading) removed
|
||||||
assert.equal(chef.convertDistance.argOptions.inputUnits[0], "Nanometres (nm)");
|
assert.equal(chef.convertDistance.argOptions.inputUnits.options[0], "Nanometres (nm)");
|
||||||
assert.equal(chef.defangURL.argOptions.process[1], "Only full URLs");
|
assert.equal(chef.defangURL.argOptions.process.options[1], "Only full URLs");
|
||||||
})
|
})
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1002,8 +1002,8 @@ ExifImageHeight: 57`);
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.strictEqual(zipped.type, 7);
|
assert.strictEqual(zipped.type, 7);
|
||||||
assert.equal(zipped.value.data.toString().indexOf("sample.zip"), 30);
|
assert.ok(zipped.value.data.toString().includes("sample.zip"));
|
||||||
assert.equal(zipped.value.data.toString().indexOf("added"), 122);
|
assert.ok(zipped.value.data.toString().includes("added"));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("Unzip", () => {
|
it("Unzip", () => {
|
||||||
|
@ -1018,5 +1018,16 @@ ExifImageHeight: 57`);
|
||||||
assert.equal(unzipped.value[0].name, "zipped.zip");
|
assert.equal(unzipped.value[0].name, "zipped.zip");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
it("Unzip with password", () => {
|
||||||
|
const zipped = chef.zip("some content", {
|
||||||
|
password: "abcd",
|
||||||
|
});
|
||||||
|
const unzipped = chef.unzip(zipped, {
|
||||||
|
password: "abcd",
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(unzipped.value[0].data, "some content");
|
||||||
|
}),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue