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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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_cache_unittest.cc ('k') | net/http/http_auth_gssapi_posix_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) 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 <ostream> 5 #include <ostream>
6 6
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/http/http_auth_filter.h" 10 #include "net/http/http_auth_filter.h"
(...skipping 17 matching lines...) Expand all
28 }; 28 };
29 29
30 struct UrlData { 30 struct UrlData {
31 GURL url; 31 GURL url;
32 HttpAuth::Target target; 32 HttpAuth::Target target;
33 bool matches; 33 bool matches;
34 int match_bits; 34 int match_bits;
35 }; 35 };
36 36
37 static const UrlData urls[] = { 37 static const UrlData urls[] = {
38 { GURL(""), 38 { GURL(std::string()), HttpAuth::AUTH_NONE, false, 0 },
39 HttpAuth::AUTH_NONE, false, 0 }, 39 { GURL("http://foo.cn"), HttpAuth::AUTH_PROXY, true, ALL_SERVERS_MATCH },
40 { GURL("http://foo.cn"), 40 { GURL("http://foo.cn"), HttpAuth::AUTH_SERVER, false, 0 },
41 HttpAuth::AUTH_PROXY, true, ALL_SERVERS_MATCH }, 41 { GURL("http://slashdot.org"), HttpAuth::AUTH_NONE, false, 0 },
42 { GURL("http://foo.cn"), 42 { GURL("http://www.google.com"), HttpAuth::AUTH_SERVER, true, 1 << 0 },
43 HttpAuth::AUTH_SERVER, false, 0 }, 43 { GURL("http://www.google.com"), HttpAuth::AUTH_PROXY, true,
44 { GURL("http://slashdot.org"), 44 ALL_SERVERS_MATCH },
45 HttpAuth::AUTH_NONE, false, 0 },
46 { GURL("http://www.google.com"),
47 HttpAuth::AUTH_SERVER, true, 1 << 0 },
48 { GURL("http://www.google.com"),
49 HttpAuth::AUTH_PROXY, true, ALL_SERVERS_MATCH },
50 { GURL("https://login.facebook.com/login.php?login_attempt=1"), 45 { GURL("https://login.facebook.com/login.php?login_attempt=1"),
51 HttpAuth::AUTH_NONE, false, 0 }, 46 HttpAuth::AUTH_NONE, false, 0 },
52 { GURL("http://codereview.chromium.org/634002/show"), 47 { GURL("http://codereview.chromium.org/634002/show"), HttpAuth::AUTH_SERVER,
53 HttpAuth::AUTH_SERVER, true, 1 << 3 }, 48 true, 1 << 3 },
54 { GURL("http://code.google.com/p/chromium/issues/detail?id=34505"), 49 { GURL("http://code.google.com/p/chromium/issues/detail?id=34505"),
55 HttpAuth::AUTH_SERVER, true, 1 << 0 }, 50 HttpAuth::AUTH_SERVER, true, 1 << 0 },
56 { GURL("http://code.google.com/p/chromium/issues/list?can=2&q=label:" 51 { GURL("http://code.google.com/p/chromium/issues/list?can=2&q=label:"
57 "spdy&sort=owner&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20" 52 "spdy&sort=owner&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20"
58 "Summary%20Modified%20Owner%20Mstone%20OS"), 53 "Summary%20Modified%20Owner%20Mstone%20OS"),
59 HttpAuth::AUTH_SERVER, true, 1 << 3 }, 54 HttpAuth::AUTH_SERVER, true, 1 << 3 },
60 { GURL("https://www.linkedin.com/secure/login?trk=hb_signin"), 55 { GURL("https://www.linkedin.com/secure/login?trk=hb_signin"),
61 HttpAuth::AUTH_SERVER, true, 1 << 1 }, 56 HttpAuth::AUTH_SERVER, true, 1 << 1 },
62 { GURL("http://www.linkedin.com/mbox?displayMBoxItem=&" 57 { GURL("http://www.linkedin.com/mbox?displayMBoxItem=&"
63 "itemID=I1717980652_2&trk=COMM_HP_MSGVW_MEBC_MEBC&goback=.hom"), 58 "itemID=I1717980652_2&trk=COMM_HP_MSGVW_MEBC_MEBC&goback=.hom"),
64 HttpAuth::AUTH_SERVER, true, 1 << 1 }, 59 HttpAuth::AUTH_SERVER, true, 1 << 1 },
65 { GURL("http://news.slashdot.org/story/10/02/18/190236/" 60 { GURL("http://news.slashdot.org/story/10/02/18/190236/"
66 "New-Plan-Lets-Top-HS-Students-Graduate-2-Years-Early"), 61 "New-Plan-Lets-Top-HS-Students-Graduate-2-Years-Early"),
67 HttpAuth::AUTH_PROXY, true, ALL_SERVERS_MATCH }, 62 HttpAuth::AUTH_PROXY, true, ALL_SERVERS_MATCH },
68 { GURL("http://codereview.chromium.org/646068/diff/4001/5003"), 63 { GURL("http://codereview.chromium.org/646068/diff/4001/5003"),
69 HttpAuth::AUTH_SERVER, true, 1 << 3 }, 64 HttpAuth::AUTH_SERVER, true, 1 << 3 },
70 { GURL("http://codereview.chromium.gag/646068/diff/4001/5003"), 65 { GURL("http://codereview.chromium.gag/646068/diff/4001/5003"),
71 HttpAuth::AUTH_SERVER, true, 1 << 4 }, 66 HttpAuth::AUTH_SERVER, true, 1 << 4 },
72 { GURL("http://codereview.chromium.gog/646068/diff/4001/5003"), 67 { GURL("http://codereview.chromium.gog/646068/diff/4001/5003"),
73 HttpAuth::AUTH_SERVER, true, 1 << 5 }, 68 HttpAuth::AUTH_SERVER, true, 1 << 5 },
74 }; 69 };
75 70
76 } // namespace 71 } // namespace
77 72
78 TEST(HttpAuthFilterTest, EmptyFilter) { 73 TEST(HttpAuthFilterTest, EmptyFilter) {
79 // Create an empty filter 74 // Create an empty filter
80 HttpAuthFilterWhitelist filter(""); 75 HttpAuthFilterWhitelist filter((std::string()));
81 for (size_t i = 0; i < arraysize(urls); i++) { 76 for (size_t i = 0; i < arraysize(urls); i++) {
82 EXPECT_EQ(urls[i].target == HttpAuth::AUTH_PROXY, 77 EXPECT_EQ(urls[i].target == HttpAuth::AUTH_PROXY,
83 filter.IsValid(urls[i].url, urls[i].target)) 78 filter.IsValid(urls[i].url, urls[i].target))
84 << " " << i << ": " << urls[i].url; 79 << " " << i << ": " << urls[i].url;
85 } 80 }
86 } 81 }
87 82
88 TEST(HttpAuthFilterTest, NonEmptyFilter) { 83 TEST(HttpAuthFilterTest, NonEmptyFilter) {
89 // Create an non-empty filter 84 // Create an non-empty filter
90 std::string server_whitelist_filter_string; 85 std::string server_whitelist_filter_string;
91 for (size_t i = 0; i < arraysize(server_whitelist_array); ++i) { 86 for (size_t i = 0; i < arraysize(server_whitelist_array); ++i) {
92 if (!server_whitelist_filter_string.empty()) 87 if (!server_whitelist_filter_string.empty())
93 server_whitelist_filter_string += ","; 88 server_whitelist_filter_string += ",";
94 server_whitelist_filter_string += "*"; 89 server_whitelist_filter_string += "*";
95 server_whitelist_filter_string += server_whitelist_array[i]; 90 server_whitelist_filter_string += server_whitelist_array[i];
96 } 91 }
97 HttpAuthFilterWhitelist filter(server_whitelist_filter_string); 92 HttpAuthFilterWhitelist filter(server_whitelist_filter_string);
98 for (size_t i = 0; i < arraysize(urls); i++) { 93 for (size_t i = 0; i < arraysize(urls); i++) {
99 EXPECT_EQ(urls[i].matches, filter.IsValid(urls[i].url, urls[i].target)) 94 EXPECT_EQ(urls[i].matches, filter.IsValid(urls[i].url, urls[i].target))
100 << " " << i << ": " << urls[i].url; 95 << " " << i << ": " << urls[i].url;
101 } 96 }
102 } 97 }
103 98
104 } // namespace net 99 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_cache_unittest.cc ('k') | net/http/http_auth_gssapi_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698