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

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

Issue 242135: Merge r25564 and r26588 from the trunk.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Undo an extraneous comment change Created 11 years, 2 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.cc ('k') | net/http/http_auth_handler_digest_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "net/http/http_auth_handler_basic.h" 8 #include "net/http/http_auth_handler_basic.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 TEST(HttpAuthHandlerBasicTest, GenerateCredentials) { 12 TEST(HttpAuthHandlerBasicTest, GenerateCredentials) {
13 static const struct { 13 static const struct {
14 const wchar_t* username; 14 const wchar_t* username;
15 const wchar_t* password; 15 const wchar_t* password;
16 const char* expected_credentials; 16 const char* expected_credentials;
17 } tests[] = { 17 } tests[] = {
18 { L"foo", L"bar", "Basic Zm9vOmJhcg==" }, 18 { L"foo", L"bar", "Basic Zm9vOmJhcg==" },
19 // Empty username 19 // Empty username
20 { L"", L"foobar", "Basic OmZvb2Jhcg==" }, 20 { L"", L"foobar", "Basic OmZvb2Jhcg==" },
21 // Empty password 21 // Empty password
22 { L"anon", L"", "Basic YW5vbjo=" }, 22 { L"anon", L"", "Basic YW5vbjo=" },
23 // Empty username and empty password. 23 // Empty username and empty password.
24 { L"", L"", "Basic Og==" }, 24 { L"", L"", "Basic Og==" },
25 }; 25 };
26 GURL origin("http://www.example.com");
26 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 27 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
27 std::string challenge = "Basic realm=\"Atlantis\""; 28 std::string challenge = "Basic realm=\"Atlantis\"";
28 scoped_refptr<HttpAuthHandlerBasic> basic = new HttpAuthHandlerBasic; 29 scoped_refptr<HttpAuthHandlerBasic> basic = new HttpAuthHandlerBasic;
29 basic->InitFromChallenge(challenge.begin(), challenge.end(), 30 basic->InitFromChallenge(challenge.begin(), challenge.end(),
30 HttpAuth::AUTH_SERVER); 31 HttpAuth::AUTH_SERVER, origin);
31 std::string credentials = basic->GenerateCredentials(tests[i].username, 32 std::string credentials = basic->GenerateCredentials(tests[i].username,
32 tests[i].password, 33 tests[i].password,
33 NULL, NULL); 34 NULL, NULL);
34 EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str()); 35 EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
35 } 36 }
36 } 37 }
37 38
38 } // namespace net 39 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler.cc ('k') | net/http/http_auth_handler_digest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698