Chromium Code Reviews| 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"); |