Chromium Code Reviews| 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 3fa52136d65272472c6cca0257ecda2750fe4a9e..da835bf1fe99e67455d62cb931465ab35c1a1b16 100644 |
| --- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc |
| +++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc |
| @@ -78,6 +78,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" |
| @@ -141,6 +143,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); |
| @@ -844,6 +849,37 @@ class RemoveLocalStorageTester { |
| DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); |
| }; |
| +class ClearHttpAuthDataTester { |
|
mmenke
2016/08/09 14:40:20
Think this makes the tests needlessly obscure. Lo
Tomasz Moniuszko
2016/08/25 10:32:59
Done. I inlined the code.
|
| + public: |
| + explicit ClearHttpAuthDataTester(TestingProfile* profile) { |
| + net::HttpNetworkSession* http_session = profile->GetRequestContext() |
| + ->GetURLRequestContext() |
| + ->http_transaction_factory() |
| + ->GetSession(); |
| + DCHECK(http_session); |
| + 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)); |
| + } |
| + |
| + ~ClearHttpAuthDataTester() { |
| + EXPECT_EQ(nullptr, |
| + http_auth_cache_->Lookup(kOrigin1, kTestRealm, |
| + net::HttpAuth::AUTH_SCHEME_BASIC)); |
| + } |
| + |
| + private: |
| + net::HttpAuthCache* http_auth_cache_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ClearHttpAuthDataTester); |
| +}; |
| + |
| class MockDomainReliabilityService : public DomainReliabilityService { |
| public: |
| MockDomainReliabilityService() {} |
| @@ -2599,6 +2635,22 @@ TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| host_settings[0].primary_pattern); |
| } |
| +// Test that removing cookies clears HTTP auth data. |
| +TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) { |
| + ClearHttpAuthDataTester tester(GetProfile()); |
| + |
| + BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, |
| + BrowsingDataRemover::REMOVE_COOKIES, false); |
| +} |
| + |
| +// Test that removing passwords clears HTTP auth data. |
| +TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { |
| + ClearHttpAuthDataTester tester(GetProfile()); |
| + |
| + BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, |
| + BrowsingDataRemover::REMOVE_PASSWORDS, false); |
| +} |
| + |
| class MultipleTasksObserver { |
| public: |
| // A simple implementation of BrowsingDataRemover::Observer. |