Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: tools/chrome_proxy/webdriver/bypass.py

Issue 2742693006: Add Data Saver ChromeDriver test for MissingViaHeader4xx bypass behavior (Closed)
Patch Set: Rebased on master Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 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 common 5 import common
6 from common import TestDriver 6 from common import TestDriver
7 from common import IntegrationTest 7 from common import IntegrationTest
8 8
9 9
10 class Bypass(IntegrationTest): 10 class Bypass(IntegrationTest):
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 for response in responses: 95 for response in responses:
96 self.assertNotHasChromeProxyViaHeader(response) 96 self.assertNotHasChromeProxyViaHeader(response)
97 97
98 # Load HTTP page and check that Data Saver is used. 98 # Load HTTP page and check that Data Saver is used.
99 test_driver.LoadURL('http://check.googlezip.net/test.html') 99 test_driver.LoadURL('http://check.googlezip.net/test.html')
100 responses = test_driver.GetHTTPResponses() 100 responses = test_driver.GetHTTPResponses()
101 self.assertNotEqual(0, len(responses)) 101 self.assertNotEqual(0, len(responses))
102 for response in responses: 102 for response in responses:
103 self.assertHasChromeProxyViaHeader(response) 103 self.assertHasChromeProxyViaHeader(response)
104 104
105 # Verify that when Chrome receives a 4xx response through a Data Reduction
106 # Proxy that doesn't set a proper via header, Chrome bypasses all proxies and
107 # retries the request over direct.
108 def testMissingViaHeader4xxBypass(self):
109 with TestDriver() as test_driver:
110 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
111
112 # Set the primary Data Reduction Proxy to be the test server, which does
113 # not add any Via headers.
114 test_driver.AddChromeArg('--data-reduction-proxy-http-proxies='
115 'https://chromeproxy-test.appspot.com;'
116 'http://compress.googlezip.net')
117
118 # Load a page that will come back with a 4xx response code and without the
119 # proper via header. Chrome should bypass all proxies and retry the
120 # request.
121 test_driver.LoadURL(
122 'http://chromeproxy-test.appspot.com/default?respStatus=414')
123 responses = test_driver.GetHTTPResponses()
124 self.assertNotEqual(0, len(responses))
125 for response in responses:
126 self.assertNotHasChromeProxyViaHeader(response)
127 self.assertEqual(u'http/1.1', response.protocol)
128
129 # Check that the BlockTypePrimary histogram has a single entry in the
130 # MissingViaHeader4xx category (which is enum value 4), to make sure that
131 # the bypass was caused by the missing via header logic and not something
132 # else.
133 histogram = test_driver.GetHistogram(
134 "DataReductionProxy.BlockTypePrimary")
135 self.assertEqual(1, histogram['count'])
136 self.assertIn({'count': 1, 'high': 5, 'low': 4}, histogram['buckets'])
137
105 138
106 if __name__ == '__main__': 139 if __name__ == '__main__':
107 IntegrationTest.RunAllTests() 140 IntegrationTest.RunAllTests()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698