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

Function TestServerTLSHintConnections

test/conn_test.go:526–544  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

524}
525
526func TestServerTLSHintConnections(t *testing.T) {
527 s, opts := RunServerWithConfig("./configs/tls.conf")
528 defer s.Shutdown()
529
530 endpoint := fmt.Sprintf("%s:%d", opts.Host, opts.Port)
531 secureURL := fmt.Sprintf("tls://%s:%s@%s/", opts.Username, opts.Password, endpoint)
532
533 nc, err := nats.Connect(secureURL, nats.RootCAs("./configs/certs/badca.pem"))
534 if err == nil {
535 nc.Close()
536 t.Fatal("Expected an error from bad RootCA file")
537 }
538
539 nc, err = nats.Connect(secureURL, nats.RootCAs("./configs/certs/ca.pem"))
540 if err != nil {
541 t.Fatalf("Failed to create secure (TLS) connection: %v", err)
542 }
543 defer nc.Close()
544}
545
546func TestClosedConnections(t *testing.T) {
547 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 4

ConnectMethod · 0.80
FatalfMethod · 0.80
RunServerWithConfigFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected