Server IP : 85.214.239.14 / Your IP : 52.15.92.58 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/proc/3/task/3/root/proc/3/root/lib/python3/dist-packages/winrm/tests/ |
Upload File : |
import pytest from winrm.protocol import Protocol def test_open_shell_and_close_shell(protocol_fake): shell_id = protocol_fake.open_shell() assert shell_id == '11111111-1111-1111-1111-111111111113' protocol_fake.close_shell(shell_id) def test_run_command_with_arguments_and_cleanup_command(protocol_fake): shell_id = protocol_fake.open_shell() command_id = protocol_fake.run_command(shell_id, 'ipconfig', ['/all']) assert command_id == '11111111-1111-1111-1111-111111111114' protocol_fake.cleanup_command(shell_id, command_id) protocol_fake.close_shell(shell_id) def test_run_command_without_arguments_and_cleanup_command(protocol_fake): shell_id = protocol_fake.open_shell() command_id = protocol_fake.run_command(shell_id, 'hostname') assert command_id == '11111111-1111-1111-1111-111111111114' protocol_fake.cleanup_command(shell_id, command_id) protocol_fake.close_shell(shell_id) def test_get_command_output(protocol_fake): shell_id = protocol_fake.open_shell() command_id = protocol_fake.run_command(shell_id, 'ipconfig', ['/all']) std_out, std_err, status_code = protocol_fake.get_command_output( shell_id, command_id) assert status_code == 0 assert b'Windows IP Configuration' in std_out assert len(std_err) == 0 protocol_fake.cleanup_command(shell_id, command_id) protocol_fake.close_shell(shell_id) def test_set_timeout_as_sec(): protocol = Protocol('endpoint', username='username', password='password', read_timeout_sec='30', operation_timeout_sec='29') assert protocol.read_timeout_sec == 30 assert protocol.operation_timeout_sec == 29 def test_fail_set_read_timeout_as_sec(): with pytest.raises(ValueError) as exc: protocol = Protocol('endpoint', username='username', password='password', read_timeout_sec='30a', operation_timeout_sec='29') assert str(exc.value) == "failed to parse read_timeout_sec as int: " \ "invalid literal for int() with base 10: '30a'" def test_fail_set_operation_timeout_as_sec(): with pytest.raises(ValueError) as exc: protocol = Protocol('endpoint', username='username', password='password', read_timeout_sec=30, operation_timeout_sec='29a') assert str(exc.value) == "failed to parse operation_timeout_sec as int: " \ "invalid literal for int() with base 10: '29a'"