forked from p15670423/monkey
Fixed travis bugs caused by disabled ZT tests
This commit is contained in:
parent
9540c93013
commit
35b8efb79d
|
@ -1,56 +0,0 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
import common.common_consts.zero_trust_consts as zero_trust_consts
|
|
||||||
from monkey_island.cc.models.zero_trust.event import Event
|
|
||||||
from monkey_island.cc.models.zero_trust.segmentation_finding import SegmentationFinding
|
|
||||||
from monkey_island.cc.testing.IslandTestCase import IslandTestCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestSegmentationFinding(IslandTestCase):
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Broken during ScoutSuite refactoring, need to be fixed")
|
|
||||||
def test_create_or_add_to_existing_finding(self):
|
|
||||||
self.fail_if_not_testing_env()
|
|
||||||
self.clean_finding_db()
|
|
||||||
|
|
||||||
first_segment = "1.1.1.0/24"
|
|
||||||
second_segment = "2.2.2.0-2.2.2.254"
|
|
||||||
third_segment = "3.3.3.3"
|
|
||||||
event = Event.create_event("bla", "bla", zero_trust_consts.EVENT_TYPE_MONKEY_NETWORK)
|
|
||||||
|
|
||||||
SegmentationFinding.create_or_add_to_existing_finding(
|
|
||||||
subnets=[first_segment, second_segment],
|
|
||||||
status=zero_trust_consts.STATUS_FAILED,
|
|
||||||
segmentation_event=event
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()), 1)
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()[0].events), 1)
|
|
||||||
|
|
||||||
SegmentationFinding.create_or_add_to_existing_finding(
|
|
||||||
# !!! REVERSE ORDER
|
|
||||||
subnets=[second_segment, first_segment],
|
|
||||||
status=zero_trust_consts.STATUS_FAILED,
|
|
||||||
segmentation_event=event
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()), 1)
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()[0].events), 2)
|
|
||||||
|
|
||||||
SegmentationFinding.create_or_add_to_existing_finding(
|
|
||||||
# !!! REVERSE ORDER
|
|
||||||
subnets=[first_segment, third_segment],
|
|
||||||
status=zero_trust_consts.STATUS_FAILED,
|
|
||||||
segmentation_event=event
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()), 2)
|
|
||||||
|
|
||||||
SegmentationFinding.create_or_add_to_existing_finding(
|
|
||||||
# !!! REVERSE ORDER
|
|
||||||
subnets=[second_segment, third_segment],
|
|
||||||
status=zero_trust_consts.STATUS_FAILED,
|
|
||||||
segmentation_event=event
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(len(SegmentationFinding.objects()), 3)
|
|
|
@ -1,13 +1,11 @@
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
import common.common_consts.zero_trust_consts as zero_trust_consts
|
import common.common_consts.zero_trust_consts as zero_trust_consts
|
||||||
from monkey_island.cc.models import Monkey
|
from monkey_island.cc.models import Monkey
|
||||||
from monkey_island.cc.models.zero_trust.event import Event
|
from monkey_island.cc.models.zero_trust.event import Event
|
||||||
from monkey_island.cc.models.zero_trust.finding import Finding
|
from monkey_island.cc.models.zero_trust.finding import Finding
|
||||||
from monkey_island.cc.models.zero_trust.segmentation_finding import SegmentationFinding
|
|
||||||
from monkey_island.cc.services.telemetry.zero_trust_checks.segmentation import create_or_add_findings_for_all_pairs
|
from monkey_island.cc.services.telemetry.zero_trust_checks.segmentation import create_or_add_findings_for_all_pairs
|
||||||
|
from monkey_island.cc.services.zero_trust.monkey_finding_service import MonkeyFindingService
|
||||||
from monkey_island.cc.testing.IslandTestCase import IslandTestCase
|
from monkey_island.cc.testing.IslandTestCase import IslandTestCase
|
||||||
|
|
||||||
FIRST_SUBNET = "1.1.1.1"
|
FIRST_SUBNET = "1.1.1.1"
|
||||||
|
@ -17,7 +15,6 @@ THIRD_SUBNET = "3.3.3.3-3.3.3.200"
|
||||||
|
|
||||||
class TestSegmentationChecks(IslandTestCase):
|
class TestSegmentationChecks(IslandTestCase):
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Broken during ScoutSuite refactoring, need to be fixed")
|
|
||||||
def test_create_findings_for_all_done_pairs(self):
|
def test_create_findings_for_all_done_pairs(self):
|
||||||
self.fail_if_not_testing_env()
|
self.fail_if_not_testing_env()
|
||||||
self.clean_finding_db()
|
self.clean_finding_db()
|
||||||
|
@ -40,10 +37,13 @@ class TestSegmentationChecks(IslandTestCase):
|
||||||
2)
|
2)
|
||||||
|
|
||||||
# This is a monkey from 2nd subnet communicated with 1st subnet.
|
# This is a monkey from 2nd subnet communicated with 1st subnet.
|
||||||
SegmentationFinding.create_or_add_to_existing_finding(
|
MonkeyFindingService.create_or_add_to_existing(
|
||||||
[FIRST_SUBNET, SECOND_SUBNET],
|
status=zero_trust_consts.STATUS_FAILED,
|
||||||
zero_trust_consts.STATUS_FAILED,
|
test=zero_trust_consts.TEST_SEGMENTATION,
|
||||||
Event.create_event(title="sdf", message="asd", event_type=zero_trust_consts.EVENT_TYPE_MONKEY_NETWORK)
|
events=[Event.create_event(title="sdf",
|
||||||
|
message="asd",
|
||||||
|
event_type=zero_trust_consts.EVENT_TYPE_MONKEY_NETWORK)]
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
Loading…
Reference in New Issue