mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-14 12:38:45 +00:00
test: adapt caddy testing environment into a smoke test
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
27
test/caddy/test.mjs
Normal file
27
test/caddy/test.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
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)}`);
|
||||
}
|
||||
Reference in New Issue
Block a user