make chunkSize < len(host) and remove retries

This commit is contained in:
Chotiwat Chawannakul 2024-02-16 15:36:10 -08:00
parent 525931b437
commit 6d8a4207d5

View file

@ -214,62 +214,53 @@ var _ = framework.IngressNginxDescribe("[Flag] enable-ssl-passthrough", func() {
conn, err := next(ctx, network, addr) conn, err := next(ctx, network, addr)
return &writeThrottledConn{ return &writeThrottledConn{
Conn: conn, Conn: conn,
chunkSize: 50, chunkSize: len(host) / 3,
}, err }, err
} }
} }
tries := 3
ginkgo.It("should handle known traffic without Host header", func() { ginkgo.It("should handle known traffic without Host header", func() {
for i := 0; i < tries; i++ { f.HTTPTestClientWithTLSConfig(tlsConfig).
f.HTTPTestClientWithTLSConfig(tlsConfig). GET("/").
GET("/"). WithURL(url).
WithURL(url). ForceResolve(f.GetNginxIP(), 443).
ForceResolve(f.GetNginxIP(), 443). WithDialContextMiddleware(throttleMiddleware).
WithDialContextMiddleware(throttleMiddleware). Expect().
Expect(). Status(http.StatusOK)
Status(http.StatusOK)
}
}) })
ginkgo.It("should handle insecure traffic without Host header", func() { ginkgo.It("should handle insecure traffic without Host header", func() {
for i := 0; i < tries; i++ { //nolint:gosec // Ignore the gosec error in testing
//nolint:gosec // Ignore the gosec error in testing f.HTTPTestClientWithTLSConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}).
f.HTTPTestClientWithTLSConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}). GET("/").
GET("/"). WithURL(url).
WithURL(url). ForceResolve(f.GetNginxIP(), 443).
ForceResolve(f.GetNginxIP(), 443). WithDialContextMiddleware(throttleMiddleware).
WithDialContextMiddleware(throttleMiddleware). Expect().
Expect(). Status(http.StatusOK)
Status(http.StatusOK)
}
}) })
ginkgo.It("should handle known traffic with Host header", func() { ginkgo.It("should handle known traffic with Host header", func() {
for i := 0; i < tries; i++ { f.HTTPTestClientWithTLSConfig(tlsConfig).
f.HTTPTestClientWithTLSConfig(tlsConfig). GET("/").
GET("/"). WithURL(url).
WithURL(url). WithHeader("Host", host).
WithHeader("Host", host). ForceResolve(f.GetNginxIP(), 443).
ForceResolve(f.GetNginxIP(), 443). WithDialContextMiddleware(throttleMiddleware).
WithDialContextMiddleware(throttleMiddleware). Expect().
Expect(). Status(http.StatusOK)
Status(http.StatusOK)
}
}) })
ginkgo.It("should handle insecure traffic with Host header", func() { ginkgo.It("should handle insecure traffic with Host header", func() {
for i := 0; i < tries; i++ { //nolint:gosec // Ignore the gosec error in testing
//nolint:gosec // Ignore the gosec error in testing f.HTTPTestClientWithTLSConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}).
f.HTTPTestClientWithTLSConfig(&tls.Config{ServerName: host, InsecureSkipVerify: true}). GET("/").
GET("/"). WithURL(url).
WithURL(url). WithHeader("Host", host).
WithHeader("Host", host). ForceResolve(f.GetNginxIP(), 443).
ForceResolve(f.GetNginxIP(), 443). WithDialContextMiddleware(throttleMiddleware).
WithDialContextMiddleware(throttleMiddleware). Expect().
Expect(). Status(http.StatusOK)
Status(http.StatusOK)
}
}) })
}) })
}) })