ci / verify (pull_request) Successful in 15m34s
新增图片矢量化、视频超分、每日用量、计价与任务隔离能力,并通过环境变量解析平台凭据。 已通过 Go 全量门禁、迁移检查、镜像构建以及 Vectorizer 五格式和 Topaz 3 秒视频真实 DEV 验收。
77 lines
1.8 KiB
Go
77 lines
1.8 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
gatewaydocs "github.com/easyai/easyai-ai-gateway/apps/api/docs"
|
|
)
|
|
|
|
func TestOpenAPIPublicRoutesUseCanonicalV1Prefix(t *testing.T) {
|
|
var document struct {
|
|
Paths map[string]any `json:"paths"`
|
|
}
|
|
if err := json.Unmarshal(gatewaydocs.SwaggerJSON, &document); err != nil {
|
|
t.Fatalf("decode embedded OpenAPI document: %v", err)
|
|
}
|
|
|
|
legacyPrefixes := []string{
|
|
"/v1/",
|
|
"/v1beta/",
|
|
"/kling/",
|
|
"/upload/",
|
|
"/api/v3/",
|
|
"/chat/",
|
|
"/images/",
|
|
"/song/",
|
|
"/music/",
|
|
"/speech/",
|
|
"/voice_clone",
|
|
"/tasks",
|
|
}
|
|
legacyExact := map[string]bool{
|
|
"/healthz": true,
|
|
"/readyz": true,
|
|
"/api-docs-json": true,
|
|
"/api-docs-yaml": true,
|
|
"/responses": true,
|
|
"/embeddings": true,
|
|
"/reranks": true,
|
|
}
|
|
for route := range document.Paths {
|
|
if legacyExact[route] {
|
|
t.Errorf("legacy public route must not be advertised in OpenAPI: %s", route)
|
|
}
|
|
for _, prefix := range legacyPrefixes {
|
|
if strings.HasPrefix(route, prefix) {
|
|
t.Errorf("legacy public route must not be advertised in OpenAPI: %s", route)
|
|
}
|
|
}
|
|
}
|
|
|
|
required := []string{
|
|
"/api/v1/healthz",
|
|
"/api/v1/readyz",
|
|
"/api/v1/openapi.json",
|
|
"/api/v1/chat/completions",
|
|
"/api/v1/responses",
|
|
"/api/v1/images/generations",
|
|
"/api/v1/images/vectorize",
|
|
"/api/v1/videos/generations",
|
|
"/api/v1/videos/upscales",
|
|
"/api/v1/pricing/estimate",
|
|
"/api/workspace/token-usage/daily",
|
|
"/api/v1/models/{model}:generateContent",
|
|
"/api/v1/videos/omni-video",
|
|
"/api/v1/kling/v1/videos/omni-video",
|
|
"/api/v1/kling/v2/omni-video/{model}",
|
|
"/api/v1/contents/generations/tasks",
|
|
}
|
|
for _, route := range required {
|
|
if _, ok := document.Paths[route]; !ok {
|
|
t.Errorf("canonical public route missing from OpenAPI: %s", route)
|
|
}
|
|
}
|
|
}
|