mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-05 16:28:17 +00:00
27 lines
642 B
JavaScript
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)}`);
|
|
} |