Files
Final_PGA/backend/tests/identifiers.test.ts
2026-03-19 18:00:46 +07:00

16 lines
571 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { assertSafeIdentifier, quoteQualifiedName } from "../src/lib/identifiers.js";
test("safe identifier accepts public_table", () => {
assert.doesNotThrow(() => assertSafeIdentifier("finance_table"));
});
test("safe identifier rejects SQL injection attempts", () => {
assert.throws(() => assertSafeIdentifier("users; drop table users"));
});
test("quoteQualifiedName supports schema-qualified names", () => {
assert.equal(quoteQualifiedName("public.users"), "\"public\".\"users\"");
});