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

Side by Side Diff: jingle/glue/proxy_resolving_client_socket_unittest.cc

Issue 2552403002: Copy AuthCache from main request context into webrtc context (Closed)
Patch Set: Copy AuthCache from main request context into webrtc context Created 3 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 | « jingle/glue/proxy_resolving_client_socket.cc ('k') | no next file » | 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 "jingle/glue/proxy_resolving_client_socket.h" 5 #include "jingle/glue/proxy_resolving_client_socket.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 net::URLRequestContext* context = 109 net::URLRequestContext* context =
110 url_request_context_getter_->GetURLRequestContext(); 110 url_request_context_getter_->GetURLRequestContext();
111 const net::ProxyRetryInfoMap& retry_info = 111 const net::ProxyRetryInfoMap& retry_info =
112 context->proxy_service()->proxy_retry_info(); 112 context->proxy_service()->proxy_retry_info();
113 113
114 EXPECT_EQ(1u, retry_info.size()); 114 EXPECT_EQ(1u, retry_info.size());
115 net::ProxyRetryInfoMap::const_iterator iter = retry_info.find("bad:99"); 115 net::ProxyRetryInfoMap::const_iterator iter = retry_info.find("bad:99");
116 EXPECT_TRUE(iter != retry_info.end()); 116 EXPECT_TRUE(iter != retry_info.end());
117 } 117 }
118 118
119 TEST_F(ProxyResolvingClientSocketTest, ReusesHTTPAuthCache) {
120 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter(
121 new net::TestURLRequestContextGetter(
122 base::ThreadTaskRunnerHandle::Get(),
123 std::unique_ptr<net::TestURLRequestContext>(
124 new MyTestURLRequestContext)));
125 net::MockClientSocketFactory socket_factory;
126 net::HostPortPair dest("example.com", 443);
127
128 // What the client of the socket expects to read:
129 net::MockRead reads[] = {
130 net::MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"
131 "Proxy-Authenticate: Basic realm=\"test_realm\"\r\n"
132 "\r\n"),
133 net::MockRead("HTTP/1.1 200 Success\r\n\r\n")
134 };
135 // What the client of the socket should write:
136 net::MockWrite writes[] = {
137 net::MockWrite("CONNECT example.com:443 HTTP/1.1\r\n"
138 "Host: example.com:443\r\n"
139 "Proxy-Connection: keep-alive\r\n"
140 "\r\n"),
141 net::MockWrite("CONNECT example.com:443 HTTP/1.1\r\n"
142 "Host: example.com:443\r\n"
143 "Proxy-Authorization: dXNlcm5hbWU6cGFzc3dvcmQ=\r\n"
144 "Proxy-Connection: keep-alive\r\n"
145 "\r\n")
146 };
147 net::StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
148 arraysize(writes));
149 socket_data.set_connect_data(net::MockConnect(net::ASYNC, net::OK));
150 socket_factory.AddSocketDataProvider(&socket_data);
151
152 ProxyResolvingClientSocket proxy_resolving_socket(
153 &socket_factory,
154 url_request_context_getter,
155 net::SSLConfig(),
156 dest);
157
158 net::TestCompletionCallback callback;
159 int status = proxy_resolving_socket.Connect(callback.callback());
160 EXPECT_EQ(net::ERR_IO_PENDING, status);
161 status = callback.WaitForResult();
162 EXPECT_EQ(net::ERR_PROXY_AUTH_REQUESTED, status);
163
164 // TODO(cfredric): seed socket factory with credentials, verify that prcs
165 // sends those credentials on 407.
166 }
167
119 // TODO(sanjeevr): Add more unit-tests. 168 // TODO(sanjeevr): Add more unit-tests.
120 } // namespace jingle_glue 169 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « jingle/glue/proxy_resolving_client_socket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698