예제 #1
0
    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"
        )
예제 #2
0
    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")
예제 #3
0
    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')
예제 #4
0
    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')
예제 #5
0
 def testDelNoteFromHostSYNC(self):
     host = Host('coco')
     note = ModelObjectNote("int_mock0")
     host.addChild(note)
     self.genericDelTest(host,
                         note,
                         controller.ModelController.delNoteFromHostASYNC,
                         process_pending=True)
예제 #6
0
 def testDelVulnFromHostASYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0")
     host.addChild(vuln)
     self.genericDelTest(host,
                         vuln,
                         controller.ModelController.delVulnFromHostASYNC,
                         process_pending=True)
예제 #7
0
    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") 
예제 #8
0
    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")
예제 #9
0
 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")
예제 #10
0
 def testDelNoteFromModelObjectSYNC(self):
     host = Host('coco')
     note = ModelObjectNote("int_mock0") 
     host.addChild(note.getID(), note)
     self.genericDelTest(host, note, 
             controller.ModelController.delNoteSYNC)
예제 #11
0
 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)
예제 #12
0
 def testDelVulnFromObjectSYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0") 
     host.addChild(vuln.getID(), vuln)
     self.genericDelTest(host, vuln,
             controller.ModelController.delVulnSYNC)
예제 #13
0
 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)
예제 #14
0
 def testDelNoteFromModelObjectSYNC(self):
     host = Host('coco')
     note = ModelObjectNote("int_mock0")
     host.addChild(note)
     self.genericDelTest(host, note, controller.ModelController.delNoteSYNC)
예제 #15
0
 def testDelVulnFromObjectSYNC(self):
     host = Host('coco')
     vuln = ModelObjectVuln("int_mock0")
     host.addChild(vuln)
     self.genericDelTest(host, vuln, controller.ModelController.delVulnSYNC)
예제 #16
0
 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")