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

Side by Side 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 unified diff | Download patch
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 <string> 5 #include <string>
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC, 370 origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC,
371 AuthCredentials(kAdmin, kPassword))); 371 AuthCredentials(kAdmin, kPassword)));
372 372
373 // Make sure that removing one entry still leaves the other available for 373 // Make sure that removing one entry still leaves the other available for
374 // lookup. 374 // lookup.
375 HttpAuthCache::Entry* entry = cache.Lookup( 375 HttpAuthCache::Entry* entry = cache.Lookup(
376 origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST); 376 origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
377 EXPECT_FALSE(NULL == entry); 377 EXPECT_FALSE(NULL == entry);
378 } 378 }
379 379
380 TEST(HttpAuthCacheTest, ClearEntriesAddedWithin) {
381 GURL origin("http://foobar.com");
382
383 HttpAuthCache cache;
384 cache.Add(origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm1",
385 AuthCredentials(kAlice, k123), "/");
386 cache.Add(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm2",
387 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.
388
389 base::TimeTicks start_time = base::TimeTicks::Now();
390
391 cache.Add(origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm3",
392 AuthCredentials(kAlice2, k1234), "/");
393 cache.Add(origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm4",
394 AuthCredentials(kUsername, kPassword), "/");
395 // Add path to existing entry.
396 cache.Add(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC, "basic realm=Realm2",
397 AuthCredentials(kAdmin, kPassword), "/baz/");
398
399 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
400
401 EXPECT_NE(nullptr,
402 cache.Lookup(origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC));
403 EXPECT_NE(nullptr,
404 cache.Lookup(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC));
405 // Creation time is set for a whole entry rather than for a particular path.
406 // Path added within the requested duration isn't be removed.
407 EXPECT_NE(nullptr, cache.LookupByPath(origin, "/baz/"));
408 EXPECT_EQ(nullptr,
409 cache.Lookup(origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC));
410 EXPECT_EQ(nullptr,
411 cache.Lookup(origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC));
412 }
413
380 TEST(HttpAuthCacheTest, UpdateStaleChallenge) { 414 TEST(HttpAuthCacheTest, UpdateStaleChallenge) {
381 HttpAuthCache cache; 415 HttpAuthCache cache;
382 GURL origin("http://foobar2.com"); 416 GURL origin("http://foobar2.com");
383 std::unique_ptr<HttpAuthHandler> digest_handler(new MockAuthHandler( 417 std::unique_ptr<HttpAuthHandler> digest_handler(new MockAuthHandler(
384 HttpAuth::AUTH_SCHEME_DIGEST, kRealm1, HttpAuth::AUTH_PROXY)); 418 HttpAuth::AUTH_SCHEME_DIGEST, kRealm1, HttpAuth::AUTH_PROXY));
385 HttpAuthCache::Entry* entry_pre = cache.Add( 419 HttpAuthCache::Entry* entry_pre = cache.Add(
386 origin, 420 origin,
387 digest_handler->realm(), 421 digest_handler->realm(),
388 digest_handler->auth_scheme(), 422 digest_handler->auth_scheme(),
389 "Digest realm=Realm1," 423 "Digest realm=Realm1,"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 CheckPathExistence(0, i, false); 634 CheckPathExistence(0, i, false);
601 635
602 for (int i = 0; i < kMaxPaths; ++i) 636 for (int i = 0; i < kMaxPaths; ++i)
603 CheckPathExistence(0, i + 3, true); 637 CheckPathExistence(0, i + 3, true);
604 638
605 for (int i = 0; i < kMaxRealms; ++i) 639 for (int i = 0; i < kMaxRealms; ++i)
606 CheckRealmExistence(i, true); 640 CheckRealmExistence(i, true);
607 } 641 }
608 642
609 } // namespace net 643 } // namespace net
OLDNEW
« 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