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

Unified Diff: net/ftp/ftp_auth_cache_unittest.cc

Issue 1151843002: DO NOT LAND Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/ftp/ftp_auth_cache_unittest.cc
diff --git a/net/ftp/ftp_auth_cache_unittest.cc b/net/ftp/ftp_auth_cache_unittest.cc
index 892153c39dd356fdf25330e09a58f82d480649f7..806516220eb7a9e22949e06591ba57b1b5082174 100644
--- a/net/ftp/ftp_auth_cache_unittest.cc
+++ b/net/ftp/ftp_auth_cache_unittest.cc
@@ -10,6 +10,7 @@
#include "net/base/auth.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+#include "url/origin.h"
using base::ASCIIToUTF16;
@@ -34,8 +35,8 @@ const base::string16 kUsername3(ASCIIToUTF16("username3"));
TEST(FtpAuthCacheTest, LookupAddRemove) {
FtpAuthCache cache;
- GURL origin1("ftp://foo1");
- GURL origin2("ftp://foo2");
+ url::Origin origin1("ftp://foo1");
+ url::Origin origin2("ftp://foo2");
// Lookup non-existent entry.
EXPECT_TRUE(cache.Lookup(origin1) == NULL);
@@ -81,8 +82,8 @@ TEST(FtpAuthCacheTest, LookupAddRemove) {
TEST(FtpAuthCacheTest, LookupWithPort) {
FtpAuthCache cache;
- GURL origin1("ftp://foo:80");
- GURL origin2("ftp://foo:21");
+ url::Origin origin1("ftp://foo:80");
+ url::Origin origin2("ftp://foo:21");
cache.Add(origin1, AuthCredentials(kUsername, kPassword));
cache.Add(origin2, AuthCredentials(kUsername, kPassword));
@@ -91,71 +92,78 @@ TEST(FtpAuthCacheTest, LookupWithPort) {
}
TEST(FtpAuthCacheTest, NormalizedKey) {
- // GURL is automatically canonicalized. Hence the following variations in
- // url format should all map to the same entry (case insensitive host,
+ // url::Origin is automatically canonicalized. Hence the following variations
+ // in url format should all map to the same entry (case insensitive host,
// default port of 21).
FtpAuthCache cache;
// Add.
- cache.Add(GURL("ftp://HoSt:21"), AuthCredentials(kUsername, kPassword));
+ cache.Add(url::Origin(GURL("ftp://HoSt:21")),
+ AuthCredentials(kUsername, kPassword));
// Lookup.
- FtpAuthCache::Entry* entry1 = cache.Lookup(GURL("ftp://HoSt:21"));
+ FtpAuthCache::Entry* entry1 =
+ cache.Lookup(url::Origin(GURL("ftp://HoSt:21")));
ASSERT_TRUE(entry1);
- EXPECT_EQ(entry1, cache.Lookup(GURL("ftp://host:21")));
- EXPECT_EQ(entry1, cache.Lookup(GURL("ftp://host")));
+ EXPECT_EQ(entry1, cache.Lookup(url::Origin(GURL("ftp://host:21"))));
+ EXPECT_EQ(entry1, cache.Lookup(url::Origin(GURL("ftp://host"))));
// Overwrite.
- cache.Add(GURL("ftp://host"), AuthCredentials(kOthername, kOtherword));
- FtpAuthCache::Entry* entry2 = cache.Lookup(GURL("ftp://HoSt:21"));
+ cache.Add(url::Origin(GURL("ftp://host")),
+ AuthCredentials(kOthername, kOtherword));
+ FtpAuthCache::Entry* entry2 =
+ cache.Lookup(url::Origin(GURL("ftp://HoSt:21")));
ASSERT_TRUE(entry2);
- EXPECT_EQ(GURL("ftp://host"), entry2->origin);
+ EXPECT_EQ(url::Origin(GURL("ftp://host")), entry2->origin);
EXPECT_EQ(kOthername, entry2->credentials.username());
EXPECT_EQ(kOtherword, entry2->credentials.password());
// Remove
- cache.Remove(GURL("ftp://HOsT"), AuthCredentials(kOthername, kOtherword));
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL);
+ cache.Remove(url::Origin(GURL("ftp://HOsT")),
+ AuthCredentials(kOthername, kOtherword));
+ EXPECT_TRUE(cache.Lookup(url::Origin(GURL("ftp://host"))) == NULL);
}
TEST(FtpAuthCacheTest, OnlyRemoveMatching) {
FtpAuthCache cache;
- cache.Add(GURL("ftp://host"), AuthCredentials(kUsername, kPassword));
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host")));
+ cache.Add(url::Origin("ftp://host"), AuthCredentials(kUsername, kPassword));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host")));
// Auth data doesn't match, shouldn't remove.
- cache.Remove(GURL("ftp://host"), AuthCredentials(kBogus, kBogus));
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host")));
+ cache.Remove(url::Origin("ftp://host"), AuthCredentials(kBogus, kBogus));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host")));
// Auth data matches, should remove.
- cache.Remove(GURL("ftp://host"), AuthCredentials(kUsername, kPassword));
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL);
+ cache.Remove(url::Origin("ftp://host"),
+ AuthCredentials(kUsername, kPassword));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host")) == NULL);
}
TEST(FtpAuthCacheTest, EvictOldEntries) {
FtpAuthCache cache;
for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) {
- cache.Add(GURL("ftp://host" + base::IntToString(i)),
+ cache.Add(url::Origin("ftp://host" + base::IntToString(i)),
AuthCredentials(kUsername, kPassword));
}
// No entries should be evicted before reaching the limit.
for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) {
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i))));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host" + base::IntToString(i))));
}
// Adding one entry should cause eviction of the first entry.
- cache.Add(GURL("ftp://last_host"), AuthCredentials(kUsername, kPassword));
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL);
+ cache.Add(url::Origin("ftp://last_host"),
+ AuthCredentials(kUsername, kPassword));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host0")) == NULL);
// Remaining entries should not get evicted.
for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) {
- EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i))));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://host" + base::IntToString(i))));
}
- EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host")));
+ EXPECT_TRUE(cache.Lookup(url::Origin("ftp://last_host")));
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698