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

Side by Side Diff: net/spdy/spdy_proxy_client_socket_unittest.cc

Issue 2365263004: Make (almost) all SpdySessions secure in unittests. (Closed)
Patch Set: Created 4 years, 2 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/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_pool_unittest.cc » ('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/spdy/spdy_proxy_client_socket.h" 5 #include "net/spdy/spdy_proxy_client_socket.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 12 matching lines...) Expand all
23 #include "net/log/test_net_log_entry.h" 23 #include "net/log/test_net_log_entry.h"
24 #include "net/log/test_net_log_util.h" 24 #include "net/log/test_net_log_util.h"
25 #include "net/socket/client_socket_factory.h" 25 #include "net/socket/client_socket_factory.h"
26 #include "net/socket/socket_test_util.h" 26 #include "net/socket/socket_test_util.h"
27 #include "net/socket/tcp_client_socket.h" 27 #include "net/socket/tcp_client_socket.h"
28 #include "net/spdy/buffered_spdy_framer.h" 28 #include "net/spdy/buffered_spdy_framer.h"
29 #include "net/spdy/spdy_http_utils.h" 29 #include "net/spdy/spdy_http_utils.h"
30 #include "net/spdy/spdy_protocol.h" 30 #include "net/spdy/spdy_protocol.h"
31 #include "net/spdy/spdy_session_pool.h" 31 #include "net/spdy/spdy_session_pool.h"
32 #include "net/spdy/spdy_test_util_common.h" 32 #include "net/spdy/spdy_test_util_common.h"
33 #include "net/test/cert_test_util.h"
33 #include "net/test/gtest_util.h" 34 #include "net/test/gtest_util.h"
35 #include "net/test/test_data_directory.h"
34 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
36 #include "testing/platform_test.h" 38 #include "testing/platform_test.h"
37 39
38 using net::test::IsError; 40 using net::test::IsError;
39 using net::test::IsOk; 41 using net::test::IsOk;
40 42
41 //----------------------------------------------------------------------------- 43 //-----------------------------------------------------------------------------
42 44
43 namespace { 45 namespace {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 PlatformTest::TearDown(); 176 PlatformTest::TearDown();
175 } 177 }
176 178
177 void SpdyProxyClientSocketTest::Initialize(MockRead* reads, 179 void SpdyProxyClientSocketTest::Initialize(MockRead* reads,
178 size_t reads_count, 180 size_t reads_count,
179 MockWrite* writes, 181 MockWrite* writes,
180 size_t writes_count) { 182 size_t writes_count) {
181 data_.reset( 183 data_.reset(
182 new SequencedSocketData(reads, reads_count, writes, writes_count)); 184 new SequencedSocketData(reads, reads_count, writes, writes_count));
183 data_->set_connect_data(connect_data_); 185 data_->set_connect_data(connect_data_);
186 session_deps_.socket_factory->AddSocketDataProvider(data_.get());
184 187
185 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); 188 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
189 ssl.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
190 ASSERT_TRUE(ssl.cert);
191 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
192
186 session_deps_.host_resolver->set_synchronous_mode(true); 193 session_deps_.host_resolver->set_synchronous_mode(true);
187 194
188 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 195 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
189 196
190 // Creates the SPDY session and stream. 197 // Creates the SPDY session and stream.
191 spdy_session_ = CreateInsecureSpdySession( 198 spdy_session_ = CreateSecureSpdySession(
192 session_.get(), endpoint_spdy_session_key_, NetLogWithSource()); 199 session_.get(), endpoint_spdy_session_key_, NetLogWithSource());
193 base::WeakPtr<SpdyStream> spdy_stream( 200 base::WeakPtr<SpdyStream> spdy_stream(
194 CreateStreamSynchronously( 201 CreateStreamSynchronously(
195 SPDY_BIDIRECTIONAL_STREAM, spdy_session_, url_, LOWEST, 202 SPDY_BIDIRECTIONAL_STREAM, spdy_session_, url_, LOWEST,
196 net_log_.bound())); 203 net_log_.bound()));
197 ASSERT_TRUE(spdy_stream.get() != NULL); 204 ASSERT_TRUE(spdy_stream.get() != NULL);
198 205
199 // Create the SpdyProxyClientSocket. 206 // Create the SpdyProxyClientSocket.
200 sock_.reset(new SpdyProxyClientSocket( 207 sock_.reset(new SpdyProxyClientSocket(
201 spdy_stream, user_agent_, endpoint_host_port_pair_, proxy_host_port_, 208 spdy_stream, user_agent_, endpoint_host_port_pair_, proxy_host_port_,
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1354
1348 EXPECT_FALSE(sock_.get()); 1355 EXPECT_FALSE(sock_.get());
1349 EXPECT_TRUE(read_callback.have_result()); 1356 EXPECT_TRUE(read_callback.have_result());
1350 EXPECT_FALSE(write_callback_.have_result()); 1357 EXPECT_FALSE(write_callback_.have_result());
1351 1358
1352 // Let the RST_STREAM write while |rst| is in-scope. 1359 // Let the RST_STREAM write while |rst| is in-scope.
1353 base::RunLoop().RunUntilIdle(); 1360 base::RunLoop().RunUntilIdle();
1354 } 1361 }
1355 1362
1356 } // namespace net 1363 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698