def test_response_has_redirect_headers_false(self): plugin = global_redirect() body = '<meta generator="">' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertFalse(plugin._response_has_redirect(resp))
def test_response_has_redirect_meta(self): plugin = global_redirect() body = '<meta http-equiv="refresh" content="0; url=">' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._response_has_redirect(resp))
def test_response_has_redirect_js_false(self): plugin = global_redirect() body = '<script>alert(window.location)</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertFalse(plugin._response_has_redirect(resp))
def test_javascript_redirect_assign(self): plugin = global_redirect() body = '<script>window.location.assign("http://www.w3af.org")</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._javascript_redirect(resp))
def test_response_has_redirect_headers_false(self): plugin = global_redirect() body = '<meta generator="">' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertFalse(plugin._response_has_redirect(resp))
def test_response_has_redirect_js_false(self): plugin = global_redirect() body = '<script>alert(window.location)</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertFalse(plugin._response_has_redirect(resp))
def test_response_has_redirect_meta(self): plugin = global_redirect() body = '<meta http-equiv="refresh" content="0; url=">' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._response_has_redirect(resp))
def test_response_has_redirect_headers(self): plugin = global_redirect() body = '' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html'), ('Location', 'http://w3af.org')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._response_has_redirect(resp))
def test_javascript_redirect_assign(self): plugin = global_redirect() body = '<script>window.location.assign("http://www.w3af.org")</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._javascript_redirect(resp))
def test_response_has_redirect_headers(self): plugin = global_redirect() body = '' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html'), ('Location', 'http://w3af.org')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) self.assertTrue(plugin._response_has_redirect(resp))
def test_extract_script_code_new_line(self): plugin = global_redirect() body = '<script>var x=1;\nvar y=2;alert(1)</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) code = plugin._extract_script_code(resp) code = [c for c in code] self.assertEqual(code, [u'var x=1', u'var y=2', u'alert(1)'])
def test_extract_script_code_new_line(self): plugin = global_redirect() body = '<script>var x=1;\nvar y=2;alert(1)</script>' url = URL('http://www.w3af.com/') headers = Headers([('content-type', 'text/html')]) resp = HTTPResponse(200, body, headers, url, url, _id=1) code = plugin._extract_script_code(resp) code = [c for c in code] self.assertEqual(code, [u'var x=1', u'var y=2', u'alert(1)'])