(t *testing.T)
| 261 | } |
| 262 | |
| 263 | func TestUserCredentialsChainedFile(t *testing.T) { |
| 264 | if server.VERSION[0] == '1' { |
| 265 | t.Skip() |
| 266 | } |
| 267 | ts := runTrustServer() |
| 268 | defer ts.Shutdown() |
| 269 | |
| 270 | chainedFile := createTmpFile(t, []byte(chained)) |
| 271 | defer os.Remove(chainedFile) |
| 272 | |
| 273 | url := fmt.Sprintf("nats://127.0.0.1:%d", TEST_PORT) |
| 274 | nc, err := nats.Connect(url, nats.UserCredentials(chainedFile)) |
| 275 | if err != nil { |
| 276 | t.Fatalf("Expected to connect, got %v", err) |
| 277 | } |
| 278 | nc.Close() |
| 279 | |
| 280 | chainedFile = createTmpFile(t, []byte("invalid content")) |
| 281 | defer os.Remove(chainedFile) |
| 282 | nc, err = nats.Connect(url, nats.UserCredentials(chainedFile)) |
| 283 | if err == nil || !strings.Contains(err.Error(), |
| 284 | "error signing nonce: unable to extract key pair from file") { |
| 285 | if nc != nil { |
| 286 | nc.Close() |
| 287 | } |
| 288 | t.Fatalf("Expected error about invalid creds file, got %q", err) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | func TestReconnectMissingCredentials(t *testing.T) { |
| 293 | ts := runTrustServer() |
nothing calls this directly
no test coverage detected