Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"context"
"crypto/rand"
"crypto/x509"
"errors"
"io"
"maps"
Expand All @@ -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
Expand All @@ -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) {
Expand Down
Loading