release: WRNexusJS 0.4.0
This commit is contained in:
@@ -3,7 +3,11 @@ import { evaluateCaptchaRisk, shouldRequireCaptcha, validCaptchaGrant } from "..
|
||||
|
||||
describe("adaptive CAPTCHA policy", () => {
|
||||
test("raises risk from automation signals", () => {
|
||||
const result = evaluateCaptchaRisk({ failedAttempts: 3, completionMs: 200, suspiciousHeaders: true });
|
||||
const result = evaluateCaptchaRisk({
|
||||
failedAttempts: 3,
|
||||
completionMs: 200,
|
||||
suspiciousHeaders: true,
|
||||
});
|
||||
expect(result.challenge).toBe(true);
|
||||
expect(result.reasons).toContain("too-fast");
|
||||
});
|
||||
@@ -14,7 +18,12 @@ describe("adaptive CAPTCHA policy", () => {
|
||||
});
|
||||
|
||||
test("accepts an unexpired route grant", () => {
|
||||
const grant = validCaptchaGrant([{ action: "page", routeGroup: "/reports", provider: "self-hosted", expiresAt: 200 }], "page", 100, "/reports");
|
||||
const grant = validCaptchaGrant(
|
||||
[{ action: "page", routeGroup: "/reports", provider: "self-hosted", expiresAt: 200 }],
|
||||
"page",
|
||||
100,
|
||||
"/reports",
|
||||
);
|
||||
expect(grant?.provider).toBe("self-hosted");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user