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

Side by Side Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 114933003: Minor cleanup of QUIC MockConnection and PacketSavingConnection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/reliable_quic_stream_test.cc ('k') | net/quic/test_tools/quic_test_utils.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 (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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 CryptoTestUtils::FakeClientOptions::FakeClientOptions() 127 CryptoTestUtils::FakeClientOptions::FakeClientOptions()
128 : dont_verify_certs(false), 128 : dont_verify_certs(false),
129 channel_id_enabled(false) { 129 channel_id_enabled(false) {
130 } 130 }
131 131
132 // static 132 // static
133 int CryptoTestUtils::HandshakeWithFakeServer( 133 int CryptoTestUtils::HandshakeWithFakeServer(
134 PacketSavingConnection* client_conn, 134 PacketSavingConnection* client_conn,
135 QuicCryptoClientStream* client) { 135 QuicCryptoClientStream* client) {
136 QuicGuid guid(1); 136 PacketSavingConnection* server_conn = new PacketSavingConnection(true);
137 IPAddressNumber ip;
138 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip));
139 IPEndPoint addr = IPEndPoint(ip, 1);
140 PacketSavingConnection* server_conn =
141 new PacketSavingConnection(guid, addr, true);
142 TestSession server_session(server_conn, DefaultQuicConfig(), true); 137 TestSession server_session(server_conn, DefaultQuicConfig(), true);
143 138
144 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 139 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
145 QuicRandom::GetInstance()); 140 QuicRandom::GetInstance());
146 SetupCryptoServerConfigForTest( 141 SetupCryptoServerConfigForTest(
147 server_session.connection()->clock(), 142 server_session.connection()->clock(),
148 server_session.connection()->random_generator(), 143 server_session.connection()->random_generator(),
149 server_session.config(), &crypto_config); 144 server_session.config(), &crypto_config);
150 145
151 QuicCryptoServerStream server(crypto_config, &server_session); 146 QuicCryptoServerStream server(crypto_config, &server_session);
152 server_session.SetCryptoStream(&server); 147 server_session.SetCryptoStream(&server);
153 148
154 // The client's handshake must have been started already. 149 // The client's handshake must have been started already.
155 CHECK_NE(0u, client_conn->packets_.size()); 150 CHECK_NE(0u, client_conn->packets_.size());
156 151
157 CommunicateHandshakeMessages(client_conn, client, server_conn, &server); 152 CommunicateHandshakeMessages(client_conn, client, server_conn, &server);
158 153
159 CompareClientAndServerKeys(client, &server); 154 CompareClientAndServerKeys(client, &server);
160 155
161 return client->num_sent_client_hellos(); 156 return client->num_sent_client_hellos();
162 } 157 }
163 158
164 // static 159 // static
165 int CryptoTestUtils::HandshakeWithFakeClient( 160 int CryptoTestUtils::HandshakeWithFakeClient(
166 PacketSavingConnection* server_conn, 161 PacketSavingConnection* server_conn,
167 QuicCryptoServerStream* server, 162 QuicCryptoServerStream* server,
168 const FakeClientOptions& options) { 163 const FakeClientOptions& options) {
169 QuicGuid guid(1); 164 PacketSavingConnection* client_conn = new PacketSavingConnection(false);
170 IPAddressNumber ip;
171 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip));
172 IPEndPoint addr = IPEndPoint(ip, 1);
173 PacketSavingConnection* client_conn =
174 new PacketSavingConnection(guid, addr, false);
175 TestSession client_session(client_conn, DefaultQuicConfig(), false); 165 TestSession client_session(client_conn, DefaultQuicConfig(), false);
176 QuicCryptoClientConfig crypto_config; 166 QuicCryptoClientConfig crypto_config;
177 167
178 client_session.config()->SetDefaults(); 168 client_session.config()->SetDefaults();
179 crypto_config.SetDefaults(); 169 crypto_config.SetDefaults();
180 // TODO(rtenneti): Enable testing of ProofVerifier. 170 // TODO(rtenneti): Enable testing of ProofVerifier.
181 // if (!options.dont_verify_certs) { 171 // if (!options.dont_verify_certs) {
182 // crypto_config.SetProofVerifier(ProofVerifierForTesting()); 172 // crypto_config.SetProofVerifier(ProofVerifierForTesting());
183 // } 173 // }
184 if (options.channel_id_enabled) { 174 if (options.channel_id_enabled) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); 510 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg));
521 scoped_ptr<CryptoHandshakeMessage> parsed( 511 scoped_ptr<CryptoHandshakeMessage> parsed(
522 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 512 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
523 CHECK(parsed.get()); 513 CHECK(parsed.get());
524 514
525 return *parsed; 515 return *parsed;
526 } 516 }
527 517
528 } // namespace test 518 } // namespace test
529 } // namespace net 519 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream_test.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698