#2257: added common node attributes page + ability to set node operating state via config + tests
This commit is contained in:
@@ -141,6 +141,17 @@ simulation:
|
||||
default_gateway: 192.168.10.1
|
||||
dns_server: 192.168.1.10
|
||||
# pre installed services and applications
|
||||
- ref: client_3
|
||||
type: computer
|
||||
hostname: client_3
|
||||
ip_address: 192.168.10.23
|
||||
subnet_mask: 255.255.255.0
|
||||
default_gateway: 192.168.10.1
|
||||
dns_server: 192.168.1.10
|
||||
start_up_duration: 0
|
||||
shut_down_duration: 0
|
||||
operating_state: "OFF"
|
||||
# pre installed services and applications
|
||||
|
||||
links:
|
||||
- ref: switch_1___client_1
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from primaite.config.load import example_config_path
|
||||
from primaite.simulator.network.container import Network
|
||||
from tests.integration_tests.configuration_file_parsing import DMZ_NETWORK, load_config
|
||||
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
|
||||
from primaite.simulator.network.hardware.nodes.host.computer import Computer
|
||||
from tests.integration_tests.configuration_file_parsing import BASIC_CONFIG, DMZ_NETWORK, load_config
|
||||
|
||||
|
||||
def test_example_config():
|
||||
@@ -24,3 +26,19 @@ def test_dmz_config():
|
||||
assert len(network.routers) == 2 # 2 routers in network
|
||||
assert len(network.switches) == 3 # 3 switches in network
|
||||
assert len(network.servers) == 2 # 2 servers in network
|
||||
|
||||
|
||||
def test_basic_config():
|
||||
"""Test that the basic_switched_network config can be parsed properly."""
|
||||
game = load_config(BASIC_CONFIG)
|
||||
network: Network = game.simulation.network
|
||||
assert len(network.nodes) == 4 # 4 nodes in network
|
||||
|
||||
client_1: Computer = network.get_node_by_hostname("client_1")
|
||||
assert client_1.operating_state == NodeOperatingState.ON
|
||||
client_2: Computer = network.get_node_by_hostname("client_2")
|
||||
assert client_2.operating_state == NodeOperatingState.ON
|
||||
|
||||
# client 3 should not be online
|
||||
client_3: Computer = network.get_node_by_hostname("client_3")
|
||||
assert client_3.operating_state == NodeOperatingState.OFF
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from ipaddress import IPv4Address
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
from primaite.game.game import APPLICATION_TYPES_MAPPING, SERVICE_TYPES_MAPPING
|
||||
import yaml
|
||||
|
||||
from primaite.config.load import example_config_path
|
||||
from primaite.game.agent.data_manipulation_bot import DataManipulationAgent
|
||||
from primaite.game.agent.interface import ProxyAgent, RandomAgent
|
||||
from primaite.game.game import APPLICATION_TYPES_MAPPING, PrimaiteGame, SERVICE_TYPES_MAPPING
|
||||
from primaite.simulator.network.container import Network
|
||||
from primaite.simulator.network.hardware.nodes.host.computer import Computer
|
||||
from primaite.simulator.system.applications.database_client import DatabaseClient
|
||||
from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot
|
||||
|
||||
Reference in New Issue
Block a user