Route portal login hashing through authenticated signer

This commit is contained in:
2026-03-13 14:01:18 +00:00
parent 82f891ada8
commit 6094874851
4 changed files with 63 additions and 13 deletions
+20
View File
@@ -112,6 +112,26 @@ test("gethash_api returns hash for valid api path", async () => {
});
});
test("gethash_api returns hash for allow-listed getportallogin path", async () => {
const mod = loadModule("pages/api/endpoint/gethash_api.js", {
hashAPIPath: () => "&hash=login",
getSession: async () => ({ user: { id: "u1" } }),
nextConnect: createNextConnectMock(),
middleware: () => {}
});
const req = {
query: { path: "/api/endpoint/getportallogin_api?emailAddress=a@b.com" }
};
const res = createRes();
await mod.default.handler(req, res);
assert.strictEqual(res.state.statusCode, 200);
assert.deepStrictEqual(JSON.parse(JSON.stringify(res.state.jsonBody)), {
hash: "&hash=login"
});
});
test("gethash_api rejects unauthenticated requests with 401", async () => {
const mod = loadModule("pages/api/endpoint/gethash_api.js", {
hashAPIPath: () => "&hash=expected",