Beispiel #1
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)
Beispiel #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)
Beispiel #3
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)
Beispiel #4
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?")