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

Side by Side Diff: net/http/http_network_transaction_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: Added net/base/test_proxy_delegate.{h,cc} 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
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_proxy_client_socket_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <limits> 10 #include <limits>
(...skipping 14 matching lines...) Expand all
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/test/test_file_util.h" 26 #include "base/test/test_file_util.h"
27 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
28 #include "net/base/auth.h" 28 #include "net/base/auth.h"
29 #include "net/base/chunked_upload_data_stream.h" 29 #include "net/base/chunked_upload_data_stream.h"
30 #include "net/base/completion_callback.h" 30 #include "net/base/completion_callback.h"
31 #include "net/base/elements_upload_data_stream.h" 31 #include "net/base/elements_upload_data_stream.h"
32 #include "net/base/load_timing_info.h" 32 #include "net/base/load_timing_info.h"
33 #include "net/base/load_timing_info_test_util.h" 33 #include "net/base/load_timing_info_test_util.h"
34 #include "net/base/net_errors.h" 34 #include "net/base/net_errors.h"
35 #include "net/base/proxy_delegate.h"
35 #include "net/base/request_priority.h" 36 #include "net/base/request_priority.h"
36 #include "net/base/test_completion_callback.h" 37 #include "net/base/test_completion_callback.h"
37 #include "net/base/test_data_directory.h" 38 #include "net/base/test_data_directory.h"
39 #include "net/base/test_proxy_delegate.h"
38 #include "net/base/upload_bytes_element_reader.h" 40 #include "net/base/upload_bytes_element_reader.h"
39 #include "net/base/upload_file_element_reader.h" 41 #include "net/base/upload_file_element_reader.h"
40 #include "net/cert/mock_cert_verifier.h" 42 #include "net/cert/mock_cert_verifier.h"
41 #include "net/dns/host_cache.h" 43 #include "net/dns/host_cache.h"
42 #include "net/dns/mock_host_resolver.h" 44 #include "net/dns/mock_host_resolver.h"
43 #include "net/http/http_auth_challenge_tokenizer.h" 45 #include "net/http/http_auth_challenge_tokenizer.h"
44 #include "net/http/http_auth_handler_digest.h" 46 #include "net/http/http_auth_handler_digest.h"
45 #include "net/http/http_auth_handler_mock.h" 47 #include "net/http/http_auth_handler_mock.h"
46 #include "net/http/http_auth_handler_ntlm.h" 48 #include "net/http/http_auth_handler_ntlm.h"
47 #include "net/http/http_auth_scheme.h" 49 #include "net/http/http_auth_scheme.h"
48 #include "net/http/http_basic_state.h" 50 #include "net/http/http_basic_state.h"
49 #include "net/http/http_basic_stream.h" 51 #include "net/http/http_basic_stream.h"
50 #include "net/http/http_network_session.h" 52 #include "net/http/http_network_session.h"
51 #include "net/http/http_network_session_peer.h" 53 #include "net/http/http_network_session_peer.h"
52 #include "net/http/http_request_headers.h" 54 #include "net/http/http_request_headers.h"
53 #include "net/http/http_server_properties_impl.h" 55 #include "net/http/http_server_properties_impl.h"
54 #include "net/http/http_stream.h" 56 #include "net/http/http_stream.h"
55 #include "net/http/http_stream_factory.h" 57 #include "net/http/http_stream_factory.h"
56 #include "net/http/http_stream_parser.h" 58 #include "net/http/http_stream_parser.h"
57 #include "net/http/http_transaction_test_util.h" 59 #include "net/http/http_transaction_test_util.h"
58 #include "net/log/net_log.h" 60 #include "net/log/net_log.h"
59 #include "net/log/test_net_log.h" 61 #include "net/log/test_net_log.h"
60 #include "net/log/test_net_log_entry.h" 62 #include "net/log/test_net_log_entry.h"
61 #include "net/log/test_net_log_util.h" 63 #include "net/log/test_net_log_util.h"
62 #include "net/proxy/mock_proxy_resolver.h" 64 #include "net/proxy/mock_proxy_resolver.h"
63 #include "net/proxy/proxy_config_service_fixed.h" 65 #include "net/proxy/proxy_config_service_fixed.h"
64 #include "net/proxy/proxy_info.h" 66 #include "net/proxy/proxy_info.h"
65 #include "net/proxy/proxy_resolver.h" 67 #include "net/proxy/proxy_resolver.h"
68 #include "net/proxy/proxy_server.h"
66 #include "net/proxy/proxy_service.h" 69 #include "net/proxy/proxy_service.h"
67 #include "net/socket/client_socket_factory.h" 70 #include "net/socket/client_socket_factory.h"
68 #include "net/socket/client_socket_pool.h" 71 #include "net/socket/client_socket_pool.h"
69 #include "net/socket/client_socket_pool_manager.h" 72 #include "net/socket/client_socket_pool_manager.h"
70 #include "net/socket/connection_attempts.h" 73 #include "net/socket/connection_attempts.h"
71 #include "net/socket/mock_client_socket_pool_manager.h" 74 #include "net/socket/mock_client_socket_pool_manager.h"
72 #include "net/socket/next_proto.h" 75 #include "net/socket/next_proto.h"
73 #include "net/socket/socket_test_util.h" 76 #include "net/socket/socket_test_util.h"
74 #include "net/socket/ssl_client_socket.h" 77 #include "net/socket/ssl_client_socket.h"
75 #include "net/spdy/spdy_framer.h" 78 #include "net/spdy/spdy_framer.h"
(...skipping 7606 matching lines...) Expand 10 before | Expand all | Expand 10 after
7682 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 7685 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
7683 TestLoadTimingNotReusedWithPac(load_timing_info, 7686 TestLoadTimingNotReusedWithPac(load_timing_info,
7684 CONNECT_TIMING_HAS_SSL_TIMES); 7687 CONNECT_TIMING_HAS_SSL_TIMES);
7685 7688
7686 trans.reset(); 7689 trans.reset();
7687 session->CloseAllConnections(); 7690 session->CloseAllConnections();
7688 } 7691 }
7689 7692
7690 // Test that an explicitly trusted SPDY proxy can push a resource from an 7693 // Test that an explicitly trusted SPDY proxy can push a resource from an
7691 // origin that is different from that of its associated resource. 7694 // origin that is different from that of its associated resource.
7692 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) { 7695 TEST_P(HttpNetworkTransactionTest, CrossOriginSPDYProxyPush) {
7696 // Configure the proxy delegate to allow cross-origin SPDY pushes.
7697 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
7698 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI(
7699 "https://myproxy:443", net::ProxyServer::SCHEME_HTTP));
7693 HttpRequestInfo request; 7700 HttpRequestInfo request;
7694 HttpRequestInfo push_request; 7701 HttpRequestInfo push_request;
7695 7702
7696 request.method = "GET"; 7703 request.method = "GET";
7697 request.url = GURL("http://www.example.org/"); 7704 request.url = GURL("http://www.example.org/");
7698 push_request.method = "GET"; 7705 push_request.method = "GET";
7699 push_request.url = GURL("http://www.another-origin.com/foo.dat"); 7706 push_request.url = GURL("http://www.another-origin.com/foo.dat");
7700 7707
7701 // Configure against https proxy server "myproxy:70". 7708 // Configure against https proxy server "myproxy:443".
7702 session_deps_.proxy_service = 7709 session_deps_.proxy_service =
7703 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"); 7710 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:443");
7704 BoundTestNetLog log; 7711 BoundTestNetLog log;
7705 session_deps_.net_log = log.bound().net_log(); 7712 session_deps_.net_log = log.bound().net_log();
7706 7713
7707 // Enable cross-origin push. 7714 session_deps_.proxy_delegate.reset(proxy_delegate.release());
7708 session_deps_.trusted_spdy_proxy = "myproxy:70";
7709 7715
7710 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7716 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7711 7717
7712 scoped_ptr<SpdyFrame> stream1_syn( 7718 scoped_ptr<SpdyFrame> stream1_syn(
7713 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 7719 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
7714 7720
7715 MockWrite spdy_writes[] = { 7721 MockWrite spdy_writes[] = {
7716 CreateMockWrite(*stream1_syn, 0, ASYNC), 7722 CreateMockWrite(*stream1_syn, 0, ASYNC),
7717 }; 7723 };
7718 7724
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7800 EXPECT_EQ(load_timing_info.socket_log_id, 7806 EXPECT_EQ(load_timing_info.socket_log_id,
7801 push_load_timing_info.socket_log_id); 7807 push_load_timing_info.socket_log_id);
7802 7808
7803 trans.reset(); 7809 trans.reset();
7804 push_trans.reset(); 7810 push_trans.reset();
7805 session->CloseAllConnections(); 7811 session->CloseAllConnections();
7806 } 7812 }
7807 7813
7808 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. 7814 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content.
7809 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { 7815 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) {
7816 // Configure the proxy delegate to allow cross-origin SPDY pushes.
7817 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
7818 proxy_delegate->set_trusted_spdy_proxy(net::ProxyServer::FromURI(
7819 "https://myproxy:443", net::ProxyServer::SCHEME_HTTP));
7810 HttpRequestInfo request; 7820 HttpRequestInfo request;
7811 7821
7812 request.method = "GET"; 7822 request.method = "GET";
7813 request.url = GURL("http://www.example.org/"); 7823 request.url = GURL("http://www.example.org/");
7814 7824
7815 // Configure against https proxy server "myproxy:70". 7825 session_deps_.proxy_service =
7816 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); 7826 ProxyService::CreateFixed("https://myproxy:443");
7817 BoundTestNetLog log; 7827 BoundTestNetLog log;
7818 session_deps_.net_log = log.bound().net_log(); 7828 session_deps_.net_log = log.bound().net_log();
7819 7829
7820 // Enable cross-origin push. 7830 // Enable cross-origin push.
7821 session_deps_.trusted_spdy_proxy = "myproxy:70"; 7831 session_deps_.proxy_delegate.reset(proxy_delegate.release());
7822 7832
7823 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7833 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7824 7834
7825 scoped_ptr<SpdyFrame> stream1_syn( 7835 scoped_ptr<SpdyFrame> stream1_syn(
7826 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 7836 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
7827 7837
7828 scoped_ptr<SpdyFrame> push_rst( 7838 scoped_ptr<SpdyFrame> push_rst(
7829 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); 7839 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
7830 7840
7831 MockWrite spdy_writes[] = { 7841 MockWrite spdy_writes[] = {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
7881 EXPECT_EQ(OK, rv); 7891 EXPECT_EQ(OK, rv);
7882 EXPECT_EQ("hello!", response_data); 7892 EXPECT_EQ("hello!", response_data);
7883 7893
7884 trans.reset(); 7894 trans.reset();
7885 session->CloseAllConnections(); 7895 session->CloseAllConnections();
7886 } 7896 }
7887 7897
7888 // Test that an explicitly trusted SPDY proxy can push same-origin HTTPS 7898 // Test that an explicitly trusted SPDY proxy can push same-origin HTTPS
7889 // resources. 7899 // resources.
7890 TEST_P(HttpNetworkTransactionTest, SameOriginProxyPushCorrectness) { 7900 TEST_P(HttpNetworkTransactionTest, SameOriginProxyPushCorrectness) {
7901 // Configure the proxy delegate to allow cross-origin SPDY pushes.
7902 scoped_ptr<TestProxyDelegate> proxy_delegate(new TestProxyDelegate());
7903 proxy_delegate->set_trusted_spdy_proxy(
7904 net::ProxyServer::FromURI("myproxy:70", net::ProxyServer::SCHEME_HTTP));
7905
7891 HttpRequestInfo request; 7906 HttpRequestInfo request;
7892 7907
7893 request.method = "GET"; 7908 request.method = "GET";
7894 request.url = GURL("http://www.example.org/"); 7909 request.url = GURL("http://www.example.org/");
7895 7910
7896 // Configure against https proxy server "myproxy:70". 7911 // Configure against https proxy server "myproxy:70".
7897 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70"); 7912 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70");
7898 BoundTestNetLog log; 7913 BoundTestNetLog log;
7899 session_deps_.net_log = log.bound().net_log(); 7914 session_deps_.net_log = log.bound().net_log();
7900 7915
7901 // Enable cross-origin push. 7916 // Enable cross-origin push.
7902 session_deps_.trusted_spdy_proxy = "myproxy:70"; 7917 session_deps_.proxy_delegate.reset(proxy_delegate.release());
7903 7918
7904 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7919 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7905 7920
7906 scoped_ptr<SpdyFrame> stream1_syn( 7921 scoped_ptr<SpdyFrame> stream1_syn(
7907 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, false)); 7922 spdy_util_.ConstructSpdyGet(nullptr, 0, false, 1, LOWEST, false));
7908 7923
7909 scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush( 7924 scoped_ptr<SpdyFrame> stream2_syn(spdy_util_.ConstructSpdyPush(
7910 nullptr, 0, 2, 1, "https://myproxy:70/foo.dat")); 7925 nullptr, 0, 2, 1, "https://myproxy:70/foo.dat"));
7911 7926
7912 MockWrite spdy_writes[] = { 7927 MockWrite spdy_writes[] = {
(...skipping 8032 matching lines...) Expand 10 before | Expand all | Expand 10 after
15945 base::MessageLoop::current()->RunUntilIdle(); 15960 base::MessageLoop::current()->RunUntilIdle();
15946 15961
15947 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 15962 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
15948 HttpRequestHeaders headers; 15963 HttpRequestHeaders headers;
15949 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 15964 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
15950 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 15965 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
15951 } 15966 }
15952 #endif // !defined(OS_IOS) 15967 #endif // !defined(OS_IOS)
15953 15968
15954 } // namespace net 15969 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.cc ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698