def __init__(self, name, manager, shared=CONF.getAutoShareWorkspace()): self.name = name self.description = "" self.customer = "" self.start_date = datetime.date(1, 1, 1) self.finish_date = datetime.date(1, 1, 1) self.id = name self._command_history = None self._model_controller = None self._workspace_manager = manager self.shared = shared self._path = os.path.join(CONF.getPersistencePath(), name) self._persistence_excluded_filenames = [ "categories.xml", "workspace.xml" ] self.container = ModelObjectContainer() self.__conflicts = [] self._object_factory = model.common.factory self._object_factory.register(model.hosts.Host) self._report_path = os.path.join(CONF.getReportPath(), name) self._report_ppath = os.path.join(self._report_path, "process") if not os.path.exists(self._report_path): os.mkdir(self._report_path) if not os.path.exists(self._report_ppath): os.mkdir(self._report_ppath)
def setUp(self): self._model_controller = controller.ModelController(mock()) self.cm = mock(CommandManager) when(self.cm).saveCommand().thenReturn(True) self._plugin_controller = PluginController("test", {}, self.cm) class PluginTest(PluginBase): def __init__(self): PluginBase.__init__(self) self.id = "Test" self.name = "Test" def parseOutputString(self, output, debug=False): pass self.workspace = mock(Workspace) when(self.workspace).getContainee().thenReturn(ModelObjectContainer()) self._model_controller.setWorkspace(self.workspace) self.plugin = PluginTest() api.setUpAPIs(self._model_controller) self._plugin_controller.setActivePlugin(self.plugin) self.cmdinfo = CommandRunInformation( **{'workspace': 'test', 'itime': time(), 'command': 'test', 'params': 'test'})
def setUp(self): """ Generic test to verify that the object exists and can be instantiated without problems. """ self.model_controller = controller.ModelController(mock()) self.workspace = mock(Workspace) when(self.workspace).getContainee().thenReturn(ModelObjectContainer()) self.cm = mock(CommandManager) when(self.cm).saveCommand().thenReturn(True) self.model_controller.setWorkspace(self.workspace) self._plugin_controller = PluginControllerForApi("test", {"netsparker": plugin.NessusPlugin()}, self.cm) api.setUpAPIs(self.model_controller)
def setUp(self): self.workspace = mock(Workspace) self.workspace.name = "default" self.workspace._dmanager = mock(PersistenceManager()) when(self.workspace._dmanager).saveDocument().thenReturn(True) when(self.workspace).getContainee().thenReturn(ModelObjectContainer()) self.model_controller.setWorkspace(self.workspace) model.api.setUpAPIs(self.model_controller) self.url_input = "http://127.0.0.1:9977/cmd/input" self.url_output = "http://127.0.0.1:9977/cmd/output" self.url_active_plugins = "http://127.0.0.1:9977/cmd/active-plugins" self.headers = { 'Content-type': 'application/json', 'Accept': 'application/json' } self.url_model_edit_vulns = "http://127.0.0.1:9977/model/edit/vulns" self.url_model_del_vulns = "http://127.0.0.1:9977/model/del/vulns"