| OLD | NEW | 
|    1 # Copyright 2016 The Chromium Authors. All rights reserved. |    1 # Copyright 2016 The Chromium Authors. All rights reserved. | 
|    2 # Use of this source code is governed by a BSD-style license that can be |    2 # Use of this source code is governed by a BSD-style license that can be | 
|    3 # found in the LICENSE file. |    3 # found in the LICENSE file. | 
|    4  |    4  | 
|    5 import argparse |    5 import argparse | 
|    6 import json |    6 import json | 
|    7 import logging |    7 import logging | 
|    8 import os |    8 import os | 
|    9 import re |    9 import re | 
|   10 import socket |   10 import socket | 
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  554   unittest.TestCase class. |  554   unittest.TestCase class. | 
|  555   """ |  555   """ | 
|  556  |  556  | 
|  557   def assertHasChromeProxyViaHeader(self, http_response): |  557   def assertHasChromeProxyViaHeader(self, http_response): | 
|  558     """Asserts that the Via header in the given HTTPResponse matches the |  558     """Asserts that the Via header in the given HTTPResponse matches the | 
|  559     expected value as given on the command line. |  559     expected value as given on the command line. | 
|  560  |  560  | 
|  561     Args: |  561     Args: | 
|  562       http_response: The HTTPResponse object to check. |  562       http_response: The HTTPResponse object to check. | 
|  563     """ |  563     """ | 
 |  564     self.assertIn('via', http_response.response_headers) | 
|  564     expected_via_header = ParseFlags().via_header_value |  565     expected_via_header = ParseFlags().via_header_value | 
|  565     self.assertIn('via', http_response.response_headers) |  566     actual_via_headers = http_response.response_headers['via'].split(',') | 
|  566     self.assertEqual(expected_via_header, http_response.response_headers['via']) |  567     self.assertIn(expected_via_header, actual_via_headers, "Via header not in " | 
 |  568       "response headers! Expected: %s, Actual: %s" % | 
 |  569       (expected_via_header, actual_via_headers)) | 
|  567  |  570  | 
|  568   def assertNotHasChromeProxyViaHeader(self, http_response): |  571   def assertNotHasChromeProxyViaHeader(self, http_response): | 
|  569     """Asserts that the Via header in the given HTTPResponse does not match the |  572     """Asserts that the Via header in the given HTTPResponse does not match the | 
|  570     expected value as given on the command line. |  573     expected value as given on the command line. | 
|  571  |  574  | 
|  572     Args: |  575     Args: | 
|  573       http_response: The HTTPResponse object to check. |  576       http_response: The HTTPResponse object to check. | 
|  574     """ |  577     """ | 
|  575     expected_via_header = ParseFlags().via_header_value |  | 
|  576     self.assertNotIn('via', http_response.response_headers) |  | 
|  577     if 'via' in http_response.response_headers: |  578     if 'via' in http_response.response_headers: | 
|  578       self.assertNotIn(expected_via_header, |  579       expected_via_header = ParseFlags().via_header_value | 
|  579         http_response.response_headers['via']) |  580       actual_via_headers = http_response.response_headers['via'].split(',') | 
 |  581       self.assertNotIn(expected_via_header, actual_via_headers, "Via header " | 
 |  582         "found in response headers! Not expected: %s, Actual: %s" % | 
 |  583         (expected_via_header, actual_via_headers)) | 
|  580  |  584  | 
|  581   def checkLoFiResponse(self, http_response, expected_lo_fi): |  585   def checkLoFiResponse(self, http_response, expected_lo_fi): | 
|  582     """Asserts that if expected the response headers contain the Lo-Fi directive |  586     """Asserts that if expected the response headers contain the Lo-Fi directive | 
|  583     then the request headers do too. Also checks that the content size is less |  587     then the request headers do too. Also checks that the content size is less | 
|  584     than 100 if |expected_lo_fi|. Otherwise, checks that the response and |  588     than 100 if |expected_lo_fi|. Otherwise, checks that the response and | 
|  585     request headers don't contain the Lo-Fi directive and the content size is |  589     request headers don't contain the Lo-Fi directive and the content size is | 
|  586     greater than 100. |  590     greater than 100. | 
|  587  |  591  | 
|  588     Args: |  592     Args: | 
|  589       http_response: The HTTPResponse object to check. |  593       http_response: The HTTPResponse object to check. | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  731       args[0].skipTest('This test runs on Mac OS only.') |  735       args[0].skipTest('This test runs on Mac OS only.') | 
|  732   return wrapper |  736   return wrapper | 
|  733  |  737  | 
|  734 def NotMac(func): |  738 def NotMac(func): | 
|  735   def wrapper(*args, **kwargs): |  739   def wrapper(*args, **kwargs): | 
|  736     if sys.platform == 'darwin': |  740     if sys.platform == 'darwin': | 
|  737       func(*args, **kwargs) |  741       func(*args, **kwargs) | 
|  738     else: |  742     else: | 
|  739       args[0].skipTest('This test does not run on Mac OS.') |  743       args[0].skipTest('This test does not run on Mac OS.') | 
|  740   return wrapper |  744   return wrapper | 
| OLD | NEW |