def test_composite_host(self): # add host host = Host(name="pepito", os="linux") host.setDescription("Some description") host.setOwned(True) self.mapper_manager.save(host) # add inteface iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06") iface.setDescription("Some description") iface.setOwned(True) iface.addHostname("www.test.com") iface.setIPv4({ "address": "192.168.10.168", "mask": "255.255.255.0", "gateway": "192.168.10.1", "DNS": "192.168.10.1" }) iface.setPortsOpened(2) iface.setPortsClosed(3) iface.setPortsFiltered(4) host.addChild(iface) self.mapper_manager.save(iface) h = self.mapper_manager.find(host.getID()) self.assertEquals( len(h.getAllInterfaces()), len(host.getAllInterfaces()), "Interfaces from original host should be equals to retrieved host's interfaces" ) i = self.mapper_manager.find(h.getAllInterfaces()[0].getID()) self.assertEquals( i.getID(), iface.getID(), "Interface's id' from original host should be equals to retrieved host's interface's id" )
def test_composite_host(self): # add host host = Host(name="pepito", os="linux") host.setDescription("Some description") host.setOwned(True) self.mapper_manager.save(host) # add inteface iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06") iface.setDescription("Some description") iface.setOwned(True) iface.addHostname("www.test.com") iface.setIPv4({ "address": "192.168.10.168", "mask": "255.255.255.0", "gateway": "192.168.10.1", "DNS": "192.168.10.1" }) iface.setPortsOpened(2) iface.setPortsClosed(3) iface.setPortsFiltered(4) host.addChild(iface) self.mapper_manager.save(iface) h = self.mapper_manager.find(host.getID()) self.assertEquals( len(h.getAllInterfaces()), len(host.getAllInterfaces()), "Interfaces from original host should be equals to retrieved host's interfaces") i = self.mapper_manager.find(h.getAllInterfaces()[0].getID()) self.assertEquals( i.getID(), iface.getID(), "Interface's id' from original host should be equals to retrieved host's interface's id")
def testAddInterfaceToHost(self): host = Host('coco') inter = Interface('cuca') host.addChild(inter) self.assertIn(inter, host.childs.values(), 'Interface not in childs') self.assertIn(inter, host.getAllInterfaces(), 'Interface not accessible')
def testDelNoteFromHostSYNC(self): host = Host('coco') note = ModelObjectNote("int_mock0") host.addChild(note) self.genericDelTest(host, note, controller.ModelController.delNoteFromHostASYNC, process_pending=True)
def testDelVulnFromHostASYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnFromHostASYNC, process_pending=True)
def testHostWithMultipleChildTypes(self): host = Host('coco') inter = Interface('cuca') vuln = ModelObjectVuln('vuln') host.addChild(inter) host.addChild(vuln) self.assertEquals(len(host.getVulns()), 1, "Vulns added is not 1") self.assertIn(vuln, host.getVulns(), "Vuln not accessible") self.assertEquals(len(host.getAllInterfaces()), 1, "Interfaces added is not 1")
def testHostWithCredentials(self): host = Host('coco') cred = ModelObjectCred('coco', 'coco123') host.addChild(cred) self.assertEquals(len(host.getCreds()), 1, "Creds added is not 1") self.assertIn(cred, host.getCreds(), "Cred not accessible")
def testDelNoteFromModelObjectSYNC(self): host = Host('coco') note = ModelObjectNote("int_mock0") host.addChild(note.getID(), note) self.genericDelTest(host, note, controller.ModelController.delNoteSYNC)
def testDelNoteFromHostSYNC(self): host = Host('coco') note = ModelObjectNote("int_mock0") host.addChild(note.getID(), note) self.genericDelTest(host, note, controller.ModelController.delNoteFromHostASYNC, process_pending=True)
def testDelVulnFromObjectSYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln.getID(), vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnSYNC)
def testDelVulnFromHostASYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln.getID(), vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnFromHostASYNC, process_pending=True)
def testDelNoteFromModelObjectSYNC(self): host = Host('coco') note = ModelObjectNote("int_mock0") host.addChild(note) self.genericDelTest(host, note, controller.ModelController.delNoteSYNC)
def testDelVulnFromObjectSYNC(self): host = Host('coco') vuln = ModelObjectVuln("int_mock0") host.addChild(vuln) self.genericDelTest(host, vuln, controller.ModelController.delVulnSYNC)