Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { resolveCaptchaConfig, getSitekey, isCaptchaConfigured } from "./config.js";
|
||||
|
||||
describe("resolveCaptchaConfig", () => {
|
||||
it("maps env vars to config", () => {
|
||||
const cfg = resolveCaptchaConfig({
|
||||
MCAPTCHA_INSTANCE_URL: "https://captcha.tool-ctrl.de",
|
||||
MCAPTCHA_ACCOUNT_SECRET: "secret",
|
||||
MCAPTCHA_SITEKEY_LOGIN: "login-key",
|
||||
MCAPTCHA_SITEKEY_FORMS: "forms-key",
|
||||
MCAPTCHA_SITEKEY_BOOKING: "booking-key",
|
||||
});
|
||||
expect(cfg.provider).toBe("mcaptcha");
|
||||
expect(cfg.instanceUrl).toBe("https://captcha.tool-ctrl.de");
|
||||
expect(getSitekey(cfg, "login")).toBe("login-key");
|
||||
expect(getSitekey(cfg, "booking")).toBe("booking-key");
|
||||
expect(isCaptchaConfigured(cfg)).toBe(true);
|
||||
});
|
||||
|
||||
it("defaults failOpen to true and respects explicit false", () => {
|
||||
expect(resolveCaptchaConfig({}).failOpen).toBe(true);
|
||||
expect(resolveCaptchaConfig({ CAPTCHA_FAIL_OPEN: "false" }).failOpen).toBe(false);
|
||||
expect(resolveCaptchaConfig({ CAPTCHA_FAIL_OPEN: "true" }).failOpen).toBe(true);
|
||||
});
|
||||
|
||||
it("treats blank env values as undefined and reports unconfigured", () => {
|
||||
const cfg = resolveCaptchaConfig({ MCAPTCHA_INSTANCE_URL: " ", MCAPTCHA_ACCOUNT_SECRET: "" });
|
||||
expect(cfg.instanceUrl).toBeUndefined();
|
||||
expect(cfg.accountSecret).toBeUndefined();
|
||||
expect(isCaptchaConfigured(cfg)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user