MCPcopy
hub / github.com/bettercap/bettercap / TestHttpProxyConfigure

Function TestHttpProxyConfigure

modules/http_proxy/http_proxy_test.go:174–348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func TestHttpProxyConfigure(t *testing.T) {
175 tests := []struct {
176 name string
177 params map[string]string
178 expectErr bool
179 validate func(*HttpProxy) error
180 }{
181 {
182 name: "default configuration",
183 params: map[string]string{
184 "http.port": "80",
185 "http.proxy.address": "192.168.1.100",
186 "http.proxy.port": "8080",
187 "http.proxy.redirect": "true",
188 "http.proxy.script": "",
189 "http.proxy.injectjs": "",
190 "http.proxy.blacklist": "",
191 "http.proxy.whitelist": "",
192 "http.proxy.sslstrip": "false",
193 },
194 expectErr: false,
195 validate: func(mod *HttpProxy) error {
196 if mod.proxy == nil {
197 return fmt.Errorf("proxy not initialized")
198 }
199 if mod.proxy.Address != "192.168.1.100" {
200 return fmt.Errorf("expected address 192.168.1.100, got %s", mod.proxy.Address)
201 }
202 if !mod.proxy.doRedirect {
203 return fmt.Errorf("expected redirect to be true")
204 }
205 if mod.proxy.Stripper == nil {
206 return fmt.Errorf("SSL stripper not initialized")
207 }
208 if mod.proxy.Stripper.Enabled() {
209 return fmt.Errorf("SSL stripper should be disabled")
210 }
211 return nil
212 },
213 },
214 // Note: SSL stripping test removed as it requires elevated permissions
215 // to create network capture handles
216 {
217 name: "with blacklist and whitelist",
218 params: map[string]string{
219 "http.port": "80",
220 "http.proxy.address": "192.168.1.100",
221 "http.proxy.port": "8080",
222 "http.proxy.redirect": "false",
223 "http.proxy.script": "",
224 "http.proxy.injectjs": "",
225 "http.proxy.blacklist": "*.evil.com,bad.site.org",
226 "http.proxy.whitelist": "*.good.com,safe.site.org",
227 "http.proxy.sslstrip": "false",
228 },
229 expectErr: false,
230 validate: func(mod *HttpProxy) error {
231 if len(mod.proxy.Blacklist) != 2 {

Callers

nothing calls this directly

Calls 8

ConfigureMethod · 0.95
NewHttpProxyFunction · 0.85
validateMethod · 0.80
createMockSessionFunction · 0.70
EnabledMethod · 0.45
RunMethod · 0.45
SetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected