#2912 - Updated to include __all__ and some test fixes. New extensible actions documentation page
This commit is contained in:
@@ -4,7 +4,7 @@ from ipaddress import IPv4Address
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from primaite.game.agent.actions import (
|
||||
from primaite.game.agent.actions.config import (
|
||||
ConfigureDatabaseClientAction,
|
||||
ConfigureDoSBotAction,
|
||||
ConfigureRansomwareScriptAction,
|
||||
@@ -35,10 +35,10 @@ class TestConfigureDatabaseAction:
|
||||
db_client: DatabaseClient = client_1.software_manager.software["DatabaseClient"]
|
||||
|
||||
action = (
|
||||
"CONFIGURE_DATABASE_CLIENT",
|
||||
"configure_database_client",
|
||||
{
|
||||
"node_id": 0,
|
||||
"config": {
|
||||
"node_name": "client_1",
|
||||
"model_config": {
|
||||
"server_ip_address": "192.168.1.99",
|
||||
"server_password": "admin123",
|
||||
},
|
||||
@@ -53,7 +53,7 @@ class TestConfigureDatabaseAction:
|
||||
def test_configure_ip(self, game_and_agent):
|
||||
game, agent = game_and_agent
|
||||
agent: ControlledAgent
|
||||
agent.action_manager.actions["CONFIGURE_DATABASE_CLIENT"] = ConfigureDatabaseClientAction(agent.action_manager)
|
||||
agent.action_manager.actions["configure_database_client"] = ConfigureDatabaseClientAction(agent.action_manager)
|
||||
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
@@ -124,15 +124,15 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
"router_acl_add_rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 4, # 4th rule
|
||||
"permission": 2, # DENY
|
||||
"source_ip_id": 3, # 10.0.1.2 (client_1)
|
||||
"dest_ip_id": 6, # 10.0.2.3 (server_2)
|
||||
"dest_port_id": 1, # ALL
|
||||
"source_port_id": 1, # ALL
|
||||
"protocol_name": "ALL", # ALL
|
||||
"source_wildcard_id": 0,
|
||||
"dest_wildcard_id": 0,
|
||||
"position": 4,
|
||||
"permission": "DENY",
|
||||
"src_ip": "10.0.1.2",
|
||||
"src_wildcard": 0,
|
||||
"source_port": "ALL",
|
||||
"dst_ip": "10.0.2.3",
|
||||
"dst_wildcard": 0,
|
||||
"dst_port": "ALL",
|
||||
"protocol_name": "ALL",
|
||||
},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -148,18 +148,18 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
|
||||
# 4: Add a rule to block server_1 from reaching server_2 on router (this should not affect comms as they are on same subnet)
|
||||
action = (
|
||||
"ROUTER_ACL_ADDRULE",
|
||||
"router_acl_add_rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 5, # 5th rule
|
||||
"permission": 2, # DENY
|
||||
"source_ip_id": 5, # 10.0.2.2 (server_1)
|
||||
"dest_ip_id": 6, # 10.0.2.3 (server_2)
|
||||
"dest_port_id": 1, # ALL
|
||||
"source_port_id": 1, # ALL
|
||||
"protocol_id": 1, # ALL
|
||||
"source_wildcard_id": 0,
|
||||
"dest_wildcard_id": 0,
|
||||
"permission": "DENY", # DENY
|
||||
"src_ip": "10.0.2.2", # 10.0.2.2 (server_1)
|
||||
"src_wildcard": 0,
|
||||
"source_port": "ALL", # ALL
|
||||
"dst_ip": "10.0.2.3", # 10.0.2.3 (server_2)
|
||||
"dst_wildcard": 0,
|
||||
"dst_port": "ALL", # ALL
|
||||
"protocol_name": "ALL", # ALL
|
||||
},
|
||||
)
|
||||
agent.store_action(action)
|
||||
|
||||
Reference in New Issue
Block a user