Browse Source

test: remove ACL options from default test config

pull/3037/head
Frank Schroeder 8 years ago
parent
commit
0f912c8aad
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
  1. 30
      command/agent/acl_endpoint_test.go
  2. 26
      command/agent/acl_test.go
  3. 2
      command/agent/event_endpoint_test.go
  4. 6
      command/agent/snapshot_endpoint_test.go
  5. 7
      command/agent/testagent.go
  6. 2
      command/agent/user_event_test.go

30
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

26
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)

2
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()

6
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)

7
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

2
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()

Loading…
Cancel
Save