(t *testing.T)
| 616 | } |
| 617 | |
| 618 | func TestHTTPProxyWithTestServer(t *testing.T) { |
| 619 | // Create a test HTTP server |
| 620 | testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 621 | w.WriteHeader(http.StatusOK) |
| 622 | w.Write([]byte("<html><head></head><body>Test Page</body></html>")) |
| 623 | })) |
| 624 | defer testServer.Close() |
| 625 | |
| 626 | sess, _ := createMockSession() |
| 627 | proxy := NewHTTPProxy(sess, "test") |
| 628 | |
| 629 | // Configure proxy with JS injection |
| 630 | err := proxy.Configure("127.0.0.1", 0, 80, false, "", "console.log('injected');", false) |
| 631 | if err != nil { |
| 632 | t.Fatalf("Configure failed: %v", err) |
| 633 | } |
| 634 | |
| 635 | // Create a simple test to verify proxy is initialized |
| 636 | if proxy.Proxy == nil { |
| 637 | t.Error("Proxy not initialized") |
| 638 | } |
| 639 | |
| 640 | if proxy.jsHook == "" { |
| 641 | t.Error("JavaScript hook not set") |
| 642 | } |
| 643 | |
| 644 | // Note: Testing actual proxy behavior would require setting up the proxy server |
| 645 | // and making HTTP requests through it, which is complex in a unit test environment |
| 646 | } |
| 647 | |
| 648 | func TestHTTPProxyScriptLoading(t *testing.T) { |
| 649 | sess, _ := createMockSession() |
nothing calls this directly
no test coverage detected