simplify production database configuration

This commit is contained in:
2026-08-16 12:40:43 +08:00
parent 8cb8b5e463
commit b26f9679ab
17 changed files with 199 additions and 234 deletions

View File

@@ -12,14 +12,25 @@ describe("PostgreSQL script configuration", () => {
expect(getScriptDataBackend({ NODE_ENV: "test", ZHINIAN_DATA_BACKEND: "postgres" })).toBe("postgres");
});
it("rejects connection-string SSL options that could override the verified CA configuration", () => {
it("accepts SSL settings in the single DATABASE_URL value", async () => {
const pool = createPostgresPool({
env: {
NODE_ENV: "test",
ZHINIAN_DATA_BACKEND: "postgres",
DATABASE_URL: "postgresql://app:secret@rds.example:5432/app?sslmode=verify-full"
}
});
await pool.end();
});
it("rejects unsupported connection-string SSL options", () => {
expect(() => createPostgresPool({
env: {
NODE_ENV: "test",
ZHINIAN_DATA_BACKEND: "postgres",
DATABASE_URL: "postgresql://app:secret@rds.example:5432/app?sslmode=no-verify"
DATABASE_URL: "postgresql://app:secret@rds.example:5432/app?sslcert=unexpected"
}
})).toThrow("must not contain SSL query parameters");
})).toThrow("unsupported SSL query parameters");
});
it("quotes PostgreSQL role identifiers without allowing SQL syntax injection", () => {