OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_client_session.h" | 5 #include "net/quic/quic_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 TEST_P(QuicClientSessionTest, CanPool) { | 147 TEST_P(QuicClientSessionTest, CanPool) { |
148 // Load a cert that is valid for: | 148 // Load a cert that is valid for: |
149 // www.example.org | 149 // www.example.org |
150 // mail.example.org | 150 // mail.example.org |
151 // www.example.com | 151 // www.example.com |
152 | 152 |
153 ProofVerifyDetailsChromium details; | 153 ProofVerifyDetailsChromium details; |
154 details.cert_verify_result.verified_cert = | 154 details.cert_verify_result.verified_cert = |
155 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 155 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
156 ASSERT_TRUE(details.cert_verify_result.verified_cert); | 156 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); |
157 | 157 |
158 session_.OnProofVerifyDetailsAvailable(details); | 158 session_.OnProofVerifyDetailsAvailable(details); |
159 CompleteCryptoHandshake(); | 159 CompleteCryptoHandshake(); |
160 | 160 |
161 | 161 |
162 EXPECT_TRUE(session_.CanPool("www.example.org")); | 162 EXPECT_TRUE(session_.CanPool("www.example.org")); |
163 EXPECT_TRUE(session_.CanPool("mail.example.org")); | 163 EXPECT_TRUE(session_.CanPool("mail.example.org")); |
164 EXPECT_TRUE(session_.CanPool("mail.example.com")); | 164 EXPECT_TRUE(session_.CanPool("mail.example.com")); |
165 EXPECT_FALSE(session_.CanPool("mail.google.com")); | 165 EXPECT_FALSE(session_.CanPool("mail.google.com")); |
166 } | 166 } |
167 | 167 |
168 TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) { | 168 TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) { |
169 // Load a cert that is valid for: | 169 // Load a cert that is valid for: |
170 // www.example.org | 170 // www.example.org |
171 // mail.example.org | 171 // mail.example.org |
172 // www.example.com | 172 // www.example.com |
173 | 173 |
174 ProofVerifyDetailsChromium details; | 174 ProofVerifyDetailsChromium details; |
175 details.cert_verify_result.verified_cert = | 175 details.cert_verify_result.verified_cert = |
176 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 176 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
177 ASSERT_TRUE(details.cert_verify_result.verified_cert); | 177 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); |
178 | 178 |
179 session_.OnProofVerifyDetailsAvailable(details); | 179 session_.OnProofVerifyDetailsAvailable(details); |
180 CompleteCryptoHandshake(); | 180 CompleteCryptoHandshake(); |
181 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 181 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
182 | 182 |
183 EXPECT_TRUE(session_.CanPool("www.example.org")); | 183 EXPECT_TRUE(session_.CanPool("www.example.org")); |
184 EXPECT_TRUE(session_.CanPool("mail.example.org")); | 184 EXPECT_TRUE(session_.CanPool("mail.example.org")); |
185 EXPECT_FALSE(session_.CanPool("mail.example.com")); | 185 EXPECT_FALSE(session_.CanPool("mail.example.com")); |
186 EXPECT_FALSE(session_.CanPool("mail.google.com")); | 186 EXPECT_FALSE(session_.CanPool("mail.google.com")); |
187 } | 187 } |
188 | 188 |
189 TEST_P(QuicClientSessionTest, ConnectionNotPooledWithDifferentPin) { | 189 TEST_P(QuicClientSessionTest, ConnectionNotPooledWithDifferentPin) { |
190 uint8 primary_pin = 1; | 190 uint8 primary_pin = 1; |
191 uint8 backup_pin = 2; | 191 uint8 backup_pin = 2; |
192 uint8 bad_pin = 3; | 192 uint8 bad_pin = 3; |
193 AddPin(&transport_security_state_, "mail.example.org", primary_pin, | 193 AddPin(&transport_security_state_, "mail.example.org", primary_pin, |
194 backup_pin); | 194 backup_pin); |
195 | 195 |
196 ProofVerifyDetailsChromium details; | 196 ProofVerifyDetailsChromium details; |
197 details.cert_verify_result.verified_cert = | 197 details.cert_verify_result.verified_cert = |
198 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 198 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
199 details.cert_verify_result.is_issued_by_known_root = true; | 199 details.cert_verify_result.is_issued_by_known_root = true; |
200 details.cert_verify_result.public_key_hashes.push_back( | 200 details.cert_verify_result.public_key_hashes.push_back( |
201 GetTestHashValue(bad_pin)); | 201 GetTestHashValue(bad_pin)); |
202 | 202 |
203 ASSERT_TRUE(details.cert_verify_result.verified_cert); | 203 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); |
204 | 204 |
205 session_.OnProofVerifyDetailsAvailable(details); | 205 session_.OnProofVerifyDetailsAvailable(details); |
206 CompleteCryptoHandshake(); | 206 CompleteCryptoHandshake(); |
207 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 207 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
208 | 208 |
209 EXPECT_FALSE(session_.CanPool("mail.example.org")); | 209 EXPECT_FALSE(session_.CanPool("mail.example.org")); |
210 } | 210 } |
211 | 211 |
212 TEST_P(QuicClientSessionTest, ConnectionPooledWithMatchingPin) { | 212 TEST_P(QuicClientSessionTest, ConnectionPooledWithMatchingPin) { |
213 uint8 primary_pin = 1; | 213 uint8 primary_pin = 1; |
214 uint8 backup_pin = 2; | 214 uint8 backup_pin = 2; |
215 AddPin(&transport_security_state_, "mail.example.org", primary_pin, | 215 AddPin(&transport_security_state_, "mail.example.org", primary_pin, |
216 backup_pin); | 216 backup_pin); |
217 | 217 |
218 ProofVerifyDetailsChromium details; | 218 ProofVerifyDetailsChromium details; |
219 details.cert_verify_result.verified_cert = | 219 details.cert_verify_result.verified_cert = |
220 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); | 220 ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
221 details.cert_verify_result.is_issued_by_known_root = true; | 221 details.cert_verify_result.is_issued_by_known_root = true; |
222 details.cert_verify_result.public_key_hashes.push_back( | 222 details.cert_verify_result.public_key_hashes.push_back( |
223 GetTestHashValue(primary_pin)); | 223 GetTestHashValue(primary_pin)); |
224 | 224 |
225 ASSERT_TRUE(details.cert_verify_result.verified_cert); | 225 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); |
226 | 226 |
227 session_.OnProofVerifyDetailsAvailable(details); | 227 session_.OnProofVerifyDetailsAvailable(details); |
228 CompleteCryptoHandshake(); | 228 CompleteCryptoHandshake(); |
229 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 229 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
230 | 230 |
231 EXPECT_TRUE(session_.CanPool("mail.example.org")); | 231 EXPECT_TRUE(session_.CanPool("mail.example.org")); |
232 } | 232 } |
233 | 233 |
234 } // namespace | 234 } // namespace |
235 } // namespace test | 235 } // namespace test |
236 } // namespace net | 236 } // namespace net |
OLD | NEW |