mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-23 15:42:12 +03:00
Validated on the combined batch board over release/v3.8.50 tip d91238b7: static gates clean, typecheck:core clean, focused tests green.
Strict schema + {sanitized, rejected} DB boundary — silent validation degradation now answers 400 with the offending keys. Caller audit done: only the providers write path consumes the sanitizers. Thank you @maxmad64bis!
25 lines
906 B
TypeScript
25 lines
906 B
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
sanitizeRateLimitOverrides,
|
|
sanitizeQuotaWindowThresholds,
|
|
} from "@/lib/db/providers/columns";
|
|
|
|
test("sanitizeRateLimitOverrides surfaces rejected keys (blocking, not silent)", () => {
|
|
const r = sanitizeRateLimitOverrides({ rpm: 10, foo: 1, tpm: -1 });
|
|
assert.deepEqual(r.sanitized, { rpm: 10 });
|
|
assert.deepEqual(r.rejected.sort(), ["foo", "tpm"]);
|
|
});
|
|
|
|
test("sanitizeQuotaWindowThresholds surfaces key-too-long and out-of-range", () => {
|
|
const r = sanitizeQuotaWindowThresholds({ ["a".repeat(65)]: 50, win: 101 });
|
|
assert.ok(r.rejected.length >= 1);
|
|
assert.ok(r.rejected.includes("win"));
|
|
});
|
|
|
|
test("valid input yields no rejected keys", () => {
|
|
const r = sanitizeRateLimitOverrides({ rpm: 10, tpm: 20 });
|
|
assert.deepEqual(r.rejected, []);
|
|
assert.deepEqual(r.sanitized, { rpm: 10, tpm: 20 });
|
|
});
|