forked from p15670423/monkey
Add unit tests for `set_server_ips_in_config()` in monkey_island/cc/services/config.py
This commit is contained in:
parent
11e6b9e281
commit
f9ea196b98
|
@ -0,0 +1,31 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import monkey_island.cc.services.config
|
||||||
|
from monkey_island.cc.environment import Environment
|
||||||
|
from monkey_island.cc.services.config import ConfigService
|
||||||
|
|
||||||
|
IPS = ["0.0.0.0", "9.9.9.9"]
|
||||||
|
PORT = 9999
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def config(monkeypatch):
|
||||||
|
monkeypatch.setattr("monkey_island.cc.services.config.local_ip_addresses",
|
||||||
|
lambda: IPS)
|
||||||
|
monkeypatch.setattr(Environment, "_ISLAND_PORT", PORT)
|
||||||
|
config = ConfigService.get_default_config(True)
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_server_ips_in_config_command_servers(config):
|
||||||
|
ConfigService.set_server_ips_in_config(config)
|
||||||
|
expected_config_command_servers = [f"{ip}:{PORT}" for ip in IPS]
|
||||||
|
assert config["internal"]["island_server"]["command_servers"] ==\
|
||||||
|
expected_config_command_servers
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_server_ips_in_config_current_server(config):
|
||||||
|
ConfigService.set_server_ips_in_config(config)
|
||||||
|
expected_config_current_server = f"{IPS[0]}:{PORT}"
|
||||||
|
assert config["internal"]["island_server"]["current_server"] ==\
|
||||||
|
expected_config_current_server
|
Loading…
Reference in New Issue