mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 16:44:45 +00:00
test: verify gateway HTTP arguments
This commit is contained in:
@@ -318,7 +318,8 @@ describe("fuzz: readJsonBodyOrError", () => {
|
||||
}
|
||||
|
||||
const maxBytes = randInt(rng, 1, 1 << 20);
|
||||
const result = await readJsonBodyOrError(makeRequest(), res, maxBytes);
|
||||
const req = makeRequest();
|
||||
const result = await readJsonBodyOrError(req, res, maxBytes);
|
||||
if (pick === 0) {
|
||||
expect(result).toEqual(expectedValue);
|
||||
} else {
|
||||
@@ -326,7 +327,7 @@ describe("fuzz: readJsonBodyOrError", () => {
|
||||
expect(res.statusCode).toBe(expectedStatus);
|
||||
expect(end).toHaveBeenCalledWith(expectedBody);
|
||||
}
|
||||
expect(readJsonBodyMock).toHaveBeenLastCalledWith(expect.anything(), maxBytes);
|
||||
expect(readJsonBodyMock).toHaveBeenLastCalledWith(req, maxBytes);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -107,6 +107,7 @@ describe("handleGatewayPostJsonEndpoint", () => {
|
||||
const mockedSendMissingScopeForbidden = vi.mocked(sendMissingScopeForbidden);
|
||||
mockedSendMissingScopeForbidden.mockClear();
|
||||
vi.mocked(readJsonBodyOrError).mockClear();
|
||||
const res = {} as unknown as ServerResponse;
|
||||
|
||||
const result = await handleGatewayPostJsonEndpoint(
|
||||
{
|
||||
@@ -114,7 +115,7 @@ describe("handleGatewayPostJsonEndpoint", () => {
|
||||
method: "POST",
|
||||
headers: { host: "localhost" },
|
||||
} as unknown as IncomingMessage,
|
||||
{} as unknown as ServerResponse,
|
||||
res,
|
||||
{
|
||||
pathname: "/v1/ok",
|
||||
auth: {} as unknown as ResolvedGatewayAuth,
|
||||
@@ -127,10 +128,7 @@ describe("handleGatewayPostJsonEndpoint", () => {
|
||||
expect(vi.mocked(authorizeOperatorScopesForMethod)).toHaveBeenCalledWith("chat.send", [
|
||||
"operator.approvals",
|
||||
]);
|
||||
expect(mockedSendMissingScopeForbidden).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
"operator.write",
|
||||
);
|
||||
expect(mockedSendMissingScopeForbidden).toHaveBeenCalledWith(res, "operator.write");
|
||||
expect(vi.mocked(readJsonBodyOrError)).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -368,9 +368,9 @@ test("sessions.delete returns unavailable when active run does not stop", async
|
||||
>;
|
||||
expect(store["agent:main:discord:group:dev"]?.sessionId).toBe("sess-active");
|
||||
const filesAfterDeleteAttempt = await fs.readdir(dir);
|
||||
expect(filesAfterDeleteAttempt).not.toContainEqual(
|
||||
expect.stringMatching(/^sess-active\.jsonl\.deleted\./),
|
||||
);
|
||||
expect(
|
||||
filesAfterDeleteAttempt.filter((fileName) => fileName.startsWith("sess-active.jsonl.deleted.")),
|
||||
).toEqual([]);
|
||||
|
||||
ws.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user