diff --git a/src/primaite/game/game.py b/src/primaite/game/game.py index ef54893e..fbf6ea50 100644 --- a/src/primaite/game/game.py +++ b/src/primaite/game/game.py @@ -359,13 +359,18 @@ class PrimaiteGame: for nic_num, nic_cfg in node_cfg["network_interfaces"].items(): new_node.connect_nic(NIC(ip_address=nic_cfg["ip_address"], subnet_mask=nic_cfg["subnet_mask"])) - new_node.start_up_duration = int(node_cfg.get("start_up_duration", 3)) - new_node.shut_down_duration = int(node_cfg.get("shut_down_duration", 3)) + # temporarily set to 0 so all nodes are initially on + new_node.start_up_duration = 0 + new_node.shut_down_duration = 0 net.add_node(new_node) new_node.power_on() game.ref_map_nodes[node_ref] = new_node.uuid + # set start up and shut down duration + new_node.start_up_duration = int(node_cfg.get("start_up_duration", 3)) + new_node.shut_down_duration = int(node_cfg.get("shut_down_duration", 3)) + # 2. create links between nodes for link_cfg in links_cfg: node_a = net.nodes[game.ref_map_nodes[link_cfg["endpoint_a_ref"]]] diff --git a/tests/integration_tests/configuration_file_parsing/nodes/network/test_firewall_config.py b/tests/integration_tests/configuration_file_parsing/nodes/network/test_firewall_config.py index ae71809b..2e0556e9 100644 --- a/tests/integration_tests/configuration_file_parsing/nodes/network/test_firewall_config.py +++ b/tests/integration_tests/configuration_file_parsing/nodes/network/test_firewall_config.py @@ -1,6 +1,7 @@ import pytest from primaite.simulator.network.container import Network +from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.nodes.host.computer import Computer from primaite.simulator.network.hardware.nodes.host.server import Server from primaite.simulator.network.hardware.nodes.network.firewall import Firewall @@ -20,7 +21,10 @@ def test_firewall_is_in_configuration(dmz_config): """Test that the firewall exists in the configuration file.""" network: Network = dmz_config - assert network.get_node_by_hostname("firewall") + firewall: Firewall = network.get_node_by_hostname("firewall") + + assert firewall + assert firewall.operating_state == NodeOperatingState.ON def test_firewall_routes_are_correctly_added(dmz_config): @@ -39,6 +43,11 @@ def test_firewall_routes_are_correctly_added(dmz_config): assert external_computer.ping(client_1.network_interface[1].ip_address) assert external_server.ping(client_1.network_interface[1].ip_address) + # client_1 should be able to ping other nodes + assert client_1.ping(dmz_server.network_interface[1].ip_address) + assert client_1.ping(external_computer.network_interface[1].ip_address) + assert client_1.ping(external_server.network_interface[1].ip_address) + def test_firewall_acl_rules_correctly_added(dmz_config): """ diff --git a/tests/integration_tests/configuration_file_parsing/nodes/network/test_router_config.py b/tests/integration_tests/configuration_file_parsing/nodes/network/test_router_config.py index fbaca12d..4382cc30 100644 --- a/tests/integration_tests/configuration_file_parsing/nodes/network/test_router_config.py +++ b/tests/integration_tests/configuration_file_parsing/nodes/network/test_router_config.py @@ -1,6 +1,7 @@ import pytest from primaite.simulator.network.container import Network +from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.nodes.host.computer import Computer from primaite.simulator.network.hardware.nodes.host.server import Server from primaite.simulator.network.hardware.nodes.network.router import ACLAction, Router @@ -19,7 +20,10 @@ def test_router_is_in_configuration(dmz_config): """Test that the router exists in the configuration file.""" network: Network = dmz_config - assert network.get_node_by_hostname("router_1") + router_1: Router = network.get_node_by_hostname("router_1") + + assert router_1 + assert router_1.operating_state == NodeOperatingState.ON def test_router_routes_are_correctly_added(dmz_config):