Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.1 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { applyDamengSslUrlParams, damengSslFormConfig } from "@/lib/database/damengSslOptions";

describe("Dameng SSL URL parameters", () => {
  it("reads SSL fields without changing parameter casing requirements", () => {
    expect(damengSslFormConfig("schema=APP&sslFilesPath=/Users/test/dmcert&sslkeystorePass=secret&sslProtocol=TLSv1.2")).toEqual({
      enabled: true,
      sslFilesPath: "/Users/test/dmcert",
      sslKeystorePassword: "secret",
      sslProtocol: "TLSv1.2",
    });
  });

  it("updates SSL fields while preserving unrelated URL parameters", () => {
    expect(applyDamengSslUrlParams("?schema=APP;compatMode=oracle", true, "/opt/dm/cert", "changeit", "TLSv1.2")).toBe("schema=APP&compatMode=oracle&sslFilesPath=/opt/dm/cert&sslkeystorePass=changeit&sslProtocol=TLSv1.2");
  });

  it("removes only managed SSL fields when SSL is disabled", () => {
    expect(applyDamengSslUrlParams("schema=APP&sslFilesPath=/opt/dm/cert&sslkeystorePass=secret&sslProtocol=TLSv1.2&foo=", false, "", "", "")).toBe("schema=APP&foo=");
  });
});