fix(storage): 修复腾讯云 COS 连接测试异常 (#362)

This commit is contained in:
MasterChiefCN
2026-08-31 15:06:34 +08:00
committed by GitHub
parent 3d0adf1e9c
commit 875f45d70f
4 changed files with 68 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test";
import { changesRequireOSSRetest, DEFAULT_OSS_PATH_PREFIX, getS3PresetHints } from "../src/lib/oss-settings";
import { changesRequireOSSRetest, DEFAULT_OSS_PATH_PREFIX, getS3PresetHints, normalizeOSSConnectionTestInput } from "../src/lib/oss-settings";
describe("OSS settings helpers", () => {
test("provides editable S3 endpoint hints for known presets", () => {
@@ -17,4 +17,30 @@ describe("OSS settings helpers", () => {
test("uses the product path prefix by default", () => {
expect(DEFAULT_OSS_PATH_PREFIX).toBe("open-ai-canvas");
});
test("normalizes a Tencent COS test draft when S3-only fields are not mounted", () => {
const input = normalizeOSSConnectionTestInput({
provider: "tencent",
region: " ap-guangzhou ",
endpoint: " https://cos.ap-guangzhou.myqcloud.com/ ",
bucket: " example-1250000000 ",
accessKeyId: " secret-id ",
accessKeySecret: " secret-key ",
pathPrefix: " /canvas/ ",
});
expect(input).toMatchObject({
provider: "tencent",
region: "ap-guangzhou",
endpoint: "https://cos.ap-guangzhou.myqcloud.com",
cdnBaseUrl: "",
bucket: "example-1250000000",
accessKeyId: "secret-id",
accessKeySecret: "secret-key",
sessionToken: "",
pathPrefix: "canvas",
s3Preset: "custom",
pathStyle: false,
});
});
});