| 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 time | 5 import time |
| 6 | 6 |
| 7 import common | 7 import common |
| 8 from common import TestDriver | 8 from common import TestDriver |
| 9 from common import IntegrationTest | 9 from common import IntegrationTest |
| 10 | 10 from decorators import Slow |
| 11 | 11 |
| 12 class ReenableAfterBypass(IntegrationTest): | 12 class ReenableAfterBypass(IntegrationTest): |
| 13 """Tests for ensuring that DRPs are reenabled after bypasses expire. | 13 """Tests for ensuring that DRPs are reenabled after bypasses expire. |
| 14 | 14 |
| 15 These tests take a very long time to run since they wait for their respective | 15 These tests take a very long time to run since they wait for their respective |
| 16 bypasses to expire. These tests have been separated out into their own file in | 16 bypasses to expire. These tests have been separated out into their own file in |
| 17 order to make it easier to run these tests separately from the others. | 17 order to make it easier to run these tests separately from the others. |
| 18 """ | 18 """ |
| 19 | 19 |
| 20 # Verify that longer bypasses triggered by the Data Reduction Proxy only last | 20 # Verify that longer bypasses triggered by the Data Reduction Proxy only last |
| 21 # as long as they're supposed to, and that the proxy is used once again after | 21 # as long as they're supposed to, and that the proxy is used once again after |
| 22 # the bypass has ended. | 22 # the bypass has ended. |
| 23 @Slow |
| 23 def testReenableAfterSetBypass(self): | 24 def testReenableAfterSetBypass(self): |
| 24 with TestDriver() as test_driver: | 25 with TestDriver() as test_driver: |
| 25 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 26 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 26 | 27 |
| 27 # Load URL that triggers a 20-second bypass of all proxies. | 28 # Load URL that triggers a 20-second bypass of all proxies. |
| 28 test_driver.LoadURL('http://check.googlezip.net/block20/') | 29 test_driver.LoadURL('http://check.googlezip.net/block20/') |
| 29 responses = test_driver.GetHTTPResponses() | 30 responses = test_driver.GetHTTPResponses() |
| 30 self.assertNotEqual(0, len(responses)) | 31 self.assertNotEqual(0, len(responses)) |
| 31 for response in responses: | 32 for response in responses: |
| 32 self.assertNotHasChromeProxyViaHeader(response) | 33 self.assertNotHasChromeProxyViaHeader(response) |
| 33 | 34 |
| 34 # Verify that the Data Reduction Proxy is still bypassed. | 35 # Verify that the Data Reduction Proxy is still bypassed. |
| 35 test_driver.LoadURL('http://check.googlezip.net/test.html') | 36 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 36 responses = test_driver.GetHTTPResponses() | 37 responses = test_driver.GetHTTPResponses() |
| 37 self.assertNotEqual(0, len(responses)) | 38 self.assertNotEqual(0, len(responses)) |
| 38 for response in responses: | 39 for response in responses: |
| 39 self.assertNotHasChromeProxyViaHeader(response) | 40 self.assertNotHasChromeProxyViaHeader(response) |
| 40 | 41 |
| 41 # Verify that the Data Reduction Proxy is no longer bypassed after 20 | 42 # Verify that the Data Reduction Proxy is no longer bypassed after 20 |
| 42 # seconds. | 43 # seconds. |
| 43 time.sleep(20) | 44 time.sleep(20) |
| 44 test_driver.LoadURL('http://check.googlezip.net/test.html') | 45 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 45 responses = test_driver.GetHTTPResponses() | 46 responses = test_driver.GetHTTPResponses() |
| 46 self.assertNotEqual(0, len(responses)) | 47 self.assertNotEqual(0, len(responses)) |
| 47 for response in responses: | 48 for response in responses: |
| 48 self.assertHasChromeProxyViaHeader(response) | 49 self.assertHasChromeProxyViaHeader(response) |
| 49 | 50 |
| 50 # Verify that when the Data Reduction Proxy responds with the "block=0" | 51 # Verify that when the Data Reduction Proxy responds with the "block=0" |
| 51 # directive, Chrome bypasses all proxies for the next 1-5 minutes. | 52 # directive, Chrome bypasses all proxies for the next 1-5 minutes. |
| 53 @Slow |
| 52 def testReenableAfterBypass(self): | 54 def testReenableAfterBypass(self): |
| 53 with TestDriver() as test_driver: | 55 with TestDriver() as test_driver: |
| 54 test_driver.AddChromeArg('--enable-spdy-proxy-auth') | 56 test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| 55 | 57 |
| 56 # Load URL that triggers a bypass of all proxies that lasts between 1 and | 58 # Load URL that triggers a bypass of all proxies that lasts between 1 and |
| 57 # 5 minutes. | 59 # 5 minutes. |
| 58 test_driver.LoadURL('http://check.googlezip.net/block/') | 60 test_driver.LoadURL('http://check.googlezip.net/block/') |
| 59 responses = test_driver.GetHTTPResponses() | 61 responses = test_driver.GetHTTPResponses() |
| 60 self.assertNotEqual(0, len(responses)) | 62 self.assertNotEqual(0, len(responses)) |
| 61 for response in responses: | 63 for response in responses: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 time.sleep(60 * 4 + 30) | 76 time.sleep(60 * 4 + 30) |
| 75 test_driver.LoadURL('http://check.googlezip.net/test.html') | 77 test_driver.LoadURL('http://check.googlezip.net/test.html') |
| 76 responses = test_driver.GetHTTPResponses() | 78 responses = test_driver.GetHTTPResponses() |
| 77 self.assertNotEqual(0, len(responses)) | 79 self.assertNotEqual(0, len(responses)) |
| 78 for response in responses: | 80 for response in responses: |
| 79 self.assertHasChromeProxyViaHeader(response) | 81 self.assertHasChromeProxyViaHeader(response) |
| 80 | 82 |
| 81 | 83 |
| 82 if __name__ == '__main__': | 84 if __name__ == '__main__': |
| 83 IntegrationTest.RunAllTests() | 85 IntegrationTest.RunAllTests() |
| OLD | NEW |