diff --git a/command/agent/acl_endpoint_test.go b/command/agent/acl_endpoint_test.go index 6a77e655a9..526c01bdf8 100644 --- a/command/agent/acl_endpoint_test.go +++ b/command/agent/acl_endpoint_test.go @@ -30,9 +30,9 @@ func makeTestACL(t *testing.T, srv *HTTPServer) string { return aclResp.ID } -func TestACLUpdate(t *testing.T) { +func TestACL_Update(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() id := makeTestACL(t, a.srv) @@ -59,9 +59,9 @@ func TestACLUpdate(t *testing.T) { } } -func TestACLUpdate_Upsert(t *testing.T) { +func TestACL_UpdateUpsert(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() body := bytes.NewBuffer(nil) @@ -86,9 +86,9 @@ func TestACLUpdate_Upsert(t *testing.T) { } } -func TestACLDestroy(t *testing.T) { +func TestACL_Destroy(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() id := makeTestACL(t, a.srv) @@ -117,9 +117,9 @@ func TestACLDestroy(t *testing.T) { } } -func TestACLClone(t *testing.T) { +func TestACL_Clone(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() id := makeTestACL(t, a.srv) @@ -153,10 +153,10 @@ func TestACLClone(t *testing.T) { } } -func TestACLGet(t *testing.T) { +func TestACL_Get(t *testing.T) { t.Parallel() - t.Run("", func(t *testing.T) { - a := NewTestAgent(t.Name(), nil) + t.Run("wrong id", func(t *testing.T) { + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() req, _ := http.NewRequest("GET", "/v1/acl/info/nope", nil) @@ -174,8 +174,8 @@ func TestACLGet(t *testing.T) { } }) - t.Run("", func(t *testing.T) { - a := NewTestAgent(t.Name(), nil) + t.Run("right id", func(t *testing.T) { + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() id := makeTestACL(t, a.srv) @@ -196,9 +196,9 @@ func TestACLGet(t *testing.T) { }) } -func TestACLList(t *testing.T) { +func TestACL_List(t *testing.T) { t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() var ids []string diff --git a/command/agent/acl_test.go b/command/agent/acl_test.go index 410920d068..e0b65a4a1f 100644 --- a/command/agent/acl_test.go +++ b/command/agent/acl_test.go @@ -61,7 +61,7 @@ func TestACL_Version8(t *testing.T) { func TestACL_Disabled(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDisabledTTL = 10 * time.Millisecond cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -114,7 +114,7 @@ func TestACL_Disabled(t *testing.T) { func TestACL_Special_IDs(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue cfg.ACLAgentMasterToken = "towel" a := NewTestAgent(t.Name(), cfg) @@ -166,7 +166,7 @@ func TestACL_Special_IDs(t *testing.T) { func TestACL_Down_Deny(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDownPolicy = "deny" cfg.ACLEnforceVersion8 = &BoolTrue @@ -196,7 +196,7 @@ func TestACL_Down_Deny(t *testing.T) { func TestACL_Down_Allow(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDownPolicy = "allow" cfg.ACLEnforceVersion8 = &BoolTrue @@ -226,7 +226,7 @@ func TestACL_Down_Allow(t *testing.T) { func TestACL_Down_Extend(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDownPolicy = "extend-cache" cfg.ACLEnforceVersion8 = &BoolTrue @@ -304,7 +304,7 @@ func TestACL_Down_Extend(t *testing.T) { func TestACL_Cache(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -486,7 +486,7 @@ func catalogPolicy(req *structs.ACLPolicyRequest, reply *structs.ACLPolicy) erro func TestACL_vetServiceRegister(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -532,7 +532,7 @@ func TestACL_vetServiceRegister(t *testing.T) { func TestACL_vetServiceUpdate(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -568,7 +568,7 @@ func TestACL_vetServiceUpdate(t *testing.T) { func TestACL_vetCheckRegister(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -651,7 +651,7 @@ func TestACL_vetCheckRegister(t *testing.T) { func TestACL_vetCheckUpdate(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -707,7 +707,7 @@ func TestACL_vetCheckUpdate(t *testing.T) { func TestACL_filterMembers(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -743,7 +743,7 @@ func TestACL_filterMembers(t *testing.T) { func TestACL_filterServices(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) @@ -774,7 +774,7 @@ func TestACL_filterServices(t *testing.T) { func TestACL_filterChecks(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLEnforceVersion8 = &BoolTrue a := NewTestAgent(t.Name(), cfg) diff --git a/command/agent/event_endpoint_test.go b/command/agent/event_endpoint_test.go index eb5ecd5500..08171be859 100644 --- a/command/agent/event_endpoint_test.go +++ b/command/agent/event_endpoint_test.go @@ -54,7 +54,7 @@ func TestEventFire(t *testing.T) { func TestEventFire_token(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDefaultPolicy = "deny" a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() diff --git a/command/agent/snapshot_endpoint_test.go b/command/agent/snapshot_endpoint_test.go index c7f152a3cb..99c27572e3 100644 --- a/command/agent/snapshot_endpoint_test.go +++ b/command/agent/snapshot_endpoint_test.go @@ -54,7 +54,7 @@ func TestSnapshot_Options(t *testing.T) { t.Parallel() for _, method := range []string{"GET", "PUT"} { t.Run(method, func(t *testing.T) { - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() body := bytes.NewBuffer(nil) @@ -67,7 +67,7 @@ func TestSnapshot_Options(t *testing.T) { }) t.Run(method, func(t *testing.T) { - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() body := bytes.NewBuffer(nil) @@ -80,7 +80,7 @@ func TestSnapshot_Options(t *testing.T) { }) t.Run(method, func(t *testing.T) { - a := NewTestAgent(t.Name(), nil) + a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() body := bytes.NewBuffer(nil) diff --git a/command/agent/testagent.go b/command/agent/testagent.go index 54a10ecb97..a0f14210f9 100644 --- a/command/agent/testagent.go +++ b/command/agent/testagent.go @@ -227,7 +227,9 @@ func pickRandomPorts(c *Config) { port := 1030 + int(rand.Int31n(6440))*10 c.Ports.DNS = port + 1 c.Ports.HTTP = port + 2 - c.Ports.HTTPS = port + 3 + // when we enable HTTPS then we need to fix finding the + // "first" HTTP server since that might be HTTPS server + // c.Ports.HTTPS = port + 3 c.Ports.SerfLan = port + 4 c.Ports.SerfWan = port + 5 c.Ports.Server = port + 6 @@ -258,9 +260,6 @@ func TestConfig() *Config { cfg.Datacenter = "dc1" cfg.Bootstrap = true cfg.Server = true - cfg.ACLEnforceVersion8 = &BoolFalse - cfg.ACLDatacenter = cfg.Datacenter - cfg.ACLMasterToken = "root" ccfg := consul.DefaultConfig() cfg.ConsulConfig = ccfg diff --git a/command/agent/user_event_test.go b/command/agent/user_event_test.go index 94142b44ed..e5ff987b79 100644 --- a/command/agent/user_event_test.go +++ b/command/agent/user_event_test.go @@ -183,7 +183,7 @@ func TestFireReceiveEvent(t *testing.T) { func TestUserEventToken(t *testing.T) { t.Parallel() - cfg := TestConfig() + cfg := TestACLConfig() cfg.ACLDefaultPolicy = "deny" // Set the default policies to deny a := NewTestAgent(t.Name(), cfg) defer a.Shutdown()