Files
anubis-mirror/test/caddy/test.mjs
2025-07-18 22:02:34 -04:00

27 lines
643 B
JavaScript

async function testWithUserAgent(userAgent) {
const statusCode =
await fetch("https://relayd.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)}`);
}