diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index a939e96e89..43daf2187e 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -2375,6 +2375,42 @@ func TestLoad_IntegrationWithFlags(t *testing.T) { rt.DataDir = dataDir }, }) + run(t, testCase{ + desc: "h2ping check without h2ping_use_tls set", + args: []string{ + `-data-dir=` + dataDir, + }, + json: []string{ + `{ "check": { "name": "a", "h2ping": "localhost:55555", "interval": "5s" } }`, + }, + hcl: []string{ + `check = { name = "a" h2ping = "localhost:55555" interval = "5s" }`, + }, + expected: func(rt *RuntimeConfig) { + rt.Checks = []*structs.CheckDefinition{ + {Name: "a", H2PING: "localhost:55555", H2PingUseTLS: true, OutputMaxSize: checks.DefaultBufSize, Interval: 5 * time.Second}, + } + rt.DataDir = dataDir + }, + }) + run(t, testCase{ + desc: "h2ping check with h2ping_use_tls set to false", + args: []string{ + `-data-dir=` + dataDir, + }, + json: []string{ + `{ "check": { "name": "a", "h2ping": "localhost:55555", "h2ping_use_tls": false, "interval": "5s" } }`, + }, + hcl: []string{ + `check = { name = "a" h2ping = "localhost:55555" h2ping_use_tls = false interval = "5s" }`, + }, + expected: func(rt *RuntimeConfig) { + rt.Checks = []*structs.CheckDefinition{ + {Name: "a", H2PING: "localhost:55555", H2PingUseTLS: false, OutputMaxSize: checks.DefaultBufSize, Interval: 5 * time.Second}, + } + rt.DataDir = dataDir + }, + }) run(t, testCase{ desc: "alias check with no node", args: []string{ diff --git a/agent/http_decode_test.go b/agent/http_decode_test.go index ba8f060410..50347f6e1e 100644 --- a/agent/http_decode_test.go +++ b/agent/http_decode_test.go @@ -702,7 +702,7 @@ func h2pingUseTLSEqFn(out interface{}, want interface{}) error { return nil } -var h2pingUseTLSFields = []string{`"H2PingUseTLS": %s`, `"h2ping_use_tls": %s`} +var h2pingUseTLSFields = []string{`"H2PING": "testing"`, `"H2PingUseTLS": %s`, `"h2ping_use_tls": %s`} var translateH2PingUseTLS = []translateKeyTestCase{ { desc: "H2PingUseTLS: both set", @@ -715,21 +715,21 @@ var translateH2PingUseTLS = []translateKeyTestCase{ desc: "H2PingUseTLS:: first set", in: []interface{}{`false`}, want: false, - jsonFmtStr: "{" + h2pingUseTLSFields[0] + "}", + jsonFmtStr: "{" + strings.Join(h2pingUseTLSFields[0:2], ",") + "}", equalityFn: h2pingUseTLSEqFn, }, { desc: "H2PingUseTLS: second set", in: []interface{}{`false`}, want: false, - jsonFmtStr: "{" + h2pingUseTLSFields[1] + "}", + jsonFmtStr: "{" + h2pingUseTLSFields[0] + "," + h2pingUseTLSFields[2] + "}", equalityFn: h2pingUseTLSEqFn, }, { desc: "H2PingUseTLS: neither set", in: []interface{}{}, want: true, // zero value - jsonFmtStr: "{" + `"h2ping":"testing"` + "}", + jsonFmtStr: "{" + h2pingUseTLSFields[0] + "}", equalityFn: h2pingUseTLSEqFn, }, }