mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-20 21:43:56 +08:00
- 前端连接表单新增额外连接参数入口,支持 URI query 格式录入与解析回填 - MySQL 兼容驱动支持 JDBC 常见参数映射,修复 UTF-8 字符集与 serverTimezone 兼容问题 - 扩展 Oracle、PostgreSQL 兼容、SQL Server、ClickHouse、MongoDB、达梦、TDengine 参数合并 - 按不同驱动通道处理 DSN、URI、Options 与 Settings,避免统一透传导致连接异常 - 修复编辑已保存连接时解析无认证 URI 会清空已有账号密码的问题 - 补充连接参数透传、缓存隔离、DSN 合并与 URI 回填回归测试
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { mergeParsedUriValuesForForm } from "./connectionUriMerge";
|
|
|
|
describe("mergeParsedUriValuesForForm", () => {
|
|
it("keeps saved credentials when parsed URI has no auth section", () => {
|
|
const result = mergeParsedUriValuesForForm(
|
|
{
|
|
user: "root",
|
|
password: "saved-password",
|
|
host: "192.168.1.10",
|
|
port: 3306,
|
|
database: "old_db",
|
|
connectionParams: "application_name=GoNavi",
|
|
timeout: 30,
|
|
},
|
|
{
|
|
host: "192.168.1.240",
|
|
port: 3306,
|
|
user: "",
|
|
password: "",
|
|
database: "mkefu_location_dev_local",
|
|
connectionParams: "",
|
|
timeout: undefined,
|
|
useSSL: false,
|
|
},
|
|
"jdbc:mysql://192.168.1.240:3306/mkefu_location_dev_local?characterEncoding=UTF-8",
|
|
);
|
|
|
|
expect(result).toMatchObject({
|
|
uri: "jdbc:mysql://192.168.1.240:3306/mkefu_location_dev_local?characterEncoding=UTF-8",
|
|
host: "192.168.1.240",
|
|
port: 3306,
|
|
database: "mkefu_location_dev_local",
|
|
useSSL: false,
|
|
});
|
|
expect(result).not.toHaveProperty("user");
|
|
expect(result).not.toHaveProperty("password");
|
|
expect(result).not.toHaveProperty("connectionParams");
|
|
expect(result).not.toHaveProperty("timeout");
|
|
});
|
|
|
|
it("allows URI credentials to replace existing credentials when provided", () => {
|
|
const result = mergeParsedUriValuesForForm(
|
|
{
|
|
user: "root",
|
|
password: "old-password",
|
|
},
|
|
{
|
|
user: "uri_user",
|
|
password: "uri-password",
|
|
},
|
|
"mysql://uri_user:uri-password@127.0.0.1:3306/app",
|
|
);
|
|
|
|
expect(result).toMatchObject({
|
|
user: "uri_user",
|
|
password: "uri-password",
|
|
});
|
|
});
|
|
|
|
it("keeps existing database when URI omits a database path", () => {
|
|
const result = mergeParsedUriValuesForForm(
|
|
{
|
|
database: "saved_db",
|
|
},
|
|
{
|
|
host: "127.0.0.1",
|
|
database: "",
|
|
},
|
|
"mysql://127.0.0.1:3306",
|
|
);
|
|
|
|
expect(result.database).toBeUndefined();
|
|
expect(result.host).toBe("127.0.0.1");
|
|
});
|
|
});
|