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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_channel_id_helper_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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_remover_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_channel_id_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "crypto/ec_private_key.h"
12 #include "net/ssl/channel_id_service.h" 14 #include "net/ssl/channel_id_service.h"
13 #include "net/url_request/url_request_context.h" 15 #include "net/url_request/url_request_context.h"
14 #include "net/url_request/url_request_context_getter.h" 16 #include "net/url_request/url_request_context_getter.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 using content::BrowserThread; 19 using content::BrowserThread;
18 20
19 class BrowsingDataChannelIDHelperTest 21 class BrowsingDataChannelIDHelperTest
20 : public testing::Test, 22 : public testing::Test,
21 public net::SSLConfigService::Observer { 23 public net::SSLConfigService::Observer {
22 public: 24 public:
23 BrowsingDataChannelIDHelperTest() : ssl_config_changed_count_(0) { 25 BrowsingDataChannelIDHelperTest() : ssl_config_changed_count_(0) {
24 } 26 }
25 27
26 void SetUp() override { 28 void SetUp() override {
27 testing_profile_.reset(new TestingProfile()); 29 testing_profile_.reset(new TestingProfile());
28 30
29 testing_profile_->GetSSLConfigService()->AddObserver(this); 31 testing_profile_->GetSSLConfigService()->AddObserver(this);
30 } 32 }
31 33
32 void TearDown() override { 34 void TearDown() override {
33 testing_profile_->GetSSLConfigService()->RemoveObserver(this); 35 testing_profile_->GetSSLConfigService()->RemoveObserver(this);
34 } 36 }
35 37
36 void CreateChannelIDsForTest() { 38 void CreateChannelIDsForTest() {
37 net::URLRequestContext* context = 39 net::URLRequestContext* context =
38 testing_profile_->GetRequestContext()->GetURLRequestContext(); 40 testing_profile_->GetRequestContext()->GetURLRequestContext();
39 net::ChannelIDStore* channel_id_store = 41 net::ChannelIDStore* channel_id_store =
40 context->channel_id_service()->GetChannelIDStore(); 42 context->channel_id_service()->GetChannelIDStore();
41 channel_id_store->SetChannelID("https://www.google.com:443", 43 channel_id_store->SetChannelID(
42 base::Time(), base::Time(), 44 make_scoped_ptr(new net::ChannelIDStore::ChannelID(
43 "key", "cert"); 45 "https://www.google.com:443", base::Time(),
44 channel_id_store->SetChannelID("https://www.youtube.com:443", 46 make_scoped_ptr(crypto::ECPrivateKey::Create()))));
45 base::Time(), base::Time(), 47 channel_id_store->SetChannelID(
46 "key", "cert"); 48 make_scoped_ptr(new net::ChannelIDStore::ChannelID(
49 "https://www.youtube.com:443", base::Time(),
50 make_scoped_ptr(crypto::ECPrivateKey::Create()))));
47 } 51 }
48 52
49 void FetchCallback( 53 void FetchCallback(
50 const net::ChannelIDStore::ChannelIDList& channel_ids) { 54 const net::ChannelIDStore::ChannelIDList& channel_ids) {
51 DCHECK_CURRENTLY_ON(BrowserThread::UI); 55 DCHECK_CURRENTLY_ON(BrowserThread::UI);
52 channel_id_list_ = channel_ids; 56 channel_id_list_ = channel_ids;
53 } 57 }
54 58
55 // net::SSLConfigService::Observer implementation: 59 // net::SSLConfigService::Observer implementation:
56 void OnSSLConfigChanged() override { ssl_config_changed_count_++; } 60 void OnSSLConfigChanged() override { ssl_config_changed_count_++; }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 134 }
131 135
132 TEST_F(BrowsingDataChannelIDHelperTest, CannedEmpty) { 136 TEST_F(BrowsingDataChannelIDHelperTest, CannedEmpty) {
133 std::string origin = "https://www.google.com"; 137 std::string origin = "https://www.google.com";
134 138
135 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper( 139 scoped_refptr<CannedBrowsingDataChannelIDHelper> helper(
136 new CannedBrowsingDataChannelIDHelper()); 140 new CannedBrowsingDataChannelIDHelper());
137 141
138 ASSERT_TRUE(helper->empty()); 142 ASSERT_TRUE(helper->empty());
139 helper->AddChannelID(net::ChannelIDStore::ChannelID( 143 helper->AddChannelID(net::ChannelIDStore::ChannelID(
140 origin, base::Time(), base::Time(), "key", "cert")); 144 origin, base::Time(), make_scoped_ptr(crypto::ECPrivateKey::Create())));
141 ASSERT_FALSE(helper->empty()); 145 ASSERT_FALSE(helper->empty());
142 helper->Reset(); 146 helper->Reset();
143 ASSERT_TRUE(helper->empty()); 147 ASSERT_TRUE(helper->empty());
144 } 148 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_remover_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698