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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 months 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/reliable_quic_stream_test.cc ('k') | net/quic/test_tools/quic_connection_peer.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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 CryptoTestUtils::FakeClientOptions::FakeClientOptions() 176 CryptoTestUtils::FakeClientOptions::FakeClientOptions()
177 : dont_verify_certs(false), 177 : dont_verify_certs(false),
178 channel_id_enabled(false), 178 channel_id_enabled(false),
179 channel_id_source_async(false) { 179 channel_id_source_async(false) {
180 } 180 }
181 181
182 // static 182 // static
183 int CryptoTestUtils::HandshakeWithFakeServer( 183 int CryptoTestUtils::HandshakeWithFakeServer(
184 PacketSavingConnection* client_conn, 184 PacketSavingConnection* client_conn,
185 QuicCryptoClientStream* client) { 185 QuicCryptoClientStream* client) {
186 PacketSavingConnection* server_conn = 186 PacketSavingConnection* server_conn = new PacketSavingConnection(
187 new PacketSavingConnection(true, client_conn->supported_versions()); 187 Perspective::IS_SERVER, client_conn->supported_versions());
188 TestSession server_session(server_conn, DefaultQuicConfig()); 188 TestSession server_session(server_conn, DefaultQuicConfig());
189 server_session.InitializeSession(); 189 server_session.InitializeSession();
190 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 190 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
191 QuicRandom::GetInstance()); 191 QuicRandom::GetInstance());
192 192
193 SetupCryptoServerConfigForTest( 193 SetupCryptoServerConfigForTest(
194 server_session.connection()->clock(), 194 server_session.connection()->clock(),
195 server_session.connection()->random_generator(), 195 server_session.connection()->random_generator(),
196 server_session.config(), &crypto_config); 196 server_session.config(), &crypto_config);
197 197
198 QuicCryptoServerStream server(crypto_config, &server_session); 198 QuicCryptoServerStream server(crypto_config, &server_session);
199 server_session.SetCryptoStream(&server); 199 server_session.SetCryptoStream(&server);
200 200
201 // The client's handshake must have been started already. 201 // The client's handshake must have been started already.
202 CHECK_NE(0u, client_conn->encrypted_packets_.size()); 202 CHECK_NE(0u, client_conn->encrypted_packets_.size());
203 203
204 CommunicateHandshakeMessages(client_conn, client, server_conn, &server); 204 CommunicateHandshakeMessages(client_conn, client, server_conn, &server);
205 205
206 CompareClientAndServerKeys(client, &server); 206 CompareClientAndServerKeys(client, &server);
207 207
208 return client->num_sent_client_hellos(); 208 return client->num_sent_client_hellos();
209 } 209 }
210 210
211 // static 211 // static
212 int CryptoTestUtils::HandshakeWithFakeClient( 212 int CryptoTestUtils::HandshakeWithFakeClient(
213 PacketSavingConnection* server_conn, 213 PacketSavingConnection* server_conn,
214 QuicCryptoServerStream* server, 214 QuicCryptoServerStream* server,
215 const FakeClientOptions& options) { 215 const FakeClientOptions& options) {
216 PacketSavingConnection* client_conn = new PacketSavingConnection(false); 216 PacketSavingConnection* client_conn =
217 new PacketSavingConnection(Perspective::IS_CLIENT);
217 // Advance the time, because timers do not like uninitialized times. 218 // Advance the time, because timers do not like uninitialized times.
218 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 219 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1));
219 TestClientSession client_session(client_conn, DefaultQuicConfig()); 220 TestClientSession client_session(client_conn, DefaultQuicConfig());
220 QuicCryptoClientConfig crypto_config; 221 QuicCryptoClientConfig crypto_config;
221 222
222 if (!options.dont_verify_certs) { 223 if (!options.dont_verify_certs) {
223 // TODO(wtc): replace this with ProofVerifierForTesting() when we have 224 // TODO(wtc): replace this with ProofVerifierForTesting() when we have
224 // a working ProofSourceForTesting(). 225 // a working ProofSourceForTesting().
225 crypto_config.SetProofVerifier(FakeProofVerifierForTesting()); 226 crypto_config.SetProofVerifier(FakeProofVerifierForTesting());
226 } 227 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); 625 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg));
625 scoped_ptr<CryptoHandshakeMessage> parsed( 626 scoped_ptr<CryptoHandshakeMessage> parsed(
626 CryptoFramer::ParseMessage(bytes->AsStringPiece())); 627 CryptoFramer::ParseMessage(bytes->AsStringPiece()));
627 CHECK(parsed.get()); 628 CHECK(parsed.get());
628 629
629 return *parsed; 630 return *parsed;
630 } 631 }
631 632
632 } // namespace test 633 } // namespace test
633 } // namespace net 634 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream_test.cc ('k') | net/quic/test_tools/quic_connection_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698