def test_parser_simple_link(self): response = HTTPResponse( 200, '<a href="/index.aspx">ASP.NET</a>', Headers(), self.url, self.url ) w = WMLParser( response ) re, parsed = w.get_references() # TODO: Shouldn't this be the other way around?! self.assertEqual(len(parsed), 0) self.assertEqual(u'http://www.w3af.com/index.aspx', re[0].url_string)
def test_parser_simple_link(self): response = HTTPResponse(200, '<a href="/index.aspx">ASP.NET</a>', Headers(), self.url, self.url) w = WMLParser(response) re, parsed = w.get_references() # TODO: Shouldn't this be the other way around?! self.assertEqual(len(parsed), 0) self.assertEqual(u'http://www.w3af.com/index.aspx', re[0].url_string)
def test_parser_re_link(self): """Get a link by applying regular expressions""" response = HTTPResponse(200, 'header /index.aspx footer', Headers(), self.url, self.url) w = WMLParser( response ) re, parsed = w.get_references() # TODO: Shouldn't this be the other way around?! self.assertEqual([], re) self.assertEqual(len(parsed), 1) self.assertEqual(u'http://www.w3af.com/index.aspx', parsed[0].url_string)
def test_parser_re_link(self): """Get a link by applying regular expressions""" response = HTTPResponse(200, 'header /index.aspx footer', Headers(), self.url, self.url) w = WMLParser(response) re, parsed = w.get_references() # TODO: Shouldn't this be the other way around?! self.assertEqual([], re) self.assertEqual(len(parsed), 1) self.assertEqual(u'http://www.w3af.com/index.aspx', parsed[0].url_string)
def __init__(self, http_resp): # Create the proper parser instance, please note that # the order in which we ask for the type is not random, # first we discard the images which account for a great # % of the URLs in a site, then we ask for WML which is # a very specific thing to match, then we try text or HTML # which is very generic (if we would have exchanged these two # we would have never got to WML), etc. if http_resp.is_image(): msg = 'There is no parser for images.' raise BaseFrameworkException(msg) elif self._is_wml(http_resp): parser = WMLParser(http_resp) elif http_resp.is_text_or_html(): parser = HTMLParser(http_resp) elif self._is_pdf(http_resp): parser = PDFParser(http_resp) elif self._is_swf(http_resp): parser = SWFParser(http_resp) else: msg = 'There is no parser for "%s".' % http_resp.get_url() raise BaseFrameworkException(msg) self._parser = parser
def test_parser_simple_form(self): form = """<go method="post" href="post.php"> <postfield name="clave" value="$(clave)"/> <postfield name="cuenta" value="$(cuenta)"/> <postfield name="tipdat" value="D"/> </go>""" response = HTTPResponse( 200, form, Headers(), self.url, self.url) w = WMLParser(response) forms = w.get_forms() self.assertEqual(len(forms), 1) form = forms[0] self.assertEqual(form.get_action().url_string, u'http://www.w3af.com/post.php') self.assertIn('clave', form) self.assertIn('cuenta', form) self.assertIn('tipdat', form)