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

Side by Side Diff: net/http/http_network_transaction_ssl_unittest.cc

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // properties begin SSL 3.0 fallbacks), this test will not crash (and bring 122 // properties begin SSL 3.0 fallbacks), this test will not crash (and bring
123 // down all of net_unittests), but it will fail gracefully. 123 // down all of net_unittests), but it will fail gracefully.
124 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); 124 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR);
125 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2); 125 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2);
126 StaticSocketDataProvider data2(NULL, 0, NULL, 0); 126 StaticSocketDataProvider data2(NULL, 0, NULL, 0);
127 mock_socket_factory_.AddSocketDataProvider(&data2); 127 mock_socket_factory_.AddSocketDataProvider(&data2);
128 128
129 scoped_refptr<HttpNetworkSession> session( 129 scoped_refptr<HttpNetworkSession> session(
130 new HttpNetworkSession(session_params_)); 130 new HttpNetworkSession(session_params_));
131 scoped_ptr<HttpNetworkTransaction> trans( 131 scoped_ptr<HttpNetworkTransaction> trans(
132 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); 132 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
133 133
134 SSLConfig& ssl_config = GetServerSSLConfig(trans.get()); 134 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
135 ssl_config.unrestricted_ssl3_fallback_enabled = false; 135 ssl_config.unrestricted_ssl3_fallback_enabled = false;
136 136
137 TestCompletionCallback callback; 137 TestCompletionCallback callback;
138 // This will consume only |ssl_data1|. |ssl_data2| will not be consumed. 138 // This will consume only |ssl_data1|. |ssl_data2| will not be consumed.
139 int rv = callback.GetResult( 139 int rv = callback.GetResult(
140 trans->Start(GetRequestInfo("https://www.google.com/"), 140 trans->Start(GetRequestInfo("https://www.google.com/"),
141 callback.callback(), BoundNetLog())); 141 callback.callback(), BoundNetLog()));
142 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 142 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
(...skipping 25 matching lines...) Expand all
168 // handshake which will be attempted after the TLS 1.0 168 // handshake which will be attempted after the TLS 1.0
169 // handshake fails. 169 // handshake fails.
170 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); 170 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR);
171 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2); 171 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2);
172 StaticSocketDataProvider data2(NULL, 0, NULL, 0); 172 StaticSocketDataProvider data2(NULL, 0, NULL, 0);
173 mock_socket_factory_.AddSocketDataProvider(&data2); 173 mock_socket_factory_.AddSocketDataProvider(&data2);
174 174
175 scoped_refptr<HttpNetworkSession> session( 175 scoped_refptr<HttpNetworkSession> session(
176 new HttpNetworkSession(session_params_)); 176 new HttpNetworkSession(session_params_));
177 scoped_ptr<HttpNetworkTransaction> trans( 177 scoped_ptr<HttpNetworkTransaction> trans(
178 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); 178 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
179 179
180 SSLConfig& ssl_config = GetServerSSLConfig(trans.get()); 180 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
181 ssl_config.unrestricted_ssl3_fallback_enabled = true; 181 ssl_config.unrestricted_ssl3_fallback_enabled = true;
182 182
183 TestCompletionCallback callback; 183 TestCompletionCallback callback;
184 // This will consume |ssl_data1| and |ssl_data2|. 184 // This will consume |ssl_data1| and |ssl_data2|.
185 int rv = callback.GetResult( 185 int rv = callback.GetResult(
186 trans->Start(GetRequestInfo("https://www.google.com/"), 186 trans->Start(GetRequestInfo("https://www.google.com/"),
187 callback.callback(), BoundNetLog())); 187 callback.callback(), BoundNetLog()));
188 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 188 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
(...skipping 26 matching lines...) Expand all
215 // handshake which will be attempted after the TLS 1.0 215 // handshake which will be attempted after the TLS 1.0
216 // handshake fails. 216 // handshake fails.
217 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); 217 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR);
218 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2); 218 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2);
219 StaticSocketDataProvider data2(NULL, 0, NULL, 0); 219 StaticSocketDataProvider data2(NULL, 0, NULL, 0);
220 mock_socket_factory_.AddSocketDataProvider(&data2); 220 mock_socket_factory_.AddSocketDataProvider(&data2);
221 221
222 scoped_refptr<HttpNetworkSession> session( 222 scoped_refptr<HttpNetworkSession> session(
223 new HttpNetworkSession(session_params_)); 223 new HttpNetworkSession(session_params_));
224 scoped_ptr<HttpNetworkTransaction> trans( 224 scoped_ptr<HttpNetworkTransaction> trans(
225 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); 225 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
226 226
227 SSLConfig& ssl_config = GetServerSSLConfig(trans.get()); 227 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
228 ssl_config.unrestricted_ssl3_fallback_enabled = false; 228 ssl_config.unrestricted_ssl3_fallback_enabled = false;
229 229
230 TestCompletionCallback callback; 230 TestCompletionCallback callback;
231 // This will consume |ssl_data1| and |ssl_data2|. 231 // This will consume |ssl_data1| and |ssl_data2|.
232 int rv = callback.GetResult( 232 int rv = callback.GetResult(
233 trans->Start(GetRequestInfo("https://www.paypal.com/"), 233 trans->Start(GetRequestInfo("https://www.paypal.com/"),
234 callback.callback(), BoundNetLog())); 234 callback.callback(), BoundNetLog()));
235 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 235 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // handshake which will be attempted after the TLS 1.0 268 // handshake which will be attempted after the TLS 1.0
269 // handshake fails. 269 // handshake fails.
270 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR); 270 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR);
271 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data3); 271 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data3);
272 StaticSocketDataProvider data3(NULL, 0, NULL, 0); 272 StaticSocketDataProvider data3(NULL, 0, NULL, 0);
273 mock_socket_factory_.AddSocketDataProvider(&data3); 273 mock_socket_factory_.AddSocketDataProvider(&data3);
274 274
275 scoped_refptr<HttpNetworkSession> session( 275 scoped_refptr<HttpNetworkSession> session(
276 new HttpNetworkSession(session_params_)); 276 new HttpNetworkSession(session_params_));
277 scoped_ptr<HttpNetworkTransaction> trans( 277 scoped_ptr<HttpNetworkTransaction> trans(
278 new HttpNetworkTransaction(DEFAULT_PRIORITY, session)); 278 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
279 279
280 SSLConfig& ssl_config = GetServerSSLConfig(trans.get()); 280 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
281 ssl_config.unrestricted_ssl3_fallback_enabled = true; 281 ssl_config.unrestricted_ssl3_fallback_enabled = true;
282 282
283 TestCompletionCallback callback; 283 TestCompletionCallback callback;
284 // This will consume |ssl_data1|, |ssl_data2| and |ssl_data3|. 284 // This will consume |ssl_data1|, |ssl_data2| and |ssl_data3|.
285 int rv = callback.GetResult( 285 int rv = callback.GetResult(
286 trans->Start(GetRequestInfo("https://www.paypal.com/"), 286 trans->Start(GetRequestInfo("https://www.paypal.com/"),
287 callback.callback(), BoundNetLog())); 287 callback.callback(), BoundNetLog()));
288 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 288 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
289 289
290 SocketDataProviderArray<SocketDataProvider>& mock_data = 290 SocketDataProviderArray<SocketDataProvider>& mock_data =
291 mock_socket_factory_.mock_data(); 291 mock_socket_factory_.mock_data();
292 // Confirms that |ssl_data1|, |ssl_data2| and |ssl_data3| are consumed. 292 // Confirms that |ssl_data1|, |ssl_data2| and |ssl_data3| are consumed.
293 EXPECT_EQ(3u, mock_data.next_index()); 293 EXPECT_EQ(3u, mock_data.next_index());
294 294
295 // |version_max| fallbacks to SSL 3.0. 295 // |version_max| fallbacks to SSL 3.0.
296 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max); 296 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max);
297 EXPECT_TRUE(ssl_config.version_fallback); 297 EXPECT_TRUE(ssl_config.version_fallback);
298 } 298 }
299 299
300 } // namespace net 300 } // namespace net
301 301
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_spdy3_unittest.cc ('k') | net/http/http_pipelined_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698