def test_basic(self): u = URL('http://www.w3af.com') req = HTTPRequest(u) self.assertEqual(req.get_full_url(), 'http://www.w3af.com/') self.assertEqual(req.get_uri().url_string, 'http://www.w3af.com/')
class TestSed(unittest.TestCase): def setUp(self): create_temp_dir() self.plugin = sed() self.url = URL('http://www.w3af.com/') self.request = HTTPRequest(self.url) def tearDown(self): self.plugin.end() def test_blank_body(self): body = '' headers = Headers([('content-type', 'text/html')]) response = HTTPResponse(200, body, headers, self.url, self.url, _id=1) option_list = self.plugin.get_options() option_list['expressions'].set_value('qh/User/NotLuser/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(self.request) mod_response = self.plugin.mangle_response(response) self.assertEqual(mod_request.get_headers(), self.request.get_headers()) self.assertEqual(mod_response.get_headers(), response.get_headers()) self.assertEqual(mod_request.get_uri(), self.request.get_uri()) self.assertEqual(mod_response.get_uri(), response.get_uri()) self.assertEqual(mod_response.get_body(), response.get_body()) def test_response_body(self): body = 'hello user!' headers = Headers([('content-type', 'text/html')]) response = HTTPResponse(200, body, headers, self.url, self.url, _id=1) option_list = self.plugin.get_options() option_list['expressions'].set_value('sb/user/notluser/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(self.request) mod_response = self.plugin.mangle_response(response) self.assertEqual(mod_request.get_headers(), self.request.get_headers()) self.assertEqual(mod_response.get_headers(), response.get_headers()) self.assertEqual(mod_request.get_uri(), self.request.get_uri()) self.assertEqual(mod_response.get_uri(), response.get_uri()) self.assertEqual(mod_response.get_body(), 'hello notluser!') def test_request_headers(self): headers = Headers([('content-type', 'text/html')]) request = HTTPRequest(self.url, headers=headers) option_list = self.plugin.get_options() option_list['expressions'].set_value('qh/html/xml/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(request) value, _ = mod_request.get_headers().iget('content-type') self.assertEqual(value, 'text/xml')
class TestSed(unittest.TestCase): def setUp(self): create_temp_dir() self.plugin = sed() self.url = URL('http://www.w3af.com/') self.request = HTTPRequest(self.url) def tearDown(self): self.plugin.end() def test_blank_body(self): body = '' headers = Headers([('content-type', 'text/html')]) response = HTTPResponse(200, body, headers, self.url, self.url, _id=1) option_list = self.plugin.get_options() option_list['expressions'].set_value('qh/User/NotLuser/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(self.request) mod_response = self.plugin.mangle_response(response) self.assertEqual(mod_request.get_headers(), self.request.get_headers()) self.assertEqual(mod_response.get_headers(), response.get_headers()) self.assertEqual(mod_request.get_uri(), self.request.get_uri()) self.assertEqual(mod_response.get_uri(), response.get_uri()) self.assertEqual(mod_response.get_body(), response.get_body()) def test_response_body(self): body = 'hello user!' headers = Headers([('content-type', 'text/html')]) response = HTTPResponse(200, body, headers, self.url, self.url, _id=1) option_list = self.plugin.get_options() option_list['expressions'].set_value('sb/user/notluser/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(self.request) mod_response = self.plugin.mangle_response(response) self.assertEqual(mod_request.get_headers(), self.request.get_headers()) self.assertEqual(mod_response.get_headers(), response.get_headers()) self.assertEqual(mod_request.get_uri(), self.request.get_uri()) self.assertEqual(mod_response.get_uri(), response.get_uri()) self.assertEqual(mod_response.get_body(), 'hello notluser!') def test_request_headers(self): headers = Headers([('content-type', 'text/html')]) request = HTTPRequest(self.url, headers=headers) option_list = self.plugin.get_options() option_list['expressions'].set_value('qh/html/xml/') self.plugin.set_options(option_list) mod_request = self.plugin.mangle_request(request) value, _ = mod_request.get_headers().iget('content-type') self.assertEqual(value, 'text/xml')
def test_basic(self): u = URL('http://www.w3af.com') req = HTTPRequest(u) self.assertEqual(req.get_full_url(), 'http://www.w3af.com/') self.assertEqual(req.get_uri().url_string, 'http://www.w3af.com/')