Skip to content

Commit

Permalink
Add respbody error assertion and defer resp.Body.Close ()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaycean committed Mar 1, 2021
1 parent be91a89 commit d75b79a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/test/e2enew/ssl/ssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var _ = ginkgo.Describe("SSL Basic", func() {
"cert": string(testCert),
"key": string(apisixKey),
})
assert.Nil(t, err)
// Before configuring SSL, make a HTTPS request
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
http.DefaultTransport.(*http.Transport).DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
Expand All @@ -68,6 +69,7 @@ var _ = ginkgo.Describe("SSL Basic", func() {
}
_, err = http.Get("https://www.test2.com:9443")
assert.NotNil(t, err)
defer resp.Body.Close()
assert.EqualError(t, err, "Get https://www.test2.com:9443: remote error: tls: internal error")
//create ssl fail - key and cert not match
base.RunTestCase(base.HttpTestCase{
Expand Down Expand Up @@ -166,6 +168,7 @@ var _ = ginkgo.Describe("SSL Basic", func() {
time.Sleep(time.Duration(500) * time.Millisecond)
_, err := http.Get("https://www.test2.com:9443")
assert.NotNil(t, err)
defer resp.Body.Close()
assert.EqualError(t, err, "Get https://www.test2.com:9443: remote error: tls: internal error")
})
ginkgo.It("enable SSL", func() {
Expand Down

0 comments on commit d75b79a

Please sign in to comment.