Files
anubis-mirror/test/caddy/test.mjs
Xe Iaso a47e781d91 test(caddy): fix automated testing
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-07-19 04:44:34 +00:00

27 lines
642 B
JavaScript

async function testWithUserAgent(userAgent) {
const statusCode =
await fetch("https://caddy.local.cetacean.club:8443/reqmeta", {
headers: {
"User-Agent": userAgent,
}
})
.then(resp => resp.status);
return statusCode;
}
const codes = {
Mozilla: await testWithUserAgent("Mozilla"),
curl: await testWithUserAgent("curl"),
}
const expected = {
Mozilla: 401,
curl: 200,
};
console.log("Mozilla:", codes.Mozilla);
console.log("curl: ", codes.curl);
if (JSON.stringify(codes) !== JSON.stringify(expected)) {
throw new Error(`wanted ${JSON.stringify(expected)}, got: ${JSON.stringify(codes)}`);
}