diff --git a/monkey/monkey_island/cc/services/agent_signals_service.py b/monkey/monkey_island/cc/services/agent_signals_service.py index e58b21cb4eb..dc9cc3b5beb 100644 --- a/monkey/monkey_island/cc/services/agent_signals_service.py +++ b/monkey/monkey_island/cc/services/agent_signals_service.py @@ -51,7 +51,7 @@ def _agent_is_first_to_register(self, agent: Agent) -> bool: first_to_register = min( agents_on_same_machine, key=lambda a: a.registration_time, default=agent ) - return agent is first_to_register + return agent.id == first_to_register.id def _agents_running_on_machine(self, machine_id: MachineID): return [ diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_agent_signals_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_agent_signals_service.py index bf0edd3782d..19aac00ea4f 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_agent_signals_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_agent_signals_service.py @@ -1,3 +1,4 @@ +from copy import copy from unittest.mock import MagicMock from uuid import UUID @@ -75,7 +76,7 @@ def get_agent_by_id(agent_id: AgentID) -> Agent: agent_repository.get_progenitor = MagicMock(return_value=AGENT_1) agent_repository.get_agent_by_id = MagicMock(side_effect=get_agent_by_id) agent_repository.get_running_agents = MagicMock( - return_value=[a for a in ALL_AGENTS if a.stop_time is None] + return_value=[copy(a) for a in ALL_AGENTS if a.stop_time is None] ) return agent_repository