mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-10-06 07:39:50 +08:00
- Add context helpers to manage execution-scoped proxy overrides - Prioritize request proxy over credential and global proxy settings across HTTP and uTLS clients - Propagate request proxy in conductor execution and plugin host adapters - Isolate Codex WebSocket connection reuse by proxy endpoint Closes: #6013
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package executor
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v7/internal/config"
|
|
cliproxyauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
|
cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/executor"
|
|
sdkconfig "github.com/router-for-me/CLIProxyAPI/v7/sdk/config"
|
|
)
|
|
|
|
func TestRequestProxyOverridesCredentialProxyForWebsocketAndAntigravity(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const requestProxy = "http://request-proxy.example:8081"
|
|
ctx := cliproxyexecutor.WithRequestProxyURL(context.Background(), requestProxy)
|
|
cfg := &config.Config{SDKConfig: sdkconfig.SDKConfig{ProxyURL: "http://global-proxy.example:8082"}}
|
|
auth := &cliproxyauth.Auth{ProxyURL: "http://auth-proxy.example:8080"}
|
|
|
|
if got := antigravityProxyURL(ctx, cfg, auth); got != requestProxy {
|
|
t.Fatalf("antigravity proxy = %q, want %q", got, requestProxy)
|
|
}
|
|
|
|
dialer := newProxyAwareWebsocketDialer(ctx, cfg, auth)
|
|
if dialer.Proxy == nil {
|
|
t.Fatal("websocket proxy function is nil")
|
|
}
|
|
req, errReq := http.NewRequest(http.MethodGet, "https://upstream.example/v1", nil)
|
|
if errReq != nil {
|
|
t.Fatalf("request: %v", errReq)
|
|
}
|
|
proxyURL, errProxy := dialer.Proxy(req)
|
|
if errProxy != nil {
|
|
t.Fatalf("websocket proxy: %v", errProxy)
|
|
}
|
|
if proxyURL == nil || proxyURL.String() != requestProxy {
|
|
t.Fatalf("websocket proxy = %v, want %s", proxyURL, requestProxy)
|
|
}
|
|
}
|