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

Unified Diff: chrome/browser/net/quota_policy_channel_id_store_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | net/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/quota_policy_channel_id_store_unittest.cc
diff --git a/chrome/browser/net/quota_policy_channel_id_store_unittest.cc b/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
index dda262e37586a5e44b150d11e783ae9a50e25966..670bf883b8118c53ab184f4ba615b7c1442056bf 100644
--- a/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
+++ b/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
@@ -20,6 +20,7 @@
#include "net/cookies/cookie_util.h"
#include "net/ssl/ssl_client_cert_type.h"
#include "net/test/cert_test_util.h"
+#include "net/test/channel_id_test_util.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -55,13 +56,6 @@ class QuotaPolicyChannelIDStoreTest : public testing::Test {
ScopedVector<net::DefaultChannelIDStore::ChannelID> channel_ids;
Load(&channel_ids);
ASSERT_EQ(0u, channel_ids.size());
- // Make sure the store gets written at least once.
- store_->AddChannelID(
- net::DefaultChannelIDStore::ChannelID("google.com",
- base::Time::FromInternalValue(1),
- base::Time::FromInternalValue(2),
- "a",
- "b"));
}
void TearDown() override {
@@ -77,12 +71,14 @@ class QuotaPolicyChannelIDStoreTest : public testing::Test {
// Test if data is stored as expected in the QuotaPolicy database.
TEST_F(QuotaPolicyChannelIDStoreTest, TestPersistence) {
- store_->AddChannelID(
- net::DefaultChannelIDStore::ChannelID("foo.com",
- base::Time::FromInternalValue(3),
- base::Time::FromInternalValue(4),
- "c",
- "d"));
+ scoped_ptr<crypto::ECPrivateKey> goog_key(crypto::ECPrivateKey::Create());
+ scoped_ptr<crypto::ECPrivateKey> foo_key(crypto::ECPrivateKey::Create());
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "google.com", base::Time::FromInternalValue(1),
+ make_scoped_ptr(goog_key->Copy())));
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "foo.com", base::Time::FromInternalValue(3),
+ make_scoped_ptr(foo_key->Copy())));
ScopedVector<net::DefaultChannelIDStore::ChannelID> channel_ids;
// Replace the store effectively destroying the current one and forcing it
@@ -109,15 +105,11 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPersistence) {
foo_channel_id = channel_ids[0];
}
ASSERT_EQ("google.com", goog_channel_id->server_identifier());
- ASSERT_STREQ("a", goog_channel_id->private_key().c_str());
- ASSERT_STREQ("b", goog_channel_id->cert().c_str());
+ EXPECT_TRUE(net::KeysEqual(goog_key.get(), goog_channel_id->key()));
ASSERT_EQ(1, goog_channel_id->creation_time().ToInternalValue());
- ASSERT_EQ(2, goog_channel_id->expiration_time().ToInternalValue());
ASSERT_EQ("foo.com", foo_channel_id->server_identifier());
- ASSERT_STREQ("c", foo_channel_id->private_key().c_str());
- ASSERT_STREQ("d", foo_channel_id->cert().c_str());
+ EXPECT_TRUE(net::KeysEqual(foo_key.get(), foo_channel_id->key()));
ASSERT_EQ(3, foo_channel_id->creation_time().ToInternalValue());
- ASSERT_EQ(4, foo_channel_id->expiration_time().ToInternalValue());
// Now delete the channel ID and check persistence again.
store_->DeleteChannelID(*channel_ids[0]);
@@ -138,12 +130,12 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPersistence) {
// Test if data is stored as expected in the QuotaPolicy database.
TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
- store_->AddChannelID(
- net::DefaultChannelIDStore::ChannelID("nonpersistent.com",
- base::Time::FromInternalValue(3),
- base::Time::FromInternalValue(4),
- "c",
- "d"));
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "google.com", base::Time::FromInternalValue(1),
+ make_scoped_ptr(crypto::ECPrivateKey::Create())));
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "nonpersistent.com", base::Time::FromInternalValue(3),
+ make_scoped_ptr(crypto::ECPrivateKey::Create())));
ScopedVector<net::DefaultChannelIDStore::ChannelID> channel_ids;
// Replace the store effectively destroying the current one and forcing it
@@ -172,10 +164,10 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
// being committed to disk.
store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
"nonpersistent.com", base::Time::FromInternalValue(5),
- base::Time::FromInternalValue(6), "e", "f"));
+ make_scoped_ptr(crypto::ECPrivateKey::Create())));
store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
"persistent.com", base::Time::FromInternalValue(7),
- base::Time::FromInternalValue(8), "g", "h"));
+ make_scoped_ptr(crypto::ECPrivateKey::Create())));
// Now close the store, and the nonpersistent.com channel IDs should be
// deleted according to policy.
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698