Skip to content

Commit

Permalink
Remove ACME tests. Add check for tlsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby committed Dec 9, 2024
1 parent 90bd4cc commit c3b07e9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
2 changes: 1 addition & 1 deletion listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (app *App) Listen(addr string, config ...ListenConfig) error {
}

Check warning on line 199 in listen.go

View check run for this annotation

Codecov / codecov/patch

listen.go#L195-L199

Added lines #L195 - L199 were not covered by tests
}

if cfg.TLSConfigFunc != nil {
if tlsConfig != nil && cfg.TLSConfigFunc != nil {
cfg.TLSConfigFunc(tlsConfig)
}

Expand Down
59 changes: 0 additions & 59 deletions listen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttputil"
"golang.org/x/crypto/acme"
"golang.org/x/crypto/acme/autocert"
)

// go test -run Test_Listen
Expand Down Expand Up @@ -259,35 +257,6 @@ func Test_Listen_TLS(t *testing.T) {
}))
}

// go test -run Test_Listen_Acme_TLS
func Test_Listen_Acme_TLS(t *testing.T) {
dir, err := os.Getwd()
require.NoError(t, err)
dir, err = os.MkdirTemp(dir, "certs")
require.NoError(t, err)
defer os.RemoveAll(dir) //nolint:errcheck // ignore error

// Certificate manager
m := &autocert.Manager{
Prompt: autocert.AcceptTOS,
// Replace with your domain
HostPolicy: autocert.HostWhitelist("example.com"),
// Folder to store the certificates
Cache: autocert.DirCache(dir),
// Define the Client for test
Client: &acme.Client{
DirectoryURL: "https://acme-staging-v02.api.letsencrypt.org/directory",
},
}

app := New()

require.NoError(t, app.Listen(":0", ListenConfig{
DisableStartupMessage: true,
AutoCertManager: m,
}))
}

// go test -run Test_Listen_TLS_Prefork
func Test_Listen_TLS_Prefork(t *testing.T) {
testPreforkMaster = true
Expand Down Expand Up @@ -315,34 +284,6 @@ func Test_Listen_TLS_Prefork(t *testing.T) {
}))
}

// go test -run Test_Listen_Acme_TLS_Prefork
func Test_Listen_Acme_TLS_Prefork(t *testing.T) {
dir, err := os.MkdirTemp(".", "certs")
require.NoError(t, err)
defer os.RemoveAll(dir) //nolint:errcheck // ignore error

// Certificate manager
m := &autocert.Manager{
Prompt: autocert.AcceptTOS,
// Replace with your domain
HostPolicy: autocert.HostWhitelist("example.com"),
// Folder to store the certificates
Cache: autocert.DirCache(dir),
// Define the Client for test
Client: &acme.Client{
DirectoryURL: "https://acme-staging-v02.api.letsencrypt.org/directory",
},
}

app := New()

require.NoError(t, app.Listen(":0", ListenConfig{
DisableStartupMessage: true,
EnablePrefork: true,
AutoCertManager: m,
}))
}

// go test -run Test_Listen_MutualTLS
func Test_Listen_MutualTLS(t *testing.T) {
app := New()
Expand Down

0 comments on commit c3b07e9

Please sign in to comment.