diff --git a/monkey/common/agent_configuration/agent_configuration.py b/monkey/common/agent_configuration/agent_configuration.py index 1fb99f868..7b780096f 100644 --- a/monkey/common/agent_configuration/agent_configuration.py +++ b/monkey/common/agent_configuration/agent_configuration.py @@ -1,6 +1,6 @@ from typing import Tuple -from pydantic import PositiveFloat +from pydantic import confloat from common.base_models import MutableInfectionMonkeyBaseModel @@ -12,7 +12,7 @@ from .agent_sub_configurations import ( class AgentConfiguration(MutableInfectionMonkeyBaseModel): - keep_tunnel_open_time: PositiveFloat + keep_tunnel_open_time: confloat(ge=0) custom_pbas: CustomPBAConfiguration post_breach_actions: Tuple[PluginConfiguration, ...] credential_collectors: Tuple[PluginConfiguration, ...] diff --git a/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py b/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py index 3431b980d..b90490906 100644 --- a/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py +++ b/monkey/tests/unit_tests/common/agent_configuration/test_agent_configuration.py @@ -252,7 +252,16 @@ def test_agent_configuration(): assert config_dict == AGENT_CONFIGURATION -def test_agent_configuration__negative_keep_tunnel_open_time(): +def test_agent_configuration__negative_keep_tunnel_open_time_zero(): + keep_tunnel_open_time_zero_configuration = AGENT_CONFIGURATION.copy() + keep_tunnel_open_time_zero_configuration["keep_tunnel_open_time"] = 0 + + ac = AgentConfiguration(**keep_tunnel_open_time_zero_configuration) + + assert ac.keep_tunnel_open_time == 0 + + +def test_agent_configuration__keep_tunnel_open_time(): negative_keep_tunnel_open_time_configuration = AGENT_CONFIGURATION.copy() negative_keep_tunnel_open_time_configuration["keep_tunnel_open_time"] = -1