forked from p15670423/monkey
Moved unit test files and profiling test decorator into test directory away from production code
This commit is contained in:
parent
832453fdb5
commit
c85ac0f610
|
@ -1,4 +0,0 @@
|
||||||
# Without these imports pytests can't use fixtures,
|
|
||||||
# because they are not found
|
|
||||||
from .fixture_enum import FixtureEnum # noqa: F401
|
|
||||||
from .mongomock_fixtures import * # noqa: F401,F403
|
|
|
@ -1,3 +1,3 @@
|
||||||
# Without these imports pytests can't use fixtures,
|
# Without these imports pytests can't use fixtures,
|
||||||
# because they are not found
|
# because they are not found
|
||||||
from monkey_island.cc.test_common.fixtures import * # noqa: F401,F403
|
from tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403
|
||||||
|
|
|
@ -3,10 +3,10 @@ import uuid
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from monkey_island.cc.models.monkey import Monkey, MonkeyNotFoundError
|
from monkey_island.cc.models.monkey import Monkey, MonkeyNotFoundError
|
||||||
from monkey_island.cc.models.monkey_ttl import MonkeyTtl
|
from monkey_island.cc.models.monkey_ttl import MonkeyTtl
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import pytest
|
import pytest
|
||||||
from mongoengine import ValidationError
|
from mongoengine import ValidationError
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
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.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.monkey_finding import MonkeyFinding
|
from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding
|
||||||
from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
|
from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails()
|
MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails()
|
||||||
MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"]
|
MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
from mongoengine import ValidationError
|
from mongoengine import ValidationError
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
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.zero_trust.finding import Finding
|
from monkey_island.cc.models.zero_trust.finding import Finding
|
||||||
|
@ -7,7 +8,6 @@ from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFind
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
||||||
from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails
|
from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails
|
||||||
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import RULES
|
from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import RULES
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails()
|
MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails()
|
||||||
MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"]
|
MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"]
|
||||||
|
|
|
@ -2,10 +2,10 @@ import logging
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from mongomock import ObjectId
|
from mongomock import ObjectId
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from monkey_island.cc.models.edge import Edge
|
from monkey_island.cc.models.edge import Edge
|
||||||
from monkey_island.cc.services.edge.edge import EdgeService
|
from monkey_island.cc.services.edge.edge import EdgeService
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from common.common_consts import zero_trust_consts
|
from common.common_consts import zero_trust_consts
|
||||||
from monkey_island.cc.models.zero_trust.event import Event
|
from monkey_island.cc.models.zero_trust.event import Event
|
||||||
|
@ -9,7 +10,6 @@ from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding
|
||||||
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_finding_service import (
|
from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_finding_service import (
|
||||||
MonkeyZTFindingService,
|
MonkeyZTFindingService,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
EVENTS = [
|
EVENTS = [
|
||||||
Event.create_event(
|
Event.create_event(
|
||||||
|
|
|
@ -2,6 +2,7 @@ from unittest.mock import MagicMock
|
||||||
|
|
||||||
import dpath.util
|
import dpath.util
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from common.config_value_paths import AWS_KEYS_PATH
|
from common.config_value_paths import AWS_KEYS_PATH
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
|
@ -10,7 +11,6 @@ from monkey_island.cc.services.config import ConfigService
|
||||||
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import (
|
from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import (
|
||||||
is_aws_keys_setup,
|
is_aws_keys_setup,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
|
|
||||||
class MockObject:
|
class MockObject:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
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.scoutsuite_finding import ScoutSuiteFinding
|
from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding
|
||||||
|
@ -9,7 +10,6 @@ from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data im
|
||||||
RULES,
|
RULES,
|
||||||
SCOUTSUITE_FINDINGS,
|
SCOUTSUITE_FINDINGS,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
|
|
||||||
class TestScoutSuiteZTFindingService:
|
class TestScoutSuiteZTFindingService:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from common.common_consts.zero_trust_consts import (
|
from common.common_consts.zero_trust_consts import (
|
||||||
DEVICES,
|
DEVICES,
|
||||||
|
@ -22,7 +23,6 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service impo
|
||||||
EnrichedFinding,
|
EnrichedFinding,
|
||||||
FindingService,
|
FindingService,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures.fixture_enum import FixtureEnum
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE)
|
@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from common.common_consts import zero_trust_consts
|
from common.common_consts import zero_trust_consts
|
||||||
from common.common_consts.zero_trust_consts import (
|
from common.common_consts.zero_trust_consts import (
|
||||||
|
@ -16,7 +17,6 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.pillar_service impor
|
||||||
from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_finding_data import ( # noqa: E501
|
from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_finding_data import ( # noqa: E501
|
||||||
save_example_findings,
|
save_example_findings,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE)
|
@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
from tests.monkey_island.cc.fixture_enum import FixtureEnum
|
||||||
|
|
||||||
from common.common_consts import zero_trust_consts
|
from common.common_consts import zero_trust_consts
|
||||||
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
|
from monkey_island.cc.services.zero_trust.test_common.finding_data import (
|
||||||
|
@ -8,7 +9,6 @@ from monkey_island.cc.services.zero_trust.test_common.finding_data import (
|
||||||
from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service import (
|
from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service import (
|
||||||
PrincipleService,
|
PrincipleService,
|
||||||
)
|
)
|
||||||
from monkey_island.cc.test_common.fixtures import FixtureEnum
|
|
||||||
|
|
||||||
EXPECTED_DICT = {
|
EXPECTED_DICT = {
|
||||||
"test_pillar1": [
|
"test_pillar1": [
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Profiling island
|
# Profiling island
|
||||||
|
|
||||||
To profile specific methods on island a `@profile(sort_args=['cumulative'], print_args=[100])`
|
To profile specific methods on island a `@profile(sort_args=['cumulative'], print_args=[100])`
|
||||||
decorator can be used.
|
decorator can be used.
|
||||||
Use it as a parameterised decorator(`@profile()`). After decorated method is used, a file will appear in a
|
Use it as a parameterised decorator(`@profile()`). After decorated method is used, a file will appear in a
|
||||||
directory provided in `profiler_decorator.py`. Filename describes the path of
|
directory provided in `profiler_decorator.py`. Filename describes the path of
|
||||||
the method that was profiled. For example if method `monkey_island/cc/resources/netmap.get`
|
the method that was profiled. For example if method `monkey_island/cc/resources/netmap.get`
|
||||||
was profiled, then the results of this profiling will appear in
|
was profiled, then the results of this profiling will appear in
|
||||||
`monkey_island_cc_resources_netmap_get`.
|
`monkey_island_cc_resources_netmap_get`.
|
Loading…
Reference in New Issue