diff --git a/app_test.go b/app_test.go index da638b8e2f..1a6d360048 100644 --- a/app_test.go +++ b/app_test.go @@ -967,6 +967,35 @@ func Test_App_Listen_Prefork(t *testing.T) { utils.AssertEqual(t, nil, app.Listen(":99999")) } +// go test -run Test_App_ListenTLS +func Test_App_ListenTLS(t *testing.T) { + app := New() + + // invalid port + utils.AssertEqual(t, false, app.ListenTLS(":99999", "./.github/testdata/ssl.pem", "./.github/testdata/ssl.key") == nil) + // missing perm/cert file + utils.AssertEqual(t, false, app.ListenTLS(":0", "", "./.github/testdata/ssl.key") == nil) + + go func() { + time.Sleep(1000 * time.Millisecond) + utils.AssertEqual(t, nil, app.Shutdown()) + }() + + utils.AssertEqual(t, nil, app.ListenTLS(":0", "./.github/testdata/ssl.pem", "./.github/testdata/ssl.key")) +} + +// go test -run Test_App_ListenTLS_Prefork +func Test_App_ListenTLS_Prefork(t *testing.T) { + testPreforkMaster = true + + app := New(Config{DisableStartupMessage: true, Prefork: true}) + + // invalid key file content + utils.AssertEqual(t, false, app.ListenTLS(":0", "./.github/testdata/ssl.pem", "./.github/testdata/template.html") == nil) + + utils.AssertEqual(t, nil, app.ListenTLS(":99999", "./.github/testdata/ssl.pem", "./.github/testdata/ssl.key")) +} + // go test -run Test_App_Listener func Test_App_Listener(t *testing.T) { app := New() @@ -990,7 +1019,7 @@ func Test_App_Listener_Prefork(t *testing.T) { utils.AssertEqual(t, nil, app.Listener(ln)) } -func Test_App_Listener_TLS(t *testing.T) { +func Test_App_Listener_TLS_Listener(t *testing.T) { // Create tls certificate cer, err := tls.LoadX509KeyPair("./.github/testdata/ssl.pem", "./.github/testdata/ssl.key") if err != nil {