test(smoke): add comprehensive in-memory HTTP router smoke test
This commit is contained in:
parent
ee02daba79
commit
ed70e4d1cd
60
src/tests/smoke_test.ts
Normal file
60
src/tests/smoke_test.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import { assertEquals } from "jsr:@std/assert@1";
|
||||||
|
import app from "../main.ts";
|
||||||
|
|
||||||
|
Deno.test("[Smoke Test] Core Server Routing & Hypermedia Endpoints", async () => {
|
||||||
|
// 1. Health check
|
||||||
|
const resHealth = await app.fetch(new Request("http://localhost/healthz"));
|
||||||
|
assertEquals(resHealth.status, 200);
|
||||||
|
assertEquals(await resHealth.text(), "OK");
|
||||||
|
|
||||||
|
// 2. Public Login page returns HTML
|
||||||
|
const resLogin = await app.fetch(new Request("http://localhost/login"));
|
||||||
|
assertEquals(resLogin.status, 200);
|
||||||
|
assertEquals(
|
||||||
|
resLogin.headers.get("content-type")?.includes("text/html"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 3. Public Register page returns HTML
|
||||||
|
const resRegister = await app.fetch(new Request("http://localhost/register"));
|
||||||
|
assertEquals(resRegister.status, 200);
|
||||||
|
assertEquals(
|
||||||
|
resRegister.headers.get("content-type")?.includes("text/html"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Public Join page returns HTML
|
||||||
|
const resJoin = await app.fetch(new Request("http://localhost/join"));
|
||||||
|
assertEquals(resJoin.status, 200);
|
||||||
|
assertEquals(
|
||||||
|
resJoin.headers.get("content-type")?.includes("text/html"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 5. Unauthenticated Dashboard redirects to /login
|
||||||
|
const resDash = await app.fetch(
|
||||||
|
new Request("http://localhost/dashboard/sessions"),
|
||||||
|
);
|
||||||
|
assertEquals(resDash.status, 302);
|
||||||
|
assertEquals(resDash.headers.get("location")?.includes("/login"), true);
|
||||||
|
|
||||||
|
// 6. Magic Link Pass without token redirects to /login
|
||||||
|
const resPass = await app.fetch(new Request("http://localhost/pass"));
|
||||||
|
assertEquals(resPass.status, 302);
|
||||||
|
assertEquals(
|
||||||
|
resPass.headers.get("location")?.includes(
|
||||||
|
"/login?error=invalid_or_expired_pass",
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 7. Forward Auth check without host returns 400
|
||||||
|
const resForwardAuth = await app.fetch(
|
||||||
|
new Request("http://localhost/api/forward-auth"),
|
||||||
|
);
|
||||||
|
assertEquals(resForwardAuth.status, 400);
|
||||||
|
|
||||||
|
// 8. Admin route unauthenticated redirects or denies
|
||||||
|
const resAdmin = await app.fetch(new Request("http://localhost/admin/users"));
|
||||||
|
assertEquals(resAdmin.status === 302 || resAdmin.status === 401, true);
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user