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 import time | 6 import time |
7 from common import TestDriver | 7 from common import TestDriver |
8 from common import IntegrationTest | 8 from common import IntegrationTest |
9 from decorators import NotAndroid | 9 from decorators import NotAndroid |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 self.assertEqual(2, len(responses)) | 58 self.assertEqual(2, len(responses)) |
59 for response in responses: | 59 for response in responses: |
60 chrome_proxy_header = response.request_headers['chrome-proxy'] | 60 chrome_proxy_header = response.request_headers['chrome-proxy'] |
61 self.assertIn('s=', chrome_proxy_header) | 61 self.assertIn('s=', chrome_proxy_header) |
62 self.assertNotIn('ps=', chrome_proxy_header) | 62 self.assertNotIn('ps=', chrome_proxy_header) |
63 self.assertNotIn('sid=', chrome_proxy_header) | 63 self.assertNotIn('sid=', chrome_proxy_header) |
64 # Verify that the proxy server honored the session ID. | 64 # Verify that the proxy server honored the session ID. |
65 self.assertHasChromeProxyViaHeader(response) | 65 self.assertHasChromeProxyViaHeader(response) |
66 self.assertEqual(200, response.status) | 66 self.assertEqual(200, response.status) |
67 | 67 |
| 68 # Verify unique page IDs are sent in the Chrome-Proxy header. |
| 69 def testPageID(self): |
| 70 with TestDriver() as t: |
| 71 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 72 page_identifiers = [] |
| 73 page_loads = 5 |
| 74 |
| 75 for i in range (0, page_loads): |
| 76 t.LoadURL('http://check.googlezip.net/test.html') |
| 77 responses = t.GetHTTPResponses() |
| 78 self.assertEqual(2, len(responses)) |
| 79 pid_in_page_count = 0 |
| 80 page_id = '' |
| 81 for response in responses: |
| 82 self.assertHasChromeProxyViaHeader(response) |
| 83 self.assertEqual(200, response.status) |
| 84 chrome_proxy_header = response.request_headers['chrome-proxy'] |
| 85 chrome_proxy_directives = chrome_proxy_header.split(',') |
| 86 for directive in chrome_proxy_directives: |
| 87 if 'pid=' in directive: |
| 88 pid_in_page_count = pid_in_page_count+1 |
| 89 page_id = directive.split('=')[1] |
| 90 self.assertNotEqual('', page_id) |
| 91 self.assertNotIn(page_id, page_identifiers) |
| 92 page_identifiers.append(page_id) |
| 93 self.assertEqual(1, pid_in_page_count) |
| 94 |
68 # Ensure that block causes resources to load from the origin directly. | 95 # Ensure that block causes resources to load from the origin directly. |
69 def testCheckBlockIsWorking(self): | 96 def testCheckBlockIsWorking(self): |
70 with TestDriver() as t: | 97 with TestDriver() as t: |
71 t.AddChromeArg('--enable-spdy-proxy-auth') | 98 t.AddChromeArg('--enable-spdy-proxy-auth') |
72 t.LoadURL('http://check.googlezip.net/block') | 99 t.LoadURL('http://check.googlezip.net/block') |
73 responses = t.GetHTTPResponses() | 100 responses = t.GetHTTPResponses() |
74 self.assertNotEqual(0, len(responses)) | 101 self.assertNotEqual(0, len(responses)) |
75 for response in responses: | 102 for response in responses: |
76 self.assertNotHasChromeProxyViaHeader(response) | 103 self.assertNotHasChromeProxyViaHeader(response) |
77 | 104 |
78 # Ensure image, css, and javascript resources are compressed. | 105 # Ensure image, css, and javascript resources are compressed. |
79 def testCheckImageCssJavascriptIsCompressed(self): | 106 def testCheckImageCssJavascriptIsCompressed(self): |
80 with TestDriver() as t: | 107 with TestDriver() as t: |
81 t.AddChromeArg('--enable-spdy-proxy-auth') | 108 t.AddChromeArg('--enable-spdy-proxy-auth') |
82 t.LoadURL('http://check.googlezip.net/static') | 109 t.LoadURL('http://check.googlezip.net/static') |
83 # http://check.googlezip.net/static is a test page that has | 110 # http://check.googlezip.net/static is a test page that has |
84 # image/css/javascript resources. | 111 # image/css/javascript resources. |
85 responses = t.GetHTTPResponses() | 112 responses = t.GetHTTPResponses() |
86 self.assertNotEqual(0, len(responses)) | 113 self.assertNotEqual(0, len(responses)) |
87 for response in responses: | 114 for response in responses: |
88 self.assertHasChromeProxyViaHeader(response) | 115 self.assertHasChromeProxyViaHeader(response) |
89 | 116 |
90 if __name__ == '__main__': | 117 if __name__ == '__main__': |
91 IntegrationTest.RunAllTests() | 118 IntegrationTest.RunAllTests() |
OLD | NEW |