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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 1076063002: Remove certificates from Channel ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Udpate KeysEqual to fail if preconditions fail Created 5 years, 7 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) 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/guid.h" 15 #include "base/guid.h"
16 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/prefs/testing_pref_service.h" 18 #include "base/prefs/testing_pref_service.h"
18 #include "base/run_loop.h" 19 #include "base/run_loop.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/task/cancelable_task_tracker.h" 21 #include "base/task/cancelable_task_tracker.h"
21 #include "chrome/browser/autofill/personal_data_manager_factory.h" 22 #include "chrome/browser/autofill/personal_data_manager_factory.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/browsing_data/browsing_data_helper.h" 24 #include "chrome/browser/browsing_data/browsing_data_helper.h"
24 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 25 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
25 #include "chrome/browser/domain_reliability/service_factory.h" 26 #include "chrome/browser/domain_reliability/service_factory.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 channel_id_service_ = profile->GetRequestContext()-> 326 channel_id_service_ = profile->GetRequestContext()->
326 GetURLRequestContext()->channel_id_service(); 327 GetURLRequestContext()->channel_id_service();
327 ssl_config_service_ = profile->GetSSLConfigService(); 328 ssl_config_service_ = profile->GetSSLConfigService();
328 ssl_config_service_->AddObserver(this); 329 ssl_config_service_->AddObserver(this);
329 } 330 }
330 331
331 ~RemoveChannelIDTester() override { 332 ~RemoveChannelIDTester() override {
332 ssl_config_service_->RemoveObserver(this); 333 ssl_config_service_->RemoveObserver(this);
333 } 334 }
334 335
335 int ChannelIDCount() { 336 int ChannelIDCount() { return channel_id_service_->channel_id_count(); }
336 return channel_id_service_->cert_count();
337 }
338 337
339 // Add a server bound cert for |server| with specific creation and expiry 338 // Add a server bound cert for |server| with specific creation and expiry
340 // times. The cert and key data will be filled with dummy values. 339 // times. The cert and key data will be filled with dummy values.
341 void AddChannelIDWithTimes(const std::string& server_identifier, 340 void AddChannelIDWithTimes(const std::string& server_identifier,
342 base::Time creation_time, 341 base::Time creation_time) {
343 base::Time expiration_time) { 342 GetChannelIDStore()->SetChannelID(
344 GetChannelIDStore()->SetChannelID(server_identifier, 343 make_scoped_ptr(new net::ChannelIDStore::ChannelID(
345 creation_time, 344 server_identifier, creation_time,
346 expiration_time, 345 make_scoped_ptr(crypto::ECPrivateKey::Create()))));
347 "a",
348 "b");
349 } 346 }
350 347
351 // Add a server bound cert for |server|, with the current time as the 348 // Add a server bound cert for |server|, with the current time as the
352 // creation time. The cert and key data will be filled with dummy values. 349 // creation time. The cert and key data will be filled with dummy values.
353 void AddChannelID(const std::string& server_identifier) { 350 void AddChannelID(const std::string& server_identifier) {
354 base::Time now = base::Time::Now(); 351 base::Time now = base::Time::Now();
355 AddChannelIDWithTimes(server_identifier, 352 AddChannelIDWithTimes(server_identifier, now);
356 now,
357 now + base::TimeDelta::FromDays(1));
358 } 353 }
359 354
360 void GetChannelIDList(net::ChannelIDStore::ChannelIDList* channel_ids) { 355 void GetChannelIDList(net::ChannelIDStore::ChannelIDList* channel_ids) {
361 GetChannelIDStore()->GetAllChannelIDs( 356 GetChannelIDStore()->GetAllChannelIDs(
362 base::Bind(&RemoveChannelIDTester::GetAllChannelIDsCallback, 357 base::Bind(&RemoveChannelIDTester::GetAllChannelIDsCallback,
363 channel_ids)); 358 channel_ids));
364 } 359 }
365 360
366 net::ChannelIDStore* GetChannelIDStore() { 361 net::ChannelIDStore* GetChannelIDStore() {
367 return channel_id_service_->GetChannelIDStore(); 362 return channel_id_service_->GetChannelIDStore();
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 EXPECT_EQ(1, tester.ssl_config_changed_count()); 1047 EXPECT_EQ(1, tester.ssl_config_changed_count());
1053 EXPECT_EQ(0, tester.ChannelIDCount()); 1048 EXPECT_EQ(0, tester.ChannelIDCount());
1054 } 1049 }
1055 1050
1056 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) { 1051 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) {
1057 RemoveChannelIDTester tester(GetProfile()); 1052 RemoveChannelIDTester tester(GetProfile());
1058 1053
1059 base::Time now = base::Time::Now(); 1054 base::Time now = base::Time::Now();
1060 tester.AddChannelID(kTestOrigin1); 1055 tester.AddChannelID(kTestOrigin1);
1061 tester.AddChannelIDWithTimes(kTestOrigin2, 1056 tester.AddChannelIDWithTimes(kTestOrigin2,
1062 now - base::TimeDelta::FromHours(2), 1057 now - base::TimeDelta::FromHours(2));
1063 now);
1064 EXPECT_EQ(0, tester.ssl_config_changed_count()); 1058 EXPECT_EQ(0, tester.ssl_config_changed_count());
1065 EXPECT_EQ(2, tester.ChannelIDCount()); 1059 EXPECT_EQ(2, tester.ChannelIDCount());
1066 1060
1067 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, 1061 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR,
1068 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); 1062 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false);
1069 1063
1070 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); 1064 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask());
1071 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); 1065 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask());
1072 EXPECT_EQ(1, tester.ssl_config_changed_count()); 1066 EXPECT_EQ(1, tester.ssl_config_changed_count());
1073 ASSERT_EQ(1, tester.ChannelIDCount()); 1067 ASSERT_EQ(1, tester.ChannelIDCount());
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 // TODO(ttuttle): This isn't actually testing the no-monitor case, since 1978 // TODO(ttuttle): This isn't actually testing the no-monitor case, since
1985 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed 1979 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed
1986 // for some unrelated test cases. This should be fixed so it tests the no- 1980 // for some unrelated test cases. This should be fixed so it tests the no-
1987 // monitor case again. 1981 // monitor case again.
1988 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { 1982 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) {
1989 BlockUntilBrowsingDataRemoved( 1983 BlockUntilBrowsingDataRemoved(
1990 BrowsingDataRemover::EVERYTHING, 1984 BrowsingDataRemover::EVERYTHING,
1991 BrowsingDataRemover::REMOVE_HISTORY | 1985 BrowsingDataRemover::REMOVE_HISTORY |
1992 BrowsingDataRemover::REMOVE_COOKIES, false); 1986 BrowsingDataRemover::REMOVE_COOKIES, false);
1993 } 1987 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698