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

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

Issue 2717573002: Adding origin timeout integration test (Closed)
Patch Set: 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 28 matching lines...) Expand all
39 39
40 # Ensure Chrome does not use Data Saver for HTTPS requests. 40 # Ensure Chrome does not use Data Saver for HTTPS requests.
41 def testHttpsBypass(self): 41 def testHttpsBypass(self):
42 with TestDriver() as t: 42 with TestDriver() as t:
43 t.AddChromeArg('--enable-spdy-proxy-auth') 43 t.AddChromeArg('--enable-spdy-proxy-auth')
44 44
45 # Load HTTP page and check that Data Saver is used. 45 # Load HTTP page and check that Data Saver is used.
46 t.LoadURL('http://check.googlezip.net/test.html') 46 t.LoadURL('http://check.googlezip.net/test.html')
47 responses = t.GetHTTPResponses() 47 responses = t.GetHTTPResponses()
48 self.assertEqual(2, len(responses)) 48 self.assertEqual(2, len(responses))
49 for response in t.GetHTTPResponses(): 49 for response in responses:
50 self.assertHasChromeProxyViaHeader(response) 50 self.assertHasChromeProxyViaHeader(response)
51 51
52 # Load HTTPS page and check that Data Saver is not used. 52 # Load HTTPS page and check that Data Saver is not used.
53 t.LoadURL('https://check.googlezip.net/test.html') 53 t.LoadURL('https://check.googlezip.net/test.html')
54 responses = t.GetHTTPResponses() 54 responses = t.GetHTTPResponses()
55 self.assertEqual(2, len(responses)) 55 self.assertEqual(2, len(responses))
56 for response in t.GetHTTPResponses(): 56 for response in responses:
57 self.assertNotHasChromeProxyViaHeader(response) 57 self.assertNotHasChromeProxyViaHeader(response)
58 58
59 # Verify that CORS requests receive a block-once from the data reduction 59 # Verify that CORS requests receive a block-once from the data reduction
60 # proxy by checking that those requests are retried without data reduction 60 # proxy by checking that those requests are retried without data reduction
61 # proxy. 61 # proxy.
62 def testCorsBypass(self): 62 def testCorsBypass(self):
63 with TestDriver() as test_driver: 63 with TestDriver() as test_driver:
64 test_driver.AddChromeArg('--enable-spdy-proxy-auth') 64 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
65 test_driver.LoadURL('http://www.gstatic.com/chrome/googlezip/cors/') 65 test_driver.LoadURL('http://www.gstatic.com/chrome/googlezip/cors/')
66 66
67 # Navigate to a different page to verify that later requests are not 67 # Navigate to a different page to verify that later requests are not
68 # blocked. 68 # blocked.
69 test_driver.LoadURL('http://check.googlezip.net/test.html') 69 test_driver.LoadURL('http://check.googlezip.net/test.html')
70 70
71 cors_requests = 0 71 cors_requests = 0
72 same_origin_requests = 0 72 same_origin_requests = 0
73 for response in test_driver.GetHTTPResponses(): 73 for response in test_driver.GetHTTPResponses():
74 # The origin header implies that |response| is a CORS request. 74 # The origin header implies that |response| is a CORS request.
75 if ('origin' not in response.request_headers): 75 if ('origin' not in response.request_headers):
76 self.assertHasChromeProxyViaHeader(response) 76 self.assertHasChromeProxyViaHeader(response)
77 same_origin_requests = same_origin_requests + 1 77 same_origin_requests = same_origin_requests + 1
78 else: 78 else:
79 self.assertNotHasChromeProxyViaHeader(response) 79 self.assertNotHasChromeProxyViaHeader(response)
80 cors_requests = cors_requests + 1 80 cors_requests = cors_requests + 1
81 # Verify that both CORS and same origin requests were seen. 81 # Verify that both CORS and same origin requests were seen.
82 self.assertNotEqual(0, same_origin_requests) 82 self.assertNotEqual(0, same_origin_requests)
83 self.assertNotEqual(0, cors_requests) 83 self.assertNotEqual(0, cors_requests)
84 84
85 # Verify that when an origin times out using Data Saver, the request bypassed.
tbansal1 2017/02/23 21:41:13 s/request/request is fetched directly and data sav
RyanSturm 2017/02/23 21:47:30 Done.
86 def testOriginTimeoutBypass(self):
tbansal1 2017/02/23 21:41:13 may be change test name to testOriginTimeoutBlockO
RyanSturm 2017/02/23 21:47:30 Done.
87 with TestDriver() as test_driver:
88 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
89
90 # Load URL that times out when the proxy server tries to access it.
91 test_driver.LoadURL('http://chromeproxy-test.appspot.com/blackhole')
92 responses = test_driver.GetHTTPResponses()
93 self.assertNotEqual(1, len(responses))
Robert Ogden 2017/02/23 21:50:46 Pretty sure this should be assert equals. This ass
tbansal1 2017/02/23 21:56:14 A safer check might be assertNotEqual(0, ...) so t
RyanSturm 2017/02/23 22:03:05 It was supposed to be a 0, changed it somehow. Goo
94 for response in responses:
95 self.assertNotHasChromeProxyViaHeader(response)
96
97 # Load HTTP page and check that Data Saver is used.
98 test_driver.LoadURL('http://check.googlezip.net/test.html')
99 responses = test_driver.GetHTTPResponses()
100 self.assertEqual(2, len(responses))
101 for response in responses:
102 self.assertHasChromeProxyViaHeader(response)
103
104
85 if __name__ == '__main__': 105 if __name__ == '__main__':
86 IntegrationTest.RunAllTests() 106 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