#2258: missing some configuration items + added more tests
This commit is contained in:
@@ -283,7 +283,16 @@ class PrimaiteGame:
|
|||||||
opt = service_cfg["options"]
|
opt = service_cfg["options"]
|
||||||
new_service.configure_backup(backup_server=IPv4Address(opt.get("backup_server_ip")))
|
new_service.configure_backup(backup_server=IPv4Address(opt.get("backup_server_ip")))
|
||||||
new_service.start()
|
new_service.start()
|
||||||
|
if service_type == "FTPServer":
|
||||||
|
if "options" in service_cfg:
|
||||||
|
opt = service_cfg["options"]
|
||||||
|
new_service.server_password = opt.get("server_password")
|
||||||
|
new_service.start()
|
||||||
|
if service_type == "NTPClient":
|
||||||
|
if "options" in service_cfg:
|
||||||
|
opt = service_cfg["options"]
|
||||||
|
new_service.ntp_server = IPv4Address(opt.get("ntp_server_ip"))
|
||||||
|
new_service.start()
|
||||||
if "applications" in node_cfg:
|
if "applications" in node_cfg:
|
||||||
for application_cfg in node_cfg["applications"]:
|
for application_cfg in node_cfg["applications"]:
|
||||||
new_application = None
|
new_application = None
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ simulation:
|
|||||||
type: DatabaseClient
|
type: DatabaseClient
|
||||||
options:
|
options:
|
||||||
db_server_ip: 192.168.1.10
|
db_server_ip: 192.168.1.10
|
||||||
|
server_password: arcd
|
||||||
- ref: data_manipulation_bot
|
- ref: data_manipulation_bot
|
||||||
type: DataManipulationBot
|
type: DataManipulationBot
|
||||||
options:
|
options:
|
||||||
@@ -92,6 +93,7 @@ simulation:
|
|||||||
data_manipulation_p_of_success: 0.8
|
data_manipulation_p_of_success: 0.8
|
||||||
payload: "DELETE"
|
payload: "DELETE"
|
||||||
server_ip: 192.168.1.21
|
server_ip: 192.168.1.21
|
||||||
|
server_password: arcd
|
||||||
- ref: dos_bot
|
- ref: dos_bot
|
||||||
type: DoSBot
|
type: DoSBot
|
||||||
options:
|
options:
|
||||||
@@ -116,8 +118,12 @@ simulation:
|
|||||||
type: WebServer
|
type: WebServer
|
||||||
- ref: client_1_ftp_server
|
- ref: client_1_ftp_server
|
||||||
type: FTPServer
|
type: FTPServer
|
||||||
|
options:
|
||||||
|
server_password: arcd
|
||||||
- ref: client_1_ntp_client
|
- ref: client_1_ntp_client
|
||||||
type: NTPClient
|
type: NTPClient
|
||||||
|
options:
|
||||||
|
ntp_server_ip: 192.168.1.10
|
||||||
- ref: client_1_ntp_server
|
- ref: client_1_ntp_server
|
||||||
type: NTPServer
|
type: NTPServer
|
||||||
- ref: client_2
|
- ref: client_2
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from primaite.game.agent.data_manipulation_bot import DataManipulationAgent
|
|||||||
from primaite.game.agent.interface import ProxyAgent, RandomAgent
|
from primaite.game.agent.interface import ProxyAgent, RandomAgent
|
||||||
from primaite.game.game import APPLICATION_TYPES_MAPPING, PrimaiteGame, SERVICE_TYPES_MAPPING
|
from primaite.game.game import APPLICATION_TYPES_MAPPING, PrimaiteGame, SERVICE_TYPES_MAPPING
|
||||||
from primaite.simulator.network.container import Network
|
from primaite.simulator.network.container import Network
|
||||||
from primaite.simulator.network.hardware.nodes.computer import Computer
|
from primaite.simulator.network.hardware.nodes.host.computer import Computer
|
||||||
from primaite.simulator.system.applications.database_client import DatabaseClient
|
from primaite.simulator.system.applications.database_client import DatabaseClient
|
||||||
from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot
|
from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot
|
||||||
from primaite.simulator.system.applications.red_applications.dos_bot import DoSBot
|
from primaite.simulator.system.applications.red_applications.dos_bot import DoSBot
|
||||||
@@ -109,6 +109,7 @@ def test_database_client_install():
|
|||||||
database_client: DatabaseClient = client_1.software_manager.software.get("DatabaseClient")
|
database_client: DatabaseClient = client_1.software_manager.software.get("DatabaseClient")
|
||||||
|
|
||||||
assert database_client.server_ip_address == IPv4Address("192.168.1.10")
|
assert database_client.server_ip_address == IPv4Address("192.168.1.10")
|
||||||
|
assert database_client.server_password == "arcd"
|
||||||
|
|
||||||
|
|
||||||
def test_data_manipulation_bot_install():
|
def test_data_manipulation_bot_install():
|
||||||
@@ -122,6 +123,7 @@ def test_data_manipulation_bot_install():
|
|||||||
assert data_manipulation_bot.payload == "DELETE"
|
assert data_manipulation_bot.payload == "DELETE"
|
||||||
assert data_manipulation_bot.data_manipulation_p_of_success == 0.8
|
assert data_manipulation_bot.data_manipulation_p_of_success == 0.8
|
||||||
assert data_manipulation_bot.port_scan_p_of_success == 0.8
|
assert data_manipulation_bot.port_scan_p_of_success == 0.8
|
||||||
|
assert data_manipulation_bot.server_password == "arcd"
|
||||||
|
|
||||||
|
|
||||||
def test_dos_bot_install():
|
def test_dos_bot_install():
|
||||||
@@ -149,6 +151,16 @@ def test_dns_client_install():
|
|||||||
assert dns_client.dns_server == IPv4Address("192.168.1.10")
|
assert dns_client.dns_server == IPv4Address("192.168.1.10")
|
||||||
|
|
||||||
|
|
||||||
|
def test_dns_server_install():
|
||||||
|
"""Test that the DNS Client service can be configured via config."""
|
||||||
|
game = load_config(BASIC_CONFIG)
|
||||||
|
client_1: Computer = game.simulation.network.get_node_by_hostname("client_1")
|
||||||
|
|
||||||
|
dns_server: DNSServer = client_1.software_manager.software.get("DNSServer")
|
||||||
|
|
||||||
|
assert dns_server.dns_lookup("arcd.com") == IPv4Address("192.168.1.10")
|
||||||
|
|
||||||
|
|
||||||
def test_database_service_install():
|
def test_database_service_install():
|
||||||
"""Test that the Database Service can be configured via config."""
|
"""Test that the Database Service can be configured via config."""
|
||||||
game = load_config(BASIC_CONFIG)
|
game = load_config(BASIC_CONFIG)
|
||||||
@@ -186,6 +198,7 @@ def test_ftp_server_install():
|
|||||||
|
|
||||||
ftp_server_service: FTPServer = client_1.software_manager.software.get("FTPServer")
|
ftp_server_service: FTPServer = client_1.software_manager.software.get("FTPServer")
|
||||||
assert ftp_server_service is not None
|
assert ftp_server_service is not None
|
||||||
|
assert ftp_server_service.server_password == "arcd"
|
||||||
|
|
||||||
|
|
||||||
def test_ntp_client_install():
|
def test_ntp_client_install():
|
||||||
@@ -195,6 +208,7 @@ def test_ntp_client_install():
|
|||||||
|
|
||||||
ntp_client_service: NTPClient = client_1.software_manager.software.get("NTPClient")
|
ntp_client_service: NTPClient = client_1.software_manager.software.get("NTPClient")
|
||||||
assert ntp_client_service is not None
|
assert ntp_client_service is not None
|
||||||
|
assert ntp_client_service.ntp_server == IPv4Address("192.168.1.10")
|
||||||
|
|
||||||
|
|
||||||
def test_ntp_server_install():
|
def test_ntp_server_install():
|
||||||
|
|||||||
Reference in New Issue
Block a user