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

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

Issue 8863: Add some extra unit-tests to make sure we cover all permutations of {basic_au... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 password 19 // Empty password
20 { L"anon", L"", "Basic YW5vbjo=" }, 20 { L"anon", L"", "Basic YW5vbjo=" },
21 // Empty username and empty password.
22 { L"", L"", "Basic Og==" },
21 }; 23 };
22 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 24 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
23 std::string challenge = "Basic realm=\"Atlantis\""; 25 std::string challenge = "Basic realm=\"Atlantis\"";
24 HttpAuthHandlerBasic basic; 26 HttpAuthHandlerBasic basic;
25 basic.InitFromChallenge(challenge.begin(), challenge.end(), 27 basic.InitFromChallenge(challenge.begin(), challenge.end(),
26 HttpAuth::AUTH_SERVER); 28 HttpAuth::AUTH_SERVER);
27 std::string credentials = basic.GenerateCredentials(tests[i].username, 29 std::string credentials = basic.GenerateCredentials(tests[i].username,
28 tests[i].password, 30 tests[i].password,
29 NULL, NULL); 31 NULL, NULL);
30 EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str()); 32 EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
31 } 33 }
32 } 34 }
33 35
34 } // namespace net 36 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth_handler_digest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698