MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / TestVerifySSHConnectionCtxRespectsContext

Function TestVerifySSHConnectionCtxRespectsContext

utils/ssh_test.go:414–431  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

412}
413
414func 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
433func TestNewSSHConfigErrors(t *testing.T) {
434 t.Run("missing key file", func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

generateRSAKeyPairFunction · 0.85
savePrivateKeyToFileFunction · 0.85
VerifySSHConnectionCtxFunction · 0.85
setupTestEnvironmentFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected