MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestParse

Function TestParse

sdk/proxyutil/proxy_test.go:25–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestParse(t *testing.T) {
26 t.Parallel()
27
28 tests := []struct {
29 name string
30 input string
31 want Mode
32 wantErr bool
33 }{
34 {name: "inherit", input: "", want: ModeInherit},
35 {name: "direct", input: "direct", want: ModeDirect},
36 {name: "none", input: "none", want: ModeDirect},
37 {name: "http", input: "http://proxy.example.com:8080", want: ModeProxy},
38 {name: "https", input: "https://proxy.example.com:8443", want: ModeProxy},
39 {name: "socks5", input: "socks5://proxy.example.com:1080", want: ModeProxy},
40 {name: "socks5h", input: "socks5h://proxy.example.com:1080", want: ModeProxy},
41 {name: "invalid", input: "bad-value", want: ModeInvalid, wantErr: true},
42 }
43
44 for _, tt := range tests {
45 tt := tt
46 t.Run(tt.name, func(t *testing.T) {
47 t.Parallel()
48
49 setting, errParse := Parse(tt.input)
50 if tt.wantErr && errParse == nil {
51 t.Fatal("expected error, got nil")
52 }
53 if !tt.wantErr && errParse != nil {
54 t.Fatalf("unexpected error: %v", errParse)
55 }
56 if setting.Mode != tt.want {
57 t.Fatalf("mode = %d, want %d", setting.Mode, tt.want)
58 }
59 })
60 }
61}
62
63func TestBuildHTTPTransportDirectBypassesProxy(t *testing.T) {
64 t.Parallel()

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected