def test_star_new(self): filepath = Files.temp_put(""" virtualbox.virtualbox.machines = cuckoo2, cuckoo3 virtualbox.cuckoo2.ip = 192.168.56.102 virtualbox.cuckoo3.ip = 192.168.56.103 virtualbox.notexistingvm.ip = 1.2.3.4 """) assert read_kv_conf(filepath) == { "virtualbox": { "virtualbox": { "machines": [ "cuckoo2", "cuckoo3", ], }, "cuckoo2": { "ip": "192.168.56.102", }, "cuckoo3": { "ip": "192.168.56.103", }, "notexistingvm": { "ip": "1.2.3.4", }, }, }
def test_star_existing(self): filepath = Files.temp_put(""" virtualbox.cuckoo1.resultserver_port = 1234 """) assert read_kv_conf(filepath) == { "virtualbox": { "cuckoo1": { "resultserver_port": 1234, }, }, }
def init(ctx, conf): """Initializes Cuckoo and its configuration.""" if conf and os.path.exists(conf): cfg = read_kv_conf(conf) else: cfg = None # If this is a new install, also apply the provided configuration. cuckoo_init(logging.INFO, ctx.parent, cfg) # If this is an existing install, overwrite the supervisord.conf # configuration file (if needed) as well as the Cuckoo configuration. write_supervisor_conf(ctx.parent.user or getuser()) write_cuckoo_conf(cfg)
def test_success(self): filepath = Files.temp_put(""" cuckoo.cuckoo.version_check = off auxiliary.sniffer.enabled = no """) assert read_kv_conf(filepath) == { "cuckoo": { "cuckoo": { "version_check": False, }, }, "auxiliary": { "sniffer": { "enabled": False, }, }, }
def test_fail3(self): filepath = Files.temp_put("cuckoo.cuckoo.version_check = foo") with pytest.raises(CuckooConfigurationError) as e: read_kv_conf(filepath) e.match("Invalid flat configuration entry")
def test_fail2(self): filepath = Files.temp_put("a.b.c : d") with pytest.raises(CuckooConfigurationError) as e: read_kv_conf(filepath) e.match("missing .* character")
def test_fail1(self): filepath = Files.temp_put("a = b") with pytest.raises(CuckooConfigurationError) as e: read_kv_conf(filepath) e.match("Invalid configuration entry")