From 34da7ccd64d2cbc4eed9d0d6a47be1d6dc190c85 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Mon, 12 Dec 2016 22:09:35 -0800 Subject: [PATCH] Adds a unit test to make sure the status endpoint doesn't ever show anything with "token" in the name. --- command/agent/agent_endpoint_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index 522a508d13..d9db96210e 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -1,6 +1,7 @@ package agent import ( + "bytes" "errors" "fmt" "io" @@ -117,6 +118,15 @@ func TestHTTPAgentSelf(t *testing.T) { if val.Coord != nil { t.Fatalf("should have been nil: %v", val.Coord) } + + // Make sure there's nothing called "token" that's leaked. + raw, err := srv.marshalJSON(req, obj) + if err != nil { + t.Fatalf("err: %v", err) + } + if bytes.Contains(bytes.ToLower(raw), []byte("token")) { + t.Fatalf("bad: %s", raw) + } } func TestHTTPAgentReload(t *testing.T) {