Island: Add default value for Machine.network_interfaces

This commit is contained in:
Mike Salvatore 2022-08-29 20:18:01 -04:00
parent da8ed9e6db
commit 40601b955c
2 changed files with 10 additions and 1 deletions

View File

@ -20,7 +20,7 @@ class Machine(MutableInfectionMonkeyBaseModel):
hardware_id: Optional[HardwareID]
"""An identifier generated by the agent that uniquely identifies a machine"""
network_interfaces: Sequence[IPv4Interface]
network_interfaces: Sequence[IPv4Interface] = Field(default_factory=tuple)
"""The machine's networking interfaces"""
operating_system: Optional[OperatingSystem]

View File

@ -141,6 +141,15 @@ def test_network_interfaces_sequence_is_immutable():
assert not isinstance(m.network_interfaces, MutableSequence)
def test_network_interfaces_default():
missing_network_interfaces_dict = MACHINE_OBJECT_DICT.copy()
del missing_network_interfaces_dict["network_interfaces"]
m = Machine(**missing_network_interfaces_dict)
assert len(m.network_interfaces) == 0
def test_operating_system_set_valid_value():
m = Machine(**MACHINE_OBJECT_DICT)