(t *testing.T)
| 412 | } |
| 413 | |
| 414 | func TestVerifySSHConnectionCtxRespectsContext(t *testing.T) { |
| 415 | tmpDir, cleanup := setupTestEnvironment(t) |
| 416 | defer cleanup() |
| 417 | |
| 418 | clientPrivateKey, _, _ := generateRSAKeyPair(t) |
| 419 | keyFile := filepath.Join(tmpDir, "verify_cancel_key") |
| 420 | savePrivateKeyToFile(t, clientPrivateKey, keyFile) |
| 421 | |
| 422 | ctx, cancel := context.WithTimeout(context.Background(), 1500*time.Millisecond) |
| 423 | defer cancel() |
| 424 | |
| 425 | err := VerifySSHConnectionCtx(ctx, "127.0.0.1", keyFile, 65501) |
| 426 | require.Error(t, err) |
| 427 | // Error can be either "SSH verification failed" or "SSH connection cancelled" depending on timing |
| 428 | assert.True(t, strings.Contains(err.Error(), "SSH verification failed") || |
| 429 | strings.Contains(err.Error(), "SSH connection cancelled"), |
| 430 | "unexpected error: %s", err.Error()) |
| 431 | } |
| 432 | |
| 433 | func TestNewSSHConfigErrors(t *testing.T) { |
| 434 | t.Run("missing key file", func(t *testing.T) { |
nothing calls this directly
no test coverage detected