Beispiel #1
0
    def testAddNoteToServiceGetsMapperDispatchSaveSYNC(self): 
        service = Service("servi")
        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, service.getID(), note)

        verify(mappersManager).getMapper(note.class_signature)
        verify(objectMapper).save(note)
Beispiel #2
0
    def testAddVulnToServiceGetsMapperDispatchSaveSYNC(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.addVulnToServiceSYNC(None, service.getID(), vuln)

        verify(mappersManager).getMapper(vuln.class_signature)
        verify(objectMapper).save(vuln)
Beispiel #3
0
    def testAddCredToServiceGetsMapperDispatchSaveSYNC(self): 
        service = Service("pepito")
        cred = ModelObjectCred("usr", "pass")

        mappersManager = self.createMapperMock()
        objectMapper = mock()
        when(mappersManager).getMapper(cred.class_signature).thenReturn(objectMapper)
        when(objectMapper).save(cred).thenReturn(True)

        model_controller = controller.ModelController(mock(), mappersManager)

        model_controller.addCredToServiceSYNC(None, cred.getID(), cred)

        verify(mappersManager).getMapper(cred.class_signature)
        verify(objectMapper).save(cred)
Beispiel #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)
Beispiel #5
0
    def testEditServiceSyncGetsMapperDispatchedASYNC(self):
        service = Service("coquito")

        params = ('new_name', 'new_desc', 'upd', 9000, 'closed', '2.1', True)
        self.genericEdit(service, params, controller.ModelController.editServiceASYNC, process_pending=True)

        self.assertEquals(service.getName(), 'new_name', "Name not updated")
        self.assertEquals(service.getDescription(), 'new_desc', "Description not updated")
        self.assertEquals(service.getProtocol(), 'upd', "Protocol not updated")
        self.assertEquals(service.isOwned(), True, "Owned status not updated")
Beispiel #6
0
 def testDelCredentialFromModelObjectSYNC(self):
     service = Service('coco')
     cred = ModelObjectCred("int_mock0") 
     service.addChild(cred)
     self.genericDelTest(service, cred, 
             controller.ModelController.delCredSYNC)
Beispiel #7
0
 def testDelCredentialFromServiceASYNC(self):
     service = Service('coco')
     cred = ModelObjectCred("int_mock0") 
     service.addChild(cred)
     self.genericDelTest(service, cred, 
             controller.ModelController.delCredFromServiceASYNC, process_pending=True)
Beispiel #8
0
 def testDelNoteFromServiceASYNC(self):
     service = Service('coco')
     note = ModelObjectNote("int_mock0") 
     service.addChild(note)
     self.genericDelTest(service, note, 
             controller.ModelController.delNoteFromServiceASYNC, process_pending=True)
Beispiel #9
0
 def testDelVulnFromServiceASYNC(self):
     service = Service('coco')
     vuln = ModelObjectVuln("int_mock0") 
     service.addChild(vuln)
     self.genericDelTest(service, vuln, 
             controller.ModelController.delVulnFromServiceASYNC, process_pending=True)
Beispiel #10
0
 def testInterfaceFromHostRemovedASYNC(self):
     service = Service('coco')
     interface = Interface("int_mock0") 
     interface.addChild(service)
     self.genericDelTest(interface, service,
             controller.ModelController.delServiceFromInterfaceASYNC, process_pending=True)