diff --git a/dial_test.go b/dial_test.go index 11b88ab8..6c4c564f 100644 --- a/dial_test.go +++ b/dial_test.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "crypto/rand" + "crypto/x509" "errors" "io" "maps" @@ -28,6 +29,21 @@ func TestBadDials(t *testing.T) { t.Run("badReq", func(t *testing.T) { t.Parallel() + t.Run("badTLS", func(t *testing.T) { + t.Parallel() + + srv := httptest.NewTLSServer(nil) + defer srv.Close() + + ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) + defer cancel() + _, _, err := websocket.Dial(ctx, srv.URL, nil) + var certErr x509.UnknownAuthorityError + if !errors.As(err, &certErr) { + t.Fatalf("expected an untrusted certificate error, got %v", err) + } + }) + testCases := []struct { name string url string @@ -43,10 +59,6 @@ func TestBadDials(t *testing.T) { name: "badURLScheme", url: "ftp://nhooyr.io", }, - { - name: "badTLS", - url: "wss://totallyfake.nhooyr.io", - }, { name: "badReader", rand: func(p []byte) (int, error) {