Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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): | |
|
megjablon
2017/03/11 00:51:47
Isn't this the ChromeProxyHTTPToDirectFallback tel
sclittle
2017/03/11 01:29:03
The non-4xx test below is the counterpart for the
| |
| 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 'http://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 | |
| 128 # Check that the BlockTypePrimary histogram has a single entry in the | |
| 129 # MissingViaHeader4xx category (which is enum value 4), to make sure that | |
| 130 # the bypass was caused by the missing via header logic and not something | |
| 131 # else. | |
| 132 histogram = test_driver.GetHistogram( | |
| 133 "DataReductionProxy.BlockTypePrimary") | |
| 134 self.assertEqual(1, histogram['count']) | |
| 135 self.assertIn({'count': 1, 'high': 5, 'low': 4}, histogram['buckets']) | |
| 136 | |
| 137 # Verify that when Chrome receives a non-4xx response through a Data Reduction | |
| 138 # Proxy that doesn't set a proper via header, Chrome falls back to the next | |
| 139 # available proxy. | |
| 140 def testMissingViaHeaderNon4xxFallback(self): | |
|
megjablon
2017/03/11 00:51:47
The telemetry tests check the remote port, should
sclittle
2017/03/11 01:29:03
Done.
| |
| 141 with TestDriver() as test_driver: | |
| 142 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 143 | |
| 144 # Set the primary Data Reduction Proxy to be the test server, which does | |
| 145 # not add any Via headers. The fallback Data Reduction Proxy is set to the | |
| 146 # canonical Data Reduction Proxy target. | |
| 147 test_driver.AddChromeArg('--data-reduction-proxy-http-proxies=' | |
| 148 'http://chromeproxy-test.appspot.com;' | |
| 149 'http://compress.googlezip.net') | |
| 150 | |
| 151 # Load a page that should fall back off of the test server proxy, and onto | |
| 152 # the canonical proxy that will set the correct Via header. | |
| 153 test_driver.LoadURL('http://chromeproxy-test.appspot.com/default') | |
| 154 responses = test_driver.GetHTTPResponses() | |
| 155 self.assertNotEqual(0, len(responses)) | |
| 156 for response in responses: | |
| 157 self.assertHasChromeProxyViaHeader(response) | |
| 158 | |
| 159 # Check that the BypassTypePrimary histogram has a single entry in the | |
| 160 # MissingViaHeaderOther category (which is enum value 5), to make sure | |
| 161 # that the bypass was caused by the missing via header logic and not | |
| 162 # something else. | |
| 163 histogram = test_driver.GetHistogram( | |
| 164 "DataReductionProxy.BypassTypePrimary") | |
| 165 self.assertEqual(1, histogram['count']) | |
| 166 self.assertIn({'count': 1, 'high': 6, 'low': 5}, histogram['buckets']) | |
| 105 | 167 |
| 106 if __name__ == '__main__': | 168 if __name__ == '__main__': |
| 107 IntegrationTest.RunAllTests() | 169 IntegrationTest.RunAllTests() |
| OLD | NEW |