Files
mtusi2026lab7/student-tests/openobserve-request-path.test.ts

28 lines
1.0 KiB
TypeScript

import { test, expect } from "bun:test";
import { validateOpenObservePath } from "../scripts/openobserve-request-path";
test("native URLSearchParams PromQL spaces stay valid before any credential or process port", () => {
const path =
"/api/default/prometheus/api/v1/query?" +
new URLSearchParams({
query: "histogram_quantile(0.95,sum by(le)(http_duration_bucket))",
});
expect(() => validateOpenObservePath(path)).not.toThrow();
});
for (const path of [
"https://foreign/api/default/streams",
"/api/foreign/streams",
"/api/default/streams\r\nX: bad",
"/api/default/_search#fragment",
"/api/default/space in path",
])
test(`rejects invalid request URI ${JSON.stringify(path)}`, () => {
expect(() => validateOpenObservePath(path)).toThrow(
"INVALID_OPENOBSERVE_REQUEST_PATH",
);
});
test("pinned plugin organization editor endpoint remains available", () => {
expect(() =>
validateOpenObservePath("/api/organizations?page_num=0&page_size=1000"),
).not.toThrow();
});