From f342d10dc5e8b0494ba069b380e9b8c00d2792c8 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 29 Apr 2021 15:58:29 -0700 Subject: [PATCH] tstest/integration: set an HTTP_PROXY to catch bogus requests Signed-off-by: Brad Fitzpatrick --- tstest/integration/integration_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tstest/integration/integration_test.go b/tstest/integration/integration_test.go index 01d68d44d..7f0fe6e14 100644 --- a/tstest/integration/integration_test.go +++ b/tstest/integration/integration_test.go @@ -41,13 +41,26 @@ func TestIntegration(t *testing.T) { ts := httptest.NewServer(logc) defer ts.Close() + httpProxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + var got bytes.Buffer + r.Write(&got) + err := fmt.Errorf("unexpected HTTP proxy via proxy: %s", got.Bytes()) + t.Error(err) + go panic(err) + })) + defer httpProxy.Close() + socketPath := filepath.Join(td, "tailscale.sock") dcmd := exec.Command(daemonExe, "--tun=userspace-networking", "--state="+filepath.Join(td, "tailscale.state"), "--socket="+socketPath, ) - dcmd.Env = append(os.Environ(), "TS_LOG_TARGET="+ts.URL) + dcmd.Env = append(os.Environ(), + "TS_LOG_TARGET="+ts.URL, + "HTTP_PROXY="+httpProxy.URL, + "HTTPS_PROXY="+httpProxy.URL, + ) if err := dcmd.Start(); err != nil { t.Fatalf("starting tailscaled: %v", err) } @@ -64,6 +77,11 @@ func TestIntegration(t *testing.T) { t.Fatal(err) } + if os.Getenv("TS_RUN_TEST") == "failing_up" { + // Force a connection through the HTTP proxy to panic and fail. + exec.Command(cliExe, "--socket="+socketPath, "up").Run() + } + if err := tstest.WaitFor(20*time.Second, func() error { const sub = `Program starting: ` if !logc.logsContains(mem.S(sub)) {