Fix panic in tls manager

This commit is contained in:
Julien Salleyron 2019-06-21 16:32:04 +02:00 committed by Traefiker Bot
parent 69a1817c3f
commit 69cf05df9a
2 changed files with 33 additions and 5 deletions

View file

@ -62,3 +62,30 @@ func TestTLSInStore(t *testing.T) {
t.Fatal("got error: default store must have TLS certificates.")
}
}
func TestTLSInvalidStore(t *testing.T) {
dynamicConfigs :=
[]*Configuration{
{
Certificate: &Certificate{
CertFile: localhostCert,
KeyFile: localhostKey,
},
},
}
tlsManager := NewManager()
tlsManager.UpdateConfigs(map[string]Store{
"default": {
DefaultCertificate: &Certificate{
CertFile: "/wrong",
KeyFile: "/wrong",
},
},
}, nil, dynamicConfigs)
certs := tlsManager.GetStore("default").DynamicCerts.Get().(map[string]*tls.Certificate)
if len(certs) == 0 {
t.Fatal("got error: default store must have TLS certificates.")
}
}