From f535f971859adde5c6886b3aa8019e904ec228ef Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Fri, 13 Oct 2023 15:20:32 -0400 Subject: [PATCH] Fix unit test for control-plane failing due to added policies --- .../server-acl-init/command_ent_test.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/control-plane/subcommand/server-acl-init/command_ent_test.go b/control-plane/subcommand/server-acl-init/command_ent_test.go index a67a2d0e41..ad171a7cfc 100644 --- a/control-plane/subcommand/server-acl-init/command_ent_test.go +++ b/control-plane/subcommand/server-acl-init/command_ent_test.go @@ -320,6 +320,11 @@ func TestRun_ACLPolicyUpdates(t *testing.T) { require.NoError(t, err) // Check that the expected policies were created. + // There will be more policies returned in the List API that are defaults + // existing in Consul on startup, including but not limited to: + // * global-management + // * builtin/global-read-only + // * agent-token firstRunExpectedPolicies := []string{ "anonymous-token-policy", "client-policy", @@ -336,12 +341,6 @@ func TestRun_ACLPolicyUpdates(t *testing.T) { policies, _, err := consul.ACL().PolicyList(nil) require.NoError(t, err) - // Check that we have the right number of policies. The actual - // policies will have two more than expected because of the - // global management and namespace management polices that - // are automatically created, the latter in consul-ent v1.7+. - require.Equal(t, len(firstRunExpectedPolicies), len(policies)-2) - // Collect the actual policies into a map to make it easier to assert // on their existence and contents. actualPolicies := make(map[string]string) @@ -388,12 +387,6 @@ func TestRun_ACLPolicyUpdates(t *testing.T) { policies, _, err = consul.ACL().PolicyList(nil) require.NoError(t, err) - // Check that we have the right number of policies. The actual - // policies will have two more than expected because of the - // global management and namespace management polices that - // are automatically created, the latter in consul-ent v1.7+. - require.Equal(t, len(secondRunExpectedPolicies), len(policies)-2) - // Collect the actual policies into a map to make it easier to assert // on their existence and contents. actualPolicies = make(map[string]string)