(t *testing.T)
| 368 | } |
| 369 | |
| 370 | func TestWSWithTLSCustomDialer(t *testing.T) { |
| 371 | sopts := testWSGetDefaultOptions(t, true) |
| 372 | s := RunServerWithOptions(sopts) |
| 373 | defer s.Shutdown() |
| 374 | |
| 375 | sd := &testSkipTLSDialer{ |
| 376 | dialer: &net.Dialer{ |
| 377 | Timeout: 2 * time.Second, |
| 378 | }, |
| 379 | skipTLS: true, |
| 380 | } |
| 381 | |
| 382 | // Connect with CustomDialer that fails since TLSHandshake is disabled. |
| 383 | copts := make([]nats.Option, 0) |
| 384 | copts = append(copts, nats.Secure(&tls.Config{InsecureSkipVerify: true})) |
| 385 | copts = append(copts, nats.SetCustomDialer(sd)) |
| 386 | _, err := nats.Connect(fmt.Sprintf("wss://localhost:%d", sopts.Websocket.Port), copts...) |
| 387 | if err == nil { |
| 388 | t.Fatalf("Expected error on connect: %v", err) |
| 389 | } |
| 390 | if err.Error() != `invalid websocket connection` { |
| 391 | t.Logf("Expected invalid websocket connection: %v", err) |
| 392 | } |
| 393 | |
| 394 | // Retry with the dialer. |
| 395 | copts = make([]nats.Option, 0) |
| 396 | sd = &testSkipTLSDialer{ |
| 397 | dialer: &net.Dialer{ |
| 398 | Timeout: 2 * time.Second, |
| 399 | }, |
| 400 | skipTLS: false, |
| 401 | } |
| 402 | copts = append(copts, nats.Secure(&tls.Config{InsecureSkipVerify: true})) |
| 403 | copts = append(copts, nats.SetCustomDialer(sd)) |
| 404 | nc, err := nats.Connect(fmt.Sprintf("wss://localhost:%d", sopts.Websocket.Port), copts...) |
| 405 | if err != nil { |
| 406 | t.Fatalf("Unexpected error on connect: %v", err) |
| 407 | } |
| 408 | defer nc.Close() |
| 409 | } |
| 410 | |
| 411 | func TestWSGossipAndReconnect(t *testing.T) { |
| 412 | o1 := testWSGetDefaultOptions(t, false) |
nothing calls this directly
no test coverage detected