tstest/integration: set an HTTP_PROXY to catch bogus requests

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1871/head
Brad Fitzpatrick 4 years ago
parent 80429b97e5
commit f342d10dc5

@ -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)) {

Loading…
Cancel
Save