mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-28 18:08:15 +03:00
26 lines
593 B
TypeScript
26 lines
593 B
TypeScript
import t from "tap";
|
|
import mockApi from "./mock-api";
|
|
|
|
export function RequireNeutralAuthentication(url: string, method: "GET" | "POST" = "GET") {
|
|
t.test(`Testing authentication for ${method} ${url}.`, async (t) => {
|
|
let res;
|
|
|
|
if (method === "GET") {
|
|
res = await mockApi.get(url);
|
|
} else {
|
|
res = await mockApi.post(url);
|
|
}
|
|
|
|
t.equal(res.status, 403, "Should return 403 immediately.");
|
|
t.equal(
|
|
res.body.description,
|
|
"You are not authorised to perform this action.",
|
|
"Should return an appropriate error message."
|
|
);
|
|
|
|
// CloseAllConnections();
|
|
|
|
t.end();
|
|
});
|
|
}
|