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/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include "net/quic/crypto/channel_id.h" | 7 #include "net/quic/crypto/channel_id.h" |
8 #include "net/quic/crypto/common_cert_set.h" | 8 #include "net/quic/crypto/common_cert_set.h" |
9 #include "net/quic/crypto/crypto_handshake.h" | 9 #include "net/quic/crypto/crypto_handshake.h" |
10 #include "net/quic/crypto/quic_crypto_server_config.h" | 10 #include "net/quic/crypto/quic_crypto_server_config.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 TestClientSession client_session(client_conn, DefaultQuicConfig()); | 168 TestClientSession client_session(client_conn, DefaultQuicConfig()); |
169 QuicCryptoClientConfig crypto_config; | 169 QuicCryptoClientConfig crypto_config; |
170 | 170 |
171 client_session.config()->SetDefaults(); | 171 client_session.config()->SetDefaults(); |
172 crypto_config.SetDefaults(); | 172 crypto_config.SetDefaults(); |
173 // TODO(rtenneti): Enable testing of ProofVerifier. | 173 // TODO(rtenneti): Enable testing of ProofVerifier. |
174 // if (!options.dont_verify_certs) { | 174 // if (!options.dont_verify_certs) { |
175 // crypto_config.SetProofVerifier(ProofVerifierForTesting()); | 175 // crypto_config.SetProofVerifier(ProofVerifierForTesting()); |
176 // } | 176 // } |
177 if (options.channel_id_enabled) { | 177 if (options.channel_id_enabled) { |
178 crypto_config.SetChannelIDSigner(ChannelIDSignerForTesting()); | 178 crypto_config.SetChannelIDSource(ChannelIDSourceForTesting()); |
179 } | 179 } |
180 QuicServerId server_id(kServerHostname, kServerPort, false, | 180 QuicServerId server_id(kServerHostname, kServerPort, false, |
181 PRIVACY_MODE_DISABLED); | 181 PRIVACY_MODE_DISABLED); |
182 QuicCryptoClientStream client(server_id, &client_session, NULL, | 182 QuicCryptoClientStream client(server_id, &client_session, NULL, |
183 &crypto_config); | 183 &crypto_config); |
184 client_session.SetCryptoStream(&client); | 184 client_session.SetCryptoStream(&client); |
185 | 185 |
186 CHECK(client.CryptoConnect()); | 186 CHECK(client.CryptoConnect()); |
187 CHECK_EQ(1u, client_conn->packets_.size()); | 187 CHECK_EQ(1u, client_conn->packets_.size()); |
188 | 188 |
189 CommunicateHandshakeMessages(client_conn, &client, server_conn, server); | 189 CommunicateHandshakeMessages(client_conn, &client, server_conn, server); |
190 | 190 |
191 CompareClientAndServerKeys(&client, server); | 191 CompareClientAndServerKeys(&client, server); |
192 | 192 |
193 if (options.channel_id_enabled) { | 193 if (options.channel_id_enabled) { |
194 EXPECT_EQ( | 194 scoped_ptr<ChannelIDKey> channel_id_key; |
195 crypto_config.channel_id_signer()->GetKeyForHostname(kServerHostname), | 195 EXPECT_TRUE(crypto_config.channel_id_source()->GetChannelIDKey( |
196 server->crypto_negotiated_params().channel_id); | 196 kServerHostname, &channel_id_key)); |
| 197 EXPECT_EQ(channel_id_key->SerializeKey(), |
| 198 server->crypto_negotiated_params().channel_id); |
197 } | 199 } |
198 | 200 |
199 return client.num_sent_client_hellos(); | 201 return client.num_sent_client_hellos(); |
200 } | 202 } |
201 | 203 |
202 // static | 204 // static |
203 void CryptoTestUtils::SetupCryptoServerConfigForTest( | 205 void CryptoTestUtils::SetupCryptoServerConfigForTest( |
204 const QuicClock* clock, | 206 const QuicClock* clock, |
205 QuicRandom* rand, | 207 QuicRandom* rand, |
206 QuicConfig* config, | 208 QuicConfig* config, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); | 518 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); |
517 scoped_ptr<CryptoHandshakeMessage> parsed( | 519 scoped_ptr<CryptoHandshakeMessage> parsed( |
518 CryptoFramer::ParseMessage(bytes->AsStringPiece())); | 520 CryptoFramer::ParseMessage(bytes->AsStringPiece())); |
519 CHECK(parsed.get()); | 521 CHECK(parsed.get()); |
520 | 522 |
521 return *parsed; | 523 return *parsed; |
522 } | 524 } |
523 | 525 |
524 } // namespace test | 526 } // namespace test |
525 } // namespace net | 527 } // namespace net |
OLD | NEW |