forked from p15670423/monkey
Tests: Set autouse=False for patch_report_service fixture
This commit is contained in:
parent
e4cd06d8c3
commit
c7d655ac7d
|
@ -3,6 +3,9 @@ import pytest
|
|||
from monkey_island.cc.services.ransomware import ransomware_report
|
||||
from monkey_island.cc.services.reporting.report import ReportService
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def patch_report_service_for_stats(monkeypatch):
|
||||
TEST_SCANNED_RESULTS = [{}, {}, {}, {}]
|
||||
TEST_EXPLOITED_RESULTS = [
|
||||
{"exploits": ["SSH Exploiter"]},
|
||||
|
@ -10,26 +13,23 @@ TEST_EXPLOITED_RESULTS = [
|
|||
{"exploits": ["WMI Exploiter"]},
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def patch_report_service(monkeypatch):
|
||||
monkeypatch.setattr(ReportService, "get_scanned", lambda: TEST_SCANNED_RESULTS)
|
||||
monkeypatch.setattr(ReportService, "get_exploited", lambda: TEST_EXPLOITED_RESULTS)
|
||||
|
||||
|
||||
def test_get_propagation_stats__num_scanned():
|
||||
def test_get_propagation_stats__num_scanned(patch_report_service_for_stats):
|
||||
stats = ransomware_report.get_propagation_stats()
|
||||
|
||||
assert stats["num_scanned_nodes"] == 4
|
||||
|
||||
|
||||
def test_get_propagation_stats__num_exploited():
|
||||
def test_get_propagation_stats__num_exploited(patch_report_service_for_stats):
|
||||
stats = ransomware_report.get_propagation_stats()
|
||||
|
||||
assert stats["num_exploited_nodes"] == 3
|
||||
|
||||
|
||||
def test_get_propagation_stats__num_exploited_per_exploit():
|
||||
def test_get_propagation_stats__num_exploited_per_exploit(patch_report_service_for_stats):
|
||||
stats = ransomware_report.get_propagation_stats()
|
||||
|
||||
assert stats["num_exploited_per_exploit"]["SSH Exploiter"] == 2
|
||||
|
|
Loading…
Reference in New Issue