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

Unified Diff: chrome/browser/browsing_data/browsing_data_remover_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: Replace FRIEND_TEST_ALL_PREFIXES with set_creation_time_for_testing 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
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | net/http/http_auth_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browsing_data/browsing_data_remover_unittest.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 618b9a8ceee2d91480e69b3fc8c6fcfdd70f4297..6a8bd646d599173cf96018dcf2b53aa91a2f7c95 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -80,6 +80,8 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "net/cookies/cookie_store.h"
+#include "net/http/http_network_session.h"
+#include "net/http/http_transaction_factory.h"
#include "net/ssl/channel_id_service.h"
#include "net/ssl/channel_id_store.h"
#include "net/ssl/ssl_client_cert_type.h"
@@ -147,6 +149,9 @@ const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/";
// For Autofill.
const char kWebOrigin[] = "https://www.example.com/";
+// For HTTP auth.
+const char kTestRealm[] = "TestRealm";
+
const GURL kOrigin1(kTestOrigin1);
const GURL kOrigin2(kTestOrigin2);
const GURL kOrigin3(kTestOrigin3);
@@ -2690,6 +2695,56 @@ TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) {
host_settings[0].primary_pattern);
}
+// Test that removing cookies clears HTTP auth data.
+TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) {
+ net::HttpNetworkSession* http_session = GetProfile()
+ ->GetRequestContext()
+ ->GetURLRequestContext()
+ ->http_transaction_factory()
+ ->GetSession();
+ DCHECK(http_session);
+
+ net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache();
+ http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC,
+ "test challenge",
+ net::AuthCredentials(base::ASCIIToUTF16("foo"),
+ base::ASCIIToUTF16("bar")),
+ "/");
+ CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm,
+ net::HttpAuth::AUTH_SCHEME_BASIC));
+
+ BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
+ BrowsingDataRemover::REMOVE_COOKIES, false);
+
+ EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
+ net::HttpAuth::AUTH_SCHEME_BASIC));
+}
+
+// Test that removing passwords clears HTTP auth data.
+TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) {
+ net::HttpNetworkSession* http_session = GetProfile()
+ ->GetRequestContext()
+ ->GetURLRequestContext()
+ ->http_transaction_factory()
+ ->GetSession();
+ DCHECK(http_session);
+
+ net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache();
+ http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC,
+ "test challenge",
+ net::AuthCredentials(base::ASCIIToUTF16("foo"),
+ base::ASCIIToUTF16("bar")),
+ "/");
+ CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm,
+ net::HttpAuth::AUTH_SCHEME_BASIC));
+
+ BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
+ BrowsingDataRemover::REMOVE_PASSWORDS, false);
+
+ EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
+ net::HttpAuth::AUTH_SCHEME_BASIC));
+}
+
TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) {
RemovePermissionPromptCountsTest tester(GetProfile());
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | net/http/http_auth_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698