Пример #1
0
    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")
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
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)
Пример #5
0
    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)
Пример #6
0
 def testDelVulnFromServiceASYNC(self):
     service = Service('coco')
     vuln = ModelObjectVuln("int_mock0") 
     service.addChild(vuln)
     self.genericDelTest(service, vuln, 
             controller.ModelController.delVulnFromServiceASYNC, process_pending=True)
Пример #7
0
 def testDelVulnFromObjectSYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0") 
     host.addChild(vuln)
     self.genericDelTest(host, vuln,
             controller.ModelController.delVulnSYNC)
Пример #8
0
 def testDelVulnFromHostASYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0") 
     host.addChild(vuln)
     self.genericDelTest(host, vuln,
             controller.ModelController.delVulnFromHostASYNC, process_pending=True)