Move ParseIPv4Header regression test to operations suite
This commit is contained in:
parent
367135f65f
commit
ef40b7b137
@ -18,7 +18,6 @@ import {
|
||||
import TestRegister from "../lib/TestRegister.mjs";
|
||||
import "./tests/nodeApi.mjs";
|
||||
import "./tests/operations.mjs";
|
||||
import "./tests/ParseIPv4Header.mjs";
|
||||
import "./tests/PGP.mjs";
|
||||
import "./tests/File.mjs";
|
||||
import "./tests/Dish.mjs";
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
import assert from "assert";
|
||||
import it from "../assertionHandler.mjs";
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
import ParseIPv4Header from "../../../src/core/operations/ParseIPv4Header.mjs";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
it("Parse IPv4 header: regression for Uint8Array.concat crash on truncated raw input", () => {
|
||||
const operation = new ParseIPv4Header();
|
||||
const truncatedHeader = new Uint8Array([0x45, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00]);
|
||||
// The Raw path converts the input into a Uint8Array before checksum header construction.
|
||||
const rawInput = String.fromCharCode(...truncatedHeader);
|
||||
let result;
|
||||
let thrownError;
|
||||
|
||||
try {
|
||||
result = operation.run(rawInput, ["Raw", "Data (raw)"]);
|
||||
} catch (err) {
|
||||
thrownError = err;
|
||||
}
|
||||
|
||||
assert.ok(!(thrownError instanceof TypeError), `Unexpected TypeError: ${thrownError && thrownError.message}`);
|
||||
assert.ifError(thrownError);
|
||||
assert.strictEqual(typeof result, "string");
|
||||
})
|
||||
]);
|
||||
@ -19,5 +19,16 @@ TestRegister.addTests([
|
||||
args: ["Hex", "Data (raw)"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Parse IPv4 header: regression for Uint8Array.concat crash on truncated raw input",
|
||||
input: "\x45\x00\x00\x14\x00\x00\x00\x00\x40\x06\x00\x00",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Parse IPv4 header",
|
||||
args: ["Raw", "Data (raw)"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user