From 8177e2f811414d2e7a9f5374189eedc0a0865eee Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 7 Apr 2014 12:50:42 -0700 Subject: [PATCH] agent: Adding tests for TLS configs --- command/agent/config_test.go | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index d6d3f6eaa2..6864e83c4d 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -193,6 +193,38 @@ func TestDecodeConfig(t *testing.T) { if config.EnableDebug != true { t.Fatalf("bad: %#v", config) } + + // TLS + input = `{"verify_incoming": true, "verify_outgoing": true}` + config, err = DecodeConfig(bytes.NewReader([]byte(input))) + if err != nil { + t.Fatalf("err: %s", err) + } + + if config.VerifyIncoming != true { + t.Fatalf("bad: %#v", config) + } + + if config.VerifyOutgoing != true { + t.Fatalf("bad: %#v", config) + } + + // TLS keys + input = `{"ca_file": "my/ca/file", "cert_file": "my.cert", "key_file": "key.pem"}` + config, err = DecodeConfig(bytes.NewReader([]byte(input))) + if err != nil { + t.Fatalf("err: %s", err) + } + + if config.CAFile != "my/ca/file" { + t.Fatalf("bad: %#v", config) + } + if config.CertFile != "my.cert" { + t.Fatalf("bad: %#v", config) + } + if config.KeyFile != "key.pem" { + t.Fatalf("bad: %#v", config) + } } func TestDecodeConfig_Service(t *testing.T) { @@ -318,6 +350,11 @@ func TestMergeConfig(t *testing.T) { LeaveOnTerm: true, SkipLeaveOnInt: true, EnableDebug: true, + VerifyIncoming: true, + VerifyOutgoing: true, + CAFile: "test/ca.pem", + CertFile: "test/cert.pem", + KeyFile: "test/key.pem", Checks: []*CheckDefinition{nil}, Services: []*ServiceDefinition{nil}, }