aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/http/client_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/http/client_test.go')
-rw-r--r--libgo/go/http/client_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/libgo/go/http/client_test.go b/libgo/go/http/client_test.go
index 0ad6cd7..8f61286 100644
--- a/libgo/go/http/client_test.go
+++ b/libgo/go/http/client_test.go
@@ -7,6 +7,7 @@
package http_test
import (
+ "crypto/tls"
"fmt"
. "http"
"http/httptest"
@@ -292,3 +293,26 @@ func TestClientWrites(t *testing.T) {
t.Errorf("Post request did %d Write calls, want 1", writes)
}
}
+
+func TestClientInsecureTransport(t *testing.T) {
+ ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+ w.Write([]byte("Hello"))
+ }))
+ defer ts.Close()
+
+ // TODO(bradfitz): add tests for skipping hostname checks too?
+ // would require a new cert for testing, and probably
+ // redundant with these tests.
+ for _, insecure := range []bool{true, false} {
+ tr := &Transport{
+ TLSClientConfig: &tls.Config{
+ InsecureSkipVerify: insecure,
+ },
+ }
+ c := &Client{Transport: tr}
+ _, err := c.Get(ts.URL)
+ if (err == nil) != insecure {
+ t.Errorf("insecure=%v: got unexpected err=%v", insecure, err)
+ }
+ }
+}