From 5d51b40475545efc703d8f1da4b8b6c9e58af905 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 29 Aug 2022 20:25:33 -0400 Subject: [PATCH] Island: Add default value for Machine.operating_system_version --- monkey/monkey_island/cc/models/machine.py | 2 +- .../unit_tests/monkey_island/cc/models/test_machine.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/models/machine.py b/monkey/monkey_island/cc/models/machine.py index b09e8bf99..31c5d41ad 100644 --- a/monkey/monkey_island/cc/models/machine.py +++ b/monkey/monkey_island/cc/models/machine.py @@ -26,7 +26,7 @@ class Machine(MutableInfectionMonkeyBaseModel): operating_system: Optional[OperatingSystem] """The operating system the machine is running""" - operating_system_version: str + operating_system_version: str = Field(default="") """The specific version of the operating system the machine is running""" hostname: str diff --git a/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py b/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py index a81f1823f..e60069ed6 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/test_machine.py @@ -180,6 +180,15 @@ def test_set_operating_system_version(): m.operating_system_version = "1234" +def test_operating_system_version_default_value(): + missing_operating_system_version_dict = MACHINE_OBJECT_DICT.copy() + del missing_operating_system_version_dict["operating_system_version"] + + m = Machine(**missing_operating_system_version_dict) + + assert m.operating_system_version == "" + + def test_set_hostname(): m = Machine(**MACHINE_OBJECT_DICT)