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

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

Issue 1547273003: Set trusted SPDY proxy dynamically on per-profile basis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mmenke comments Created 4 years, 10 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 (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 4891 matching lines...) Expand 10 before | Expand all | Expand 10 after
4924 } 4927 }
4925 4928
4926 // Tests that HTTP SPDY push streams that advertise an origin different from the 4929 // Tests that HTTP SPDY push streams that advertise an origin different from the
4927 // associated stream are accepted from a trusted SPDY proxy. 4930 // associated stream are accepted from a trusted SPDY proxy.
4928 TEST_P(SpdySessionTest, TrustedSpdyProxy) { 4931 TEST_P(SpdySessionTest, TrustedSpdyProxy) {
4929 // Origin of kDefaultURL should be different from the origin of 4932 // Origin of kDefaultURL should be different from the origin of
4930 // kHttpURLFromAnotherOrigin and kHttpsURLFromAnotherOrigin. 4933 // kHttpURLFromAnotherOrigin and kHttpsURLFromAnotherOrigin.
4931 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpURLFromAnotherOrigin).host()); 4934 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpURLFromAnotherOrigin).host());
4932 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpsURLFromAnotherOrigin).host()); 4935 ASSERT_NE(GURL(kDefaultURL).host(), GURL(kHttpsURLFromAnotherOrigin).host());
4933 4936
4937 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
Bence 2016/02/03 00:40:04 Move these new lines down to just above line 4968
tbansal1 2016/02/03 01:22:49 Done.
4938 proxy_delegate->set_trusted_spdy_proxy(
4939 net::ProxyServer(net::ProxyServer::SCHEME_HTTPS,
4940 HostPortPair(GURL(kDefaultURL).host(), 80)));
4941
4934 // cross_origin_push contains HTTP resource for an origin different from the 4942 // cross_origin_push contains HTTP resource for an origin different from the
4935 // origin of kDefaultURL, and should be accepted. 4943 // origin of kDefaultURL, and should be accepted.
4936 scoped_ptr<SpdyFrame> cross_origin_push(spdy_util_.ConstructSpdyPush( 4944 scoped_ptr<SpdyFrame> cross_origin_push(spdy_util_.ConstructSpdyPush(
4937 nullptr, 0, 2, 1, kHttpURLFromAnotherOrigin)); 4945 nullptr, 0, 2, 1, kHttpURLFromAnotherOrigin));
4938 // cross_origin_https_push contains HTTPS resource, and should be refused. 4946 // cross_origin_https_push contains HTTPS resource, and should be refused.
4939 scoped_ptr<SpdyFrame> cross_origin_https_push(spdy_util_.ConstructSpdyPush( 4947 scoped_ptr<SpdyFrame> cross_origin_https_push(spdy_util_.ConstructSpdyPush(
4940 nullptr, 0, 4, 1, kHttpsURLFromAnotherOrigin)); 4948 nullptr, 0, 4, 1, kHttpsURLFromAnotherOrigin));
4941 MockRead reads[] = { 4949 MockRead reads[] = {
4942 MockRead(ASYNC, ERR_IO_PENDING, 1), 4950 MockRead(ASYNC, ERR_IO_PENDING, 1),
4943 CreateMockRead(*cross_origin_push, 2), 4951 CreateMockRead(*cross_origin_push, 2),
4944 MockRead(ASYNC, ERR_IO_PENDING, 3), 4952 MockRead(ASYNC, ERR_IO_PENDING, 3),
4945 CreateMockRead(*cross_origin_https_push, 4), 4953 CreateMockRead(*cross_origin_https_push, 4),
4946 MockRead(ASYNC, ERR_IO_PENDING, 6), 4954 MockRead(ASYNC, ERR_IO_PENDING, 6),
4947 MockRead(ASYNC, 0, 7), 4955 MockRead(ASYNC, 0, 7),
4948 }; 4956 };
4949 4957
4950 scoped_ptr<SpdyFrame> req( 4958 scoped_ptr<SpdyFrame> req(
4951 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, true)); 4959 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, true));
4952 scoped_ptr<SpdyFrame> rst( 4960 scoped_ptr<SpdyFrame> rst(
4953 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_REFUSED_STREAM)); 4961 spdy_util_.ConstructSpdyRstStream(4, RST_STREAM_REFUSED_STREAM));
4954 MockWrite writes[] = { 4962 MockWrite writes[] = {
4955 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 5), 4963 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 5),
4956 }; 4964 };
4957 4965
4958 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); 4966 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
4959 session_deps_.socket_factory->AddSocketDataProvider(&data); 4967 session_deps_.socket_factory->AddSocketDataProvider(&data);
4960 session_deps_.trusted_spdy_proxy = 4968 session_deps_.proxy_delegate.reset(proxy_delegate.release());
4961 HostPortPair::FromURL(GURL(kDefaultURL)).ToString();
4962 4969
4963 CreateNetworkSession(); 4970 CreateNetworkSession();
4964 CreateInsecureSpdySession(); 4971 CreateInsecureSpdySession();
4965 4972
4966 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 4973 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
4967 SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_, LOWEST, BoundNetLog()); 4974 SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_, LOWEST, BoundNetLog());
4968 ASSERT_TRUE(spdy_stream.get() != nullptr); 4975 ASSERT_TRUE(spdy_stream.get() != nullptr);
4969 EXPECT_EQ(0u, spdy_stream->stream_id()); 4976 EXPECT_EQ(0u, spdy_stream->stream_id());
4970 test::StreamDelegateDoNothing delegate(spdy_stream); 4977 test::StreamDelegateDoNothing delegate(spdy_stream);
4971 spdy_stream->SetDelegate(&delegate); 4978 spdy_stream->SetDelegate(&delegate);
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
5440 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5447 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5441 "spdy_pooling.pem"); 5448 "spdy_pooling.pem");
5442 ssl_info.is_issued_by_known_root = true; 5449 ssl_info.is_issued_by_known_root = true;
5443 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5450 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5444 5451
5445 EXPECT_TRUE(SpdySession::CanPool( 5452 EXPECT_TRUE(SpdySession::CanPool(
5446 &tss, ssl_info, "www.example.org", "mail.example.org")); 5453 &tss, ssl_info, "www.example.org", "mail.example.org"));
5447 } 5454 }
5448 5455
5449 } // namespace net 5456 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698