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

Unified Diff: net/ftp/ftp_auth_cache_unittest.cc

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ftp/ftp_auth_cache.cc ('k') | net/ftp/ftp_network_transaction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a8c5732f7d2b53f7a5efbe27e676449f128b425f..13c20c75df633b5b8cec0dd83b8d2da9c9163e1f 100644
--- a/net/ftp/ftp_auth_cache_unittest.cc
+++ b/net/ftp/ftp_auth_cache_unittest.cc
@@ -8,6 +8,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
+#include "net/base/auth.h"
#include "testing/gtest/include/gtest/gtest.h"
using net::FtpAuthCache;
@@ -38,38 +39,38 @@ TEST(FtpAuthCacheTest, LookupAddRemove) {
EXPECT_TRUE(cache.Lookup(origin1) == NULL);
// Add entry for origin1.
- cache.Add(origin1, kUsername1, kPassword1);
+ cache.Add(origin1, net::AuthCredentials(kUsername1, kPassword1));
FtpAuthCache::Entry* entry1 = cache.Lookup(origin1);
ASSERT_TRUE(entry1);
EXPECT_EQ(origin1, entry1->origin);
- EXPECT_EQ(kUsername1, entry1->username);
- EXPECT_EQ(kPassword1, entry1->password);
+ EXPECT_EQ(kUsername1, entry1->credentials.username());
+ EXPECT_EQ(kPassword1, entry1->credentials.password());
// Add an entry for origin2.
- cache.Add(origin2, kUsername2, kPassword2);
+ cache.Add(origin2, net::AuthCredentials(kUsername2, kPassword2));
FtpAuthCache::Entry* entry2 = cache.Lookup(origin2);
ASSERT_TRUE(entry2);
EXPECT_EQ(origin2, entry2->origin);
- EXPECT_EQ(kUsername2, entry2->username);
- EXPECT_EQ(kPassword2, entry2->password);
+ EXPECT_EQ(kUsername2, entry2->credentials.username());
+ EXPECT_EQ(kPassword2, entry2->credentials.password());
// The original entry1 should still be there.
EXPECT_EQ(entry1, cache.Lookup(origin1));
// Overwrite the entry for origin1.
- cache.Add(origin1, kUsername3, kPassword3);
+ cache.Add(origin1, net::AuthCredentials(kUsername3, kPassword3));
FtpAuthCache::Entry* entry3 = cache.Lookup(origin1);
ASSERT_TRUE(entry3);
EXPECT_EQ(origin1, entry3->origin);
- EXPECT_EQ(kUsername3, entry3->username);
- EXPECT_EQ(kPassword3, entry3->password);
+ EXPECT_EQ(kUsername3, entry3->credentials.username());
+ EXPECT_EQ(kPassword3, entry3->credentials.password());
// Remove entry of origin1.
- cache.Remove(origin1, kUsername3, kPassword3);
+ cache.Remove(origin1, net::AuthCredentials(kUsername3, kPassword3));
EXPECT_TRUE(cache.Lookup(origin1) == NULL);
// Remove non-existent entry.
- cache.Remove(origin1, kUsername3, kPassword3);
+ cache.Remove(origin1, net::AuthCredentials(kUsername3, kPassword3));
EXPECT_TRUE(cache.Lookup(origin1) == NULL);
}
@@ -81,8 +82,8 @@ TEST(FtpAuthCacheTest, LookupWithPort) {
GURL origin1("ftp://foo:80");
GURL origin2("ftp://foo:21");
- cache.Add(origin1, kUsername, kPassword);
- cache.Add(origin2, kUsername, kPassword);
+ cache.Add(origin1, net::AuthCredentials(kUsername, kPassword));
+ cache.Add(origin2, net::AuthCredentials(kUsername, kPassword));
EXPECT_NE(cache.Lookup(origin1), cache.Lookup(origin2));
}
@@ -95,7 +96,7 @@ TEST(FtpAuthCacheTest, NormalizedKey) {
FtpAuthCache cache;
// Add.
- cache.Add(GURL("ftp://HoSt:21"), kUsername, kPassword);
+ cache.Add(GURL("ftp://HoSt:21"), net::AuthCredentials(kUsername, kPassword));
// Lookup.
FtpAuthCache::Entry* entry1 = cache.Lookup(GURL("ftp://HoSt:21"));
@@ -104,30 +105,31 @@ TEST(FtpAuthCacheTest, NormalizedKey) {
EXPECT_EQ(entry1, cache.Lookup(GURL("ftp://host")));
// Overwrite.
- cache.Add(GURL("ftp://host"), kOthername, kOtherword);
+ cache.Add(GURL("ftp://host"), net::AuthCredentials(kOthername, kOtherword));
FtpAuthCache::Entry* entry2 = cache.Lookup(GURL("ftp://HoSt:21"));
ASSERT_TRUE(entry2);
EXPECT_EQ(GURL("ftp://host"), entry2->origin);
- EXPECT_EQ(kOthername, entry2->username);
- EXPECT_EQ(kOtherword, entry2->password);
+ EXPECT_EQ(kOthername, entry2->credentials.username());
+ EXPECT_EQ(kOtherword, entry2->credentials.password());
// Remove
- cache.Remove(GURL("ftp://HOsT"), kOthername, kOtherword);
+ cache.Remove(GURL("ftp://HOsT"),
+ net::AuthCredentials(kOthername, kOtherword));
EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL);
}
TEST(FtpAuthCacheTest, OnlyRemoveMatching) {
FtpAuthCache cache;
- cache.Add(GURL("ftp://host"), kUsername, kPassword);
+ cache.Add(GURL("ftp://host"), net::AuthCredentials(kUsername, kPassword));
EXPECT_TRUE(cache.Lookup(GURL("ftp://host")));
// Auth data doesn't match, shouldn't remove.
- cache.Remove(GURL("ftp://host"), kBogus, kBogus);
+ cache.Remove(GURL("ftp://host"), net::AuthCredentials(kBogus, kBogus));
EXPECT_TRUE(cache.Lookup(GURL("ftp://host")));
// Auth data matches, should remove.
- cache.Remove(GURL("ftp://host"), kUsername, kPassword);
+ cache.Remove(GURL("ftp://host"), net::AuthCredentials(kUsername, kPassword));
EXPECT_TRUE(cache.Lookup(GURL("ftp://host")) == NULL);
}
@@ -136,7 +138,7 @@ TEST(FtpAuthCacheTest, EvictOldEntries) {
for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) {
cache.Add(GURL("ftp://host" + base::IntToString(i)),
- kUsername, kPassword);
+ net::AuthCredentials(kUsername, kPassword));
}
// No entries should be evicted before reaching the limit.
@@ -145,7 +147,8 @@ TEST(FtpAuthCacheTest, EvictOldEntries) {
}
// Adding one entry should cause eviction of the first entry.
- cache.Add(GURL("ftp://last_host"), kUsername, kPassword);
+ cache.Add(GURL("ftp://last_host"),
+ net::AuthCredentials(kUsername, kPassword));
EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL);
// Remaining entries should not get evicted.
« no previous file with comments | « net/ftp/ftp_auth_cache.cc ('k') | net/ftp/ftp_network_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698