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 a0acbf71d3f513530a35b0376d316c35a88ff4ea..4d4a00c23e5d4eeb4a685d536944d26664c213dc 100644 |
| --- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc |
| +++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc |
| @@ -77,6 +77,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" |
| @@ -841,6 +843,36 @@ class RemoveLocalStorageTester { |
| DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); |
| }; |
| +class ClearHTTPAuthDataTester { |
| + 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( |
| + GURL("http://foo.com"), "Realm1", net::HttpAuth::AUTH_SCHEME_BASIC, |
| + "basic realm=Realm1", net::AuthCredentials(base::ASCIIToUTF16("foo"), |
| + base::ASCIIToUTF16("bar")), |
| + "/"); |
| + } |
| + |
| + ~ClearHTTPAuthDataTester() { |
| + GURL origin("http://foobar.com"); |
| + EXPECT_EQ(nullptr, |
| + http_auth_cache_->Lookup(GURL("http://foo.com"), "Realm1", |
|
msramek
2016/08/01 14:42:37
Nit: Can you please add the same lookup to the con
|
| + net::HttpAuth::AUTH_SCHEME_BASIC)); |
| + } |
| + |
| + private: |
| + net::HttpAuthCache* http_auth_cache_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ClearHTTPAuthDataTester); |
| +}; |
| + |
| class MockDomainReliabilityService : public DomainReliabilityService { |
| public: |
| MockDomainReliabilityService() {} |
| @@ -2592,3 +2624,19 @@ TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 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); |
| +} |