2023-10-25 17:08:01 +01:00
|
|
|
from gymnasium import spaces
|
2023-09-25 16:04:04 +01:00
|
|
|
|
2023-09-26 12:54:56 +01:00
|
|
|
from primaite.game.agent.observations import FileObservation
|
2023-09-25 16:04:04 +01:00
|
|
|
from primaite.simulator.network.hardware.nodes.computer import Computer
|
|
|
|
|
from primaite.simulator.sim_container import Simulation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_file_observation():
|
|
|
|
|
sim = Simulation()
|
|
|
|
|
pc = Computer(hostname="beep", ip_address="123.123.123.123", subnet_mask="255.255.255.0")
|
|
|
|
|
sim.network.add_node(pc)
|
|
|
|
|
f = pc.file_system.create_file(file_name="dog.png")
|
|
|
|
|
|
|
|
|
|
state = sim.describe_state()
|
|
|
|
|
|
|
|
|
|
dog_file_obs = FileObservation(
|
2023-12-14 14:04:43 +00:00
|
|
|
where=["network", "nodes", pc.hostname, "file_system", "folders", "root", "files", "dog.png"]
|
2023-09-25 16:04:04 +01:00
|
|
|
)
|
2023-10-09 18:33:30 +01:00
|
|
|
assert dog_file_obs.observe(state) == {"health_status": 1}
|
2023-09-25 16:04:04 +01:00
|
|
|
assert dog_file_obs.space == spaces.Dict({"health_status": spaces.Discrete(6)})
|