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

Side by Side Diff: net/http/http_proxy_client_socket_pool_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: Updated based on design doc discussion Created 4 years, 11 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/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 HttpProxyType proxy_type; 54 HttpProxyType proxy_type;
55 NextProto protocol; 55 NextProto protocol;
56 bool priority_to_dependency; 56 bool priority_to_dependency;
57 }; 57 };
58 58
59 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; 59 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam;
60 60
61 const char kHttpProxyHost[] = "httpproxy.example.com"; 61 const char kHttpProxyHost[] = "httpproxy.example.com";
62 const char kHttpsProxyHost[] = "httpsproxy.example.com"; 62 const char kHttpsProxyHost[] = "httpsproxy.example.com";
63 63
64 class TestProxyDelegate : public ProxyDelegate {
bengr 2016/01/26 23:23:26 This has nothing to do with this CL. Please do thi
tbansal1 2016/01/27 00:13:34 This has been moved to net/spdy/spdy_test_util_co
65 public:
66 TestProxyDelegate()
67 : on_before_tunnel_request_called_(false),
68 on_tunnel_request_completed_called_(false),
69 on_tunnel_headers_received_called_(false) {
70 }
71
72 ~TestProxyDelegate() override {}
73
74 bool on_before_tunnel_request_called() const {
75 return on_before_tunnel_request_called_;
76 }
77
78 bool on_tunnel_request_completed_called() const {
79 return on_tunnel_request_completed_called_;
80 }
81
82 bool on_tunnel_headers_received_called() const {
83 return on_tunnel_headers_received_called_;
84 }
85
86 void VerifyOnTunnelRequestCompleted(const std::string& endpoint,
87 const std::string& proxy_server) const {
88 EXPECT_TRUE(on_tunnel_request_completed_called_);
89 EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals(
90 on_tunnel_request_completed_endpoint_));
91 EXPECT_TRUE(HostPortPair::FromString(proxy_server).Equals(
92 on_tunnel_request_completed_proxy_server_));
93 }
94
95 void VerifyOnTunnelHeadersReceived(const std::string& origin,
96 const std::string& proxy_server,
97 const std::string& status_line) const {
98 EXPECT_TRUE(on_tunnel_headers_received_called_);
99 EXPECT_TRUE(HostPortPair::FromString(origin).Equals(
100 on_tunnel_headers_received_origin_));
101 EXPECT_TRUE(HostPortPair::FromString(proxy_server).Equals(
102 on_tunnel_headers_received_proxy_server_));
103 EXPECT_EQ(status_line, on_tunnel_headers_received_status_line_);
104 }
105
106 // ProxyDelegate:
107 void OnResolveProxy(const GURL& url,
108 int load_flags,
109 const ProxyService& proxy_service,
110 ProxyInfo* result) override {}
111
112 void OnTunnelConnectCompleted(const HostPortPair& endpoint,
113 const HostPortPair& proxy_server,
114 int net_error) override {
115 on_tunnel_request_completed_called_ = true;
116 on_tunnel_request_completed_endpoint_ = endpoint;
117 on_tunnel_request_completed_proxy_server_ = proxy_server;
118 }
119
120 void OnFallback(const ProxyServer& bad_proxy, int net_error) override {}
121
122 void OnBeforeSendHeaders(URLRequest* request,
123 const ProxyInfo& proxy_info,
124 HttpRequestHeaders* headers) override {}
125
126 void OnBeforeTunnelRequest(const HostPortPair& proxy_server,
127 HttpRequestHeaders* extra_headers) override {
128 on_before_tunnel_request_called_ = true;
129 if (extra_headers) {
130 extra_headers->SetHeader("Foo", proxy_server.ToString());
131 }
132 }
133
134 void OnTunnelHeadersReceived(
135 const HostPortPair& origin,
136 const HostPortPair& proxy_server,
137 const HttpResponseHeaders& response_headers) override {
138 on_tunnel_headers_received_called_ = true;
139 on_tunnel_headers_received_origin_ = origin;
140 on_tunnel_headers_received_proxy_server_ = proxy_server;
141 on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine();
142 }
143
144 private:
145 bool on_before_tunnel_request_called_;
146 bool on_tunnel_request_completed_called_;
147 bool on_tunnel_headers_received_called_;
148 HostPortPair on_tunnel_request_completed_endpoint_;
149 HostPortPair on_tunnel_request_completed_proxy_server_;
150 HostPortPair on_tunnel_headers_received_origin_;
151 HostPortPair on_tunnel_headers_received_proxy_server_;
152 std::string on_tunnel_headers_received_status_line_;
153 };
154
155 } // namespace 64 } // namespace
156 65
157 class HttpProxyClientSocketPoolTest 66 class HttpProxyClientSocketPoolTest
158 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> { 67 : public ::testing::TestWithParam<HttpProxyClientSocketPoolTestParams> {
159 protected: 68 protected:
160 HttpProxyClientSocketPoolTest() 69 HttpProxyClientSocketPoolTest()
161 : session_deps_(GetParam().protocol), 70 : session_deps_(GetParam().protocol),
162 transport_socket_pool_(kMaxSockets, 71 transport_socket_pool_(kMaxSockets,
163 kMaxSocketsPerGroup, 72 kMaxSocketsPerGroup,
164 session_deps_.socket_factory.get()), 73 session_deps_.socket_factory.get()),
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // Make sure Location header was included and correct. 730 // Make sure Location header was included and correct.
822 std::string location; 731 std::string location;
823 EXPECT_TRUE(headers->IsRedirect(&location)); 732 EXPECT_TRUE(headers->IsRedirect(&location));
824 EXPECT_EQ(location, redirectTarget); 733 EXPECT_EQ(location, redirectTarget);
825 } 734 }
826 } 735 }
827 736
828 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 737 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
829 738
830 } // namespace net 739 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698