commit 6525ff5dd5882b9de5a1364e09c1e63c5d77c489 Author: Arturo Filastò art@fuffa.org Date: Fri Jan 10 11:45:47 2014 +0100
Simplify the HTTP header field manipulation test to only perform GET requests --- .../manipulation/http_header_field_manipulation.py | 40 +++++--------------- 1 file changed, 9 insertions(+), 31 deletions(-)
diff --git a/ooni/nettests/manipulation/http_header_field_manipulation.py b/ooni/nettests/manipulation/http_header_field_manipulation.py index 3fdcc5f..93beb25 100644 --- a/ooni/nettests/manipulation/http_header_field_manipulation.py +++ b/ooni/nettests/manipulation/http_header_field_manipulation.py @@ -44,7 +44,7 @@ class HTTPHeaderFieldManipulation(httpt.HTTPTest): name = "HTTP Header Field Manipulation" description = "Checks if the HTTP request the server sees is the same as the one that the client has created." author = "Arturo Filastò" - version = "0.1.3" + version = "0.1.4"
randomizeUA = False usageOptions = UsageOptions @@ -100,6 +100,9 @@ class HTTPHeaderFieldManipulation(httpt.HTTPTest): * **total** when the response is not a json object and therefore we were not able to reach the ooniprobe test backend
+ * **request_line_capitalization** when the HTTP Request line (e.x. GET / + HTTP/1.1) does not match the capitalization we set. + * **header_field_number** when the number of headers we sent does not match with the ones the backend received
@@ -113,6 +116,7 @@ class HTTPHeaderFieldManipulation(httpt.HTTPTest):
self.report['tampering'] = { 'total': False, + 'request_line_capitalization': False, 'header_name_capitalization': False, 'header_field_value': False, 'header_field_number': False @@ -132,6 +136,9 @@ class HTTPHeaderFieldManipulation(httpt.HTTPTest): self.report['tampering']['total'] = True return
+ if request_request_line != response_request_line: + self.report['tampering']['request_line_capitalization'] = True + request_headers = TrueHeaders(self.request_headers) diff = request_headers.getDiff(TrueHeaders(response_headers_dict), ignore=['Connection']) @@ -141,42 +148,13 @@ class HTTPHeaderFieldManipulation(httpt.HTTPTest): self.report['tampering']['header_field_name'] = False self.report['tampering']['header_name_diff'] = list(diff) log.msg(" total: %(total)s" % self.report['tampering']) + log.msg(" request_line_capitalization: %(request_line_capitalization)s" % self.report['tampering']) log.msg(" header_name_capitalization: %(header_name_capitalization)s" % self.report['tampering']) log.msg(" header_field_value: %(header_field_value)s" % self.report['tampering']) log.msg(" header_field_number: %(header_field_number)s" % self.report['tampering'])
- def test_get(self): - self.request_method = "GET" - self.request_headers = self.get_random_caps_headers() - return self.doRequest(self.url, self.request_method, - headers=self.request_headers) - def test_get_random_capitalization(self): self.request_method = random_capitalization("GET") self.request_headers = self.get_random_caps_headers() return self.doRequest(self.url, self.request_method, headers=self.request_headers) - - def test_post(self): - self.request_method = "POST" - self.request_headers = self.get_headers() - return self.doRequest(self.url, self.request_method, - headers=self.request_headers) - - def test_post_random_capitalization(self): - self.request_method = random_capitalization("POST") - self.request_headers = self.get_random_caps_headers() - return self.doRequest(self.url, self.request_method, - headers=self.request_headers) - - def test_put(self): - self.request_method = "PUT" - self.request_headers = self.get_headers() - return self.doRequest(self.url, self.request_method, - headers=self.request_headers) - - def test_put_random_capitalization(self): - self.request_method = random_capitalization("PUT") - self.request_headers = self.get_random_caps_headers() - return self.doRequest(self.url, self.request_method, - headers=self.request_headers)