forked from p15670423/monkey
UT: Fix database_initializer test
This commit is contained in:
parent
1748955213
commit
9ea5a56abd
|
@ -1,11 +1,9 @@
|
||||||
import json.decoder
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import mongomock
|
import mongomock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
|
|
||||||
from monkey_island.cc.setup.mongo.database_initializer import reset_database
|
from monkey_island.cc.setup.mongo.database_initializer import reset_database
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,15 +45,16 @@ def test_store_mitigations_on_mongo__invalid_mitigation(
|
||||||
reset_database()
|
reset_database()
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_mitigations():
|
def test_get_all_mitigations(monkeypatch, fake_mongo, fake_config):
|
||||||
attack_mitigation_path = (
|
fake_mongo.db.validate_collection = MagicMock(return_value=True)
|
||||||
Path(MONKEY_ISLAND_ABS_PATH) / "cc" / "setup" / "mongo" / "attack_mitigations.json"
|
|
||||||
)
|
|
||||||
|
|
||||||
with open(attack_mitigation_path) as mitigations:
|
reset_database()
|
||||||
mitigations = json.load(mitigations)["data"]
|
|
||||||
assert len(mitigations) >= 266
|
mitigations = list(fake_mongo.db.attack_mitigations.find({}))
|
||||||
mitigation = next(iter(mitigations))["mitigations"][0]
|
|
||||||
assert mitigation["name"] is not None
|
assert len(mitigations) >= 266
|
||||||
assert mitigation["description"] is not None
|
|
||||||
assert mitigation["url"] is not None
|
mitigation = mitigations[0]["mitigations"][0]
|
||||||
|
assert mitigation["name"] is not None
|
||||||
|
assert mitigation["description"] is not None
|
||||||
|
assert mitigation["url"] is not None
|
||||||
|
|
Loading…
Reference in New Issue