From 785a6d9c8e833649a9d9addfbf60c5d2668f0033 Mon Sep 17 00:00:00 2001 From: Mark Anderson Date: Thu, 5 May 2022 18:46:03 -0700 Subject: [PATCH] Add oss test Signed-off-by: Mark Anderson --- agent/agent_endpoint_oss_test.go | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 agent/agent_endpoint_oss_test.go diff --git a/agent/agent_endpoint_oss_test.go b/agent/agent_endpoint_oss_test.go new file mode 100644 index 000000000..d815bb458 --- /dev/null +++ b/agent/agent_endpoint_oss_test.go @@ -0,0 +1,49 @@ +//go:build !consulent +// +build !consulent + +package agent + +import ( + "encoding/json" + "github.com/stretchr/testify/require" + "net/http" + "net/http/httptest" + "testing" + + "github.com/hashicorp/consul/testrpc" +) + +func TestAgent_Self_VersionLacksEnt(t *testing.T) { + if testing.Short() { + t.Skip("too slow for testing.Short") + } + + t.Parallel() + + cases := map[string]struct { + hcl string + expectXDS bool + }{ + "normal": { + hcl: "primary_datacenter = \"dc1\"", + }, + } + + for name, tc := range cases { + tc := tc + t.Run(name, func(t *testing.T) { + a := NewTestAgent(t, tc.hcl) + defer a.Shutdown() + + testrpc.WaitForTestAgent(t, a.RPC, "dc1") + req, _ := http.NewRequest("GET", "/v1/agent/self", nil) + resp := httptest.NewRecorder() + a.srv.h.ServeHTTP(resp, req) + + dec := json.NewDecoder(resp.Body) + var out map[string]map[string]interface{} + require.NoError(t, dec.Decode(&out)) + require.NotContains(t, out["Config"]["Version"], "ent") + }) + } +}