def test_save_vulner_fail(self): test_xml = open('/var/tmp/test.xml', 'w') # wrong xml test_xml.write('wrong string') test_xml.close() result = save_vulnerabilities(self.scan, test_xml.name) self.assertFalse(result)
def test_save_vulner(self): Vulnerability.objects.all().delete test_xml = open('/var/tmp/test.xml', 'w') test_xml.write('<?xml version="1.0" encoding="UTF-8"?>' '<w3afrun start="1334319384">' '<vulnerability id="[106]" method="GET" name="test"' ' plugin="xss" severity="Medium" >' '<description>' 'test desc' '</description>' '<httprequest id="106">' '<status>' 'tttttt' '</status>' '<headers>' '<header content="test.test-domain.ru" field="Host"/>' '</headers>' '</httprequest>' '</vulnerability>' '</w3afrun>') test_xml.close() result = save_vulnerabilities(self.scan, test_xml.name) self.assertEqual( Vulnerability.objects.filter(scan=self.scan).count(), 1) self.assertTrue(result)
def test_save_vulner(self): Vulnerability.objects.all().delete test_xml = open('/var/tmp/test.xml', 'w') test_xml.write( '<?xml version="1.0" encoding="UTF-8"?>' '<w3afrun start="1334319384">' '<vulnerability id="[106]" method="GET" name="test"' ' plugin="xss" severity="Medium" >' '<description>' 'test desc' '</description>' '<httprequest id="106">' '<status>' 'tttttt' '</status>' '<headers>' '<header content="test.test-domain.ru" field="Host"/>' '</headers>' '</httprequest>' '</vulnerability>' '</w3afrun>' ) test_xml.close() result = save_vulnerabilities(self.scan, test_xml.name) self.assertEqual( Vulnerability.objects.filter(scan=self.scan).count(), 1) self.assertTrue(result)
def test_save_vulner_not_found(self): Vulnerability.objects.all().delete test_xml = open('/var/tmp/test.xml', 'w') test_xml.write('<?xml version="1.0" encoding="UTF-8"?>' '<w3afrun start="1334319384">' '</w3afrun>') test_xml.close() result = save_vulnerabilities(self.scan, test_xml.name) self.assertEqual( Vulnerability.objects.filter(scan=self.scan).count(), 0) self.assertTrue(result)
def test_save_vulner_not_found(self): Vulnerability.objects.all().delete test_xml = open('/var/tmp/test.xml', 'w') test_xml.write( '<?xml version="1.0" encoding="UTF-8"?>' '<w3afrun start="1334319384">' '</w3afrun>' ) test_xml.close() result = save_vulnerabilities(self.scan, test_xml.name) self.assertEqual( Vulnerability.objects.filter(scan=self.scan).count(), 0) self.assertTrue(result)