agent: refactor: use handler for test http tls server
This commit is contained in:
parent
21a0e94aea
commit
865a825116
|
@ -351,18 +351,18 @@ func TestCheckHTTP_TLSSkipVerify_defaultFalse(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockTLSHTTPServer(code int) *httptest.Server {
|
func largeBodyHandler(code int) http.Handler {
|
||||||
return httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// Body larger than 4k limit
|
// Body larger than 4k limit
|
||||||
body := bytes.Repeat([]byte{'a'}, 2*CheckBufSize)
|
body := bytes.Repeat([]byte{'a'}, 2*CheckBufSize)
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
w.Write(body)
|
w.Write(body)
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) {
|
func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
server := mockTLSHTTPServer(200)
|
server := httptest.NewTLSServer(largeBodyHandler(200))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
notif := mock.NewNotify()
|
notif := mock.NewNotify()
|
||||||
|
@ -391,7 +391,7 @@ func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) {
|
||||||
|
|
||||||
func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) {
|
func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
server := mockTLSHTTPServer(500)
|
server := httptest.NewTLSServer(largeBodyHandler(500))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
notif := mock.NewNotify()
|
notif := mock.NewNotify()
|
||||||
|
@ -419,7 +419,7 @@ func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) {
|
||||||
|
|
||||||
func TestCheckHTTP_TLSSkipVerify_false(t *testing.T) {
|
func TestCheckHTTP_TLSSkipVerify_false(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
server := mockTLSHTTPServer(200)
|
server := httptest.NewTLSServer(largeBodyHandler(200))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
notif := mock.NewNotify()
|
notif := mock.NewNotify()
|
||||||
|
|
Loading…
Reference in New Issue