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

Side by Side Diff: net/http/http_auth_handler_negotiate_unittest.cc

Issue 3013003: Don't do Negotiate with GSSAPI if default credentials are not allowed. (Closed)
Patch Set: Remove anonymous namespace to make OSX build. Created 10 years, 5 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_auth_handler_negotiate.cc ('k') | net/http/http_auth_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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_auth_handler_negotiate.h" 5 #include "net/http/http_auth_handler_negotiate.h"
6 6
7 #include "net/base/mock_host_resolver.h" 7 #include "net/base/mock_host_resolver.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/test_completion_callback.h" 9 #include "net/base/test_completion_callback.h"
10 #include "net/http/http_request_info.h" 10 #include "net/http/http_request_info.h"
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include "net/http/mock_sspi_library_win.h" 12 #include "net/http/mock_sspi_library_win.h"
13 #elif defined(OS_POSIX) 13 #elif defined(OS_POSIX)
14 #include "net/http/mock_gssapi_library_posix.h" 14 #include "net/http/mock_gssapi_library_posix.h"
15 #endif 15 #endif
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "testing/platform_test.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 typedef net::SSPILibrary SecureServicesLibrary; 20 typedef net::MockSSPILibrary MockAuthLibrary;
20 typedef net::MockSSPILibrary MockSecureServicesLibrary;
21 #elif defined(OS_POSIX) 21 #elif defined(OS_POSIX)
22 typedef net::GSSAPILibrary SecureServicesLibrary; 22 typedef net::test::MockGSSAPILibrary MockAuthLibrary;
23 typedef net::test::MockGSSAPILibrary MockSecureServicesLibrary;
24 #endif 23 #endif
25 24
26 25
27 namespace net { 26 namespace net {
28 27
29 namespace { 28 class HttpAuthHandlerNegotiateTest : public PlatformTest {
29 public:
30 virtual void SetUp() {
31 auth_library_.reset(new MockAuthLibrary());
32 SetupMocks(auth_library_.get());
33 resolver_ = new MockHostResolver();
34 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2",
35 "canonical.example.com");
30 36
31 void SetupTransactions(MockSecureServicesLibrary* mock_library) { 37 url_security_manager_.reset(new URLSecurityManagerAllow());
32 #if defined(OS_POSIX) 38 factory_.reset(new HttpAuthHandlerNegotiate::Factory());
33 // Copied from an actual transaction! 39 factory_->set_url_security_manager(url_security_manager_.get());
34 const char kAuthResponse[] = 40 factory_->set_library(auth_library_.get());
35 "\x60\x82\x02\xCA\x06\x09\x2A\x86\x48\x86\xF7\x12\x01\x02\x02\x01" 41 factory_->set_host_resolver(resolver_);
36 "\x00\x6E\x82\x02\xB9\x30\x82\x02\xB5\xA0\x03\x02\x01\x05\xA1\x03" 42 }
37 "\x02\x01\x0E\xA2\x07\x03\x05\x00\x00\x00\x00\x00\xA3\x82\x01\xC1"
38 "\x61\x82\x01\xBD\x30\x82\x01\xB9\xA0\x03\x02\x01\x05\xA1\x16\x1B"
39 "\x14\x55\x4E\x49\x58\x2E\x43\x4F\x52\x50\x2E\x47\x4F\x4F\x47\x4C"
40 "\x45\x2E\x43\x4F\x4D\xA2\x2C\x30\x2A\xA0\x03\x02\x01\x01\xA1\x23"
41 "\x30\x21\x1B\x04\x68\x6F\x73\x74\x1B\x19\x6E\x69\x6E\x6A\x61\x2E"
42 "\x63\x61\x6D\x2E\x63\x6F\x72\x70\x2E\x67\x6F\x6F\x67\x6C\x65\x2E"
43 "\x63\x6F\x6D\xA3\x82\x01\x6A\x30\x82\x01\x66\xA0\x03\x02\x01\x10"
44 "\xA1\x03\x02\x01\x01\xA2\x82\x01\x58\x04\x82\x01\x54\x2C\xB1\x2B"
45 "\x0A\xA5\xFF\x6F\xEC\xDE\xB0\x19\x6E\x15\x20\x18\x0C\x42\xB3\x2C"
46 "\x4B\xB0\x37\x02\xDE\xD3\x2F\xB4\xBF\xCA\xEC\x0E\xF9\xF3\x45\x6A"
47 "\x43\xF3\x8D\x79\xBD\xCB\xCD\xB2\x2B\xB8\xFC\xD6\xB4\x7F\x09\x48"
48 "\x14\xA7\x4F\xD2\xEE\xBC\x1B\x2F\x18\x3B\x81\x97\x7B\x28\xA4\xAF"
49 "\xA8\xA3\x7A\x31\x1B\xFC\x97\xB6\xBA\x8A\x50\x50\xD7\x44\xB8\x30"
50 "\xA4\x51\x4C\x3A\x95\x6C\xA1\xED\xE2\xEF\x17\xFE\xAB\xD2\xE4\x70"
51 "\xDE\xEB\x7E\x86\x48\xC5\x3E\x19\x5B\x83\x17\xBB\x52\x26\xC0\xF3"
52 "\x38\x0F\xB0\x8C\x72\xC9\xB0\x8B\x99\x96\x18\xE1\x9E\x67\x9D\xDC"
53 "\xF5\x39\x80\x70\x35\x3F\x98\x72\x16\x44\xA2\xC0\x10\xAA\x70\xBD"
54 "\x06\x6F\x83\xB1\xF4\x67\xA4\xBD\xDA\xF7\x79\x1D\x96\xB5\x7E\xF8"
55 "\xC6\xCF\xB4\xD9\x51\xC9\xBB\xB4\x20\x3C\xDD\xB9\x2C\x38\xEA\x40"
56 "\xFB\x02\x6C\xCB\x48\x71\xE8\xF4\x34\x5B\x63\x5D\x13\x57\xBD\xD1"
57 "\x3D\xDE\xE8\x4A\x51\x6E\xBE\x4C\xF5\xA3\x84\xF7\x4C\x4E\x58\x04"
58 "\xBE\xD1\xCC\x22\xA0\x43\xB0\x65\x99\x6A\xE0\x78\x0D\xFC\xE1\x42"
59 "\xA9\x18\xCF\x55\x4D\x23\xBD\x5C\x0D\xB5\x48\x25\x47\xCC\x01\x54"
60 "\x36\x4D\x0C\x6F\xAC\xCD\x33\x21\xC5\x63\x18\x91\x68\x96\xE9\xD1"
61 "\xD8\x23\x1F\x21\xAE\x96\xA3\xBD\x27\xF7\x4B\xEF\x4C\x43\xFF\xF8"
62 "\x22\x57\xCF\x68\x6C\x35\xD5\x21\x48\x5B\x5F\x8F\xA5\xB9\x6F\x99"
63 "\xA6\xE0\x6E\xF0\xC5\x7C\x91\xC8\x0B\x8A\x4B\x4E\x80\x59\x02\xE9"
64 "\xE8\x3F\x87\x04\xA6\xD1\xCA\x26\x3C\xF0\xDA\x57\xFA\xE6\xAF\x25"
65 "\x43\x34\xE1\xA4\x06\x1A\x1C\xF4\xF5\x21\x9C\x00\x98\xDD\xF0\xB4"
66 "\x8E\xA4\x81\xDA\x30\x81\xD7\xA0\x03\x02\x01\x10\xA2\x81\xCF\x04"
67 "\x81\xCC\x20\x39\x34\x60\x19\xF9\x4C\x26\x36\x46\x99\x7A\xFD\x2B"
68 "\x50\x8B\x2D\x47\x72\x38\x20\x43\x0E\x6E\x28\xB3\xA7\x4F\x26\xF1"
69 "\xF1\x7B\x02\x63\x58\x5A\x7F\xC8\xD0\x6E\xF5\xD1\xDA\x28\x43\x1B"
70 "\x6D\x9F\x59\x64\xDE\x90\xEA\x6C\x8C\xA9\x1B\x1E\x92\x29\x24\x23"
71 "\x2C\xE3\xEA\x64\xEF\x91\xA5\x4E\x94\xE1\xDC\x56\x3A\xAF\xD5\xBC"
72 "\xC9\xD3\x9B\x6B\x1F\xBE\x40\xE5\x40\xFF\x5E\x21\xEA\xCE\xFC\xD5"
73 "\xB0\xE5\xBA\x10\x94\xAE\x16\x54\xFC\xEB\xAB\xF1\xD4\x20\x31\xCC"
74 "\x26\xFE\xBE\xFE\x22\xB6\x9B\x1A\xE5\x55\x2C\x93\xB7\x3B\xD6\x4C"
75 "\x35\x35\xC1\x59\x61\xD4\x1F\x2E\x4C\xE1\x72\x8F\x71\x4B\x0C\x39"
76 "\x80\x79\xFA\xCD\xEA\x71\x1B\xAE\x35\x41\xED\xF9\x65\x0C\x59\xF8"
77 "\xE1\x27\xDA\xD6\xD1\x20\x32\xCD\xBF\xD1\xEF\xE2\xED\xAD\x5D\xA7"
78 "\x69\xE3\x55\xF9\x30\xD3\xD4\x08\xC8\xCA\x62\xF8\x64\xEC\x9B\x92"
79 "\x1A\xF1\x03\x2E\xCC\xDC\xEB\x17\xDE\x09\xAC\xA9\x58\x86";
80 test::GssContextMockImpl context1(
81 "localhost", // Source name
82 "example.com", // Target name
83 23, // Lifetime
84 *GSS_C_NT_HOSTBASED_SERVICE, // Mechanism
85 0, // Context flags
86 1, // Locally initiated
87 0); // Open
88 test::GssContextMockImpl context2(
89 "localhost", // Source name
90 "example.com", // Target name
91 23, // Lifetime
92 *GSS_C_NT_HOSTBASED_SERVICE, // Mechanism
93 0, // Context flags
94 1, // Locally initiated
95 1); // Open
96 test::MockGSSAPILibrary::SecurityContextQuery queries[] = {
97 { "Negotiate", // Package name
98 GSS_S_CONTINUE_NEEDED, // Major response code
99 0, // Minor response code
100 context1, // Context
101 { 0, NULL }, // Expected input token
102 { arraysize(kAuthResponse),
103 const_cast<char*>(kAuthResponse) } // Output token
104 },
105 { "Negotiate", // Package name
106 GSS_S_COMPLETE, // Major response code
107 0, // Minor response code
108 context2, // Context
109 { arraysize(kAuthResponse),
110 const_cast<char*>(kAuthResponse) }, // Expected input token
111 { arraysize(kAuthResponse),
112 const_cast<char*>(kAuthResponse) } // Output token
113 },
114 };
115 43
116 size_t i; 44 void SetupMocks(MockAuthLibrary* mock_library) {
117 for (i = 0; i < arraysize(queries); ++i) { 45 #if defined(OS_WIN)
118 mock_library->ExpectSecurityContext(queries[i].expected_package, 46 security_package_.reset(new SecPkgInfoW);
119 queries[i].response_code, 47 memset(security_package_.get(), 0x0, sizeof(SecPkgInfoW));
120 queries[i].minor_response_code, 48 security_package_->cbMaxToken = 1337;
121 queries[i].context_info, 49 mock_library->ExpectQuerySecurityPackageInfo(
122 queries[i].expected_input_token, 50 L"Negotiate", SEC_E_OK, security_package_.get());
123 queries[i].output_token); 51 #elif defined(OS_POSIX)
52 // Copied from an actual transaction!
53 const char kAuthResponse[] =
54 "\x60\x82\x02\xCA\x06\x09\x2A\x86\x48\x86\xF7\x12\x01\x02\x02\x01"
55 "\x00\x6E\x82\x02\xB9\x30\x82\x02\xB5\xA0\x03\x02\x01\x05\xA1\x03"
56 "\x02\x01\x0E\xA2\x07\x03\x05\x00\x00\x00\x00\x00\xA3\x82\x01\xC1"
57 "\x61\x82\x01\xBD\x30\x82\x01\xB9\xA0\x03\x02\x01\x05\xA1\x16\x1B"
58 "\x14\x55\x4E\x49\x58\x2E\x43\x4F\x52\x50\x2E\x47\x4F\x4F\x47\x4C"
59 "\x45\x2E\x43\x4F\x4D\xA2\x2C\x30\x2A\xA0\x03\x02\x01\x01\xA1\x23"
60 "\x30\x21\x1B\x04\x68\x6F\x73\x74\x1B\x19\x6E\x69\x6E\x6A\x61\x2E"
61 "\x63\x61\x6D\x2E\x63\x6F\x72\x70\x2E\x67\x6F\x6F\x67\x6C\x65\x2E"
62 "\x63\x6F\x6D\xA3\x82\x01\x6A\x30\x82\x01\x66\xA0\x03\x02\x01\x10"
63 "\xA1\x03\x02\x01\x01\xA2\x82\x01\x58\x04\x82\x01\x54\x2C\xB1\x2B"
64 "\x0A\xA5\xFF\x6F\xEC\xDE\xB0\x19\x6E\x15\x20\x18\x0C\x42\xB3\x2C"
65 "\x4B\xB0\x37\x02\xDE\xD3\x2F\xB4\xBF\xCA\xEC\x0E\xF9\xF3\x45\x6A"
66 "\x43\xF3\x8D\x79\xBD\xCB\xCD\xB2\x2B\xB8\xFC\xD6\xB4\x7F\x09\x48"
67 "\x14\xA7\x4F\xD2\xEE\xBC\x1B\x2F\x18\x3B\x81\x97\x7B\x28\xA4\xAF"
68 "\xA8\xA3\x7A\x31\x1B\xFC\x97\xB6\xBA\x8A\x50\x50\xD7\x44\xB8\x30"
69 "\xA4\x51\x4C\x3A\x95\x6C\xA1\xED\xE2\xEF\x17\xFE\xAB\xD2\xE4\x70"
70 "\xDE\xEB\x7E\x86\x48\xC5\x3E\x19\x5B\x83\x17\xBB\x52\x26\xC0\xF3"
71 "\x38\x0F\xB0\x8C\x72\xC9\xB0\x8B\x99\x96\x18\xE1\x9E\x67\x9D\xDC"
72 "\xF5\x39\x80\x70\x35\x3F\x98\x72\x16\x44\xA2\xC0\x10\xAA\x70\xBD"
73 "\x06\x6F\x83\xB1\xF4\x67\xA4\xBD\xDA\xF7\x79\x1D\x96\xB5\x7E\xF8"
74 "\xC6\xCF\xB4\xD9\x51\xC9\xBB\xB4\x20\x3C\xDD\xB9\x2C\x38\xEA\x40"
75 "\xFB\x02\x6C\xCB\x48\x71\xE8\xF4\x34\x5B\x63\x5D\x13\x57\xBD\xD1"
76 "\x3D\xDE\xE8\x4A\x51\x6E\xBE\x4C\xF5\xA3\x84\xF7\x4C\x4E\x58\x04"
77 "\xBE\xD1\xCC\x22\xA0\x43\xB0\x65\x99\x6A\xE0\x78\x0D\xFC\xE1\x42"
78 "\xA9\x18\xCF\x55\x4D\x23\xBD\x5C\x0D\xB5\x48\x25\x47\xCC\x01\x54"
79 "\x36\x4D\x0C\x6F\xAC\xCD\x33\x21\xC5\x63\x18\x91\x68\x96\xE9\xD1"
80 "\xD8\x23\x1F\x21\xAE\x96\xA3\xBD\x27\xF7\x4B\xEF\x4C\x43\xFF\xF8"
81 "\x22\x57\xCF\x68\x6C\x35\xD5\x21\x48\x5B\x5F\x8F\xA5\xB9\x6F\x99"
82 "\xA6\xE0\x6E\xF0\xC5\x7C\x91\xC8\x0B\x8A\x4B\x4E\x80\x59\x02\xE9"
83 "\xE8\x3F\x87\x04\xA6\xD1\xCA\x26\x3C\xF0\xDA\x57\xFA\xE6\xAF\x25"
84 "\x43\x34\xE1\xA4\x06\x1A\x1C\xF4\xF5\x21\x9C\x00\x98\xDD\xF0\xB4"
85 "\x8E\xA4\x81\xDA\x30\x81\xD7\xA0\x03\x02\x01\x10\xA2\x81\xCF\x04"
86 "\x81\xCC\x20\x39\x34\x60\x19\xF9\x4C\x26\x36\x46\x99\x7A\xFD\x2B"
87 "\x50\x8B\x2D\x47\x72\x38\x20\x43\x0E\x6E\x28\xB3\xA7\x4F\x26\xF1"
88 "\xF1\x7B\x02\x63\x58\x5A\x7F\xC8\xD0\x6E\xF5\xD1\xDA\x28\x43\x1B"
89 "\x6D\x9F\x59\x64\xDE\x90\xEA\x6C\x8C\xA9\x1B\x1E\x92\x29\x24\x23"
90 "\x2C\xE3\xEA\x64\xEF\x91\xA5\x4E\x94\xE1\xDC\x56\x3A\xAF\xD5\xBC"
91 "\xC9\xD3\x9B\x6B\x1F\xBE\x40\xE5\x40\xFF\x5E\x21\xEA\xCE\xFC\xD5"
92 "\xB0\xE5\xBA\x10\x94\xAE\x16\x54\xFC\xEB\xAB\xF1\xD4\x20\x31\xCC"
93 "\x26\xFE\xBE\xFE\x22\xB6\x9B\x1A\xE5\x55\x2C\x93\xB7\x3B\xD6\x4C"
94 "\x35\x35\xC1\x59\x61\xD4\x1F\x2E\x4C\xE1\x72\x8F\x71\x4B\x0C\x39"
95 "\x80\x79\xFA\xCD\xEA\x71\x1B\xAE\x35\x41\xED\xF9\x65\x0C\x59\xF8"
96 "\xE1\x27\xDA\xD6\xD1\x20\x32\xCD\xBF\xD1\xEF\xE2\xED\xAD\x5D\xA7"
97 "\x69\xE3\x55\xF9\x30\xD3\xD4\x08\xC8\xCA\x62\xF8\x64\xEC\x9B\x92"
98 "\x1A\xF1\x03\x2E\xCC\xDC\xEB\x17\xDE\x09\xAC\xA9\x58\x86";
99 test::GssContextMockImpl context1(
100 "localhost", // Source name
101 "example.com", // Target name
102 23, // Lifetime
103 *GSS_C_NT_HOSTBASED_SERVICE, // Mechanism
104 0, // Context flags
105 1, // Locally initiated
106 0); // Open
107 test::GssContextMockImpl context2(
108 "localhost", // Source name
109 "example.com", // Target name
110 23, // Lifetime
111 *GSS_C_NT_HOSTBASED_SERVICE, // Mechanism
112 0, // Context flags
113 1, // Locally initiated
114 1); // Open
115 test::MockGSSAPILibrary::SecurityContextQuery queries[] = {
116 { "Negotiate", // Package name
117 GSS_S_CONTINUE_NEEDED, // Major response code
118 0, // Minor response code
119 context1, // Context
120 { 0, NULL }, // Expected input token
121 { arraysize(kAuthResponse),
122 const_cast<char*>(kAuthResponse) } // Output token
123 },
124 { "Negotiate", // Package name
125 GSS_S_COMPLETE, // Major response code
126 0, // Minor response code
127 context2, // Context
128 { arraysize(kAuthResponse),
129 const_cast<char*>(kAuthResponse) }, // Expected input token
130 { arraysize(kAuthResponse),
131 const_cast<char*>(kAuthResponse) } // Output token
132 },
133 };
134
135 size_t i;
136 for (i = 0; i < arraysize(queries); ++i) {
137 mock_library->ExpectSecurityContext(queries[i].expected_package,
138 queries[i].response_code,
139 queries[i].minor_response_code,
140 queries[i].context_info,
141 queries[i].expected_input_token,
142 queries[i].output_token);
143 }
144 #endif // defined(OS_POSIX)
124 } 145 }
125 #endif // defined(OS_POSIX)
126 }
127 146
128 void CreateHandler(bool disable_cname_lookup, bool include_port, 147 int CreateHandler(bool disable_cname_lookup, bool use_port,
129 bool synchronous_resolve_mode, 148 bool synchronous_resolve_mode,
130 const std::string& url_string, 149 const std::string& url_string,
131 SecureServicesLibrary* secure_services_library, 150 scoped_ptr<HttpAuthHandlerNegotiate>* handler) {
132 scoped_ptr<HttpAuthHandlerNegotiate>* handler) { 151 factory_->set_disable_cname_lookup(disable_cname_lookup);
133 // Create a MockHostResolver - this will be referenced by the 152 factory_->set_use_port(use_port);
134 // handler (and be destroyed when the handler goes away since it holds 153 resolver_->set_synchronous_mode(synchronous_resolve_mode);
135 // the only reference). 154 GURL gurl(url_string);
136 MockHostResolver* mock_resolver = new MockHostResolver(); 155
137 scoped_refptr<HostResolver> resolver(mock_resolver); 156 // Note: This is a little tricky because CreateAuthHandlerFromString
138 mock_resolver->set_synchronous_mode(synchronous_resolve_mode); 157 // expects a scoped_ptr<HttpAuthHandler>* rather than a
139 mock_resolver->rules()->AddIPLiteralRule("alias", "10.0.0.2", 158 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast
140 "canonical.example.com"); 159 // after creating the handler, and make sure that generic_handler
141 handler->reset(new HttpAuthHandlerNegotiate(secure_services_library, 160 // no longer holds on to the HttpAuthHandlerNegotiate object.
161 scoped_ptr<HttpAuthHandler> generic_handler;
162 int rv = factory_->CreateAuthHandlerFromString("Negotiate",
163 HttpAuth::AUTH_SERVER,
164 gurl,
165 BoundNetLog(),
166 &generic_handler);
167 if (rv != OK)
168 return rv;
169 HttpAuthHandlerNegotiate* negotiate_handler =
170 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release());
171 handler->reset(negotiate_handler);
172 return rv;
173 }
174
175 private:
142 #if defined(OS_WIN) 176 #if defined(OS_WIN)
143 50, // Max token length (windows) 177 scoped_ptr<SecPkgInfoW> security_package_;
144 #endif 178 #endif
145 NULL, 179 scoped_ptr<MockAuthLibrary> auth_library_;
146 mock_resolver, 180 scoped_refptr<MockHostResolver> resolver_;
147 disable_cname_lookup, 181 scoped_ptr<URLSecurityManager> url_security_manager_;
148 include_port)); 182 scoped_ptr<HttpAuthHandlerNegotiate::Factory> factory_;
149 std::string challenge = "Negotiate"; 183 };
150 HttpAuth::ChallengeTokenizer props(challenge.begin(), challenge.end());
151 GURL gurl(url_string);
152 (*handler)->InitFromChallenge(&props, HttpAuth::AUTH_SERVER, gurl,
153 BoundNetLog());
154 }
155 184
156 } // namespace 185 TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) {
186 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
187 EXPECT_EQ(OK, CreateHandler(
188 true, false, true, "http://alias:500", &auth_handler));
157 189
158 TEST(HttpAuthHandlerNegotiateTest, DisableCname) {
159 MockSecureServicesLibrary mock_library;
160 SetupTransactions(&mock_library);
161 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
162 CreateHandler(true, false, true, "http://alias:500",
163 &mock_library, &auth_handler);
164 ASSERT_TRUE(auth_handler.get() != NULL); 190 ASSERT_TRUE(auth_handler.get() != NULL);
165 TestCompletionCallback callback; 191 TestCompletionCallback callback;
166 HttpRequestInfo request_info; 192 HttpRequestInfo request_info;
167 std::string token; 193 std::string token;
168 std::wstring username = L"foo"; 194 std::wstring username = L"foo";
169 std::wstring password = L"bar"; 195 std::wstring password = L"bar";
170 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, 196 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password,
171 &request_info, 197 &request_info,
172 &callback, &token)); 198 &callback, &token));
173 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); 199 EXPECT_EQ(L"HTTP/alias", auth_handler->spn());
174 } 200 }
175 201
176 TEST(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) { 202 TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) {
177 MockSecureServicesLibrary mock_library;
178 SetupTransactions(&mock_library);
179 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 203 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
180 CreateHandler(true, true, true, 204 EXPECT_EQ(OK, CreateHandler(
181 "http://alias:80", &mock_library, &auth_handler); 205 true, true, true, "http://alias:80", &auth_handler));
182 ASSERT_TRUE(auth_handler.get() != NULL); 206 ASSERT_TRUE(auth_handler.get() != NULL);
183 TestCompletionCallback callback; 207 TestCompletionCallback callback;
184 HttpRequestInfo request_info; 208 HttpRequestInfo request_info;
185 std::string token; 209 std::string token;
186 std::wstring username = L"foo"; 210 std::wstring username = L"foo";
187 std::wstring password = L"bar"; 211 std::wstring password = L"bar";
188 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, 212 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password,
189 &request_info, 213 &request_info,
190 &callback, &token)); 214 &callback, &token));
191 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); 215 EXPECT_EQ(L"HTTP/alias", auth_handler->spn());
192 } 216 }
193 217
194 TEST(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) { 218 TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) {
195 MockSecureServicesLibrary mock_library;
196 SetupTransactions(&mock_library);
197 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 219 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
198 CreateHandler(true, true, true, 220 EXPECT_EQ(OK, CreateHandler(
199 "http://alias:500", &mock_library, &auth_handler); 221 true, true, true, "http://alias:500", &auth_handler));
200 ASSERT_TRUE(auth_handler.get() != NULL); 222 ASSERT_TRUE(auth_handler.get() != NULL);
201 TestCompletionCallback callback; 223 TestCompletionCallback callback;
202 HttpRequestInfo request_info; 224 HttpRequestInfo request_info;
203 std::string token; 225 std::string token;
204 std::wstring username = L"foo"; 226 std::wstring username = L"foo";
205 std::wstring password = L"bar"; 227 std::wstring password = L"bar";
206 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, 228 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password,
207 &request_info, 229 &request_info,
208 &callback, &token)); 230 &callback, &token));
209 EXPECT_EQ(L"HTTP/alias:500", auth_handler->spn()); 231 EXPECT_EQ(L"HTTP/alias:500", auth_handler->spn());
210 } 232 }
211 233
212 TEST(HttpAuthHandlerNegotiateTest, CnameSync) { 234 TEST_F(HttpAuthHandlerNegotiateTest, CnameSync) {
213 MockSecureServicesLibrary mock_library;
214 SetupTransactions(&mock_library);
215 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 235 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
216 CreateHandler(false, false, true, 236 EXPECT_EQ(OK, CreateHandler(
217 "http://alias:500", &mock_library, &auth_handler); 237 false, false, true, "http://alias:500", &auth_handler));
218 ASSERT_TRUE(auth_handler.get() != NULL); 238 ASSERT_TRUE(auth_handler.get() != NULL);
219 TestCompletionCallback callback; 239 TestCompletionCallback callback;
220 HttpRequestInfo request_info; 240 HttpRequestInfo request_info;
221 std::string token; 241 std::string token;
222 std::wstring username = L"foo"; 242 std::wstring username = L"foo";
223 std::wstring password = L"bar"; 243 std::wstring password = L"bar";
224 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, 244 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password,
225 &request_info, 245 &request_info,
226 &callback, &token)); 246 &callback, &token));
227 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); 247 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn());
228 } 248 }
229 249
230 TEST(HttpAuthHandlerNegotiateTest, CnameAsync) { 250 TEST_F(HttpAuthHandlerNegotiateTest, CnameAsync) {
231 MockSecureServicesLibrary mock_library;
232 SetupTransactions(&mock_library);
233 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 251 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
234 CreateHandler(false, false, false, 252 EXPECT_EQ(OK, CreateHandler(
235 "http://alias:500", &mock_library, &auth_handler); 253 false, false, false, "http://alias:500", &auth_handler));
236 ASSERT_TRUE(auth_handler.get() != NULL); 254 ASSERT_TRUE(auth_handler.get() != NULL);
237 TestCompletionCallback callback; 255 TestCompletionCallback callback;
238 HttpRequestInfo request_info; 256 HttpRequestInfo request_info;
239 std::string token; 257 std::string token;
240 std::wstring username = L"foo"; 258 std::wstring username = L"foo";
241 std::wstring password = L"bar"; 259 std::wstring password = L"bar";
242 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( 260 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken(
243 &username, &password, &request_info, &callback, &token)); 261 &username, &password, &request_info, &callback, &token));
244 EXPECT_EQ(OK, callback.WaitForResult()); 262 EXPECT_EQ(OK, callback.WaitForResult());
245 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); 263 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn());
246 } 264 }
247 265
248 } // namespace net 266 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_negotiate.cc ('k') | net/http/http_auth_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698