From 7c594d1c05190e0aa270804a937041e5cdf3007a Mon Sep 17 00:00:00 2001 From: Julian Speckmann <176780813+KingIronMan2011@users.noreply.github.com> Date: Fri, 2 Jan 2026 04:27:08 +0100 Subject: [PATCH] Changes made from review --- test/backend-test/test-ntlm-hash.js | 47 ----------------------------- test/backend-test/test-ntlm.js | 29 ++++++++++++++++++ 2 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 test/backend-test/test-ntlm-hash.js create mode 100644 test/backend-test/test-ntlm.js diff --git a/test/backend-test/test-ntlm-hash.js b/test/backend-test/test-ntlm-hash.js deleted file mode 100644 index 9fd5d7805..000000000 --- a/test/backend-test/test-ntlm-hash.js +++ /dev/null @@ -1,47 +0,0 @@ -const test = require("node:test"); -const assert = require("node:assert"); - -const hash = require("../../server/modules/axios-ntlm/lib/hash"); - -test("Test createPseudoRandomValue", async (t) => { - await t.test("Should create string of specified length", () => { - const length = 16; - const result = hash.createPseudoRandomValue(length); - assert.strictEqual(result.length, length, "Result should have the specified length"); - assert.strictEqual(typeof result, "string", "Result should be a string"); - }); - - await t.test("Should create string of different lengths", () => { - const lengths = [ 8, 16, 32, 64 ]; - for (const length of lengths) { - const result = hash.createPseudoRandomValue(length); - assert.strictEqual(result.length, length, `Result should have length ${length}`); - } - }); - - await t.test("Should return valid hexadecimal string", () => { - const length = 32; - const result = hash.createPseudoRandomValue(length); - const hexRegex = /^[0-9a-f]+$/; - assert.ok(hexRegex.test(result), "Result should be a valid hexadecimal string"); - }); - - await t.test("Should create different values on multiple calls", () => { - const length = 16; - const results = new Set(); - const iterations = 10; - - for (let i = 0; i < iterations; i++) { - results.add(hash.createPseudoRandomValue(length)); - } - - // Stronger uniqueness assertion: expect all values to be unique for cryptographic RNG - assert.strictEqual(results.size, iterations, "All generated values should be unique"); - }); - - await t.test("Should handle length of 0", () => { - const result = hash.createPseudoRandomValue(0); - assert.strictEqual(result.length, 0, "Result should be empty string for length 0"); - assert.strictEqual(result, "", "Result should be empty string"); - }); -}); diff --git a/test/backend-test/test-ntlm.js b/test/backend-test/test-ntlm.js new file mode 100644 index 000000000..94200fc46 --- /dev/null +++ b/test/backend-test/test-ntlm.js @@ -0,0 +1,29 @@ +const test = require("node:test"); +const assert = require("node:assert"); + +const hash = require("../../server/modules/axios-ntlm/lib/hash"); + +test("Test createPseudoRandomValue", async (t) => { + await t.test("Should create string of different lengths", () => { + const lengths = [ 0, 8, 16, 32, 64 ]; + const hexRegex = /^[0-9a-f]*$/; + for (const length of lengths) { + const result = hash.createPseudoRandomValue(length); + assert.strictEqual(result.length, length, `Result should have length ${length}`); + assert.strictEqual(typeof result, "string", "Result should be a string"); + assert.ok(hexRegex.test(result), "Result should be a valid hexadecimal string"); + } + }); + + await t.test("Should create different values on multiple calls", () => { + const length = 16; + const results = new Set(); + const iterations = 10; + + for (let i = 0; i < iterations; i++) { + results.add(hash.createPseudoRandomValue(length)); + } + + assert.strictEqual(results.size, iterations, "All generated values should be unique"); + }); +}); \ No newline at end of file