From 6665206c9ee3f2e4e1c51ed15a413f73481fea3e Mon Sep 17 00:00:00 2001 From: Chelsea Holland Komlo Date: Wed, 28 Mar 2018 18:31:35 -0400 Subject: [PATCH] add test to assert invalid files return error --- nomad/structs/config/tls_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nomad/structs/config/tls_test.go b/nomad/structs/config/tls_test.go index 390039319..698855e08 100644 --- a/nomad/structs/config/tls_test.go +++ b/nomad/structs/config/tls_test.go @@ -117,6 +117,24 @@ func TestTLS_CertificateInfoIsEqual_FalseWhenUnequal(t *testing.T) { require.Nil(err) require.False(isEqual) } + + // Assert that invalid files return an error + { + a := &TLSConfig{ + CAFile: cafile, + CertFile: foocert, + KeyFile: fookey2, + } + + b := &TLSConfig{ + CAFile: cafile, + CertFile: "invalid_file", + KeyFile: fookey2, + } + isEqual, err := a.CertificateInfoIsEqual(b) + require.NotNil(err) + require.False(isEqual) + } } // Certificate info should be equal when the CA file, certificate file, and key