mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
tstest/integration: set an HTTP_PROXY to catch bogus requests
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
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…
x
Reference in New Issue
Block a user