diff --git a/internal/gateway/bedrock_test.go b/internal/gateway/bedrock_test.go index 9432d8587..7b4432b8c 100644 --- a/internal/gateway/bedrock_test.go +++ b/internal/gateway/bedrock_test.go @@ -134,6 +134,9 @@ func TestBedrockRoutes(t *testing.T) { up.mu.Lock() defer up.mu.Unlock() for _, c := range up.calls { + if !sentByTest(c.head, "ABSK-test") { + continue + } if c.path != "/anthropic/v1/messages" && c.path != "/openai/v1/chat/completions" { t.Errorf("asked at %s", c.path) } diff --git a/internal/gateway/qianfan_test.go b/internal/gateway/qianfan_test.go index 68f18aebc..4b093cd06 100644 --- a/internal/gateway/qianfan_test.go +++ b/internal/gateway/qianfan_test.go @@ -129,6 +129,9 @@ func TestQianfanTokenPlanRoutes(t *testing.T) { up.mu.Lock() defer up.mu.Unlock() for _, c := range up.calls { + if !sentByTest(c.head, "bce-v3-test") { + continue + } if !strings.HasPrefix(c.path, "/v2/tokenplan/personal/") && !strings.HasPrefix(c.path, "/anthropic/tokenplan/personal/") { t.Errorf("asked at %s", c.path) } diff --git a/internal/gateway/tokenhub_test.go b/internal/gateway/tokenhub_test.go index 6d7a0341e..2db8903aa 100644 --- a/internal/gateway/tokenhub_test.go +++ b/internal/gateway/tokenhub_test.go @@ -145,6 +145,9 @@ func TestTencentTokenHubRoutes(t *testing.T) { up.mu.Lock() defer up.mu.Unlock() for _, c := range up.calls { + if !sentByTest(c.head, "sk-tokenhub-test") { + continue + } if c.path != "/v1/chat/completions" && c.path != "/v1/responses" && c.path != "/v1/messages" { t.Errorf("asked at %s", c.path) } @@ -152,3 +155,12 @@ func TestTencentTokenHubRoutes(t *testing.T) { }) } } + +// sentByTest tells a request the gateway sent with the test's key from one +// any other program on the machine sent to the fake's loopback port: a herdr +// client's /ws/herdr reached TestTencentTokenHubRoutes' upstream on the +// Linux box and turned it red (#6535). The checks of every path asked judge +// only the former. +func sentByTest(h http.Header, key string) bool { + return h.Get("Authorization") == "Bearer "+key || h.Get("x-api-key") == key +}