返回 DeepSeek-Reasonix
proxy_test.go
根目录 / internal / config / proxy_test.go
1 package config
2
3 import "testing"
4
5 func TestDirectProxyHostsFromNoProxyProviders(t *testing.T) {
6 c := Default()
7 c.Providers = append(c.Providers, ProviderEntry{Name: "domestic", Kind: "openai", BaseURL: "https://domestic.example/v1", Model: "chat", NoProxy: true})
8 spec := c.NetworkProxySpec()
9 hasDirectHost := false
10 for _, h := range spec.DirectHosts {
11 if h == "domestic.example" {
12 hasDirectHost = true
13 }
14 if h == "api.deepseek.com" {
15 t.Errorf("DeepSeek works through the proxy and must not be forced direct: %v", spec.DirectHosts)
16 }
17 }
18 if !hasDirectHost {
19 t.Errorf("a no_proxy provider's host should land in DirectHosts, got %v", spec.DirectHosts)
20 }
21 }
22
23 func TestExplicitProxyOverridesProviderNoProxy(t *testing.T) {
24 // An explicit custom proxy (e.g. a mandatory corporate proxy) must apply to
25 // every provider, including no_proxy ones, so it isn't unreachable
26 // behind the proxy (#3635).
27 c := Default()
28 c.Providers = append(c.Providers, ProviderEntry{Name: "domestic", Kind: "openai", BaseURL: "https://domestic.example/v1", Model: "chat", NoProxy: true})
29 c.Network.ProxyMode = "custom"
30 spec := c.NetworkProxySpec()
31 for _, h := range spec.DirectHosts {
32 if h == "domestic.example" {
33 t.Fatalf("custom proxy must not force no_proxy providers direct; DirectHosts = %v", spec.DirectHosts)
34 }
35 }
36 }
37
37 lines GO