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

Side by Side Diff: net/url_request/url_request_context_builder_unittest.cc

Issue 1408433006: Support tls-server-end-point channel bindings for HTTP authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Narrower dependencies, update comments, address review comments. Created 4 years, 9 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/url_request/url_request_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "net/base/request_priority.h" 9 #include "net/base/request_priority.h"
10 #include "net/http/http_auth_challenge_tokenizer.h" 10 #include "net/http/http_auth_challenge_tokenizer.h"
11 #include "net/http/http_auth_handler.h" 11 #include "net/http/http_auth_handler.h"
12 #include "net/http/http_auth_handler_factory.h" 12 #include "net/http/http_auth_handler_factory.h"
13 #include "net/ssl/ssl_info.h"
13 #include "net/test/embedded_test_server/embedded_test_server.h" 14 #include "net/test/embedded_test_server/embedded_test_server.h"
14 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
15 #include "net/url_request/url_request_test_util.h" 16 #include "net/url_request/url_request_test_util.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
18 19
19 #if defined(OS_LINUX) || defined(OS_ANDROID) 20 #if defined(OS_LINUX) || defined(OS_ANDROID)
20 #include "net/proxy/proxy_config.h" 21 #include "net/proxy/proxy_config.h"
21 #include "net/proxy/proxy_config_service_fixed.h" 22 #include "net/proxy/proxy_config_service_fixed.h"
22 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 23 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
23 24
24 namespace net { 25 namespace net {
25 26
26 namespace { 27 namespace {
27 28
28 class MockHttpAuthHandlerFactory : public HttpAuthHandlerFactory { 29 class MockHttpAuthHandlerFactory : public HttpAuthHandlerFactory {
29 public: 30 public:
30 MockHttpAuthHandlerFactory(std::string supported_scheme, int return_code) 31 MockHttpAuthHandlerFactory(std::string supported_scheme, int return_code)
31 : return_code_(return_code), supported_scheme_(supported_scheme) {} 32 : return_code_(return_code), supported_scheme_(supported_scheme) {}
32 ~MockHttpAuthHandlerFactory() override {} 33 ~MockHttpAuthHandlerFactory() override {}
33 34
34 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, 35 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge,
35 HttpAuth::Target target, 36 HttpAuth::Target target,
37 const SSLInfo& ssl_info,
36 const GURL& origin, 38 const GURL& origin,
37 CreateReason reason, 39 CreateReason reason,
38 int nonce_count, 40 int nonce_count,
39 const BoundNetLog& net_log, 41 const BoundNetLog& net_log,
40 scoped_ptr<HttpAuthHandler>* handler) override { 42 scoped_ptr<HttpAuthHandler>* handler) override {
41 handler->reset(); 43 handler->reset();
42 44
43 return challenge->scheme() == supported_scheme_ 45 return challenge->scheme() == supported_scheme_
44 ? return_code_ 46 ? return_code_
45 : ERR_UNSUPPORTED_AUTH_SCHEME; 47 : ERR_UNSUPPORTED_AUTH_SCHEME;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 request->set_method("GET"); 93 request->set_method("GET");
92 request->Start(); 94 request->Start();
93 base::MessageLoop::current()->Run(); 95 base::MessageLoop::current()->Run();
94 EXPECT_EQ("Bar", delegate.data_received()); 96 EXPECT_EQ("Bar", delegate.data_received());
95 } 97 }
96 98
97 TEST_F(URLRequestContextBuilderTest, DefaultHttpAuthHandlerFactory) { 99 TEST_F(URLRequestContextBuilderTest, DefaultHttpAuthHandlerFactory) {
98 GURL gurl("www.google.com"); 100 GURL gurl("www.google.com");
99 scoped_ptr<HttpAuthHandler> handler; 101 scoped_ptr<HttpAuthHandler> handler;
100 scoped_ptr<URLRequestContext> context(builder_.Build()); 102 scoped_ptr<URLRequestContext> context(builder_.Build());
103 SSLInfo null_ssl_info;
101 104
102 // Verify that the default basic handler is present 105 // Verify that the default basic handler is present
103 EXPECT_EQ(OK, 106 EXPECT_EQ(OK,
104 context->http_auth_handler_factory()->CreateAuthHandlerFromString( 107 context->http_auth_handler_factory()->CreateAuthHandlerFromString(
105 "basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); 108 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl,
109 BoundNetLog(), &handler));
106 } 110 }
107 111
108 TEST_F(URLRequestContextBuilderTest, CustomHttpAuthHandlerFactory) { 112 TEST_F(URLRequestContextBuilderTest, CustomHttpAuthHandlerFactory) {
109 GURL gurl("www.google.com"); 113 GURL gurl("www.google.com");
110 const int kBasicReturnCode = OK; 114 const int kBasicReturnCode = OK;
111 scoped_ptr<HttpAuthHandler> handler; 115 scoped_ptr<HttpAuthHandler> handler;
112 builder_.SetHttpAuthHandlerFactory(make_scoped_ptr( 116 builder_.SetHttpAuthHandlerFactory(make_scoped_ptr(
113 new MockHttpAuthHandlerFactory("ExtraScheme", kBasicReturnCode))); 117 new MockHttpAuthHandlerFactory("ExtraScheme", kBasicReturnCode)));
114 scoped_ptr<URLRequestContext> context(builder_.Build()); 118 scoped_ptr<URLRequestContext> context(builder_.Build());
119 SSLInfo null_ssl_info;
115 // Verify that a handler is returned for a custom scheme. 120 // Verify that a handler is returned for a custom scheme.
116 EXPECT_EQ(kBasicReturnCode, 121 EXPECT_EQ(kBasicReturnCode,
117 context->http_auth_handler_factory()->CreateAuthHandlerFromString( 122 context->http_auth_handler_factory()->CreateAuthHandlerFromString(
118 "ExtraScheme", 123 "ExtraScheme", HttpAuth::AUTH_SERVER, null_ssl_info, gurl,
119 HttpAuth::AUTH_SERVER, 124 BoundNetLog(), &handler));
120 gurl,
121 BoundNetLog(),
122 &handler));
123 125
124 // Verify that the default basic handler isn't present 126 // Verify that the default basic handler isn't present
125 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, 127 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME,
126 context->http_auth_handler_factory()->CreateAuthHandlerFromString( 128 context->http_auth_handler_factory()->CreateAuthHandlerFromString(
127 "basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); 129 "basic", HttpAuth::AUTH_SERVER, null_ssl_info, gurl,
130 BoundNetLog(), &handler));
128 131
129 // Verify that a handler isn't returned for a bogus scheme. 132 // Verify that a handler isn't returned for a bogus scheme.
130 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, 133 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME,
131 context->http_auth_handler_factory()->CreateAuthHandlerFromString( 134 context->http_auth_handler_factory()->CreateAuthHandlerFromString(
132 "Bogus", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); 135 "Bogus", HttpAuth::AUTH_SERVER, null_ssl_info, gurl,
136 BoundNetLog(), &handler));
133 } 137 }
134 138
135 } // namespace 139 } // namespace
136 140
137 } // namespace net 141 } // namespace net
OLDNEW
« net/cert/x509_util_openssl.cc ('K') | « net/log/net_log_event_type_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698