feat(storage): 完善对象存储配置与过期策略
补齐 OSS/S3 的 Endpoint、Region、Bucket、CDN、对象前缀和签名有效期配置,并为生成结果与请求素材自动维护分级生命周期规则。普通上传继续保持永久,私有资源按配置生成限时签名 URL,管理端连接测试覆盖生命周期、上传、读取和删除。\n\n新增可重复的真实 OSS 验收脚本,凭据仅从本地环境读取,接口响应继续保持脱敏。\n\n验证:Go 全量测试、迁移安全检查、pnpm lint、pnpm test、pnpm build、本地阿里云 OSS 真实上传下载删除验收。
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { FileStorageChannel } from '@easyai-ai-gateway/contracts';
|
||||
import { channelToForm, formToPayload } from './SystemSettingsPanel';
|
||||
|
||||
describe('SystemSettingsPanel object storage form', () => {
|
||||
it('promotes legacy CDN and expiration config while preserving unknown extensions', () => {
|
||||
const channel: FileStorageChannel = {
|
||||
id: 'channel-1',
|
||||
channelKey: 'oss-primary',
|
||||
name: 'OSS primary',
|
||||
provider: 'aliyun_oss',
|
||||
credentialsPreview: {},
|
||||
scenes: ['upload', 'image_result', 'request_asset'],
|
||||
config: {
|
||||
endpoint: 'https://oss-cn-shanghai.aliyuncs.com',
|
||||
region: 'cn-shanghai',
|
||||
bucket: 'media',
|
||||
cdnDomain: 'https://cdn.example.com/',
|
||||
apiReturnExpirePolicy: '3m',
|
||||
signedUrlExpiresSeconds: 3600,
|
||||
customHeader: 'retained',
|
||||
},
|
||||
retryPolicy: {},
|
||||
priority: 100,
|
||||
status: 'enabled',
|
||||
createdAt: '2026-08-04T00:00:00Z',
|
||||
updatedAt: '2026-08-04T00:00:00Z',
|
||||
};
|
||||
|
||||
const form = channelToForm(channel);
|
||||
expect(form.publicBaseUrl).toBe('https://cdn.example.com/');
|
||||
expect(form.temporaryFileExpirePolicy).toBe('3m');
|
||||
expect(form.signedUrlExpiresMinutes).toBe('60');
|
||||
expect(JSON.parse(form.configJson)).toEqual({ customHeader: 'retained' });
|
||||
|
||||
const payload = formToPayload({
|
||||
...form,
|
||||
objectPrefix: '/gateway/',
|
||||
temporaryFileExpirePolicy: '1m',
|
||||
});
|
||||
expect(payload.config).toEqual({
|
||||
endpoint: 'https://oss-cn-shanghai.aliyuncs.com',
|
||||
region: 'cn-shanghai',
|
||||
bucket: 'media',
|
||||
publicBaseUrl: 'https://cdn.example.com',
|
||||
objectPrefix: 'gateway',
|
||||
temporaryFileExpirePolicy: '1m',
|
||||
signedUrlExpiresSeconds: 3600,
|
||||
customHeader: 'retained',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user