Index: net/ssl/default_channel_id_store_unittest.cc |
diff --git a/net/ssl/default_channel_id_store_unittest.cc b/net/ssl/default_channel_id_store_unittest.cc |
index ae27a19d76881dac7492618d36b32164b56b89b6..bda29421758a8f3922960c2e2766a4000396f742 100644 |
--- a/net/ssl/default_channel_id_store_unittest.cc |
+++ b/net/ssl/default_channel_id_store_unittest.cc |
@@ -13,6 +13,7 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/message_loop.h" |
+#include "crypto/ec_private_key.h" |
#include "net/base/net_errors.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -24,11 +25,10 @@ void CallCounter(int* counter) { |
(*counter)++; |
} |
-void GetChannelIDCallbackNotCalled(int err, |
- const std::string& server_identifier, |
- base::Time expiration_time, |
- const std::string& private_key_result, |
- const std::string& cert_result) { |
+void GetChannelIDCallbackNotCalled( |
+ int err, |
+ const std::string& server_identifier, |
+ scoped_ptr<crypto::ECPrivateKey> key_result) { |
ADD_FAILURE() << "Unexpected callback execution."; |
} |
@@ -38,22 +38,16 @@ class AsyncGetChannelIDHelper { |
void Callback(int err, |
const std::string& server_identifier, |
- base::Time expiration_time, |
- const std::string& private_key_result, |
- const std::string& cert_result) { |
+ scoped_ptr<crypto::ECPrivateKey> key_result) { |
err_ = err; |
server_identifier_ = server_identifier; |
- expiration_time_ = expiration_time; |
- private_key_ = private_key_result; |
- cert_ = cert_result; |
+ key_ = key_result.Pass(); |
called_ = true; |
} |
int err_; |
std::string server_identifier_; |
- base::Time expiration_time_; |
- std::string private_key_; |
- std::string cert_; |
+ scoped_ptr<crypto::ECPrivateKey> key_; |
bool called_; |
}; |
@@ -116,41 +110,36 @@ void MockPersistentStore::SetForceKeepSessionState() {} |
MockPersistentStore::~MockPersistentStore() {} |
+void ExpectKeysEqual(crypto::ECPrivateKey* key1, crypto::ECPrivateKey* key2) { |
+ ASSERT_TRUE(key1); |
+ ASSERT_TRUE(key2); |
+ std::string public_key1, public_key2; |
+ EXPECT_TRUE(key1->ExportRawPublicKey(&public_key1)); |
+ EXPECT_TRUE(key2->ExportRawPublicKey(&public_key2)); |
+ EXPECT_EQ(public_key1, public_key2); |
+} |
+ |
} // namespace |
TEST(DefaultChannelIDStoreTest, TestLoading) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
- persistent_store->AddChannelID( |
- DefaultChannelIDStore::ChannelID( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
- persistent_store->AddChannelID( |
- DefaultChannelIDStore::ChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ persistent_store->AddChannelID(DefaultChannelIDStore::ChannelID( |
+ "google.com", base::Time(), crypto::ECPrivateKey::Create())); |
+ persistent_store->AddChannelID(DefaultChannelIDStore::ChannelID( |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create())); |
// Make sure channel_ids load properly. |
DefaultChannelIDStore store(persistent_store.get()); |
// Load has not occurred yet. |
EXPECT_EQ(0, store.GetChannelIDCount()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(2, store.GetChannelIDCount()); |
- store.SetChannelID( |
- "twitter.com", |
- base::Time(), |
- base::Time(), |
- "g", "h"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "twitter.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Set should be synchronous now that load is done. |
EXPECT_EQ(3, store.GetChannelIDCount()); |
} |
@@ -159,118 +148,77 @@ TEST(DefaultChannelIDStoreTest, TestLoading) { |
TEST(DefaultChannelIDStoreTest, TestSettingAndGetting) { |
// No persistent store, all calls will be synchronous. |
DefaultChannelIDStore store(NULL); |
- base::Time expiration_time; |
- std::string private_key, cert; |
+ crypto::ECPrivateKey* expected_key = crypto::ECPrivateKey::Create(); |
+ |
+ scoped_ptr<crypto::ECPrivateKey> key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_FILE_NOT_FOUND, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
- base::Bind(&GetChannelIDCallbackNotCalled))); |
- EXPECT_TRUE(private_key.empty()); |
- EXPECT_TRUE(cert.empty()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(456), |
- "i", "j"); |
- EXPECT_EQ(OK, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("verisign.com", &key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
- EXPECT_EQ(456, expiration_time.ToInternalValue()); |
- EXPECT_EQ("i", private_key); |
- EXPECT_EQ("j", cert); |
+ EXPECT_FALSE(key); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time::FromInternalValue(123), expected_key))); |
+ EXPECT_EQ(OK, store.GetChannelID("verisign.com", &key, |
+ base::Bind(&GetChannelIDCallbackNotCalled))); |
+ ExpectKeysEqual(expected_key, key.get()); |
} |
TEST(DefaultChannelIDStoreTest, TestDuplicateChannelIds) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
+ crypto::ECPrivateKey* expected_key = crypto::ECPrivateKey::Create(); |
- base::Time expiration_time; |
- std::string private_key, cert; |
+ scoped_ptr<crypto::ECPrivateKey> key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(1234), |
- "a", "b"); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time::FromInternalValue(456), |
- base::Time::FromInternalValue(4567), |
- "c", "d"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time::FromInternalValue(123), |
+ crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time::FromInternalValue(456), expected_key))); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(1, store.GetChannelIDCount()); |
- EXPECT_EQ(OK, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
- base::Bind(&GetChannelIDCallbackNotCalled))); |
- EXPECT_EQ(4567, expiration_time.ToInternalValue()); |
- EXPECT_EQ("c", private_key); |
- EXPECT_EQ("d", cert); |
+ EXPECT_EQ(OK, store.GetChannelID("verisign.com", &key, |
+ base::Bind(&GetChannelIDCallbackNotCalled))); |
+ ExpectKeysEqual(expected_key, key.get()); |
} |
TEST(DefaultChannelIDStoreTest, TestAsyncGet) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
+ crypto::ECPrivateKey* expected_key = crypto::ECPrivateKey::Create(); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(1234), |
- "a", "b")); |
+ "verisign.com", base::Time::FromInternalValue(123), expected_key)); |
DefaultChannelIDStore store(persistent_store.get()); |
AsyncGetChannelIDHelper helper; |
- base::Time expiration_time; |
- std::string private_key; |
- std::string cert = "not set"; |
+ scoped_ptr<crypto::ECPrivateKey> key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("verisign.com", &key, |
base::Bind(&AsyncGetChannelIDHelper::Callback, |
base::Unretained(&helper)))); |
// Wait for load & queued get tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(1, store.GetChannelIDCount()); |
- EXPECT_EQ("not set", cert); |
+ EXPECT_FALSE(key); |
EXPECT_TRUE(helper.called_); |
EXPECT_EQ(OK, helper.err_); |
EXPECT_EQ("verisign.com", helper.server_identifier_); |
- EXPECT_EQ(1234, helper.expiration_time_.ToInternalValue()); |
- EXPECT_EQ("a", helper.private_key_); |
- EXPECT_EQ("b", helper.cert_); |
+ ExpectKeysEqual(expected_key, helper.key_.get()); |
} |
TEST(DefaultChannelIDStoreTest, TestDeleteAll) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetChannelID( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
- store.SetChannelID( |
- "harvard.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "google.com", base::Time(), crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "harvard.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -284,15 +232,9 @@ TEST(DefaultChannelIDStoreTest, TestDeleteAll) { |
TEST(DefaultChannelIDStoreTest, TestAsyncGetAndDeleteAll) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create())); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ "google.com", base::Time(), crypto::ECPrivateKey::Create())); |
ChannelIDStore::ChannelIDList pre_channel_ids; |
ChannelIDStore::ChannelIDList post_channel_ids; |
@@ -315,22 +257,15 @@ TEST(DefaultChannelIDStoreTest, TestDelete) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
- base::Time expiration_time; |
- std::string private_key, cert; |
+ scoped_ptr<crypto::ECPrivateKey> key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
- store.SetChannelID( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "google.com", base::Time(), crypto::ECPrivateKey::Create()))); |
EXPECT_EQ(2, store.GetChannelIDCount()); |
int delete_finished = 0; |
@@ -339,42 +274,28 @@ TEST(DefaultChannelIDStoreTest, TestDelete) { |
ASSERT_EQ(1, delete_finished); |
EXPECT_EQ(1, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_FILE_NOT_FOUND, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
- base::Bind(&GetChannelIDCallbackNotCalled))); |
- EXPECT_EQ(OK, |
- store.GetChannelID("google.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("verisign.com", &key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
+ EXPECT_EQ(OK, store.GetChannelID("google.com", &key, |
+ base::Bind(&GetChannelIDCallbackNotCalled))); |
int delete2_finished = 0; |
store.DeleteChannelID("google.com", |
base::Bind(&CallCounter, &delete2_finished)); |
ASSERT_EQ(1, delete2_finished); |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_FILE_NOT_FOUND, |
- store.GetChannelID("google.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("google.com", &key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
} |
TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
+ crypto::ECPrivateKey* expected_key = crypto::ECPrivateKey::Create(); |
+ persistent_store->AddChannelID( |
+ ChannelIDStore::ChannelID("a.com", base::Time::FromInternalValue(1), |
+ crypto::ECPrivateKey::Create())); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "a.com", |
- base::Time::FromInternalValue(1), |
- base::Time::FromInternalValue(2), |
- "a", "b")); |
- persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "b.com", |
- base::Time::FromInternalValue(3), |
- base::Time::FromInternalValue(4), |
- "c", "d")); |
+ "b.com", base::Time::FromInternalValue(3), expected_key)); |
DefaultChannelIDStore store(persistent_store.get()); |
int delete_finished = 0; |
store.DeleteChannelID("a.com", |
@@ -382,20 +303,16 @@ TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
AsyncGetChannelIDHelper a_helper; |
AsyncGetChannelIDHelper b_helper; |
- base::Time expiration_time; |
- std::string private_key; |
- std::string cert = "not set"; |
+ scoped_ptr<crypto::ECPrivateKey> key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetChannelID( |
- "a.com", &expiration_time, &private_key, &cert, |
- base::Bind(&AsyncGetChannelIDHelper::Callback, |
- base::Unretained(&a_helper)))); |
+ store.GetChannelID("a.com", &key, |
+ base::Bind(&AsyncGetChannelIDHelper::Callback, |
+ base::Unretained(&a_helper)))); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetChannelID( |
- "b.com", &expiration_time, &private_key, &cert, |
- base::Bind(&AsyncGetChannelIDHelper::Callback, |
- base::Unretained(&b_helper)))); |
+ store.GetChannelID("b.com", &key, |
+ base::Bind(&AsyncGetChannelIDHelper::Callback, |
+ base::Unretained(&b_helper)))); |
EXPECT_EQ(0, delete_finished); |
EXPECT_FALSE(a_helper.called_); |
@@ -404,19 +321,15 @@ TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(1, delete_finished); |
EXPECT_EQ(1, store.GetChannelIDCount()); |
- EXPECT_EQ("not set", cert); |
+ EXPECT_FALSE(key); |
EXPECT_TRUE(a_helper.called_); |
EXPECT_EQ(ERR_FILE_NOT_FOUND, a_helper.err_); |
EXPECT_EQ("a.com", a_helper.server_identifier_); |
- EXPECT_EQ(0, a_helper.expiration_time_.ToInternalValue()); |
- EXPECT_EQ("", a_helper.private_key_); |
- EXPECT_EQ("", a_helper.cert_); |
+ EXPECT_FALSE(a_helper.key_); |
EXPECT_TRUE(b_helper.called_); |
EXPECT_EQ(OK, b_helper.err_); |
EXPECT_EQ("b.com", b_helper.server_identifier_); |
- EXPECT_EQ(4, b_helper.expiration_time_.ToInternalValue()); |
- EXPECT_EQ("c", b_helper.private_key_); |
- EXPECT_EQ("d", b_helper.cert_); |
+ ExpectKeysEqual(expected_key, b_helper.key_.get()); |
} |
TEST(DefaultChannelIDStoreTest, TestGetAll) { |
@@ -424,26 +337,14 @@ TEST(DefaultChannelIDStoreTest, TestGetAll) { |
DefaultChannelIDStore store(persistent_store.get()); |
EXPECT_EQ(0, store.GetChannelIDCount()); |
- store.SetChannelID( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetChannelID( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
- store.SetChannelID( |
- "harvard.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
- store.SetChannelID( |
- "mit.com", |
- base::Time(), |
- base::Time(), |
- "g", "h"); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "verisign.com", base::Time(), crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "google.com", base::Time(), crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "harvard.com", base::Time(), crypto::ECPrivateKey::Create()))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "mit.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -456,33 +357,25 @@ TEST(DefaultChannelIDStoreTest, TestGetAll) { |
TEST(DefaultChannelIDStoreTest, TestInitializeFrom) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
- |
- store.SetChannelID( |
- "preexisting.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetChannelID( |
- "both.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
+ crypto::ECPrivateKey* preexisting_key = crypto::ECPrivateKey::Create(); |
+ crypto::ECPrivateKey* both_key = crypto::ECPrivateKey::Create(); |
+ crypto::ECPrivateKey* copied_key = crypto::ECPrivateKey::Create(); |
+ |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "preexisting.com", base::Time(), preexisting_key))); |
+ store.SetChannelID(make_scoped_ptr(new ChannelIDStore::ChannelID( |
+ "both.com", base::Time(), crypto::ECPrivateKey::Create()))); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(2, store.GetChannelIDCount()); |
ChannelIDStore::ChannelIDList source_channel_ids; |
source_channel_ids.push_back(ChannelIDStore::ChannelID( |
- "both.com", |
- base::Time(), |
- base::Time(), |
+ "both.com", base::Time(), |
// Key differs from above to test that existing entries are overwritten. |
- "e", "f")); |
- source_channel_ids.push_back(ChannelIDStore::ChannelID( |
- "copied.com", |
- base::Time(), |
- base::Time(), |
- "g", "h")); |
+ both_key)); |
+ source_channel_ids.push_back( |
+ ChannelIDStore::ChannelID("copied.com", base::Time(), copied_key)); |
store.InitializeFrom(source_channel_ids); |
EXPECT_EQ(3, store.GetChannelIDCount()); |
@@ -492,43 +385,36 @@ TEST(DefaultChannelIDStoreTest, TestInitializeFrom) { |
ChannelIDStore::ChannelIDList::iterator channel_id = channel_ids.begin(); |
EXPECT_EQ("both.com", channel_id->server_identifier()); |
- EXPECT_EQ("e", channel_id->private_key()); |
+ ExpectKeysEqual(both_key, channel_id->key()); |
++channel_id; |
EXPECT_EQ("copied.com", channel_id->server_identifier()); |
- EXPECT_EQ("g", channel_id->private_key()); |
+ ExpectKeysEqual(copied_key, channel_id->key()); |
++channel_id; |
EXPECT_EQ("preexisting.com", channel_id->server_identifier()); |
- EXPECT_EQ("a", channel_id->private_key()); |
+ ExpectKeysEqual(preexisting_key, channel_id->key()); |
} |
TEST(DefaultChannelIDStoreTest, TestAsyncInitializeFrom) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
+ crypto::ECPrivateKey* preexisting_key = crypto::ECPrivateKey::Create(); |
+ crypto::ECPrivateKey* both_key = crypto::ECPrivateKey::Create(); |
+ crypto::ECPrivateKey* copied_key = crypto::ECPrivateKey::Create(); |
+ |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "preexisting.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
+ "preexisting.com", base::Time(), preexisting_key)); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
- "both.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ "both.com", base::Time(), crypto::ECPrivateKey::Create())); |
DefaultChannelIDStore store(persistent_store.get()); |
ChannelIDStore::ChannelIDList source_channel_ids; |
source_channel_ids.push_back(ChannelIDStore::ChannelID( |
- "both.com", |
- base::Time(), |
- base::Time(), |
+ "both.com", base::Time(), |
// Key differs from above to test that existing entries are overwritten. |
- "e", "f")); |
- source_channel_ids.push_back(ChannelIDStore::ChannelID( |
- "copied.com", |
- base::Time(), |
- base::Time(), |
- "g", "h")); |
+ both_key)); |
+ source_channel_ids.push_back( |
+ ChannelIDStore::ChannelID("copied.com", base::Time(), copied_key)); |
store.InitializeFrom(source_channel_ids); |
EXPECT_EQ(0, store.GetChannelIDCount()); |
// Wait for load & queued tasks. |
@@ -541,15 +427,15 @@ TEST(DefaultChannelIDStoreTest, TestAsyncInitializeFrom) { |
ChannelIDStore::ChannelIDList::iterator channel_id = channel_ids.begin(); |
EXPECT_EQ("both.com", channel_id->server_identifier()); |
- EXPECT_EQ("e", channel_id->private_key()); |
+ ExpectKeysEqual(both_key, channel_id->key()); |
++channel_id; |
EXPECT_EQ("copied.com", channel_id->server_identifier()); |
- EXPECT_EQ("g", channel_id->private_key()); |
+ ExpectKeysEqual(copied_key, channel_id->key()); |
++channel_id; |
EXPECT_EQ("preexisting.com", channel_id->server_identifier()); |
- EXPECT_EQ("a", channel_id->private_key()); |
+ ExpectKeysEqual(preexisting_key, channel_id->key()); |
} |
} // namespace net |