mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-05-13 21:31:36 +00:00
- Introduced `WithProxyURL` variants for `CodexAuth`, `ClaudeAuth`, `IFlowAuth`, and `DeviceFlowClient`. - Updated executors to use proxy-aware constructors for improved configurability. - Added unit tests to validate proxy override precedence and functionality. Closes: #2823
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package claude
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
"golang.org/x/net/proxy"
|
|
)
|
|
|
|
func TestNewClaudeAuthWithProxyURL_OverrideDirectTakesPrecedence(t *testing.T) {
|
|
cfg := &config.Config{SDKConfig: config.SDKConfig{ProxyURL: "socks5://proxy.example.com:1080"}}
|
|
auth := NewClaudeAuthWithProxyURL(cfg, "direct")
|
|
|
|
transport, ok := auth.httpClient.Transport.(*utlsRoundTripper)
|
|
if !ok || transport == nil {
|
|
t.Fatalf("expected utlsRoundTripper, got %T", auth.httpClient.Transport)
|
|
}
|
|
if transport.dialer != proxy.Direct {
|
|
t.Fatalf("expected proxy.Direct, got %T", transport.dialer)
|
|
}
|
|
}
|
|
|
|
func TestNewClaudeAuthWithProxyURL_OverrideProxyAppliedWithoutConfig(t *testing.T) {
|
|
auth := NewClaudeAuthWithProxyURL(nil, "socks5://proxy.example.com:1080")
|
|
|
|
transport, ok := auth.httpClient.Transport.(*utlsRoundTripper)
|
|
if !ok || transport == nil {
|
|
t.Fatalf("expected utlsRoundTripper, got %T", auth.httpClient.Transport)
|
|
}
|
|
if transport.dialer == proxy.Direct {
|
|
t.Fatalf("expected proxy dialer, got %T", transport.dialer)
|
|
}
|
|
}
|