diff --git a/monkey/agent_plugins/exploiters/ssh/src/ssh_command_builder.py b/monkey/agent_plugins/exploiters/ssh/src/ssh_command_builder.py index 5c2faef2a42..3c389114b8c 100644 --- a/monkey/agent_plugins/exploiters/ssh/src/ssh_command_builder.py +++ b/monkey/agent_plugins/exploiters/ssh/src/ssh_command_builder.py @@ -1,7 +1,6 @@ from pathlib import PurePath from typing import Sequence -from common import OperatingSystem from common.types import AgentID from infection_monkey.exploit import IAgentOTPProvider from infection_monkey.i_puppet import TargetHost @@ -17,9 +16,6 @@ def build_ssh_command( remote_agent_binary_destination_path: PurePath, otp_provider: IAgentOTPProvider, ) -> str: - if target_host.operating_system != OperatingSystem.LINUX: - raise Exception(f"Unsupported operating system: {target_host.operating_system}") - otp = otp_provider.get_otp() cmdline_arguments = build_monkey_commandline_parameters( parent=agent_id, servers=servers, depth=current_depth + 1 diff --git a/monkey/tests/unit_tests/agent_plugins/exploiters/ssh/test_ssh_command_builder.py b/monkey/tests/unit_tests/agent_plugins/exploiters/ssh/test_ssh_command_builder.py index ea891e0a7a1..4364e082f45 100644 --- a/monkey/tests/unit_tests/agent_plugins/exploiters/ssh/test_ssh_command_builder.py +++ b/monkey/tests/unit_tests/agent_plugins/exploiters/ssh/test_ssh_command_builder.py @@ -1,4 +1,6 @@ +from ipaddress import IPv4Address from pathlib import PurePosixPath +from typing import Optional from unittest.mock import MagicMock import pytest @@ -24,22 +26,9 @@ def otp_provider() -> IAgentOTPProvider: return provider -def test_exception_raised_for_windows(otp_provider: IAgentOTPProvider): - target_host = TargetHost(ip="127.0.0.1", operating_system=OperatingSystem.WINDOWS) - - with pytest.raises(Exception): - build_ssh_command( - AGENT_ID, - target_host, - SERVERS, - DEPTH, - AGENT_EXE_PATH, - otp_provider, - ) - - -def test_command(otp_provider: IAgentOTPProvider): - target_host = TargetHost(ip="127.0.0.1", operating_system=OperatingSystem.LINUX) +@pytest.mark.parametrize("os", [OperatingSystem.LINUX, None]) +def test_command(otp_provider: IAgentOTPProvider, os: Optional[OperatingSystem]): + target_host = TargetHost(ip=IPv4Address("127.0.0.1"), operating_system=os) command = build_ssh_command( AGENT_ID,