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

Side by Side Diff: net/quic/quic_server_id_test.cc

Issue 1411063004: Remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enough! Created 5 years, 1 month 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 | « net/quic/quic_server_id.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "net/quic/quic_server_id.h" 5 #include "net/quic/quic_server_id.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using std::string; 9 using std::string;
10 10
11 namespace net { 11 namespace net {
12 12
13 namespace { 13 namespace {
14 14
15 TEST(QuicServerIdTest, ToString) { 15 TEST(QuicServerIdTest, ToString) {
16 HostPortPair google_host_port_pair("google.com", 10); 16 HostPortPair google_host_port_pair("google.com", 10);
17 17
18 QuicServerId google_http_server_id(google_host_port_pair, false, 18 QuicServerId google_server_id(google_host_port_pair, PRIVACY_MODE_DISABLED);
19 PRIVACY_MODE_DISABLED); 19 string google_server_id_str = google_server_id.ToString();
20 string google_http_server_id_str = google_http_server_id.ToString(); 20 EXPECT_EQ("https://google.com:10", google_server_id_str);
21 EXPECT_EQ("http://google.com:10", google_http_server_id_str);
22 21
23 QuicServerId google_https_server_id(google_host_port_pair, true, 22 QuicServerId private_server_id(google_host_port_pair, PRIVACY_MODE_ENABLED);
24 PRIVACY_MODE_DISABLED); 23 string private_server_id_str = private_server_id.ToString();
25 string google_https_server_id_str = google_https_server_id.ToString(); 24 EXPECT_EQ("https://google.com:10/private", private_server_id_str);
26 EXPECT_EQ("https://google.com:10", google_https_server_id_str);
27
28 QuicServerId private_http_server_id(google_host_port_pair, false,
29 PRIVACY_MODE_ENABLED);
30 string private_http_server_id_str = private_http_server_id.ToString();
31 EXPECT_EQ("http://google.com:10/private", private_http_server_id_str);
32
33 QuicServerId private_https_server_id(google_host_port_pair, true,
34 PRIVACY_MODE_ENABLED);
35 string private_https_server_id_str = private_https_server_id.ToString();
36 EXPECT_EQ("https://google.com:10/private", private_https_server_id_str);
37 } 25 }
38 26
39 TEST(QuicServerIdTest, LessThan) { 27 TEST(QuicServerIdTest, LessThan) {
40 QuicServerId a_10_http(HostPortPair("a.com", 10), false, 28 QuicServerId a_10_https(HostPortPair("a.com", 10), PRIVACY_MODE_DISABLED);
41 PRIVACY_MODE_DISABLED); 29 QuicServerId a_11_https(HostPortPair("a.com", 11), PRIVACY_MODE_DISABLED);
42 QuicServerId a_10_https(HostPortPair("a.com", 10), true, 30 QuicServerId b_10_https(HostPortPair("b.com", 10), PRIVACY_MODE_DISABLED);
43 PRIVACY_MODE_DISABLED); 31 QuicServerId b_11_https(HostPortPair("b.com", 11), PRIVACY_MODE_DISABLED);
44 QuicServerId a_11_http(HostPortPair("a.com", 11), false,
45 PRIVACY_MODE_DISABLED);
46 QuicServerId a_11_https(HostPortPair("a.com", 11), true,
47 PRIVACY_MODE_DISABLED);
48 QuicServerId b_10_http(HostPortPair("b.com", 10), false,
49 PRIVACY_MODE_DISABLED);
50 QuicServerId b_10_https(HostPortPair("b.com", 10), true,
51 PRIVACY_MODE_DISABLED);
52 QuicServerId b_11_http(HostPortPair("b.com", 11), false,
53 PRIVACY_MODE_DISABLED);
54 QuicServerId b_11_https(HostPortPair("b.com", 11), true,
55 PRIVACY_MODE_DISABLED);
56 32
57 QuicServerId a_10_http_private(HostPortPair("a.com", 10), false, 33 QuicServerId a_10_https_private(HostPortPair("a.com", 10),
58 PRIVACY_MODE_ENABLED);
59 QuicServerId a_10_https_private(HostPortPair("a.com", 10), true,
60 PRIVACY_MODE_ENABLED); 34 PRIVACY_MODE_ENABLED);
61 QuicServerId a_11_http_private(HostPortPair("a.com", 11), false, 35 QuicServerId a_11_https_private(HostPortPair("a.com", 11),
62 PRIVACY_MODE_ENABLED);
63 QuicServerId a_11_https_private(HostPortPair("a.com", 11), true,
64 PRIVACY_MODE_ENABLED); 36 PRIVACY_MODE_ENABLED);
65 QuicServerId b_10_http_private(HostPortPair("b.com", 10), false, 37 QuicServerId b_10_https_private(HostPortPair("b.com", 10),
66 PRIVACY_MODE_ENABLED);
67 QuicServerId b_10_https_private(HostPortPair("b.com", 10), true,
68 PRIVACY_MODE_ENABLED); 38 PRIVACY_MODE_ENABLED);
69 QuicServerId b_11_http_private(HostPortPair("b.com", 11), false, 39 QuicServerId b_11_https_private(HostPortPair("b.com", 11),
70 PRIVACY_MODE_ENABLED);
71 QuicServerId b_11_https_private(HostPortPair("b.com", 11), true,
72 PRIVACY_MODE_ENABLED); 40 PRIVACY_MODE_ENABLED);
73 41
74 // Test combinations of host, port, https and privacy being same on left and 42 // Test combinations of host, port, and privacy being same on left and
75 // right side of less than. 43 // right side of less than.
76 EXPECT_FALSE(a_10_http < a_10_http);
77 EXPECT_TRUE(a_10_http < a_10_https);
78 EXPECT_FALSE(a_10_https < a_10_http);
79 EXPECT_FALSE(a_10_https < a_10_https); 44 EXPECT_FALSE(a_10_https < a_10_https);
80
81 EXPECT_TRUE(a_10_http < a_10_http_private);
82 EXPECT_TRUE(a_10_http < a_10_https_private);
83 EXPECT_FALSE(a_10_https < a_10_http_private);
84 EXPECT_TRUE(a_10_https < a_10_https_private); 45 EXPECT_TRUE(a_10_https < a_10_https_private);
85
86 EXPECT_FALSE(a_10_http_private < a_10_http);
87 EXPECT_TRUE(a_10_http_private < a_10_https);
88 EXPECT_FALSE(a_10_https_private < a_10_http);
89 EXPECT_FALSE(a_10_https_private < a_10_https); 46 EXPECT_FALSE(a_10_https_private < a_10_https);
90
91 EXPECT_FALSE(a_10_http_private < a_10_http_private);
92 EXPECT_TRUE(a_10_http_private < a_10_https_private);
93 EXPECT_FALSE(a_10_https_private < a_10_http_private);
94 EXPECT_FALSE(a_10_https_private < a_10_https_private); 47 EXPECT_FALSE(a_10_https_private < a_10_https_private);
95 48
96 // Test with either host, port or https being different on left and right side 49 // Test with either host, port or https being different on left and right side
97 // of less than. 50 // of less than.
98 PrivacyMode left_privacy; 51 PrivacyMode left_privacy;
99 PrivacyMode right_privacy; 52 PrivacyMode right_privacy;
100 for (int i = 0; i < 4; i++) { 53 for (int i = 0; i < 4; i++) {
101 left_privacy = static_cast<PrivacyMode>(i / 2); 54 left_privacy = static_cast<PrivacyMode>(i / 2);
102 right_privacy = static_cast<PrivacyMode>(i % 2); 55 right_privacy = static_cast<PrivacyMode>(i % 2);
103 QuicServerId a_10_http_left_private(HostPortPair("a.com", 10), false, 56 QuicServerId a_10_https_left_private(HostPortPair("a.com", 10),
104 left_privacy);
105 QuicServerId a_10_http_right_private(HostPortPair("a.com", 10), false,
106 right_privacy);
107 QuicServerId a_10_https_left_private(HostPortPair("a.com", 10), true,
108 left_privacy); 57 left_privacy);
109 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10), true, 58 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10),
110 right_privacy); 59 right_privacy);
111 QuicServerId a_11_http_left_private(HostPortPair("a.com", 11), false, 60 QuicServerId a_11_https_left_private(HostPortPair("a.com", 11),
112 left_privacy);
113 QuicServerId a_11_http_right_private(HostPortPair("a.com", 11), false,
114 right_privacy);
115 QuicServerId a_11_https_left_private(HostPortPair("a.com", 11), true,
116 left_privacy); 61 left_privacy);
117 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11), true, 62 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11),
118 right_privacy); 63 right_privacy);
119 64
120 QuicServerId b_10_http_left_private(HostPortPair("b.com", 10), false, 65 QuicServerId b_10_https_left_private(HostPortPair("b.com", 10),
121 left_privacy);
122 QuicServerId b_10_http_right_private(HostPortPair("b.com", 10), false,
123 right_privacy);
124 QuicServerId b_10_https_left_private(HostPortPair("b.com", 10), true,
125 left_privacy); 66 left_privacy);
126 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10), true, 67 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10),
127 right_privacy); 68 right_privacy);
128 QuicServerId b_11_http_left_private(HostPortPair("b.com", 11), false, 69 QuicServerId b_11_https_left_private(HostPortPair("b.com", 11),
129 left_privacy);
130 QuicServerId b_11_http_right_private(HostPortPair("b.com", 11), false,
131 right_privacy);
132 QuicServerId b_11_https_left_private(HostPortPair("b.com", 11), true,
133 left_privacy); 70 left_privacy);
134 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11), true, 71 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11),
135 right_privacy); 72 right_privacy);
136 73
137 EXPECT_TRUE(a_10_http_left_private < a_11_http_right_private);
138 EXPECT_TRUE(a_10_http_left_private < a_11_https_right_private);
139 EXPECT_TRUE(a_10_https_left_private < a_11_http_right_private);
140 EXPECT_TRUE(a_10_https_left_private < a_11_https_right_private); 74 EXPECT_TRUE(a_10_https_left_private < a_11_https_right_private);
141
142 EXPECT_TRUE(a_10_http_left_private < b_10_http_right_private);
143 EXPECT_TRUE(a_10_http_left_private < b_10_https_right_private);
144 EXPECT_TRUE(a_10_https_left_private < b_10_http_right_private);
145 EXPECT_TRUE(a_10_https_left_private < b_10_https_right_private); 75 EXPECT_TRUE(a_10_https_left_private < b_10_https_right_private);
146
147 EXPECT_TRUE(a_10_http_left_private < b_11_http_right_private);
148 EXPECT_TRUE(a_10_http_left_private < b_11_https_right_private);
149 EXPECT_TRUE(a_10_https_left_private < b_11_http_right_private);
150 EXPECT_TRUE(a_10_https_left_private < b_11_https_right_private); 76 EXPECT_TRUE(a_10_https_left_private < b_11_https_right_private);
151
152 EXPECT_FALSE(a_11_http_left_private < a_10_http_right_private);
153 EXPECT_FALSE(a_11_http_left_private < a_10_https_right_private);
154 EXPECT_FALSE(a_11_https_left_private < a_10_http_right_private);
155 EXPECT_FALSE(a_11_https_left_private < a_10_https_right_private); 77 EXPECT_FALSE(a_11_https_left_private < a_10_https_right_private);
156
157 EXPECT_FALSE(a_11_http_left_private < b_10_http_right_private);
158 EXPECT_FALSE(a_11_http_left_private < b_10_https_right_private);
159 EXPECT_FALSE(a_11_https_left_private < b_10_http_right_private);
160 EXPECT_FALSE(a_11_https_left_private < b_10_https_right_private); 78 EXPECT_FALSE(a_11_https_left_private < b_10_https_right_private);
161
162 EXPECT_TRUE(a_11_http_left_private < b_11_http_right_private);
163 EXPECT_TRUE(a_11_http_left_private < b_11_https_right_private);
164 EXPECT_TRUE(a_11_https_left_private < b_11_http_right_private);
165 EXPECT_TRUE(a_11_https_left_private < b_11_https_right_private); 79 EXPECT_TRUE(a_11_https_left_private < b_11_https_right_private);
166
167 EXPECT_FALSE(b_10_http_left_private < a_10_http_right_private);
168 EXPECT_FALSE(b_10_http_left_private < a_10_https_right_private);
169 EXPECT_FALSE(b_10_https_left_private < a_10_http_right_private);
170 EXPECT_FALSE(b_10_https_left_private < a_10_https_right_private); 80 EXPECT_FALSE(b_10_https_left_private < a_10_https_right_private);
171
172 EXPECT_TRUE(b_10_http_left_private < a_11_http_right_private);
173 EXPECT_TRUE(b_10_http_left_private < a_11_https_right_private);
174 EXPECT_TRUE(b_10_https_left_private < a_11_http_right_private);
175 EXPECT_TRUE(b_10_https_left_private < a_11_https_right_private); 81 EXPECT_TRUE(b_10_https_left_private < a_11_https_right_private);
176
177 EXPECT_TRUE(b_10_http_left_private < b_11_http_right_private);
178 EXPECT_TRUE(b_10_http_left_private < b_11_https_right_private);
179 EXPECT_TRUE(b_10_https_left_private < b_11_http_right_private);
180 EXPECT_TRUE(b_10_https_left_private < b_11_https_right_private); 82 EXPECT_TRUE(b_10_https_left_private < b_11_https_right_private);
181
182 EXPECT_FALSE(b_11_http_left_private < a_10_http_right_private);
183 EXPECT_FALSE(b_11_http_left_private < a_10_https_right_private);
184 EXPECT_FALSE(b_11_https_left_private < a_10_http_right_private);
185 EXPECT_FALSE(b_11_https_left_private < a_10_https_right_private); 83 EXPECT_FALSE(b_11_https_left_private < a_10_https_right_private);
186
187 EXPECT_FALSE(b_11_http_left_private < a_11_http_right_private);
188 EXPECT_FALSE(b_11_http_left_private < a_11_https_right_private);
189 EXPECT_FALSE(b_11_https_left_private < a_11_http_right_private);
190 EXPECT_FALSE(b_11_https_left_private < a_11_https_right_private); 84 EXPECT_FALSE(b_11_https_left_private < a_11_https_right_private);
191
192 EXPECT_FALSE(b_11_http_left_private < b_10_http_right_private);
193 EXPECT_FALSE(b_11_http_left_private < b_10_https_right_private);
194 EXPECT_FALSE(b_11_https_left_private < b_10_http_right_private);
195 EXPECT_FALSE(b_11_https_left_private < b_10_https_right_private); 85 EXPECT_FALSE(b_11_https_left_private < b_10_https_right_private);
196 } 86 }
197 } 87 }
198 88
199 TEST(QuicServerIdTest, Equals) { 89 TEST(QuicServerIdTest, Equals) {
200 PrivacyMode left_privacy; 90 PrivacyMode left_privacy;
201 PrivacyMode right_privacy; 91 PrivacyMode right_privacy;
202 for (int i = 0; i < 2; i++) { 92 for (int i = 0; i < 2; i++) {
203 left_privacy = right_privacy = static_cast<PrivacyMode>(i); 93 left_privacy = right_privacy = static_cast<PrivacyMode>(i);
204 QuicServerId a_10_http_right_private(HostPortPair("a.com", 10), false, 94 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10),
205 right_privacy);
206 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10), true,
207 right_privacy); 95 right_privacy);
208 QuicServerId a_11_http_right_private(HostPortPair("a.com", 11), false, 96 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11),
209 right_privacy);
210 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11), true,
211 right_privacy); 97 right_privacy);
212 QuicServerId b_10_http_right_private(HostPortPair("b.com", 10), false, 98 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10),
213 right_privacy);
214 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10), true,
215 right_privacy); 99 right_privacy);
216 QuicServerId b_11_http_right_private(HostPortPair("b.com", 11), false, 100 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11),
217 right_privacy);
218 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11), true,
219 right_privacy); 101 right_privacy);
220 102
221 QuicServerId new_a_10_http_left_private(HostPortPair("a.com", 10), false, 103 QuicServerId new_a_10_https_left_private(HostPortPair("a.com", 10),
222 left_privacy);
223 QuicServerId new_a_10_https_left_private(HostPortPair("a.com", 10), true,
224 left_privacy); 104 left_privacy);
225 QuicServerId new_a_11_http_left_private(HostPortPair("a.com", 11), false, 105 QuicServerId new_a_11_https_left_private(HostPortPair("a.com", 11),
226 left_privacy);
227 QuicServerId new_a_11_https_left_private(HostPortPair("a.com", 11), true,
228 left_privacy); 106 left_privacy);
229 QuicServerId new_b_10_http_left_private(HostPortPair("b.com", 10), false, 107 QuicServerId new_b_10_https_left_private(HostPortPair("b.com", 10),
230 left_privacy);
231 QuicServerId new_b_10_https_left_private(HostPortPair("b.com", 10), true,
232 left_privacy); 108 left_privacy);
233 QuicServerId new_b_11_http_left_private(HostPortPair("b.com", 11), false, 109 QuicServerId new_b_11_https_left_private(HostPortPair("b.com", 11),
234 left_privacy);
235 QuicServerId new_b_11_https_left_private(HostPortPair("b.com", 11), true,
236 left_privacy); 110 left_privacy);
237 111
238 EXPECT_EQ(new_a_10_http_left_private, a_10_http_right_private);
239 EXPECT_EQ(new_a_10_https_left_private, a_10_https_right_private); 112 EXPECT_EQ(new_a_10_https_left_private, a_10_https_right_private);
240 EXPECT_EQ(new_a_11_http_left_private, a_11_http_right_private);
241 EXPECT_EQ(new_a_11_https_left_private, a_11_https_right_private); 113 EXPECT_EQ(new_a_11_https_left_private, a_11_https_right_private);
242 EXPECT_EQ(new_b_10_http_left_private, b_10_http_right_private);
243 EXPECT_EQ(new_b_10_https_left_private, b_10_https_right_private); 114 EXPECT_EQ(new_b_10_https_left_private, b_10_https_right_private);
244 EXPECT_EQ(new_b_11_http_left_private, b_11_http_right_private);
245 EXPECT_EQ(new_b_11_https_left_private, b_11_https_right_private); 115 EXPECT_EQ(new_b_11_https_left_private, b_11_https_right_private);
246 } 116 }
247 117
248 for (int i = 0; i < 2; i++) { 118 for (int i = 0; i < 2; i++) {
249 right_privacy = static_cast<PrivacyMode>(i); 119 right_privacy = static_cast<PrivacyMode>(i);
250 QuicServerId a_10_http_right_private(HostPortPair("a.com", 10), false, 120 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10),
251 right_privacy);
252 QuicServerId a_10_https_right_private(HostPortPair("a.com", 10), true,
253 right_privacy); 121 right_privacy);
254 QuicServerId a_11_http_right_private(HostPortPair("a.com", 11), false, 122 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11),
255 right_privacy);
256 QuicServerId a_11_https_right_private(HostPortPair("a.com", 11), true,
257 right_privacy); 123 right_privacy);
258 QuicServerId b_10_http_right_private(HostPortPair("b.com", 10), false, 124 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10),
259 right_privacy);
260 QuicServerId b_10_https_right_private(HostPortPair("b.com", 10), true,
261 right_privacy); 125 right_privacy);
262 QuicServerId b_11_http_right_private(HostPortPair("b.com", 11), false, 126 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11),
263 right_privacy);
264 QuicServerId b_11_https_right_private(HostPortPair("b.com", 11), true,
265 right_privacy); 127 right_privacy);
266 128
267 QuicServerId new_a_10_http_left_private(HostPortPair("a.com", 10), false, 129 QuicServerId new_a_10_https_left_private(HostPortPair("a.com", 10),
268 PRIVACY_MODE_DISABLED); 130 PRIVACY_MODE_DISABLED);
269 131
270 EXPECT_FALSE(new_a_10_http_left_private == a_10_https_right_private); 132 EXPECT_FALSE(new_a_10_https_left_private == a_11_https_right_private);
271 EXPECT_FALSE(new_a_10_http_left_private == a_11_http_right_private); 133 EXPECT_FALSE(new_a_10_https_left_private == b_10_https_right_private);
272 EXPECT_FALSE(new_a_10_http_left_private == b_10_http_right_private); 134 EXPECT_FALSE(new_a_10_https_left_private == b_11_https_right_private);
273 EXPECT_FALSE(new_a_10_http_left_private == a_11_https_right_private);
274 EXPECT_FALSE(new_a_10_http_left_private == b_10_https_right_private);
275 EXPECT_FALSE(new_a_10_http_left_private == b_11_http_right_private);
276 EXPECT_FALSE(new_a_10_http_left_private == b_11_https_right_private);
277 } 135 }
278 QuicServerId a_10_http_private(HostPortPair("a.com", 10), false, 136 QuicServerId a_10_https_private(HostPortPair("a.com", 10),
279 PRIVACY_MODE_ENABLED); 137 PRIVACY_MODE_ENABLED);
280 QuicServerId new_a_10_http_no_private(HostPortPair("a.com", 10), false, 138 QuicServerId new_a_10_https_no_private(HostPortPair("a.com", 10),
281 PRIVACY_MODE_DISABLED); 139 PRIVACY_MODE_DISABLED);
282 EXPECT_FALSE(new_a_10_http_no_private == a_10_http_private); 140 EXPECT_FALSE(new_a_10_https_no_private == a_10_https_private);
283 } 141 }
284 142
285 } // namespace 143 } // namespace
286 144
287 } // namespace net 145 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_server_id.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698