Add test for if the client CA dir is empty

Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
Ying Li
2015-10-19 13:40:38 -07:00
parent fc389b7bc3
commit fb81aaed10

View File

@@ -64,6 +64,17 @@ func TestConfigServerTLSServerCertsOnly(t *testing.T) {
assert.Nil(t, tlsConfig.ClientCAs)
}
// If a valid client cert directory is provided, but it contains no client
// certs, an error is returned.
func TestConfigServerTLSWithEmptyCACertDir(t *testing.T) {
tempDir, err := ioutil.TempDir("/tmp", "cert-test")
assert.NoError(t, err, "couldn't open temp directory")
tlsConfig, err := ConfigureServerTLS(ServerCert, ServerKey, false, tempDir)
assert.Nil(t, tlsConfig)
assert.Error(t, err)
}
// If server cert and key are provided, and client cert directory is provided,
// a valid tls.Config is returned with the clientCAs set to the certs in that
// directory.