def testEditInterfaceSyncGetsMapperDispatchedSYNC(self): inter = Interface("coquito") params = ('new_name', 'new_desc', 'hostname1', "FF:AA:EE:11:00", None, None, None, None, None, None, True) self.genericEdit(inter, params, controller.ModelController.editInterfaceSYNC) self.assertEquals(inter.getName(), 'new_name', "Name not updated") self.assertEquals(inter.getDescription(), 'new_desc', "Description not updated") self.assertEquals(inter.isOwned(), True, "Owned status not updated")
def testAddNoteToInterfaceGetsMapperDispatchSaveSYNC(self): interface = Interface("pepito") 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.addNoteToInterfaceSYNC(None, interface.getID(), note) verify(mappersManager).getMapper(note.class_signature) verify(objectMapper).save(note)
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 testAddServiceGetsMapperDispatchSaveSYNC(self): interface = Interface("int_mock0") service = Service("servi") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(service.class_signature).thenReturn(objectMapper) when(objectMapper).save(service).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addServiceToInterfaceSYNC(None, interface.getID(), service) verify(mappersManager).getMapper(service.class_signature) verify(objectMapper).save(service)
def testAddObjectSavesChildInParent(self): host = Host('coco') interface = Interface("int_mock0") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(interface.class_signature).thenReturn(objectMapper) when(objectMapper).save(interface).thenReturn(True) when(mappersManager).find(host.getID()).thenReturn(host) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addInterfaceSYNC(host.getID(), interface) verify(mappersManager).getMapper(interface.class_signature) verify(objectMapper).save(interface) self.assertEquals(interface, host.findChild(interface.getID()), "Orphan child, what happen papi?")
def testAddInterfaceGetsMapperDispatchSaveSYNC(self): host = Host('coco') interface = Interface("int_mock0") mappersManager = self.createMapperMock() objectMapper = mock() when(mappersManager).getMapper(interface.class_signature).thenReturn(objectMapper) when(objectMapper).save(interface).thenReturn(True) model_controller = controller.ModelController(mock(), mappersManager) model_controller.addInterfaceSYNC(host.getID(), interface) verify(mappersManager).getMapper(interface.class_signature) verify(objectMapper).save(interface)
def testDelNoteFromInterfaceASYNC(self): interface = Interface('coco') note = ModelObjectNote("int_mock0") interface.addChild(note) self.genericDelTest(interface, note, controller.ModelController.delNoteFromInterfaceASYNC, process_pending=True)
def testInterfaceFromHostRemovedASYNC(self): service = Service('coco') interface = Interface("int_mock0") interface.addChild(service) self.genericDelTest(interface, service, controller.ModelController.delServiceFromInterfaceASYNC, process_pending=True)
def testInterfaceFromHostRemovedSYNC(self): host = Host('coco') interface = Interface("int_mock0") self.genericDelTest(host, interface, controller.ModelController.delInterfaceSYNC)
def testDeleteModelObjectRemovesChildFromParentASYNC(self): host = Host('coco') interface = Interface("int_mock0") self.genericDelTest(host, interface, controller.ModelController.delInterfaceASYNC, process_pending=True)