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

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

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_handler_digest.cc ('k') | net/http/http_auth_handler_ntlm_portable.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) 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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return false; 60 return false;
61 } 61 }
62 62
63 // Create a token in response to the challenge. 63 // Create a token in response to the challenge.
64 // NOTE: HttpAuthHandlerDigest's implementation of GenerateAuthToken always 64 // NOTE: HttpAuthHandlerDigest's implementation of GenerateAuthToken always
65 // completes synchronously. That's why this test can get away with a 65 // completes synchronously. That's why this test can get away with a
66 // TestCompletionCallback without an IO thread. 66 // TestCompletionCallback without an IO thread.
67 TestCompletionCallback callback; 67 TestCompletionCallback callback;
68 scoped_ptr<HttpRequestInfo> request(new HttpRequestInfo()); 68 scoped_ptr<HttpRequestInfo> request(new HttpRequestInfo());
69 request->url = GURL(request_url); 69 request->url = GURL(request_url);
70 AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar")); 70 AuthCredentials credentials(base::ASCIIToUTF16("foo"),
71 base::ASCIIToUTF16("bar"));
71 int rv_generate = handler->GenerateAuthToken( 72 int rv_generate = handler->GenerateAuthToken(
72 &credentials, request.get(), callback.callback(), token); 73 &credentials, request.get(), callback.callback(), token);
73 if (rv_generate != OK) { 74 if (rv_generate != OK) {
74 ADD_FAILURE() << "Problems generating auth token"; 75 ADD_FAILURE() << "Problems generating auth token";
75 return false; 76 return false;
76 } 77 }
77 78
78 return true; 79 return true;
79 } 80 }
80 81
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 &handler); 524 &handler);
524 EXPECT_EQ(OK, rv); 525 EXPECT_EQ(OK, rv);
525 ASSERT_TRUE(handler != NULL); 526 ASSERT_TRUE(handler != NULL);
526 527
527 HttpAuthHandlerDigest* digest = 528 HttpAuthHandlerDigest* digest =
528 static_cast<HttpAuthHandlerDigest*>(handler.get()); 529 static_cast<HttpAuthHandlerDigest*>(handler.get());
529 std::string creds = 530 std::string creds =
530 digest->AssembleCredentials(tests[i].req_method, 531 digest->AssembleCredentials(tests[i].req_method,
531 tests[i].req_path, 532 tests[i].req_path,
532 AuthCredentials( 533 AuthCredentials(
533 ASCIIToUTF16(tests[i].username), 534 base::ASCIIToUTF16(tests[i].username),
534 ASCIIToUTF16(tests[i].password)), 535 base::ASCIIToUTF16(tests[i].password)),
535 tests[i].cnonce, 536 tests[i].cnonce,
536 tests[i].nonce_count); 537 tests[i].nonce_count);
537 538
538 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); 539 EXPECT_STREQ(tests[i].expected_creds, creds.c_str());
539 } 540 }
540 } 541 }
541 542
542 TEST(HttpAuthHandlerDigest, HandleAnotherChallenge) { 543 TEST(HttpAuthHandlerDigest, HandleAnotherChallenge) {
543 scoped_ptr<HttpAuthHandlerDigest::Factory> factory( 544 scoped_ptr<HttpAuthHandlerDigest::Factory> factory(
544 new HttpAuthHandlerDigest::Factory()); 545 new HttpAuthHandlerDigest::Factory());
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 EXPECT_EQ("Digest username=\"foo\", realm=\"Oblivion\", " 688 EXPECT_EQ("Digest username=\"foo\", realm=\"Oblivion\", "
688 "nonce=\"nonce-value\", uri=\"/path/to/resource\", " 689 "nonce=\"nonce-value\", uri=\"/path/to/resource\", "
689 "response=\"5b1459beda5cee30d6ff9e970a69c0ea\", " 690 "response=\"5b1459beda5cee30d6ff9e970a69c0ea\", "
690 "opaque=\"opaque text\", " 691 "opaque=\"opaque text\", "
691 "qop=auth, nc=00000001, cnonce=\"client_nonce\"", 692 "qop=auth, nc=00000001, cnonce=\"client_nonce\"",
692 auth_token); 693 auth_token);
693 } 694 }
694 695
695 696
696 } // namespace net 697 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_digest.cc ('k') | net/http/http_auth_handler_ntlm_portable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698