(t *testing.T)
| 605 | } |
| 606 | |
| 607 | func TestWSTlsNoConfig(t *testing.T) { |
| 608 | opts := GetDefaultOptions() |
| 609 | opts.Servers = []string{"wss://localhost:443"} |
| 610 | |
| 611 | nc := &Conn{Opts: opts} |
| 612 | if err := nc.setupServerPool(); err != nil { |
| 613 | t.Fatalf("Error setting up pool: %v", err) |
| 614 | } |
| 615 | // Verify that this has set Secure/TLSConfig |
| 616 | nc.mu.Lock() |
| 617 | ok := nc.Opts.Secure && nc.Opts.TLSConfig != nil |
| 618 | nc.mu.Unlock() |
| 619 | if !ok { |
| 620 | t.Fatal("Secure and TLSConfig were not set") |
| 621 | } |
| 622 | // Now try to add a bare host:ip to the pool and verify |
| 623 | // that the wss:// scheme is added. |
| 624 | if err := nc.addURLToPool("1.2.3.4:443", true, false); err != nil { |
| 625 | t.Fatalf("Error adding to pool: %v", err) |
| 626 | } |
| 627 | nc.mu.Lock() |
| 628 | for _, srv := range nc.srvPool { |
| 629 | if srv.URL.Scheme != wsSchemeTLS { |
| 630 | nc.mu.Unlock() |
| 631 | t.Fatalf("Expected scheme to be %q, got url: %s", wsSchemeTLS, srv.URL) |
| 632 | } |
| 633 | } |
| 634 | nc.mu.Unlock() |
| 635 | } |
| 636 | |
| 637 | func TestWSProxyPath(t *testing.T) { |
| 638 | const proxyPath = "proxy1" |
nothing calls this directly
no test coverage detected