| 501 | } |
| 502 | |
| 503 | func TestCommandTimeout(t *testing.T) { |
| 504 | ssh := &MakeConfig{ |
| 505 | Server: "localhost", |
| 506 | User: "root", |
| 507 | Port: "22", |
| 508 | KeyPath: "./tests/.ssh/id_rsa", |
| 509 | } |
| 510 | |
| 511 | outStr, errStr, isTimeout, err := ssh.Run("whoami; sleep 2", 1*time.Second) |
| 512 | assert.Equal(t, "root\n", outStr) |
| 513 | assert.Equal(t, "", errStr) |
| 514 | assert.False(t, isTimeout) |
| 515 | assert.NotNil(t, err) |
| 516 | assert.Equal(t, "Run Command Timeout: "+context.DeadlineExceeded.Error(), err.Error()) |
| 517 | } |
| 518 | |
| 519 | // TestProxyTimeoutHandling tests that timeout is properly respected when using proxy connections |
| 520 | // This test uses a non-existent proxy server to force a timeout during proxy connection |