chore: refactor crypto service tests for readability and lint compliance

This commit is contained in:
Mathis HERRIOT
2026-01-08 12:41:35 +01:00
parent 48b233eae4
commit a6fdbdb06d

View File

@@ -7,11 +7,13 @@ jest.mock("@noble/post-quantum/ml-kem.js", () => ({
publicKey: new Uint8Array(1184),
secretKey: new Uint8Array(2400),
})),
encapsulate: jest.fn((pk: Uint8Array) => ({
encapsulate: jest.fn((_pk: Uint8Array) => ({
cipherText: new Uint8Array(1088),
sharedSecret: new Uint8Array(32),
})),
decapsulate: jest.fn((ct: Uint8Array, sk: Uint8Array) => new Uint8Array(32)),
decapsulate: jest.fn(
(_ct: Uint8Array, _sk: Uint8Array) => new Uint8Array(32),
),
},
}));
@@ -51,7 +53,10 @@ jest.mock("jose", () => ({
if (jws.includes("tampered") || jws.split(".").length !== 3) {
throw new Error("Tampered or invalid content");
}
const payload = jws === "mocked.jws.token" ? "Important document content" : "Original content";
const payload =
jws === "mocked.jws.token"
? "Important document content"
: "Original content";
return Promise.resolve({
payload: new TextEncoder().encode(payload),
});
@@ -149,7 +154,7 @@ describe("CryptoService", () => {
it("should fail to verify tampered content", async () => {
const content = "Original content";
const jws = await service.signContent(content);
const parts = jws.split(".");
const _parts = jws.split(".");
// Tamper with the payload (middle part)
const tamperedJws = "this.is.tampered";