AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。 含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestProductionRequiresCoreDependencies(t *testing.T) {
|
||||
t.Setenv("APP_ENV", "production")
|
||||
t.Setenv("DATABASE_URL", "")
|
||||
t.Setenv("REDIS_CRITICAL_URL", "")
|
||||
t.Setenv("GATEWAY_BOOTSTRAP_API_KEY", "short")
|
||||
t.Setenv("UPSTREAM_API_KEY", "")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected structural configuration error: %v", err)
|
||||
}
|
||||
if err := cfg.ValidateRuntime(); err == nil {
|
||||
t.Fatal("expected production validation error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalDefaultsAreValid(t *testing.T) {
|
||||
t.Setenv("APP_ENV", "local")
|
||||
t.Setenv("UPSTREAM_BASE_URL", "https://example.com")
|
||||
if _, err := Load(); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProductionCanDisableBootstrapCompatibility(t *testing.T) {
|
||||
t.Setenv("APP_ENV", "production")
|
||||
t.Setenv("DATABASE_URL", "postgres://gateway:secret@db.example/gateway?sslmode=require")
|
||||
t.Setenv("REDIS_CRITICAL_URL", "rediss://redis.example/0")
|
||||
t.Setenv("GATEWAY_BOOTSTRAP_API_KEY", "")
|
||||
t.Setenv("GATEWAY_BOOTSTRAP_API_KEY_ENABLED", "false")
|
||||
t.Setenv("UPSTREAM_FALLBACK_ENABLED", "false")
|
||||
t.Setenv("CREDENTIAL_MASTER_KEY", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
|
||||
t.Setenv("UPSTREAM_BASE_URL", "https://example.com")
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := cfg.ValidateRuntime(); err != nil {
|
||||
t.Fatalf("disabled bootstrap compatibility should not require a key: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user