Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

test(ai-gateway): reject analytics label requests from another organization (#19506)

Tobias Wochinger2c70d18bcdb3
diff --git a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
index 9a4a2bba03..ed2516830b 100644
--- a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
+++ b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts
@@ -1060,6 +1060,23 @@ describe("AI gateway control plane", () => {
).rejects.toMatchObject({ code: "FORBIDDEN" });
});
+ it("rejects analytics label requests for another organization", async () => {
+ const owner = await prepare();
+ const other = await prepare();
+ await owner.caller.aiGateway.createApiKey({
+ orgId: owner.org.id,
+ name: "Owner key",
+ metadata: {},
+ });
+
+ await expect(
+ other.caller.aiGateway.getAnalyticsLabels({ orgId: owner.org.id }),
+ ).rejects.toMatchObject({
+ code: "UNAUTHORIZED",
+ message: "User is not a member of this organization",
+ });
+ });
+
it("creates, lists, and revokes only associated organization keys", async () => {
const { caller, org } = await prepare();
const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);