Skip to content

Commit 6b2fd81

Browse files
committed
test(sec): enhance security and performance in test server configs
- Set the minimum TLS version to TLS 1.2 in the test server configuration - Add `ReadHeaderTimeout` of 10 seconds to the HTTP server configurations in the tests Signed-off-by: appleboy <[email protected]>
1 parent b87353a commit 6b2fd81

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

graceful_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,19 @@ func TestWithServer(t *testing.T) {
192192
assert.NoError(t, err)
193193
tlsConfig := &tls.Config{
194194
Certificates: []tls.Certificate{cert},
195+
MinVersion: tls.VersionTLS12,
195196
}
196197
testRouterConstructor(t, func() (*Graceful, error) {
197198
return Default(
198-
WithServer(&http.Server{Addr: ":8811"}),
199-
WithServer(&http.Server{Addr: ":9443", TLSConfig: tlsConfig}),
199+
WithServer(&http.Server{
200+
Addr: ":8811",
201+
ReadHeaderTimeout: 10 * time.Second,
202+
}),
203+
WithServer(&http.Server{
204+
Addr: ":9443",
205+
TLSConfig: tlsConfig,
206+
ReadHeaderTimeout: 10 * time.Second,
207+
}),
200208
)
201209
}, "http://localhost:8811/example", "https://localhost:9443/example")
202210
}
@@ -212,7 +220,10 @@ func TestWithAll(t *testing.T) {
212220
return Default(WithAddr(":8080"),
213221
WithTLS(":8443", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"),
214222
WithListener(listener),
215-
WithServer(&http.Server{Addr: ":8811"}),
223+
WithServer(&http.Server{
224+
Addr: ":8811",
225+
ReadHeaderTimeout: 10 * time.Second,
226+
}),
216227
)
217228
},
218229
"http://localhost:8080/example",

0 commit comments

Comments
 (0)