Common: Allow 0 for maximum_depth

This commit is contained in:
Mike Salvatore 2022-08-31 08:53:10 -04:00 committed by Shreya Malviya
parent 8d991f462f
commit 326d128be8
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,6 @@
from typing import Dict, Tuple
from pydantic import PositiveFloat, PositiveInt, conint, validator
from pydantic import PositiveFloat, conint, validator
from common.base_models import MutableInfectionMonkeyBaseModel
@ -185,6 +185,6 @@ class PropagationConfiguration(MutableInfectionMonkeyBaseModel):
:param exploitation: Configuration for exploitation
"""
maximum_depth: PositiveInt
maximum_depth: conint(ge=0)
network_scan: NetworkScanConfiguration
exploitation: ExploitationConfiguration

View File

@ -229,6 +229,15 @@ def test_propagation_configuration__invalid_maximum_depth():
PropagationConfiguration(**negative_maximum_depth_configuration)
def test_propagation_configuration__maximum_depth_zero():
maximum_depth_zero_configuration = PROPAGATION_CONFIGURATION.copy()
maximum_depth_zero_configuration["maximum_depth"] = 0
pc = PropagationConfiguration(**maximum_depth_zero_configuration)
assert pc.maximum_depth == 0
def test_agent_configuration():
config = AgentConfiguration(**AGENT_CONFIGURATION)
config_dict = config.dict(simplify=True)