Add load tls file testing error.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
d6f9d132ea
commit
5d0bbdf4ad
|
@ -63,6 +63,17 @@ func TestRunTLSServer(t *testing.T) {
|
||||||
gofight.TestRequest(t, "https://localhost:8087/api/stat/go")
|
gofight.TestRequest(t, "https://localhost:8087/api/stat/go")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadTLSCertError(t *testing.T) {
|
||||||
|
initTest()
|
||||||
|
|
||||||
|
PushConf.Core.SSL = true
|
||||||
|
PushConf.Core.Port = "8087"
|
||||||
|
PushConf.Core.CertPath = "../config/config.yml"
|
||||||
|
PushConf.Core.KeyPath = "../config/config.yml"
|
||||||
|
|
||||||
|
assert.Error(t, RunHTTPServer())
|
||||||
|
}
|
||||||
|
|
||||||
func TestRootHandler(t *testing.T) {
|
func TestRootHandler(t *testing.T) {
|
||||||
initTest()
|
initTest()
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ func RunHTTPServer() error {
|
||||||
config.Certificates = make([]tls.Certificate, 1)
|
config.Certificates = make([]tls.Certificate, 1)
|
||||||
config.Certificates[0], err = tls.LoadX509KeyPair(PushConf.Core.CertPath, PushConf.Core.KeyPath)
|
config.Certificates[0], err = tls.LoadX509KeyPair(PushConf.Core.CertPath, PushConf.Core.KeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogError.Fatal("Failed to load https cert file: ", err)
|
LogError.Error("Failed to load https cert file: ", err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gracehttp.Serve(&http.Server{
|
err = gracehttp.Serve(&http.Server{
|
||||||
|
|
Loading…
Reference in New Issue