def test_model_edit_host_vuln(self): host = test_utils.create_host(self) vuln = test_utils.create_host_vuln(self, host, 'vuln', 'desc', 'high') data = { "vulnid": vuln.getID(), "hostid": host.getID(), 'name': 'coco', 'desc': 'newdesc', 'severity': 'low' } response = requests.post(self.url_model_edit_vulns, data=json.dumps(data), headers=self.headers) self.assertEquals(response.status_code, 200, "Status Code should be 200: OK") addedhost = self.model_controller.getHost(host.getID()) addedvuln = addedhost.getVuln(vuln.getID()) self.assertEquals(addedvuln.name, 'coco', 'Name not updated') self.assertEquals(addedvuln.desc, 'newdesc', 'Desc not updated') self.assertEquals(addedvuln.severity, 'low', 'Severity not updated')
def testVulnHostLookup(self): host = test_utils.create_host(self) vuln = test_utils.create_host_vuln(self, host, 'vuln', 'desc', 'high') visitor = VulnsLookupVisitor(vuln.getID()) host.accept(visitor) self.assertEquals(len(visitor.parents[0]), 1, "object hierarchy should be only host") self.assertIn(vuln, visitor.vulns)
def test_model_remove_host_vuln(self): host = test_utils.create_host(self) vuln = test_utils.create_host_vuln(self, host, 'vuln', 'desc', 'high') data = {"vulnid": vuln.getID(), "hostid": host.getID(), 'name': 'coco', 'desc': 'newdesc', 'severity': 'low'} response = requests.delete(self.url_model_del_vulns, data=json.dumps(data), headers=self.headers) self.assertEquals(response.status_code, 200, "Status Code should be 200: OK") addedhost = self.model_controller.getHost(host.getID()) addedvuln = addedhost.getVulns() self.assertEquals(len(addedvuln), 0, 'Vuln not removed from Host')
def test_model_edit_host_vuln(self): host = test_utils.create_host(self) vuln = test_utils.create_host_vuln(self, host, 'vuln', 'desc', 'high') data = {"vulnid": vuln.getID(), "hostid": host.getID(), 'name': 'coco', 'desc': 'newdesc', 'severity': 'low'} response = requests.post(self.url_model_edit_vulns, data=json.dumps(data), headers=self.headers) self.assertEquals(response.status_code, 200, "Status Code should be 200: OK") addedhost = self.model_controller.getHost(host.getID()) addedvuln = addedhost.getVuln(vuln.getID()) self.assertEquals(addedvuln.name, 'coco', 'Name not updated') self.assertEquals(addedvuln.desc, 'newdesc', 'Desc not updated') self.assertEquals(addedvuln.severity, 'low', 'Severity not updated')
def test_model_remove_host_vuln(self): host = test_utils.create_host(self) vuln = test_utils.create_host_vuln(self, host, 'vuln', 'desc', 'high') data = { "vulnid": vuln.getID(), "hostid": host.getID(), 'name': 'coco', 'desc': 'newdesc', 'severity': 'low' } response = requests.delete(self.url_model_del_vulns, data=json.dumps(data), headers=self.headers) self.assertEquals(response.status_code, 200, "Status Code should be 200: OK") addedhost = self.model_controller.getHost(host.getID()) addedvuln = addedhost.getVulns() self.assertEquals(len(addedvuln), 0, 'Vuln not removed from Host')