update more tests to new actions schema

This commit is contained in:
Marek Wolan
2025-01-17 14:38:59 +00:00
parent 03cab0fcec
commit 858406c4a3
48 changed files with 351 additions and 413 deletions

View File

@@ -56,7 +56,7 @@ def test_node_service_scan_integration(game_and_agent: Tuple[PrimaiteGame, Proxy
assert svc.health_state_visible == SoftwareHealthState.UNUSED
# 2: Scan and check that the visible state is now correct
action = ("node_service_scan", {"type": "node_service_scan", "node_name": "server_1", "service_name": "DNSServer"})
action = ("node_service_scan", {"node_name": "server_1", "service_name": "DNSServer"})
agent.store_action(action)
game.step()
assert svc.health_state_actual == SoftwareHealthState.GOOD
@@ -67,7 +67,7 @@ def test_node_service_scan_integration(game_and_agent: Tuple[PrimaiteGame, Proxy
assert svc.health_state_visible == SoftwareHealthState.GOOD
# 4: Scan and check that the visible state is now correct
action = ("node_service_scan", {"type": "node_service_scan", "node_name": "server_1", "service_name": "DNSServer"})
action = ("node_service_scan", {"node_name": "server_1", "service_name": "DNSServer"})
agent.store_action(action)
game.step()
assert svc.health_state_actual == SoftwareHealthState.COMPROMISED
@@ -88,7 +88,7 @@ def test_node_service_fix_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
svc.health_state_actual = SoftwareHealthState.COMPROMISED
# 2: Apply a patch action
action = ("node_service_fix", {"type": "node_service_fix", "node_name": "server_1", "service_name": "DNSServer"})
action = ("node_service_fix", {"node_name": "server_1", "service_name": "DNSServer"})
agent.store_action(action)
game.step()
@@ -123,7 +123,6 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
action = (
"router_acl_add_rule",
{
"type": "router_acl_add_rule",
"target_router": "router",
"position": 4,
"permission": "DENY",
@@ -151,7 +150,6 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
action = (
"router_acl_add_rule",
{
"type": "router_acl_add_rule",
"target_router": "router",
"position": 5, # 5th rule
"permission": "DENY", # DENY
@@ -192,7 +190,6 @@ def test_router_acl_removerule_integration(game_and_agent: Tuple[PrimaiteGame, P
action = (
"router_acl_remove_rule",
{
"type": "router_acl_remove_rule",
"target_router": "router",
"position": 3, # 4th rule
},
@@ -226,7 +223,6 @@ def test_host_nic_disable_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
action = (
"host_nic_disable",
{
"type": "host_nic_disable",
"node_name": "client_1", # client_1
"nic_num": 1, # the only nic (eth-1)
},
@@ -258,7 +254,6 @@ def test_host_nic_enable_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAg
action = (
"host_nic_enable",
{
"type": "host_nic_enable",
"node_name": "client_1", # client_1
"nic_num": 1, # the only nic (eth-1)
},
@@ -286,7 +281,6 @@ def test_node_file_scan_integration(game_and_agent: Tuple[PrimaiteGame, ProxyAge
action = (
"node_file_scan",
{
"type": "node_file_scan",
"node_name": "client_1", # client_1,
"folder_name": "downloads", # downloads,
"file_name": "cat.png", # cat.png
@@ -324,7 +318,6 @@ def test_node_file_delete_integration(game_and_agent: Tuple[PrimaiteGame, ProxyA
action = (
"node_file_delete",
{
"type": "node_file_delete",
"node_name": "client_1", # client_1
"folder_name": "downloads", # downloads
"file_name": "cat.png", # cat.png
@@ -348,7 +341,6 @@ def test_node_file_create(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
action = (
"node_file_create",
{
"type": "node_file_create",
"node_name": "client_1",
"folder_name": "test",
"file_name": "file.txt",
@@ -370,7 +362,6 @@ def test_node_file_access(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
action = (
"node_file_create",
{
"type": "node_file_create",
"node_name": "client_1",
"folder_name": "test",
"file_name": "file.txt",
@@ -384,7 +375,6 @@ def test_node_file_access(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
action = (
"node_file_access",
{
"type": "node_file_access",
"node_name": "client_1",
"folder_name": "test",
"file_name": "file.txt",
@@ -405,7 +395,6 @@ def test_node_folder_create(game_and_agent: Tuple[PrimaiteGame, ProxyAgent]):
action = (
"node_folder_create",
{
"type": "node_folder_create",
"node_name": "client_1",
"folder_name": "test",
},
@@ -434,7 +423,6 @@ def test_network_router_port_disable_integration(game_and_agent: Tuple[PrimaiteG
action = (
"network_port_disable",
{
"type": "network_port_disable",
"target_nodename": "router", # router
"port_id": 1, # port 1
},
@@ -467,7 +455,6 @@ def test_network_router_port_enable_integration(game_and_agent: Tuple[PrimaiteGa
action = (
"network_port_enable",
{
"type": "network_port_enable",
"target_nodename": "router", # router
"port_id": 1, # port 1
},
@@ -498,7 +485,7 @@ def test_node_application_scan_integration(game_and_agent: Tuple[PrimaiteGame, P
# 2: Scan and check that the visible state is now correct
action = (
"node_application_scan",
{"type": "node_application_scan", "node_name": "client_1", "application_name": "WebBrowser"},
{"node_name": "client_1", "application_name": "WebBrowser"},
)
agent.store_action(action)
game.step()
@@ -512,7 +499,7 @@ def test_node_application_scan_integration(game_and_agent: Tuple[PrimaiteGame, P
# 4: Scan and check that the visible state is now correct
action = (
"node_application_scan",
{"type": "node_application_scan", "node_name": "client_1", "application_name": "WebBrowser"},
{"node_name": "client_1", "application_name": "WebBrowser"},
)
agent.store_action(action)
game.step()
@@ -536,7 +523,7 @@ def test_node_application_fix_integration(game_and_agent: Tuple[PrimaiteGame, Pr
# 2: Apply a fix action
action = (
"node_application_fix",
{"type": "node_application_fix", "node_name": "client_1", "application_name": "WebBrowser"},
{"node_name": "client_1", "application_name": "WebBrowser"},
)
agent.store_action(action)
game.step()
@@ -565,7 +552,7 @@ def test_node_application_close_integration(game_and_agent: Tuple[PrimaiteGame,
# 2: Apply a close action
action = (
"node_application_close",
{"type": "node_application_close", "node_name": "client_1", "application_name": "WebBrowser"},
{"node_name": "client_1", "application_name": "WebBrowser"},
)
agent.store_action(action)
game.step()
@@ -587,7 +574,7 @@ def test_node_application_install_and_uninstall_integration(game_and_agent: Tupl
action = (
"node_application_install",
{"type": "node_application_install", "node_name": "client_1", "application_name": "DoSBot"},
{"node_name": "client_1", "application_name": "DoSBot"},
)
agent.store_action(action)
game.step()
@@ -596,7 +583,7 @@ def test_node_application_install_and_uninstall_integration(game_and_agent: Tupl
action = (
"node_application_remove",
{"type": "node_application_remove", "node_name": "client_1", "application_name": "DoSBot"},
{"node_name": "client_1", "application_name": "DoSBot"},
)
agent.store_action(action)
game.step()