Fix: use strict bool check for auth

This commit is contained in:
shamoon
2026-08-07 07:51:21 -07:00
parent 670d0a8e40
commit b33c88dba1
4 changed files with 17 additions and 3 deletions
+10
View File
@@ -100,6 +100,16 @@ describe("middleware", () => {
expect(res).toEqual({ type: "next" });
});
it.each(["false", "0", "no", "off", ""])("treats HOMEPAGE_AUTH_ENABLED=%j as disabled", async (value) => {
process.env.HOMEPAGE_AUTH_ENABLED = value;
const middleware = await loadMiddleware();
const res = await middleware(createReq("localhost:3000", "http://localhost:3000/some"));
expect(getToken).not.toHaveBeenCalled();
expect(res).toEqual({ type: "next" });
});
it("redirects to signin when auth is enabled and no token is present", async () => {
process.env.HOMEPAGE_AUTH_ENABLED = "true";
process.env.HOMEPAGE_AUTH_SECRET = "secret";