16 lines
571 B
TypeScript
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\"");
|
|
});
|