forked from p15670423/monkey
Match unit tests' class names and file names
Renamed class/file name depending on which was more applicable
This commit is contained in:
parent
6e92127807
commit
5469c7cc41
|
@ -6,7 +6,7 @@ from .aws_service import filter_instance_data_from_aws_response
|
|||
__author__ = "shay.nehmad"
|
||||
|
||||
|
||||
class TestFilterInstanceDataFromAwsResponse(TestCase):
|
||||
class TestAwsService(TestCase):
|
||||
def test_filter_instance_data_from_aws_response(self):
|
||||
json_response_full = """
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ from common.network.network_range import CidrRange, SingleIpRange
|
|||
from infection_monkey.model.victim_host_generator import VictimHostGenerator
|
||||
|
||||
|
||||
class VictimHostGeneratorTester(TestCase):
|
||||
class TestVictimHostGenerator(TestCase):
|
||||
def setUp(self):
|
||||
self.cidr_range = CidrRange("10.0.0.0/28", False) # this gives us 15 hosts
|
||||
self.local_host_range = SingleIpRange("localhost")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin # noqa: F401
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester # noqa: F401
|
||||
|
||||
|
||||
class SomeDummyPlugin:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
|
||||
|
||||
|
||||
class BadPluginInit(TestPlugin):
|
||||
class BadPluginInit(PluginTester):
|
||||
def __init__(self):
|
||||
raise Exception("TestException")
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
|
||||
|
||||
|
||||
class NoInheritance:
|
||||
pass
|
||||
|
||||
|
||||
class BadInit(TestPlugin):
|
||||
class BadInit(PluginTester):
|
||||
def __init__(self):
|
||||
raise Exception("TestException")
|
||||
|
||||
|
||||
class ProperClass(TestPlugin):
|
||||
class ProperClass(PluginTester):
|
||||
pass
|
||||
|
|
|
@ -2,7 +2,7 @@ import infection_monkey.utils.plugins.pluginTests
|
|||
from infection_monkey.utils.plugins.plugin import Plugin
|
||||
|
||||
|
||||
class TestPlugin(Plugin):
|
||||
class PluginTester(Plugin):
|
||||
classes_to_load = []
|
||||
|
||||
@staticmethod
|
||||
|
@ -11,7 +11,7 @@ class TestPlugin(Plugin):
|
|||
Decides if post breach action is enabled in config
|
||||
:return: True if it needs to be ran, false otherwise
|
||||
"""
|
||||
return class_name in TestPlugin.classes_to_load
|
||||
return class_name in PluginTester.classes_to_load
|
||||
|
||||
@staticmethod
|
||||
def base_package_file():
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
|
||||
|
||||
|
||||
class PluginWorking(TestPlugin):
|
||||
class PluginWorking(PluginTester):
|
||||
pass
|
||||
|
|
|
@ -3,33 +3,33 @@ from unittest import TestCase
|
|||
from infection_monkey.utils.plugins.pluginTests.BadImport import SomeDummyPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.BadInit import BadPluginInit
|
||||
from infection_monkey.utils.plugins.pluginTests.ComboFile import BadInit, ProperClass
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import PluginTester
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginWorking import PluginWorking
|
||||
|
||||
|
||||
class PluginTester(TestCase):
|
||||
class TestPlugin(TestCase):
|
||||
def test_combo_file(self):
|
||||
TestPlugin.classes_to_load = [BadInit.__name__, ProperClass.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
PluginTester.classes_to_load = [BadInit.__name__, ProperClass.__name__]
|
||||
to_init = PluginTester.get_classes()
|
||||
self.assertEqual(len(to_init), 2)
|
||||
objects = TestPlugin.get_instances()
|
||||
objects = PluginTester.get_instances()
|
||||
self.assertEqual(len(objects), 1)
|
||||
|
||||
def test_bad_init(self):
|
||||
TestPlugin.classes_to_load = [BadPluginInit.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
PluginTester.classes_to_load = [BadPluginInit.__name__]
|
||||
to_init = PluginTester.get_classes()
|
||||
self.assertEqual(len(to_init), 1)
|
||||
objects = TestPlugin.get_instances()
|
||||
objects = PluginTester.get_instances()
|
||||
self.assertEqual(len(objects), 0)
|
||||
|
||||
def test_bad_import(self):
|
||||
TestPlugin.classes_to_load = [SomeDummyPlugin.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
PluginTester.classes_to_load = [SomeDummyPlugin.__name__]
|
||||
to_init = PluginTester.get_classes()
|
||||
self.assertEqual(len(to_init), 0)
|
||||
|
||||
def test_flow(self):
|
||||
TestPlugin.classes_to_load = [PluginWorking.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
PluginTester.classes_to_load = [PluginWorking.__name__]
|
||||
to_init = PluginTester.get_classes()
|
||||
self.assertEqual(len(to_init), 1)
|
||||
objects = TestPlugin.get_instances()
|
||||
objects = PluginTester.get_instances()
|
||||
self.assertEqual(len(objects), 1)
|
||||
|
|
|
@ -6,7 +6,7 @@ from monkey_island.cc.database import database, mongo
|
|||
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||
|
||||
|
||||
class LogTest(flask_restful.Resource):
|
||||
class TestLog(flask_restful.Resource):
|
||||
@jwt_required
|
||||
def get(self):
|
||||
find_query = json_util.loads(request.args.get("find_query"))
|
||||
|
|
|
@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo
|
|||
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||
|
||||
|
||||
class MonkeyTest(flask_restful.Resource):
|
||||
class TestMonkey(flask_restful.Resource):
|
||||
@jwt_required
|
||||
def get(self, **kw):
|
||||
find_query = json_util.loads(request.args.get("find_query"))
|
||||
|
|
|
@ -6,7 +6,7 @@ from monkey_island.cc.database import mongo
|
|||
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||
|
||||
|
||||
class TelemetryTest(flask_restful.Resource):
|
||||
class TestTelemetry(flask_restful.Resource):
|
||||
@jwt_required
|
||||
def get(self, **kw):
|
||||
find_query = json_util.loads(request.args.get("find_query"))
|
||||
|
|
|
@ -6,7 +6,7 @@ import bson
|
|||
from monkey_island.cc.services.representations import normalize_obj
|
||||
|
||||
|
||||
class TestJsonRepresentations(TestCase):
|
||||
class TestRepresentations(TestCase):
|
||||
def test_normalize_obj(self):
|
||||
# empty
|
||||
self.assertEqual({}, normalize_obj({}))
|
||||
|
|
|
@ -3,7 +3,7 @@ from unittest import TestCase
|
|||
from monkey_island.cc.services.utils.node_states import NodeStates, NoGroupsFoundException
|
||||
|
||||
|
||||
class TestNodeGroups(TestCase):
|
||||
class TestNodeStates(TestCase):
|
||||
def test_get_group_by_keywords(self):
|
||||
self.assertEqual(NodeStates.get_by_keywords(["island"]), NodeStates.ISLAND)
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in New Issue