OLD | NEW |
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_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "net/base/host_port_pair.h" |
15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
| 18 #include "net/base/proxy_delegate.h" |
17 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
18 #include "net/base/test_data_directory.h" | 20 #include "net/base/test_data_directory.h" |
19 #include "net/base/test_data_stream.h" | 21 #include "net/base/test_data_stream.h" |
20 #include "net/log/test_net_log.h" | 22 #include "net/log/test_net_log.h" |
21 #include "net/log/test_net_log_entry.h" | 23 #include "net/log/test_net_log_entry.h" |
22 #include "net/log/test_net_log_util.h" | 24 #include "net/log/test_net_log_util.h" |
| 25 #include "net/proxy/proxy_server.h" |
23 #include "net/socket/client_socket_pool_manager.h" | 26 #include "net/socket/client_socket_pool_manager.h" |
24 #include "net/socket/next_proto.h" | 27 #include "net/socket/next_proto.h" |
25 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
26 #include "net/spdy/spdy_http_utils.h" | 29 #include "net/spdy/spdy_http_utils.h" |
27 #include "net/spdy/spdy_session_pool.h" | 30 #include "net/spdy/spdy_session_pool.h" |
28 #include "net/spdy/spdy_session_test_util.h" | 31 #include "net/spdy/spdy_session_test_util.h" |
29 #include "net/spdy/spdy_stream.h" | 32 #include "net/spdy/spdy_stream.h" |
30 #include "net/spdy/spdy_stream_test_util.h" | 33 #include "net/spdy/spdy_stream_test_util.h" |
31 #include "net/spdy/spdy_test_util_common.h" | 34 #include "net/spdy/spdy_test_util_common.h" |
32 #include "net/spdy/spdy_test_utils.h" | 35 #include "net/spdy/spdy_test_utils.h" |
(...skipping 4785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4818 } | 4821 } |
4819 | 4822 |
4820 // Tests that HTTP SPDY push streams that advertise an origin different from the | 4823 // Tests that HTTP SPDY push streams that advertise an origin different from the |
4821 // associated stream are accepted from a trusted SPDY proxy. | 4824 // associated stream are accepted from a trusted SPDY proxy. |
4822 TEST_P(SpdySessionTest, TrustedSpdyProxy) { | 4825 TEST_P(SpdySessionTest, TrustedSpdyProxy) { |
4823 // Origin of kDefaultURL should be different from the origin of | 4826 // Origin of kDefaultURL should be different from the origin of |
4824 // kHttpURLFromAnotherOrigin and kHttpsURLFromAnotherOrigin. | 4827 // kHttpURLFromAnotherOrigin and kHttpsURLFromAnotherOrigin. |
4825 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpURLFromAnotherOrigin).host()); | 4828 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpURLFromAnotherOrigin).host()); |
4826 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpsURLFromAnotherOrigin).host()); | 4829 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpsURLFromAnotherOrigin).host()); |
4827 | 4830 |
| 4831 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate()); |
| 4832 proxy_delegate->set_trusted_spdy_proxy( |
| 4833 net::ProxyServer(net::ProxyServer::SCHEME_HTTPS, |
| 4834 HostPortPair(GURL(kDefaultURL).host(), 80))); |
| 4835 |
4828 // cross_origin_push contains HTTP resource for an origin different from the | 4836 // cross_origin_push contains HTTP resource for an origin different from the |
4829 // origin of kDefaultURL, and should be accepted. | 4837 // origin of kDefaultURL, and should be accepted. |
4830 scoped_ptr<SpdyFrame> cross_origin_push(spdy_util_.ConstructSpdyPush( | 4838 scoped_ptr<SpdyFrame> cross_origin_push(spdy_util_.ConstructSpdyPush( |
4831 nullptr, 0, 2, 1, kHttpURLFromAnotherOrigin)); | 4839 nullptr, 0, 2, 1, kHttpURLFromAnotherOrigin)); |
4832 // cross_origin_https_push contains HTTPS resource, and should be refused. | 4840 // cross_origin_https_push contains HTTPS resource, and should be refused. |
4833 scoped_ptr<SpdyFrame> cross_origin_https_push(spdy_util_.ConstructSpdyPush( | 4841 scoped_ptr<SpdyFrame> cross_origin_https_push(spdy_util_.ConstructSpdyPush( |
4834 nullptr, 0, 4, 1, kHttpsURLFromAnotherOrigin)); | 4842 nullptr, 0, 4, 1, kHttpsURLFromAnotherOrigin)); |
4835 MockRead reads[] = { | 4843 MockRead reads[] = { |
4836 MockRead(ASYNC, ERR_IO_PENDING, 1), | 4844 MockRead(ASYNC, ERR_IO_PENDING, 1), |
4837 CreateMockRead(*cross_origin_push, 2), | 4845 CreateMockRead(*cross_origin_push, 2), |
4838 MockRead(ASYNC, ERR_IO_PENDING, 3), | 4846 MockRead(ASYNC, ERR_IO_PENDING, 3), |
4839 CreateMockRead(*cross_origin_https_push, 4), | 4847 CreateMockRead(*cross_origin_https_push, 4), |
4840 MockRead(ASYNC, ERR_IO_PENDING, 6), | 4848 MockRead(ASYNC, ERR_IO_PENDING, 6), |
4841 MockRead(ASYNC, 0, 7), | 4849 MockRead(ASYNC, 0, 7), |
4842 }; | 4850 }; |
4843 | 4851 |
4844 scoped_ptr<SpdyFrame> req( | 4852 scoped_ptr<SpdyFrame> req( |
4845 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, true)); | 4853 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, true)); |
4846 scoped_ptr<SpdyFrame> rst( | 4854 scoped_ptr<SpdyFrame> rst( |
4847 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_REFUSED_STREAM)); | 4855 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_REFUSED_STREAM)); |
4848 MockWrite writes[] = { | 4856 MockWrite writes[] = { |
4849 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 5), | 4857 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 5), |
4850 }; | 4858 }; |
4851 | 4859 |
4852 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 4860 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); |
4853 session_deps_.socket_factory->AddSocketDataProvider(&data); | 4861 session_deps_.socket_factory->AddSocketDataProvider(&data); |
4854 session_deps_.trusted_spdy_proxy = | 4862 session_deps_.proxy_delegate.reset(proxy_delegate.release()); |
4855 HostPortPair::FromURL(GURL(kDefaultURL)).ToString(); | |
4856 | 4863 |
4857 CreateNetworkSession(); | 4864 CreateNetworkSession(); |
4858 CreateInsecureSpdySession(); | 4865 CreateInsecureSpdySession(); |
4859 | 4866 |
4860 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( | 4867 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( |
4861 SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_, LOWEST, BoundNetLog()); | 4868 SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_, LOWEST, BoundNetLog()); |
4862 ASSERT_TRUE(spdy_stream.get() != nullptr); | 4869 ASSERT_TRUE(spdy_stream.get() != nullptr); |
4863 EXPECT_EQ(0u, spdy_stream->stream_id()); | 4870 EXPECT_EQ(0u, spdy_stream->stream_id()); |
4864 test::StreamDelegateDoNothing delegate(spdy_stream); | 4871 test::StreamDelegateDoNothing delegate(spdy_stream); |
4865 spdy_stream->SetDelegate(&delegate); | 4872 spdy_stream->SetDelegate(&delegate); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5334 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 5341 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
5335 "spdy_pooling.pem"); | 5342 "spdy_pooling.pem"); |
5336 ssl_info.is_issued_by_known_root = true; | 5343 ssl_info.is_issued_by_known_root = true; |
5337 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 5344 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
5338 | 5345 |
5339 EXPECT_TRUE(SpdySession::CanPool( | 5346 EXPECT_TRUE(SpdySession::CanPool( |
5340 &tss, ssl_info, "www.example.org", "mail.example.org")); | 5347 &tss, ssl_info, "www.example.org", "mail.example.org")); |
5341 } | 5348 } |
5342 | 5349 |
5343 } // namespace net | 5350 } // namespace net |
OLD | NEW |