MCPcopy
hub / github.com/bettercap/bettercap / TestHttpProxyAlreadyStarted

Function TestHttpProxyAlreadyStarted

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

Source from the content-addressed store, hash-verified

398}
399
400func TestHttpProxyAlreadyStarted(t *testing.T) {
401 sess, _ := createMockSession()
402 mod := NewHttpProxy(sess)
403
404 // Configure
405 sess.Env.Set("http.port", "80")
406 sess.Env.Set("http.proxy.address", "127.0.0.1")
407 sess.Env.Set("http.proxy.port", "0")
408 sess.Env.Set("http.proxy.redirect", "false")
409
410 // Start the proxy
411 err := mod.Start()
412 if err != nil {
413 t.Fatalf("Failed to start proxy: %v", err)
414 }
415
416 // Try to configure while running
417 err = mod.Configure()
418 if err == nil {
419 t.Error("Configure should fail when proxy is already running")
420 }
421
422 // Stop the proxy
423 mod.Stop()
424}
425
426func TestHTTPProxyDoProxy(t *testing.T) {
427 sess, _ := createMockSession()

Callers

nothing calls this directly

Calls 7

StartMethod · 0.95
ConfigureMethod · 0.95
StopMethod · 0.95
NewHttpProxyFunction · 0.85
createMockSessionFunction · 0.70
SetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected