Exemple #1
0
    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")
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
    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)
Exemple #5
0
    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?")
Exemple #6
0
    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)
Exemple #7
0
 def testDelNoteFromInterfaceASYNC(self):
     interface = Interface('coco')
     note = ModelObjectNote("int_mock0") 
     interface.addChild(note)
     self.genericDelTest(interface, note, 
             controller.ModelController.delNoteFromInterfaceASYNC, process_pending=True)
Exemple #8
0
 def testInterfaceFromHostRemovedASYNC(self):
     service = Service('coco')
     interface = Interface("int_mock0") 
     interface.addChild(service)
     self.genericDelTest(interface, service,
             controller.ModelController.delServiceFromInterfaceASYNC, process_pending=True)
Exemple #9
0
 def testInterfaceFromHostRemovedSYNC(self):
     host = Host('coco')
     interface = Interface("int_mock0") 
     self.genericDelTest(host, interface,
             controller.ModelController.delInterfaceSYNC)
Exemple #10
0
 def testDeleteModelObjectRemovesChildFromParentASYNC(self): 
     host = Host('coco')
     interface = Interface("int_mock0") 
     self.genericDelTest(host, interface, controller.ModelController.delInterfaceASYNC, process_pending=True)