5759c1862e
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。 含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。 Co-Authored-By: Claude <noreply@anthropic.com>
22 lines
564 B
Go
22 lines
564 B
Go
package openai
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestPrepareAvoidsDuplicatedV1BasePath(t *testing.T) {
|
|
adapter, err := New("https://example.com/proxy/v1", "secret")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
request := httptest.NewRequest("POST", "https://example.com/proxy/v1/v1/chat/completions", nil)
|
|
adapter.Prepare(request)
|
|
if request.URL.Path != "/proxy/v1/chat/completions" {
|
|
t.Fatalf("unexpected path %q", request.URL.Path)
|
|
}
|
|
if request.Header.Get("Authorization") != "Bearer secret" {
|
|
t.Fatal("upstream credential was not applied")
|
|
}
|
|
}
|