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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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.cc ('k') | net/http/http_network_session.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.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"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/test_completion_callback.h"
12 #include "net/http/http_auth_challenge_tokenizer.h" 13 #include "net/http/http_auth_challenge_tokenizer.h"
13 #include "net/http/http_auth_handler_basic.h" 14 #include "net/http/http_auth_handler_basic.h"
14 #include "net/http/http_request_info.h" 15 #include "net/http/http_request_info.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 TEST(HttpAuthHandlerBasicTest, GenerateAuthToken) { 20 TEST(HttpAuthHandlerBasicTest, GenerateAuthToken) {
20 static const struct { 21 static const struct {
21 const char* username; 22 const char* username;
(...skipping 12 matching lines...) Expand all
34 HttpAuthHandlerBasic::Factory factory; 35 HttpAuthHandlerBasic::Factory factory;
35 for (size_t i = 0; i < arraysize(tests); ++i) { 36 for (size_t i = 0; i < arraysize(tests); ++i) {
36 std::string challenge = "Basic realm=\"Atlantis\""; 37 std::string challenge = "Basic realm=\"Atlantis\"";
37 scoped_ptr<HttpAuthHandler> basic; 38 scoped_ptr<HttpAuthHandler> basic;
38 EXPECT_EQ(OK, factory.CreateAuthHandlerFromString( 39 EXPECT_EQ(OK, factory.CreateAuthHandlerFromString(
39 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic)); 40 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic));
40 AuthCredentials credentials(base::ASCIIToUTF16(tests[i].username), 41 AuthCredentials credentials(base::ASCIIToUTF16(tests[i].username),
41 base::ASCIIToUTF16(tests[i].password)); 42 base::ASCIIToUTF16(tests[i].password));
42 HttpRequestInfo request_info; 43 HttpRequestInfo request_info;
43 std::string auth_token; 44 std::string auth_token;
45 TestCompletionCallback callback;
44 int rv = basic->GenerateAuthToken(&credentials, &request_info, 46 int rv = basic->GenerateAuthToken(&credentials, &request_info,
45 CompletionCallback(), &auth_token); 47 callback.callback(), &auth_token);
46 EXPECT_EQ(OK, rv); 48 EXPECT_EQ(OK, rv);
47 EXPECT_STREQ(tests[i].expected_credentials, auth_token.c_str()); 49 EXPECT_STREQ(tests[i].expected_credentials, auth_token.c_str());
48 } 50 }
49 } 51 }
50 52
51 TEST(HttpAuthHandlerBasicTest, HandleAnotherChallenge) { 53 TEST(HttpAuthHandlerBasicTest, HandleAnotherChallenge) {
52 static const struct { 54 static const struct {
53 const char* challenge; 55 const char* challenge;
54 HttpAuth::AuthorizationResult expected_rv; 56 HttpAuth::AuthorizationResult expected_rv;
55 } tests[] = { 57 } tests[] = {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 scoped_ptr<HttpAuthHandler> basic; 190 scoped_ptr<HttpAuthHandler> basic;
189 int rv = factory.CreateAuthHandlerFromString( 191 int rv = factory.CreateAuthHandlerFromString(
190 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic); 192 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic);
191 EXPECT_EQ(tests[i].expected_rv, rv); 193 EXPECT_EQ(tests[i].expected_rv, rv);
192 if (rv == OK) 194 if (rv == OK)
193 EXPECT_EQ(tests[i].expected_realm, basic->realm()); 195 EXPECT_EQ(tests[i].expected_realm, basic->realm());
194 } 196 }
195 } 197 }
196 198
197 } // namespace net 199 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler.cc ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698