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

Side by Side 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, 3 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "content/public/browser/cookie_store_factory.h" 73 #include "content/public/browser/cookie_store_factory.h"
74 #include "content/public/browser/dom_storage_context.h" 74 #include "content/public/browser/dom_storage_context.h"
75 #include "content/public/browser/local_storage_usage_info.h" 75 #include "content/public/browser/local_storage_usage_info.h"
76 #include "content/public/browser/permission_type.h" 76 #include "content/public/browser/permission_type.h"
77 #include "content/public/browser/storage_partition.h" 77 #include "content/public/browser/storage_partition.h"
78 #include "content/public/test/mock_download_manager.h" 78 #include "content/public/test/mock_download_manager.h"
79 #include "content/public/test/test_browser_thread.h" 79 #include "content/public/test/test_browser_thread.h"
80 #include "content/public/test/test_browser_thread_bundle.h" 80 #include "content/public/test/test_browser_thread_bundle.h"
81 #include "content/public/test/test_utils.h" 81 #include "content/public/test/test_utils.h"
82 #include "net/cookies/cookie_store.h" 82 #include "net/cookies/cookie_store.h"
83 #include "net/http/http_network_session.h"
84 #include "net/http/http_transaction_factory.h"
83 #include "net/ssl/channel_id_service.h" 85 #include "net/ssl/channel_id_service.h"
84 #include "net/ssl/channel_id_store.h" 86 #include "net/ssl/channel_id_store.h"
85 #include "net/ssl/ssl_client_cert_type.h" 87 #include "net/ssl/ssl_client_cert_type.h"
86 #include "net/url_request/url_request_context.h" 88 #include "net/url_request/url_request_context.h"
87 #include "net/url_request/url_request_context_getter.h" 89 #include "net/url_request/url_request_context_getter.h"
88 #include "testing/gmock/include/gmock/gmock.h" 90 #include "testing/gmock/include/gmock/gmock.h"
89 #include "testing/gtest/include/gtest/gtest.h" 91 #include "testing/gtest/include/gtest/gtest.h"
90 #include "third_party/skia/include/core/SkBitmap.h" 92 #include "third_party/skia/include/core/SkBitmap.h"
91 #include "ui/gfx/favicon_size.h" 93 #include "ui/gfx/favicon_size.h"
92 #include "url/origin.h" 94 #include "url/origin.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const char kTestOrigin2[] = "http://host2.com:1/"; 142 const char kTestOrigin2[] = "http://host2.com:1/";
141 const char kTestOrigin3[] = "http://host3.com:1/"; 143 const char kTestOrigin3[] = "http://host3.com:1/";
142 const char kTestRegisterableDomain3[] = "host3.com"; 144 const char kTestRegisterableDomain3[] = "host3.com";
143 const char kTestOrigin4[] = "https://host3.com:1/"; 145 const char kTestOrigin4[] = "https://host3.com:1/";
144 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; 146 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/";
145 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; 147 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/";
146 148
147 // For Autofill. 149 // For Autofill.
148 const char kWebOrigin[] = "https://www.example.com/"; 150 const char kWebOrigin[] = "https://www.example.com/";
149 151
152 // For HTTP auth.
153 const char kTestRealm[] = "TestRealm";
154
150 const GURL kOrigin1(kTestOrigin1); 155 const GURL kOrigin1(kTestOrigin1);
151 const GURL kOrigin2(kTestOrigin2); 156 const GURL kOrigin2(kTestOrigin2);
152 const GURL kOrigin3(kTestOrigin3); 157 const GURL kOrigin3(kTestOrigin3);
153 const GURL kOrigin4(kTestOrigin4); 158 const GURL kOrigin4(kTestOrigin4);
154 const GURL kOriginExt(kTestOriginExt); 159 const GURL kOriginExt(kTestOriginExt);
155 const GURL kOriginDevTools(kTestOriginDevTools); 160 const GURL kOriginDevTools(kTestOriginDevTools);
156 161
157 const base::FilePath::CharType kDomStorageOrigin1[] = 162 const base::FilePath::CharType kDomStorageOrigin1[] =
158 FILE_PATH_LITERAL("http_host1_1.localstorage"); 163 FILE_PATH_LITERAL("http_host1_1.localstorage");
159 164
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, 2688 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT,
2684 base::Bind(&MatchPrimaryPattern, http_pattern)); 2689 base::Bind(&MatchPrimaryPattern, http_pattern));
2685 // Verify we only have one, and it's url1. 2690 // Verify we only have one, and it's url1.
2686 host_content_settings_map->GetSettingsForOneType( 2691 host_content_settings_map->GetSettingsForOneType(
2687 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); 2692 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings);
2688 EXPECT_EQ(1u, host_settings.size()); 2693 EXPECT_EQ(1u, host_settings.size());
2689 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), 2694 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1),
2690 host_settings[0].primary_pattern); 2695 host_settings[0].primary_pattern);
2691 } 2696 }
2692 2697
2698 // Test that removing cookies clears HTTP auth data.
2699 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemoveCookies) {
2700 net::HttpNetworkSession* http_session = GetProfile()
2701 ->GetRequestContext()
2702 ->GetURLRequestContext()
2703 ->http_transaction_factory()
2704 ->GetSession();
2705 DCHECK(http_session);
2706
2707 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache();
2708 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC,
2709 "test challenge",
2710 net::AuthCredentials(base::ASCIIToUTF16("foo"),
2711 base::ASCIIToUTF16("bar")),
2712 "/");
2713 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm,
2714 net::HttpAuth::AUTH_SCHEME_BASIC));
2715
2716 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
2717 BrowsingDataRemover::REMOVE_COOKIES, false);
2718
2719 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
2720 net::HttpAuth::AUTH_SCHEME_BASIC));
2721 }
2722
2723 // Test that removing passwords clears HTTP auth data.
2724 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) {
2725 net::HttpNetworkSession* http_session = GetProfile()
2726 ->GetRequestContext()
2727 ->GetURLRequestContext()
2728 ->http_transaction_factory()
2729 ->GetSession();
2730 DCHECK(http_session);
2731
2732 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache();
2733 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC,
2734 "test challenge",
2735 net::AuthCredentials(base::ASCIIToUTF16("foo"),
2736 base::ASCIIToUTF16("bar")),
2737 "/");
2738 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm,
2739 net::HttpAuth::AUTH_SCHEME_BASIC));
2740
2741 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
2742 BrowsingDataRemover::REMOVE_PASSWORDS, false);
2743
2744 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
2745 net::HttpAuth::AUTH_SCHEME_BASIC));
2746 }
2747
2693 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) { 2748 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) {
2694 RemovePermissionPromptCountsTest tester(GetProfile()); 2749 RemovePermissionPromptCountsTest tester(GetProfile());
2695 2750
2696 RegistrableDomainFilterBuilder filter_builder_1( 2751 RegistrableDomainFilterBuilder filter_builder_1(
2697 RegistrableDomainFilterBuilder::WHITELIST); 2752 RegistrableDomainFilterBuilder::WHITELIST);
2698 filter_builder_1.AddRegisterableDomain(kTestRegisterableDomain1); 2753 filter_builder_1.AddRegisterableDomain(kTestRegisterableDomain1);
2699 2754
2700 RegistrableDomainFilterBuilder filter_builder_2( 2755 RegistrableDomainFilterBuilder filter_builder_2(
2701 RegistrableDomainFilterBuilder::BLACKLIST); 2756 RegistrableDomainFilterBuilder::BLACKLIST);
2702 filter_builder_2.AddRegisterableDomain(kTestRegisterableDomain1); 2757 filter_builder_2.AddRegisterableDomain(kTestRegisterableDomain1);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 EXPECT_TRUE(remover->is_removing()); 3068 EXPECT_TRUE(remover->is_removing());
3014 3069
3015 // Add one more deletion and wait for it. 3070 // Add one more deletion and wait for it.
3016 BlockUntilBrowsingDataRemoved( 3071 BlockUntilBrowsingDataRemoved(
3017 browsing_data::ALL_TIME, 3072 browsing_data::ALL_TIME,
3018 BrowsingDataRemover::REMOVE_COOKIES, 3073 BrowsingDataRemover::REMOVE_COOKIES,
3019 BrowsingDataHelper::UNPROTECTED_WEB); 3074 BrowsingDataHelper::UNPROTECTED_WEB);
3020 3075
3021 EXPECT_FALSE(remover->is_removing()); 3076 EXPECT_FALSE(remover->is_removing());
3022 } 3077 }
OLDNEW
« 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