#3062 - First pass at unifying naming convention for discriminators (still errors) [skip ci]
This commit is contained in:
@@ -28,27 +28,27 @@ def test_application_cannot_perform_actions_unless_running(game_and_agent_fixtur
|
||||
game, agent = game_and_agent_fixture
|
||||
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("WebBrowser")
|
||||
browser: WebBrowser = client_1.software_manager.software.get("web-browser")
|
||||
|
||||
browser.close()
|
||||
assert browser.operating_state == ApplicationOperatingState.CLOSED
|
||||
|
||||
action = ("node_application_scan", {"node_name": "client_1", "application_name": "WebBrowser"})
|
||||
action = ("node-application-scan", {"node_name": "client_1", "application_name": "web-browser"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert browser.operating_state == ApplicationOperatingState.CLOSED
|
||||
|
||||
action = ("node_application_close", {"node_name": "client_1", "application_name": "WebBrowser"})
|
||||
action = ("node-application-close", {"node_name": "client_1", "application_name": "web-browser"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert browser.operating_state == ApplicationOperatingState.CLOSED
|
||||
|
||||
action = ("node_application_fix", {"node_name": "client_1", "application_name": "WebBrowser"})
|
||||
action = ("node-application-fix", {"node_name": "client_1", "application_name": "web-browser"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert browser.operating_state == ApplicationOperatingState.CLOSED
|
||||
|
||||
action = ("node_application_execute", {"node_name": "client_1", "application_name": "WebBrowser"})
|
||||
action = ("node-application-execute", {"node_name": "client_1", "application_name": "web-browser"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert browser.operating_state == ApplicationOperatingState.CLOSED
|
||||
|
||||
@@ -32,7 +32,7 @@ def game_and_agent_fixture(game_and_agent):
|
||||
|
||||
c2_server_host = game.simulation.network.get_node_by_hostname("client_1")
|
||||
c2_server_host.software_manager.install(software_class=C2Server)
|
||||
c2_server: C2Server = c2_server_host.software_manager.software["C2Server"]
|
||||
c2_server: C2Server = c2_server_host.software_manager.software["c2-server"]
|
||||
c2_server.run()
|
||||
|
||||
return (game, agent)
|
||||
@@ -46,15 +46,15 @@ def test_c2_beacon_default(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgen
|
||||
server_1: Server = game.simulation.network.get_node_by_hostname("server_1")
|
||||
|
||||
action = (
|
||||
"node_application_install",
|
||||
{"node_name": "server_1", "application_name": "C2Beacon"},
|
||||
"node-application-install",
|
||||
{"node_name": "server_1", "application_name": "c2-beacon"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert agent.history[-1].response.status == "success"
|
||||
|
||||
action = (
|
||||
"configure_c2_beacon",
|
||||
"configure-c2-beacon",
|
||||
{
|
||||
"node_name": "server_1",
|
||||
"c2_server_ip_address": "10.0.1.2",
|
||||
@@ -68,15 +68,15 @@ def test_c2_beacon_default(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgen
|
||||
assert agent.history[-1].response.status == "success"
|
||||
|
||||
action = (
|
||||
"node_application_execute",
|
||||
{"node_name": "server_1", "application_name": "C2Beacon"},
|
||||
"node-application-execute",
|
||||
{"node_name": "server_1", "application_name": "c2-beacon"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert agent.history[-1].response.status == "success"
|
||||
|
||||
# Asserting that we've confirmed our connection
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["C2Beacon"]
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["c2-beacon"]
|
||||
assert c2_beacon.c2_connection_active == True
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ def test_c2_server_ransomware(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
||||
# Installing a database on Server_2 for the ransomware to attack
|
||||
server_2: Server = game.simulation.network.get_node_by_hostname("server_2")
|
||||
server_2.software_manager.install(DatabaseService)
|
||||
server_2.software_manager.software["DatabaseService"].start()
|
||||
server_2.software_manager.software["database-service"].start()
|
||||
# Configuring the C2 to connect to client 1 (C2 Server)
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["C2Beacon"]
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["c2-beacon"]
|
||||
c2_beacon.configure(c2_server_ip_address=IPv4Address("10.0.1.2"))
|
||||
c2_beacon.establish()
|
||||
assert c2_beacon.c2_connection_active == True
|
||||
@@ -101,15 +101,15 @@ def test_c2_server_ransomware(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
||||
# C2 Action 1: Installing the RansomwareScript & Database client via Terminal
|
||||
|
||||
action = (
|
||||
"c2_server_terminal_command",
|
||||
"c2-server-terminal-command",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"ip_address": None,
|
||||
"username": "admin",
|
||||
"password": "admin",
|
||||
"commands": [
|
||||
["software_manager", "application", "install", "RansomwareScript"],
|
||||
["software_manager", "application", "install", "DatabaseClient"],
|
||||
["software_manager", "application", "install", "ransomware-script"],
|
||||
["software_manager", "application", "install", "database-client"],
|
||||
],
|
||||
},
|
||||
)
|
||||
@@ -118,7 +118,7 @@ def test_c2_server_ransomware(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
||||
assert agent.history[-1].response.status == "success"
|
||||
|
||||
action = (
|
||||
"c2_server_ransomware_configure",
|
||||
"c2-server-ransomware-configure",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"server_ip_address": "10.0.2.3",
|
||||
@@ -131,14 +131,14 @@ def test_c2_server_ransomware(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
||||
|
||||
# Stepping a few timesteps to allow for the RansowmareScript to finish installing.
|
||||
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
game.step()
|
||||
game.step()
|
||||
|
||||
action = (
|
||||
"c2_server_ransomware_launch",
|
||||
"c2-server-ransomware-launch",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
},
|
||||
@@ -162,10 +162,10 @@ def test_c2_server_data_exfiltration(game_and_agent_fixture: Tuple[PrimaiteGame,
|
||||
# Installing a database on Server_2 (creates a database.db file.)
|
||||
server_2: Server = game.simulation.network.get_node_by_hostname("server_2")
|
||||
server_2.software_manager.install(DatabaseService)
|
||||
server_2.software_manager.software["DatabaseService"].start()
|
||||
server_2.software_manager.software["database-service"].start()
|
||||
|
||||
# Configuring the C2 to connect to client 1 (C2 Server)
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["C2Beacon"]
|
||||
c2_beacon: C2Beacon = server_1.software_manager.software["c2-beacon"]
|
||||
c2_beacon.configure(c2_server_ip_address=IPv4Address("10.0.1.2"))
|
||||
c2_beacon.establish()
|
||||
assert c2_beacon.c2_connection_active == True
|
||||
@@ -178,7 +178,7 @@ def test_c2_server_data_exfiltration(game_and_agent_fixture: Tuple[PrimaiteGame,
|
||||
# C2 Action: Data exfiltrate.
|
||||
|
||||
action = (
|
||||
"c2_server_data_exfiltrate",
|
||||
"c2-server-data-exfiltrate",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"target_file_name": "database.db",
|
||||
|
||||
@@ -31,10 +31,10 @@ class TestConfigureDatabaseAction:
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = client_1.software_manager.software["DatabaseClient"]
|
||||
db_client: DatabaseClient = client_1.software_manager.software["database-client"]
|
||||
|
||||
action = (
|
||||
"configure_database_client",
|
||||
"configure-database-client",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"server_ip_address": "192.168.1.99",
|
||||
@@ -54,10 +54,10 @@ class TestConfigureDatabaseAction:
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = client_1.software_manager.software["DatabaseClient"]
|
||||
db_client: DatabaseClient = client_1.software_manager.software["database-client"]
|
||||
|
||||
action = (
|
||||
"configure_database_client",
|
||||
"configure-database-client",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"server_ip_address": "192.168.1.99",
|
||||
@@ -76,11 +76,11 @@ class TestConfigureDatabaseAction:
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = client_1.software_manager.software["DatabaseClient"]
|
||||
db_client: DatabaseClient = client_1.software_manager.software["database-client"]
|
||||
old_ip = db_client.server_ip_address
|
||||
|
||||
action = (
|
||||
"configure_database_client",
|
||||
"configure-database-client",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"server_password": "admin123",
|
||||
@@ -115,14 +115,14 @@ class TestConfigureRansomwareScriptAction:
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(RansomwareScript)
|
||||
ransomware_script: RansomwareScript = client_1.software_manager.software["RansomwareScript"]
|
||||
ransomware_script: RansomwareScript = client_1.software_manager.software["ransomware-script"]
|
||||
|
||||
old_ip = ransomware_script.server_ip_address
|
||||
old_pw = ransomware_script.server_password
|
||||
old_payload = ransomware_script.payload
|
||||
|
||||
action = (
|
||||
"configure_ransomware_script",
|
||||
"configure-ransomware-script",
|
||||
{"node_name": "client_1", **config},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -143,9 +143,9 @@ class TestConfigureRansomwareScriptAction:
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(RansomwareScript)
|
||||
ransomware_script: RansomwareScript = client_1.software_manager.software["RansomwareScript"]
|
||||
ransomware_script: RansomwareScript = client_1.software_manager.software["ransomware-script"]
|
||||
action = (
|
||||
"configure_ransomware_script",
|
||||
"configure-ransomware-script",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"config": {"server_password": "admin123", "bad_option": 70},
|
||||
@@ -163,10 +163,10 @@ class TestConfigureDoSBot:
|
||||
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
client_1.software_manager.install(DoSBot)
|
||||
dos_bot: DoSBot = client_1.software_manager.software["DoSBot"]
|
||||
dos_bot: DoSBot = client_1.software_manager.software["dos-bot"]
|
||||
|
||||
action = (
|
||||
"configure_dos_bot",
|
||||
"configure-dos-bot",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"target_ip_address": "192.168.1.99",
|
||||
@@ -196,11 +196,11 @@ class TestConfigureYAML:
|
||||
|
||||
# make sure there's no db client on the node yet
|
||||
client_1 = env.game.simulation.network.get_node_by_hostname("client_1")
|
||||
assert client_1.software_manager.software.get("DatabaseClient") is None
|
||||
assert client_1.software_manager.software.get("database-client") is None
|
||||
|
||||
# take the install action, check that the db gets installed, step to get it to finish installing
|
||||
env.step(1)
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("DatabaseClient")
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("database-client")
|
||||
assert isinstance(db_client, DatabaseClient)
|
||||
assert db_client.operating_state == ApplicationOperatingState.INSTALLING
|
||||
env.step(0)
|
||||
@@ -224,11 +224,11 @@ class TestConfigureYAML:
|
||||
def test_c2_server_ransomware_configure(self):
|
||||
env = PrimaiteGymEnv(env_config=APP_CONFIG_YAML)
|
||||
client_2 = env.game.simulation.network.get_node_by_hostname("client_2")
|
||||
assert client_2.software_manager.software.get("RansomwareScript") is None
|
||||
assert client_2.software_manager.software.get("ransomware-script") is None
|
||||
|
||||
# install ransomware script
|
||||
env.step(2)
|
||||
ransom = client_2.software_manager.software.get("RansomwareScript")
|
||||
ransom = client_2.software_manager.software.get("ransomware-script")
|
||||
assert isinstance(ransom, RansomwareScript)
|
||||
assert ransom.operating_state == ApplicationOperatingState.INSTALLING
|
||||
env.step(0)
|
||||
@@ -250,17 +250,17 @@ class TestConfigureYAML:
|
||||
assert ransom.attack()
|
||||
|
||||
db_server = env.game.simulation.network.get_node_by_hostname("server_1")
|
||||
db_service: DatabaseService = db_server.software_manager.software.get("DatabaseService")
|
||||
db_service: DatabaseService = db_server.software_manager.software.get("database-service")
|
||||
assert db_service.db_file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
|
||||
def test_configure_dos_bot(self):
|
||||
env = PrimaiteGymEnv(env_config=APP_CONFIG_YAML)
|
||||
client_3 = env.game.simulation.network.get_node_by_hostname("client_3")
|
||||
assert client_3.software_manager.software.get("DoSBot") is None
|
||||
assert client_3.software_manager.software.get("dos-bot") is None
|
||||
|
||||
# install DoSBot
|
||||
env.step(3)
|
||||
bot = client_3.software_manager.software.get("DoSBot")
|
||||
bot = client_3.software_manager.software.get("dos-bot")
|
||||
assert isinstance(bot, DoSBot)
|
||||
assert bot.operating_state == ApplicationOperatingState.INSTALLING
|
||||
env.step(0)
|
||||
|
||||
@@ -33,7 +33,7 @@ def test_create_file(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
assert client_1.file_system.get_file(folder_name=random_folder, file_name=random_file) is None
|
||||
|
||||
action = (
|
||||
"node_file_create",
|
||||
"node-file-create",
|
||||
{"node_name": "client_1", "folder_name": random_folder, "file_name": random_file},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -51,7 +51,7 @@ def test_file_delete_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAge
|
||||
assert file.deleted is False
|
||||
|
||||
action = (
|
||||
"node_file_delete",
|
||||
"node-file-delete",
|
||||
{"node_name": "client_1", "folder_name": "downloads", "file_name": "cat.png"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -72,7 +72,7 @@ def test_file_scan_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent
|
||||
assert file.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
action = (
|
||||
"node_file_scan",
|
||||
"node-file-scan",
|
||||
{"node_name": "client_1", "folder_name": "downloads", "file_name": "cat.png"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -93,7 +93,7 @@ def test_file_repair_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAge
|
||||
assert file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
|
||||
action = (
|
||||
"node_file_repair",
|
||||
"node-file-repair",
|
||||
{"node_name": "client_1", "folder_name": "downloads", "file_name": "cat.png"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -113,7 +113,7 @@ def test_file_restore_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAg
|
||||
assert file.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
|
||||
action = (
|
||||
"node_file_restore",
|
||||
"node-file-restore",
|
||||
{"node_name": "client_1", "folder_name": "downloads", "file_name": "cat.png"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -132,7 +132,7 @@ def test_file_corrupt_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAg
|
||||
assert file.health_status == FileSystemItemHealthStatus.GOOD
|
||||
|
||||
action = (
|
||||
"node_file_corrupt",
|
||||
"node-file-corrupt",
|
||||
{"node_name": "client_1", "folder_name": "downloads", "file_name": "cat.png"},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -150,7 +150,7 @@ def test_file_access_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAge
|
||||
assert file.num_access == 0
|
||||
|
||||
action = (
|
||||
"node_file_access",
|
||||
"node-file-access",
|
||||
{"node_name": "client_1", "folder_name": file.folder_name, "file_name": file.name},
|
||||
)
|
||||
agent.store_action(action)
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_create_folder(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
assert client_1.file_system.get_folder(folder_name=random_folder) is None
|
||||
|
||||
action = (
|
||||
"node_folder_create",
|
||||
"node-folder-create",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"folder_name": random_folder,
|
||||
@@ -60,7 +60,7 @@ def test_folder_scan_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAge
|
||||
assert folder.visible_health_status == FileSystemItemHealthStatus.NONE
|
||||
|
||||
action = (
|
||||
"node_folder_scan",
|
||||
"node-folder-scan",
|
||||
{
|
||||
"node_name": "client_1", # client_1,
|
||||
"folder_name": "downloads", # downloads
|
||||
@@ -87,7 +87,7 @@ def test_folder_repair_action(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyA
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
|
||||
action = (
|
||||
"node_folder_repair",
|
||||
"node-folder-repair",
|
||||
{
|
||||
"node_name": "client_1", # client_1,
|
||||
"folder_name": "downloads", # downloads
|
||||
@@ -111,7 +111,7 @@ def test_folder_restore_action(game_and_agent_fixture: Tuple[PrimaiteGame, Proxy
|
||||
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
|
||||
|
||||
action = (
|
||||
"node_folder_restore",
|
||||
"node-folder-restore",
|
||||
{
|
||||
"node_name": "client_1", # client_1,
|
||||
"folder_name": "downloads", # downloads
|
||||
|
||||
@@ -29,7 +29,7 @@ def test_nic_cannot_be_turned_off_if_not_on(game_and_agent_fixture: Tuple[Primai
|
||||
assert nic.enabled is False
|
||||
|
||||
action = (
|
||||
"host_nic_disable",
|
||||
"host-nic-disable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
@@ -50,7 +50,7 @@ def test_nic_cannot_be_turned_on_if_already_on(game_and_agent_fixture: Tuple[Pri
|
||||
assert nic.enabled
|
||||
|
||||
action = (
|
||||
"host_nic_enable",
|
||||
"host-nic-enable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
@@ -71,7 +71,7 @@ def test_that_a_nic_can_be_enabled_and_disabled(game_and_agent_fixture: Tuple[Pr
|
||||
assert nic.enabled
|
||||
|
||||
action = (
|
||||
"host_nic_disable",
|
||||
"host-nic-disable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
@@ -83,7 +83,7 @@ def test_that_a_nic_can_be_enabled_and_disabled(game_and_agent_fixture: Tuple[Pr
|
||||
assert nic.enabled is False
|
||||
|
||||
action = (
|
||||
"host_nic_enable",
|
||||
"host-nic-enable",
|
||||
{
|
||||
"node_name": "client_1", # client_1
|
||||
"nic_num": 1, # the only nic (eth-1)
|
||||
|
||||
@@ -29,28 +29,28 @@ def test_node_startup_shutdown(game_and_agent_fixture: Tuple[PrimaiteGame, Proxy
|
||||
assert client_1.operating_state == NodeOperatingState.ON
|
||||
|
||||
# turn it off
|
||||
action = ("node_shutdown", {"node_name": "client_1"})
|
||||
action = ("node-shutdown", {"node_name": "client_1"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.operating_state == NodeOperatingState.SHUTTING_DOWN
|
||||
|
||||
for i in range(client_1.shut_down_duration + 1):
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.operating_state == NodeOperatingState.OFF
|
||||
|
||||
# turn it on
|
||||
action = ("node_startup", {"node_name": "client_1"})
|
||||
action = ("node-startup", {"node_name": "client_1"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.operating_state == NodeOperatingState.BOOTING
|
||||
|
||||
for i in range(client_1.start_up_duration + 1):
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -65,7 +65,7 @@ def test_node_cannot_be_started_up_if_node_is_already_on(game_and_agent_fixture:
|
||||
assert client_1.operating_state == NodeOperatingState.ON
|
||||
|
||||
# turn it on
|
||||
action = ("node_startup", {"node_name": "client_1"})
|
||||
action = ("node-startup", {"node_name": "client_1"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -80,14 +80,14 @@ def test_node_cannot_be_shut_down_if_node_is_already_off(game_and_agent_fixture:
|
||||
client_1.power_off()
|
||||
|
||||
for i in range(client_1.shut_down_duration + 1):
|
||||
action = ("do_nothing", {})
|
||||
action = ("do-nothing", {})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
assert client_1.operating_state == NodeOperatingState.OFF
|
||||
|
||||
# turn it ff
|
||||
action = ("node_shutdown", {"node_name": "client_1"})
|
||||
action = ("node-shutdown", {"node_name": "client_1"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ def test_service_start(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
game, agent = game_and_agent_fixture
|
||||
|
||||
server_1: Server = game.simulation.network.get_node_by_hostname("server_1")
|
||||
dns_server = server_1.software_manager.software.get("DNSServer")
|
||||
dns_server = server_1.software_manager.software.get("dns-server")
|
||||
|
||||
dns_server.pause()
|
||||
assert dns_server.operating_state == ServiceOperatingState.PAUSED
|
||||
|
||||
action = ("node_service_start", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-start", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.PAUSED
|
||||
@@ -40,7 +40,7 @@ def test_service_start(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_start", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-start", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -52,9 +52,9 @@ def test_service_resume(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent])
|
||||
game, agent = game_and_agent_fixture
|
||||
|
||||
server_1: Server = game.simulation.network.get_node_by_hostname("server_1")
|
||||
dns_server = server_1.software_manager.software.get("DNSServer")
|
||||
dns_server = server_1.software_manager.software.get("dns-server")
|
||||
|
||||
action = ("node_service_resume", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-resume", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.RUNNING
|
||||
@@ -63,7 +63,7 @@ def test_service_resume(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent])
|
||||
|
||||
assert dns_server.operating_state == ServiceOperatingState.PAUSED
|
||||
|
||||
action = ("node_service_resume", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-resume", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
|
||||
@@ -75,32 +75,32 @@ def test_service_cannot_perform_actions_unless_running(game_and_agent_fixture: T
|
||||
game, agent = game_and_agent_fixture
|
||||
|
||||
server_1: Server = game.simulation.network.get_node_by_hostname("server_1")
|
||||
dns_server = server_1.software_manager.software.get("DNSServer")
|
||||
dns_server = server_1.software_manager.software.get("dns-server")
|
||||
|
||||
dns_server.stop()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_scan", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-scan", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_pause", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-pause", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_resume", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-resume", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_restart", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-restart", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
action = ("node_service_fix", {"node_name": "server_1", "service_name": "DNSServer"})
|
||||
action = ("node-service-fix", {"node_name": "server_1", "service_name": "dns-server"})
|
||||
agent.store_action(action)
|
||||
game.step()
|
||||
assert dns_server.operating_state == ServiceOperatingState.STOPPED
|
||||
|
||||
@@ -32,11 +32,11 @@ def test_remote_login(game_and_agent_fixture: Tuple[PrimaiteGame, ProxyAgent]):
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
# create a new user account on server_1 that will be logged into remotely
|
||||
server_1_usm: UserManager = server_1.software_manager.software["UserManager"]
|
||||
server_1_usm: UserManager = server_1.software_manager.software["user-manager"]
|
||||
server_1_usm.add_user("user123", "password", is_admin=True)
|
||||
|
||||
action = (
|
||||
"node_session_remote_login",
|
||||
"node-session-remote-login",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"username": "user123",
|
||||
@@ -64,11 +64,11 @@ def test_remote_login_wrong_password(game_and_agent_fixture: Tuple[PrimaiteGame,
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
# create a new user account on server_1 that will be logged into remotely
|
||||
server_1_usm: UserManager = server_1.software_manager.software["UserManager"]
|
||||
server_1_usm: UserManager = server_1.software_manager.software["user-manager"]
|
||||
server_1_usm.add_user("user123", "password", is_admin=True)
|
||||
|
||||
action = (
|
||||
"node_session_remote_login",
|
||||
"node-session-remote-login",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"username": "user123",
|
||||
@@ -96,11 +96,11 @@ def test_remote_login_change_password(game_and_agent_fixture: Tuple[PrimaiteGame
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
# create a new user account on server_1 that will be logged into remotely
|
||||
server_1_um: UserManager = server_1.software_manager.software["UserManager"]
|
||||
server_1_um: UserManager = server_1.software_manager.software["user-manager"]
|
||||
server_1_um.add_user("user123", "password", is_admin=True)
|
||||
|
||||
action = (
|
||||
"node_account_change_password",
|
||||
"node-account-change-password",
|
||||
{
|
||||
"node_name": "server_1", # server_1
|
||||
"username": "user123",
|
||||
@@ -122,12 +122,12 @@ def test_change_password_logs_out_user(game_and_agent_fixture: Tuple[PrimaiteGam
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
# create a new user account on server_1 that will be logged into remotely
|
||||
server_1_usm: UserManager = server_1.software_manager.software["UserManager"]
|
||||
server_1_usm: UserManager = server_1.software_manager.software["user-manager"]
|
||||
server_1_usm.add_user("user123", "password", is_admin=True)
|
||||
|
||||
# Log in remotely
|
||||
action = (
|
||||
"node_session_remote_login",
|
||||
"node-session-remote-login",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"username": "user123",
|
||||
@@ -140,7 +140,7 @@ def test_change_password_logs_out_user(game_and_agent_fixture: Tuple[PrimaiteGam
|
||||
|
||||
# Change password
|
||||
action = (
|
||||
"node_account_change_password",
|
||||
"node-account-change-password",
|
||||
{
|
||||
"node_name": "server_1", # server_1
|
||||
"username": "user123",
|
||||
@@ -154,7 +154,7 @@ def test_change_password_logs_out_user(game_and_agent_fixture: Tuple[PrimaiteGam
|
||||
|
||||
# Assert that the user cannot execute an action
|
||||
action = (
|
||||
"node_send_remote_command",
|
||||
"node-send-remote-command",
|
||||
{
|
||||
"node_name": "client_1",
|
||||
"remote_ip": str(server_1.network_interface[1].ip_address),
|
||||
|
||||
Reference in New Issue
Block a user