def testEditVulnSyncGetsMapperDispatchedASYNC(self): vuln = ModelObjectVuln("coquito") params = ('new_name', 'new_desc', 'high', "ref1") self.genericEdit(vuln, params, controller.ModelController.editVulnASYNC, process_pending=True) self.assertEquals(vuln.getName(), 'new_name', "Name not updated") self.assertEquals(vuln.getDescription(), 'new_desc', "Description not updated") self.assertEquals(vuln.getSeverity(), 'high', "Severity not updated")
def testAddNoteToVulnGetsMapperDispatchSave(self): vuln = ModelObjectVuln('a vuln') note = ModelObjectNote("a_note") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(note.class_signature).thenReturn(objectMapper) when(objectMapper).save(note).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addNoteToServiceSYNC(None, vuln.getID(), note) verify(mappersManager).getMapper(note.class_signature) verify(objectMapper).save(note)
def testAddVulnToHostGetsMapperDispatchSaveSYNC(self): host = Host("pepito") vuln = ModelObjectVuln("a_vuln") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(vuln.class_signature).thenReturn(objectMapper) when(objectMapper).save(vuln).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addVulnToHostSYNC(host.getID(), vuln) verify(mappersManager).getMapper(vuln.class_signature) verify(objectMapper).save(vuln)
def testAddVulnToInterfaceGetsMapperDispatchSaveSYNC(self): interface = Interface("int0") vuln = ModelObjectVuln("a_vuln") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(vuln.class_signature).thenReturn(objectMapper) when(objectMapper).save(vuln).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addVulnToInterfaceSYNC(None, interface.getID(), vuln) verify(mappersManager).getMapper(vuln.class_signature) verify(objectMapper).save(vuln)
def testAddVulnToServiceGetsMapperDispatchSaveASYNC(self): service = Service("servi") vuln = ModelObjectVuln("a_vuln") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(vuln.class_signature).thenReturn(objectMapper) when(objectMapper).save(vuln).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addVulnToServiceASYNC(None, service.getID(), vuln) model_controller.processAllPendingActions() verify(mappersManager).getMapper(vuln.class_signature) verify(objectMapper).save(vuln)
def testDelVulnFromServiceASYNC(self): service = Service('coco') vuln = ModelObjectVuln("int_mock0") service.addChild(vuln) self.genericDelTest(service, vuln, controller.ModelController.delVulnFromServiceASYNC, process_pending=True)
def testDelVulnFromObjectSYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnSYNC)
def testDelVulnFromHostASYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnFromHostASYNC, process_pending=True)