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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 |
| 129 # Check that the BlockTypePrimary histogram has a single entry in the | 129 # Check that the BlockTypePrimary histogram has a single entry in the |
| 130 # MissingViaHeader4xx category (which is enum value 4), to make sure that | 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 | 131 # the bypass was caused by the missing via header logic and not something |
| 132 # else. | 132 # else. |
| 133 histogram = test_driver.GetHistogram( | 133 histogram = test_driver.GetHistogram( |
| 134 "DataReductionProxy.BlockTypePrimary") | 134 "DataReductionProxy.BlockTypePrimary") |
| 135 self.assertEqual(1, histogram['count']) | 135 self.assertEqual(1, histogram['count']) |
| 136 self.assertIn({'count': 1, 'high': 5, 'low': 4}, histogram['buckets']) | 136 self.assertIn({'count': 1, 'high': 5, 'low': 4}, histogram['buckets']) |
| 137 | 137 |
| 138 # Verify that the Data Reduction Proxy understands the "exp" directive. | |
| 139 def testExpDirectiveBypass(self): | |
| 140 with TestDriver() as test_driver: | |
| 141 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 142 test_driver.AddChromeArg('--data-reduction-proxy-experiment=test') | |
| 143 | |
| 144 # Verify that loading a page other than the specific exp directive test | |
| 145 # page loads through the proxy without being bypassed. | |
| 146 test_driver.LoadURL('http://check.googlezip.net/test.html') | |
| 147 responses = test_driver.GetHTTPResponses() | |
| 148 self.assertNotEqual(0, len(responses)) | |
| 149 for response in responses: | |
| 150 self.assertHasChromeProxyViaHeader(response) | |
| 151 | |
| 152 # Verify that loading the exp directive test page with "exp=test" triggers | |
| 153 # a bypass. | |
| 154 test_driver.LoadURL('http://check.googlezip.net/exp/') | |
| 155 responses = test_driver.GetHTTPResponses() | |
| 156 self.assertNotEqual(0, len(responses)) | |
| 157 for response in responses: | |
| 158 self.assertNotHasChromeProxyViaHeader(response) | |
| 159 | |
| 160 # Verify that loading the same test page without setting "exp=test" loads | |
| 161 # through the proxy without being bypassed. | |
| 162 with TestDriver() as test_driver: | |
|
megjablon
2017/03/14 22:22:55
Rather than using another test driver in another t
sclittle
2017/03/14 22:48:59
Good point. @robertogden, WDYT?
I think underscor
Robert Ogden
2017/03/15 15:43:29
I agree using a separate 'with' is cleaner, althou
sclittle
2017/03/15 18:01:35
OK, I'll leave this as-is then. Thanks!
| |
| 163 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | |
| 164 | |
| 165 test_driver.LoadURL('http://check.googlezip.net/exp/') | |
| 166 responses = test_driver.GetHTTPResponses() | |
| 167 self.assertNotEqual(0, len(responses)) | |
| 168 for response in responses: | |
| 169 self.assertHasChromeProxyViaHeader(response) | |
| 170 | |
| 138 | 171 |
| 139 if __name__ == '__main__': | 172 if __name__ == '__main__': |
| 140 IntegrationTest.RunAllTests() | 173 IntegrationTest.RunAllTests() |
| OLD | NEW |