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

Function TestUserCredentialBytes

test/nats_test.go:339–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

337}
338
339func TestUserCredentialBytes(t *testing.T) {
340 ts := runTrustServer()
341 defer ts.Shutdown()
342
343 // Test with JWT and seed as byte slices
344 jwtBytes := []byte(uJWT)
345 seedBytes := uSeed
346
347 nc, err := nats.Connect(ts.ClientURL(), nats.UserCredentialBytes(jwtBytes, seedBytes))
348 if err != nil {
349 t.Fatalf("Expected to connect with separate JWT and seed bytes, got %v", err)
350 }
351 nc.Close()
352
353 // Test with chained credentials (JWT and seed in same byte slice)
354 nc2, err := nats.Connect(ts.ClientURL(), nats.UserCredentialBytes([]byte(chained)))
355 if err != nil {
356 t.Fatalf("Expected to connect with chained credentials bytes, got %v", err)
357 }
358 nc2.Close()
359}
360
361// If we are using TLS and have multiple servers we try to match the IP
362// from a discovered server with the expected hostname for certs without IP

Callers

nothing calls this directly

Calls 4

runTrustServerFunction · 0.85
ConnectMethod · 0.80
FatalfMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected