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

Unified Diff: net/http/http_auth_cache_unittest.cc

Issue 2097043002: Clear HTTP auth data on clearing browsing data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor unit tests fixes Created 4 years, 4 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/http/http_auth_cache_unittest.cc
diff --git a/net/http/http_auth_cache_unittest.cc b/net/http/http_auth_cache_unittest.cc
index c0509ce1d50c1d323e8c45aca802e679bcdfa43a..da994c484035c420fc3a525f6d35835f04b9fa56 100644
--- a/net/http/http_auth_cache_unittest.cc
+++ b/net/http/http_auth_cache_unittest.cc
@@ -377,6 +377,40 @@ TEST(HttpAuthCacheTest, Remove) {
EXPECT_FALSE(NULL == entry);
}
+TEST(HttpAuthCacheTest, ClearEntriesAddedWithin) {
+ GURL origin("http://foobar.com");
+
+ HttpAuthCache cache;
+ cache.Add(origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm1",
+ AuthCredentials(kAlice, k123), "/");
+ cache.Add(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm2",
+ AuthCredentials(kRoot, kWileCoyote), "/");
mmenke 2016/08/09 14:40:20 I don't think we're guaranteed the time recorded h
Tomasz Moniuszko 2016/08/25 10:33:00 Done. I added EnsureTimeDifference() call.
+
+ base::TimeTicks start_time = base::TimeTicks::Now();
+
+ cache.Add(origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm3",
+ AuthCredentials(kAlice2, k1234), "/");
+ cache.Add(origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm4",
+ AuthCredentials(kUsername, kPassword), "/");
+ // Add path to existing entry.
+ cache.Add(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm2",
+ AuthCredentials(kAdmin, kPassword), "/baz/");
+
+ cache.ClearEntriesAddedWithin(base::TimeTicks::Now() - start_time);
mmenke 2016/08/09 14:40:20 I don't think we're guaranteed that no time will p
Tomasz Moniuszko 2016/08/25 10:33:00 I added EnsureTimeDifference() function which ensu
+
+ EXPECT_NE(nullptr,
+ cache.Lookup(origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC));
+ EXPECT_NE(nullptr,
+ cache.Lookup(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC));
+ // Creation time is set for a whole entry rather than for a particular path.
+ // Path added within the requested duration isn't be removed.
+ EXPECT_NE(nullptr, cache.LookupByPath(origin, "/baz/"));
+ EXPECT_EQ(nullptr,
+ cache.Lookup(origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC));
+ EXPECT_EQ(nullptr,
+ cache.Lookup(origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC));
+}
+
TEST(HttpAuthCacheTest, UpdateStaleChallenge) {
HttpAuthCache cache;
GURL origin("http://foobar2.com");
« chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('K') | « net/http/http_auth_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698