mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:24:32 +00:00
test(gateway): dedupe health status scope test setup
This commit is contained in:
@@ -467,7 +467,7 @@ describe("gateway healthHandlers.status scope handling", () => {
|
|||||||
vi.mocked(status.getStatusSummary).mockClear();
|
vi.mocked(status.getStatusSummary).mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("requests redacted status for non-admin clients", async () => {
|
async function runHealthStatus(scopes: string[]) {
|
||||||
const respond = vi.fn();
|
const respond = vi.fn();
|
||||||
const status = await import("../../commands/status.js");
|
const status = await import("../../commands/status.js");
|
||||||
const { healthHandlers } = await import("./health.js");
|
const { healthHandlers } = await import("./health.js");
|
||||||
@@ -477,27 +477,22 @@ describe("gateway healthHandlers.status scope handling", () => {
|
|||||||
params: {} as never,
|
params: {} as never,
|
||||||
respond: respond as never,
|
respond: respond as never,
|
||||||
context: {} as never,
|
context: {} as never,
|
||||||
client: { connect: { role: "operator", scopes: ["operator.read"] } } as never,
|
client: { connect: { role: "operator", scopes } } as never,
|
||||||
isWebchatConnect: () => false,
|
isWebchatConnect: () => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return { respond, status };
|
||||||
|
}
|
||||||
|
|
||||||
|
it("requests redacted status for non-admin clients", async () => {
|
||||||
|
const { respond, status } = await runHealthStatus(["operator.read"]);
|
||||||
|
|
||||||
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: false });
|
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: false });
|
||||||
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("requests full status for admin clients", async () => {
|
it("requests full status for admin clients", async () => {
|
||||||
const respond = vi.fn();
|
const { respond, status } = await runHealthStatus(["operator.admin"]);
|
||||||
const status = await import("../../commands/status.js");
|
|
||||||
const { healthHandlers } = await import("./health.js");
|
|
||||||
|
|
||||||
await healthHandlers.status({
|
|
||||||
req: {} as never,
|
|
||||||
params: {} as never,
|
|
||||||
respond: respond as never,
|
|
||||||
context: {} as never,
|
|
||||||
client: { connect: { role: "operator", scopes: ["operator.admin"] } } as never,
|
|
||||||
isWebchatConnect: () => false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: true });
|
expect(vi.mocked(status.getStatusSummary)).toHaveBeenCalledWith({ includeSensitive: true });
|
||||||
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
expect(respond).toHaveBeenCalledWith(true, { ok: true }, undefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user