Route portal login hashing through authenticated signer
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user