From abd2e160f94ab56acf36cb815bcaa516e5263f22 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 9 Aug 2021 14:04:27 -0400 Subject: [PATCH] Fix test failures Tests only specified one of the fields, but in production we copy the value from a single place, so we can do the same in tests. The AutoConfig test broke because of the problem noticed in a previous commit. The DisabledTTL is not wired up properly so it reports 0s here. Changed the test to use an explicit value. --- agent/consul/auto_config_endpoint_test.go | 4 +++- agent/consul/server_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/consul/auto_config_endpoint_test.go b/agent/consul/auto_config_endpoint_test.go index 58335a65c9..3aa45bf5ce 100644 --- a/agent/consul/auto_config_endpoint_test.go +++ b/agent/consul/auto_config_endpoint_test.go @@ -153,6 +153,8 @@ func TestAutoConfigInitialConfiguration(t *testing.T) { } c.AutoConfigAuthzAllowReuse = true + c.ACLResolverSettings.ACLDisabledTTL = 12 * time.Second + cafile := path.Join(c.DataDir, "cacert.pem") err := ioutil.WriteFile(cafile, []byte(cacert), 0600) require.NoError(t, err) @@ -263,7 +265,7 @@ func TestAutoConfigInitialConfiguration(t *testing.T) { PolicyTTL: "30s", TokenTTL: "30s", RoleTTL: "30s", - DisabledTTL: "0s", + DisabledTTL: "12s", DownPolicy: "extend-cache", DefaultPolicy: "deny", Tokens: &pbconfig.ACLTokens{ diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index ce57c44dc3..25a0b407dc 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -245,6 +245,12 @@ func testServerWithConfig(t *testing.T, cb func(*Config)) (string, *Server) { cb(config) } + // Apply config to copied fields because many tests only set the old + //values. + config.ACLResolverSettings.ACLsEnabled = config.ACLsEnabled + config.ACLResolverSettings.NodeName = config.NodeName + config.ACLResolverSettings.Datacenter = config.Datacenter + var err error srv, err = newServer(t, config) if err != nil {