|
|
@ -111,9 +111,10 @@ func TestOneNodeUp_Auth(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
t.Parallel()
|
|
|
|
bins := BuildTestBinaries(t)
|
|
|
|
bins := BuildTestBinaries(t)
|
|
|
|
|
|
|
|
|
|
|
|
env := newTestEnv(t, bins)
|
|
|
|
env := newTestEnv(t, bins, configureControl(func(control *testcontrol.Server) {
|
|
|
|
|
|
|
|
control.RequireAuth = true
|
|
|
|
|
|
|
|
}))
|
|
|
|
defer env.Close()
|
|
|
|
defer env.Close()
|
|
|
|
env.Control.RequireAuth = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n1 := newTestNode(t, env)
|
|
|
|
n1 := newTestNode(t, env)
|
|
|
|
d1 := n1.StartDaemon(t)
|
|
|
|
d1 := n1.StartDaemon(t)
|
|
|
@ -304,11 +305,21 @@ type testEnv struct {
|
|
|
|
derpShutdown func()
|
|
|
|
derpShutdown func()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type testEnvOpt interface {
|
|
|
|
|
|
|
|
modifyTestEnv(*testEnv)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type configureControl func(*testcontrol.Server)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (f configureControl) modifyTestEnv(te *testEnv) {
|
|
|
|
|
|
|
|
f(te.Control)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// newTestEnv starts a bunch of services and returns a new test
|
|
|
|
// newTestEnv starts a bunch of services and returns a new test
|
|
|
|
// environment.
|
|
|
|
// environment.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Call Close to shut everything down.
|
|
|
|
// Call Close to shut everything down.
|
|
|
|
func newTestEnv(t testing.TB, bins *Binaries) *testEnv {
|
|
|
|
func newTestEnv(t testing.TB, bins *Binaries, opts ...testEnvOpt) *testEnv {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
t.Skip("not tested/working on Windows yet")
|
|
|
|
t.Skip("not tested/working on Windows yet")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -318,7 +329,6 @@ func newTestEnv(t testing.TB, bins *Binaries) *testEnv {
|
|
|
|
DERPMap: derpMap,
|
|
|
|
DERPMap: derpMap,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
control.HTTPTestServer = httptest.NewUnstartedServer(control)
|
|
|
|
control.HTTPTestServer = httptest.NewUnstartedServer(control)
|
|
|
|
control.HTTPTestServer.Start()
|
|
|
|
|
|
|
|
trafficTrap := new(trafficTrap)
|
|
|
|
trafficTrap := new(trafficTrap)
|
|
|
|
e := &testEnv{
|
|
|
|
e := &testEnv{
|
|
|
|
t: t,
|
|
|
|
t: t,
|
|
|
@ -331,6 +341,10 @@ func newTestEnv(t testing.TB, bins *Binaries) *testEnv {
|
|
|
|
TrafficTrapServer: httptest.NewServer(trafficTrap),
|
|
|
|
TrafficTrapServer: httptest.NewServer(trafficTrap),
|
|
|
|
derpShutdown: derpShutdown,
|
|
|
|
derpShutdown: derpShutdown,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, o := range opts {
|
|
|
|
|
|
|
|
o.modifyTestEnv(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
control.HTTPTestServer.Start()
|
|
|
|
return e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|