diff --git a/src/server/management/lab-routes.ts b/src/server/management/lab-routes.ts index 5c0929e47f..6286a2908a 100644 --- a/src/server/management/lab-routes.ts +++ b/src/server/management/lab-routes.ts @@ -14,6 +14,7 @@ */ import { + ARTIFACT_CLASSES, EVIDENCE_LAYERS, EXECUTION_MODES, EVENT_KINDS, @@ -323,9 +324,10 @@ export async function handleLabRoutes(ctx: ManagementContext): Promise { + const req = new ManagementRequest(`http://127.0.0.1${path}`, { method: "GET" }); + const response = await handleManagementAPI(req, new URL(req.url), config); + expect(response).not.toBeNull(); + return response!; +} + +describe("Compatibility Lab management read filter validation", () => { + test("rejects invalid excluded values instead of silently dropping the filter", async () => { + const response = await apiGet("/api/lab/events?excluded=maybe"); + expect(response.status).toBe(400); + const body = await response.json() as { error: { code: string } }; + expect(body.error.code).toBe("invalid_excluded"); + }); + + test("rejects unsupported artifact classes instead of querying with arbitrary values", async () => { + const response = await apiGet("/api/lab/artifacts?artifactClass=not-real"); + expect(response.status).toBe(400); + const body = await response.json() as { error: { code: string } }; + expect(body.error.code).toBe("invalid_artifact_class"); + }); +});