feat: improve resource reconciliation and observability

This commit is contained in:
2026-09-11 10:51:57 +00:00 Unverified
parent 0067a2cdcd
commit e3df2f4d76
28 changed files with 2407 additions and 217 deletions
+46
View File
@@ -21,6 +21,52 @@ function request(
}
describe("kuber API authentication", () => {
test("logs every request start and completion without changing responses", async () => {
const logs: Record<string, unknown>[] = [];
const app = createApp({
store: new MemoryAuthStore(),
requestId: () => "request-log-id",
logger: {
error: () => {},
log: (entry) => logs.push(entry),
},
});
const response = await app(request("/api/v2/health"));
expect(response.status).toBe(200);
expect(logs).toEqual(
expect.arrayContaining([
expect.objectContaining({
event: "kuber.server.request.start",
requestId: "request-log-id",
method: "GET",
pathname: "/api/v2/health",
}),
expect.objectContaining({
event: "kuber.server.request.end",
requestId: "request-log-id",
status: 200,
durationMs: expect.any(Number),
}),
]),
);
});
test("ignores request logging failures", async () => {
const app = createApp({
store: new MemoryAuthStore(),
logger: {
error: () => {},
log: () => {
throw new Error("logger unavailable");
},
},
});
expect((await app(request("/api/v2/health"))).status).toBe(200);
});
test("logs in, resolves identity, and revokes the session", async () => {
const store = new MemoryAuthStore();
await store.putUser({