Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+14
-7
@@ -1,13 +1,7 @@
|
||||
// @vitest-environment node
|
||||
import { createHash } from "node:crypto";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import {
|
||||
assertPasswordPolicy,
|
||||
isPasswordPwned,
|
||||
loadPasswordPolicy,
|
||||
validatePassword,
|
||||
validatePasswordPolicy,
|
||||
} from "./password-policy.server.js";
|
||||
import { assertPasswordPolicy, isPasswordPwned, loadPasswordPolicy, validatePassword, validatePasswordPolicy } from "./password-policy.server.js";
|
||||
|
||||
function sha1Upper(value: string): string {
|
||||
return createHash("sha1").update(value).digest("hex").toUpperCase();
|
||||
@@ -123,6 +117,19 @@ describe("validatePassword", () => {
|
||||
expect(result.hibpBypassed).toBe(true);
|
||||
});
|
||||
|
||||
test("HIBP requests have a real abort signal, reject redirects and bound response bodies", async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async () => new Response("x".repeat(128 * 1024 + 1)));
|
||||
const policy = { ...ALL_FLAGS_OFF, hibpCheck: true };
|
||||
|
||||
const result = await validatePassword("Long-Enough-Password", {}, { policy, fetcher });
|
||||
|
||||
expect(result.hibpBypassed).toBe(true);
|
||||
expect(fetcher).toHaveBeenCalledWith(
|
||||
expect.stringMatching(/^https:\/\/api\.pwnedpasswords\.com\/range\//u),
|
||||
expect.objectContaining({ redirect: "error", signal: expect.any(AbortSignal) })
|
||||
);
|
||||
});
|
||||
|
||||
test("Unicode passwords are length-counted by JS string length (sufficient for the policy)", async () => {
|
||||
const policy = { ...ALL_FLAGS_OFF, minLength: 8 };
|
||||
const result = await validatePassword("Pässwört✓123", {}, { policy });
|
||||
|
||||
Reference in new issue
Block a user