55import pytest
66from jumpstarter_driver_network .driver import TcpNetwork
77
8- from jumpstarter_driver_ssh .client import SSHCommandRunResult
8+ from jumpstarter_driver_ssh .client import SSHCommandRunOptions , SSHCommandRunResult
99from jumpstarter_driver_ssh .driver import SSHWrapper
1010
1111from jumpstarter .common .exceptions import ConfigurationError
@@ -55,7 +55,7 @@ def test_ssh_command_with_default_username():
5555 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
5656
5757 # Test SSH command with default username
58- result = client .run (False , ["hostname" ])
58+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
5959 assert isinstance (result , SSHCommandRunResult )
6060
6161 # Verify subprocess.run was called
@@ -87,7 +87,7 @@ def test_ssh_command_without_default_username():
8787 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
8888
8989 # Test SSH command without default username
90- result = client .run (False , ["hostname" ])
90+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
9191 assert isinstance (result , SSHCommandRunResult )
9292
9393 # Verify subprocess.run was called
@@ -117,7 +117,7 @@ def test_ssh_command_with_user_override():
117117 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
118118
119119 # Test SSH command with -l flag overriding default username
120- result = client .run (False , ["-l" , "myuser" , "hostname" ])
120+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["-l" , "myuser" , "hostname" ])
121121 assert isinstance (result , SSHCommandRunResult )
122122
123123 # Verify subprocess.run was called
@@ -155,7 +155,7 @@ def test_ssh_command_with_port():
155155 mock_adapter .return_value .__exit__ .return_value = None
156156
157157 # Test SSH command with custom port
158- result = client .run (False , ["hostname" ])
158+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
159159 assert isinstance (result , SSHCommandRunResult )
160160
161161 # Verify subprocess.run was called
@@ -193,7 +193,7 @@ def test_ssh_command_with_direct_flag():
193193 # Mock the tcp.address() method
194194 with patch .object (client .tcp , 'address' , return_value = "tcp://192.168.1.100:22" ):
195195 # Test SSH command with direct flag
196- result = client .run (True , ["hostname" ])
196+ result = client .run (SSHCommandRunOptions ( direct = True ) , ["hostname" ])
197197 assert isinstance (result , SSHCommandRunResult )
198198
199199 # Verify subprocess.run was called
@@ -224,7 +224,7 @@ def test_ssh_command_error_handling():
224224 mock_run .side_effect = FileNotFoundError ("SSH not found" )
225225
226226 # Test SSH command error handling
227- result = client .run (False , ["hostname" ])
227+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
228228 assert isinstance (result , SSHCommandRunResult )
229229
230230 # Should return error code 127
@@ -245,7 +245,7 @@ def test_ssh_command_with_multiple_ssh_options():
245245 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
246246
247247 # Test SSH command with multiple SSH options
248- result = client .run (False , [
248+ result = client .run (SSHCommandRunOptions ( direct = False ) , [
249249 "-o" , "StrictHostKeyChecking=no" , "-i" , "/path/to/key" , "command" , "arg1" , "arg2"
250250 ])
251251 assert isinstance (result , SSHCommandRunResult )
@@ -283,7 +283,7 @@ def test_ssh_command_with_unknown_option_treated_as_command():
283283 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
284284
285285 # Test SSH command with unknown option
286- result = client .run (False , ["-l" , "user" , "-unknown" , "command" , "arg1" ])
286+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["-l" , "user" , "-unknown" , "command" , "arg1" ])
287287 assert isinstance (result , SSHCommandRunResult )
288288
289289 # Verify subprocess.run was called
@@ -317,7 +317,7 @@ def test_ssh_command_with_no_ssh_options():
317317 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
318318
319319 # Test SSH command with no SSH options
320- result = client .run (False , ["command" , "arg1" , "arg2" ])
320+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["command" , "arg1" , "arg2" ])
321321 assert isinstance (result , SSHCommandRunResult )
322322
323323 # Verify subprocess.run was called
@@ -347,7 +347,7 @@ def test_ssh_command_with_command_l_flag_does_not_interfere_with_username_inject
347347 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
348348
349349 # Test SSH command with -l flag in the command (like ls -la -l ajo)
350- result = client .run (False , ["ls" , "-la" , "-l" , "ajo" ])
350+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["ls" , "-la" , "-l" , "ajo" ])
351351 assert isinstance (result , SSHCommandRunResult )
352352
353353 # Verify subprocess.run was called
@@ -469,7 +469,7 @@ def test_ssh_command_with_identity_string():
469469 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
470470
471471 # Test SSH command with identity string
472- result = client .run (False , ["hostname" ])
472+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
473473 assert isinstance (result , SSHCommandRunResult )
474474
475475 # Verify subprocess.run was called
@@ -519,7 +519,7 @@ def test_ssh_command_with_identity_file():
519519 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
520520
521521 # Test SSH command with identity file
522- result = client .run (False , ["hostname" ])
522+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
523523 assert isinstance (result , SSHCommandRunResult )
524524
525525 # Verify subprocess.run was called
@@ -563,7 +563,7 @@ def test_ssh_command_without_identity():
563563 mock_run .return_value = MagicMock (returncode = 0 , stdout = "some stdout" , stderr = "" )
564564
565565 # Test SSH command without identity
566- result = client .run (False , ["hostname" ])
566+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
567567 assert isinstance (result , SSHCommandRunResult )
568568
569569 # Verify subprocess.run was called
@@ -608,7 +608,7 @@ def test_ssh_identity_temp_file_creation_and_cleanup():
608608 mock_temp_file .return_value = mock_temp_file_instance
609609
610610 # Test SSH command with identity
611- result = client .run (False , ["hostname" ])
611+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
612612 assert isinstance (result , SSHCommandRunResult )
613613
614614 # Verify temporary file was created
@@ -644,7 +644,7 @@ def test_ssh_identity_temp_file_creation_error():
644644 # Test SSH command with identity should raise an error
645645 # The exception will be wrapped in an ExceptionGroup due to the context manager
646646 with pytest .raises (ExceptionGroup ) as exc_info :
647- client .run (False , ["hostname" ])
647+ client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
648648
649649 # Check that the original OSError is in the exception group
650650 assert any (isinstance (e , OSError ) and "Permission denied" in str (e ) for e in exc_info .value .exceptions )
@@ -677,7 +677,7 @@ def test_ssh_identity_temp_file_cleanup_error():
677677
678678 # Test SSH command with identity - should still succeed but log warning
679679 with patch .object (client , 'logger' ) as mock_logger :
680- result = client .run (False , ["hostname" ])
680+ result = client .run (SSHCommandRunOptions ( direct = False ) , ["hostname" ])
681681 assert isinstance (result , SSHCommandRunResult )
682682
683683 # Verify chmod was called
0 commit comments