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

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

Issue 2120703003: QUIC - Race Cert Verification with host resolution if certs are (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for buildbot failure. Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/quic_stream_factory_peer.h" 5 #include "net/quic/test_tools/quic_stream_factory_peer.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "net/cert/x509_certificate.h"
10 #include "net/quic/chromium/quic_chromium_client_session.h" 11 #include "net/quic/chromium/quic_chromium_client_session.h"
11 #include "net/quic/chromium/quic_http_stream.h" 12 #include "net/quic/chromium/quic_http_stream.h"
12 #include "net/quic/chromium/quic_stream_factory.h" 13 #include "net/quic/chromium/quic_stream_factory.h"
13 #include "net/quic/core/crypto/quic_crypto_client_config.h" 14 #include "net/quic/core/crypto/quic_crypto_client_config.h"
14 #include "net/quic/core/quic_clock.h" 15 #include "net/quic/core/quic_clock.h"
16 #include "net/test/cert_test_util.h"
17 #include "net/test/test_data_directory.h"
15 18
16 using std::string; 19 using std::string;
17 using std::vector; 20 using std::vector;
18 21
19 namespace net { 22 namespace net {
20 namespace test { 23 namespace test {
21 24
22 const QuicConfig* QuicStreamFactoryPeer::GetConfig(QuicStreamFactory* factory) { 25 const QuicConfig* QuicStreamFactoryPeer::GetConfig(QuicStreamFactory* factory) {
23 return &factory->config_; 26 return &factory->config_;
24 } 27 }
25 28
26 QuicCryptoClientConfig* QuicStreamFactoryPeer::GetCryptoConfig( 29 QuicCryptoClientConfig* QuicStreamFactoryPeer::GetCryptoConfig(
27 QuicStreamFactory* factory) { 30 QuicStreamFactory* factory) {
28 return &factory->crypto_config_; 31 return &factory->crypto_config_;
29 } 32 }
30 33
31 bool QuicStreamFactoryPeer::HasActiveSession(QuicStreamFactory* factory, 34 bool QuicStreamFactoryPeer::HasActiveSession(QuicStreamFactory* factory,
32 const QuicServerId& server_id) { 35 const QuicServerId& server_id) {
33 return factory->HasActiveSession(server_id); 36 return factory->HasActiveSession(server_id);
34 } 37 }
35 38
39 bool QuicStreamFactoryPeer::HasActiveCertVerifierJob(
40 QuicStreamFactory* factory,
41 const QuicServerId& server_id) {
42 return factory->HasActiveCertVerifierJob(server_id);
43 }
44
36 QuicChromiumClientSession* QuicStreamFactoryPeer::GetActiveSession( 45 QuicChromiumClientSession* QuicStreamFactoryPeer::GetActiveSession(
37 QuicStreamFactory* factory, 46 QuicStreamFactory* factory,
38 const QuicServerId& server_id) { 47 const QuicServerId& server_id) {
39 DCHECK(factory->HasActiveSession(server_id)); 48 DCHECK(factory->HasActiveSession(server_id));
40 return factory->active_sessions_[server_id]; 49 return factory->active_sessions_[server_id];
41 } 50 }
42 51
43 std::unique_ptr<QuicHttpStream> QuicStreamFactoryPeer::CreateFromSession( 52 std::unique_ptr<QuicHttpStream> QuicStreamFactoryPeer::CreateFromSession(
44 QuicStreamFactory* factory, 53 QuicStreamFactory* factory,
45 QuicChromiumClientSession* session) { 54 QuicChromiumClientSession* session) {
(...skipping 29 matching lines...) Expand all
75 84
76 bool QuicStreamFactoryPeer::GetDelayTcpRace(QuicStreamFactory* factory) { 85 bool QuicStreamFactoryPeer::GetDelayTcpRace(QuicStreamFactory* factory) {
77 return factory->delay_tcp_race_; 86 return factory->delay_tcp_race_;
78 } 87 }
79 88
80 void QuicStreamFactoryPeer::SetDelayTcpRace(QuicStreamFactory* factory, 89 void QuicStreamFactoryPeer::SetDelayTcpRace(QuicStreamFactory* factory,
81 bool delay_tcp_race) { 90 bool delay_tcp_race) {
82 factory->delay_tcp_race_ = delay_tcp_race; 91 factory->delay_tcp_race_ = delay_tcp_race;
83 } 92 }
84 93
94 bool QuicStreamFactoryPeer::GetRaceCertVerification(
95 QuicStreamFactory* factory) {
96 return factory->race_cert_verification_;
97 }
98
99 void QuicStreamFactoryPeer::SetRaceCertVerification(
100 QuicStreamFactory* factory,
101 bool race_cert_verification) {
102 factory->race_cert_verification_ = race_cert_verification;
103 }
104
105 QuicAsyncStatus QuicStreamFactoryPeer::StartCertVerifyJob(
106 QuicStreamFactory* factory,
107 const QuicServerId& server_id,
108 int cert_verify_flags,
109 const BoundNetLog& net_log) {
110 return factory->StartCertVerifyJob(server_id, cert_verify_flags, net_log);
111 }
112
85 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory, 113 void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory,
86 int yield_after_packets) { 114 int yield_after_packets) {
87 factory->yield_after_packets_ = yield_after_packets; 115 factory->yield_after_packets_ = yield_after_packets;
88 } 116 }
89 117
90 void QuicStreamFactoryPeer::SetYieldAfterDuration( 118 void QuicStreamFactoryPeer::SetYieldAfterDuration(
91 QuicStreamFactory* factory, 119 QuicStreamFactory* factory,
92 QuicTime::Delta yield_after_duration) { 120 QuicTime::Delta yield_after_duration) {
93 factory->yield_after_duration_ = yield_after_duration; 121 factory->yield_after_duration_ = yield_after_duration;
94 } 122 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // EXPY 170 // EXPY
143 0x45, 0x58, 0x50, 0x59, 171 0x45, 0x58, 0x50, 0x59,
144 // EXPY end offset 172 // EXPY end offset
145 0x08, 0x00, 0x00, 0x00, 173 0x08, 0x00, 0x00, 0x00,
146 // Value 174 // Value
147 '1', '2', '3', '4', '5', '6', '7', '8'}; 175 '1', '2', '3', '4', '5', '6', '7', '8'};
148 176
149 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg)); 177 string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg));
150 string source_address_token("test_source_address_token"); 178 string source_address_token("test_source_address_token");
151 string signature("test_signature"); 179 string signature("test_signature");
152 string test_cert("test_cert"); 180
153 vector<string> certs; 181 vector<string> certs;
154 certs.push_back(test_cert); 182 // Load a certificate that is valid for *.example.org
183 scoped_refptr<X509Certificate> cert(
184 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
185 DCHECK(cert);
186 std::string der_bytes;
187 DCHECK(X509Certificate::GetDEREncoded(cert->os_cert_handle(), &der_bytes));
188 certs.push_back(der_bytes);
155 189
156 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_; 190 QuicCryptoClientConfig* crypto_config = &factory->crypto_config_;
157 QuicCryptoClientConfig::CachedState* cached = 191 QuicCryptoClientConfig::CachedState* cached =
158 crypto_config->LookupOrCreate(quic_server_id); 192 crypto_config->LookupOrCreate(quic_server_id);
159 QuicClock clock; 193 QuicClock clock;
160 cached->Initialize(server_config, source_address_token, certs, "", "", 194 cached->Initialize(server_config, source_address_token, certs, "", "",
161 signature, clock.WallNow()); 195 signature, clock.WallNow());
196 DCHECK(!cached->certs().empty());
162 } 197 }
163 198
164 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex( 199 QuicClientPushPromiseIndex* QuicStreamFactoryPeer::GetPushPromiseIndex(
165 QuicStreamFactory* factory) { 200 QuicStreamFactory* factory) {
166 return &factory->push_promise_index_; 201 return &factory->push_promise_index_;
167 } 202 }
168 203
169 int QuicStreamFactoryPeer::GetNumPushStreamsCreated( 204 int QuicStreamFactoryPeer::GetNumPushStreamsCreated(
170 QuicStreamFactory* factory) { 205 QuicStreamFactory* factory) {
171 return factory->num_push_streams_created_; 206 return factory->num_push_streams_created_;
172 } 207 }
173 208
174 } // namespace test 209 } // namespace test
175 } // namespace net 210 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_stream_factory_peer.h ('k') | net/tools/quic/test_tools/quic_test_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698