MCPcopy
hub / github.com/nats-io/nats.go / TestWSTlsNoConfig

Function TestWSTlsNoConfig

ws_test.go:607–635  ·  ws_test.go::TestWSTlsNoConfig
(t *testing.T)

Source from the content-addressed store, hash-verified

605}
606
607func 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
637func TestWSProxyPath(t *testing.T) {
638 const proxyPath = "proxy1"

Callers

nothing calls this directly

Calls 4

setupServerPoolMethod · 0.95
addURLToPoolMethod · 0.95
GetDefaultOptionsFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected