fix(mysql): support cleartext password auth option (#2499)

This commit is contained in:
LRcoding authored and GitHub committed 2026-07-03 13:47:47 +08:00
1 parent cabe89a19b
commit 21cec24e75
12 files changed
+187 -1

No files matched your search

@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { mysqlCleartextPasswordAuthEnabled, setMysqlCleartextPasswordAuthEnabled } from "../mysqlConnectionOptions";
describe("mysqlConnectionOptions", () => {
it("detects cleartext password auth aliases", () => {
expect(mysqlCleartextPasswordAuthEnabled("allowCleartextPasswords=true")).toBe(true);
expect(mysqlCleartextPasswordAuthEnabled("enable_cleartext_plugin=true")).toBe(true);
expect(mysqlCleartextPasswordAuthEnabled("?AllowCleartextPasswords=TRUE")).toBe(true);
expect(mysqlCleartextPasswordAuthEnabled("allowCleartextPasswords=false")).toBe(false);
});
it("enables the canonical cleartext password auth param and removes aliases", () => {
expect(setMysqlCleartextPasswordAuthEnabled("allowCleartextPasswords=true&charset=utf8mb4", true)).toBe("charset=utf8mb4&enable_cleartext_plugin=true");
});
it("disables cleartext password auth params while preserving unrelated params", () => {
expect(setMysqlCleartextPasswordAuthEnabled("allowCleartextPasswords=true&enable_cleartext_plugin=true&charset=utf8mb4&connect_timeout=10", false)).toBe("charset=utf8mb4&connect_timeout=10");
});
});