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..4e41de2d72ab5fbbfaa40a10d62d95f65ffdc979 100644 |
--- a/net/ssl/default_channel_id_store_unittest.cc |
+++ b/net/ssl/default_channel_id_store_unittest.cc |
@@ -26,9 +26,8 @@ void CallCounter(int* 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) { |
+ const std::string& public_key_result) { |
ADD_FAILURE() << "Unexpected callback execution."; |
} |
@@ -38,22 +37,19 @@ 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) { |
+ const std::string& public_key_result) { |
err_ = err; |
server_identifier_ = server_identifier; |
- expiration_time_ = expiration_time; |
private_key_ = private_key_result; |
- cert_ = cert_result; |
+ public_key_ = public_key_result; |
called_ = true; |
} |
int err_; |
std::string server_identifier_; |
- base::Time expiration_time_; |
std::string private_key_; |
- std::string cert_; |
+ std::string public_key_; |
bool called_; |
}; |
@@ -125,13 +121,11 @@ TEST(DefaultChannelIDStoreTest, TestLoading) { |
DefaultChannelIDStore::ChannelID( |
"google.com", |
base::Time(), |
- base::Time(), |
"a", "b")); |
persistent_store->AddChannelID( |
DefaultChannelIDStore::ChannelID( |
"verisign.com", |
base::Time(), |
- base::Time(), |
"c", "d")); |
// Make sure channel_ids load properly. |
@@ -141,7 +135,6 @@ TEST(DefaultChannelIDStoreTest, TestLoading) { |
store.SetChannelID( |
"verisign.com", |
base::Time(), |
- base::Time(), |
"e", "f"); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -149,7 +142,6 @@ TEST(DefaultChannelIDStoreTest, TestLoading) { |
store.SetChannelID( |
"twitter.com", |
base::Time(), |
- base::Time(), |
"g", "h"); |
// Set should be synchronous now that load is done. |
EXPECT_EQ(3, store.GetChannelIDCount()); |
@@ -159,63 +151,45 @@ 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; |
+ std::string private_key, public_key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_FILE_NOT_FOUND, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("verisign.com", &private_key, &public_key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
EXPECT_TRUE(private_key.empty()); |
- EXPECT_TRUE(cert.empty()); |
+ EXPECT_TRUE(public_key.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, |
- base::Bind(&GetChannelIDCallbackNotCalled))); |
- EXPECT_EQ(456, expiration_time.ToInternalValue()); |
+ EXPECT_EQ(OK, store.GetChannelID("verisign.com", &private_key, &public_key, |
+ base::Bind(&GetChannelIDCallbackNotCalled))); |
EXPECT_EQ("i", private_key); |
- EXPECT_EQ("j", cert); |
+ EXPECT_EQ("j", public_key); |
} |
TEST(DefaultChannelIDStoreTest, TestDuplicateChannelIds) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
- base::Time expiration_time; |
- std::string private_key, cert; |
+ std::string private_key, public_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"); |
// 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(OK, store.GetChannelID("verisign.com", &private_key, &public_key, |
+ base::Bind(&GetChannelIDCallbackNotCalled))); |
EXPECT_EQ("c", private_key); |
- EXPECT_EQ("d", cert); |
+ EXPECT_EQ("d", public_key); |
} |
TEST(DefaultChannelIDStoreTest, TestAsyncGet) { |
@@ -223,33 +197,27 @@ TEST(DefaultChannelIDStoreTest, TestAsyncGet) { |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
"verisign.com", |
base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(1234), |
"a", "b")); |
DefaultChannelIDStore store(persistent_store.get()); |
AsyncGetChannelIDHelper helper; |
- base::Time expiration_time; |
std::string private_key; |
- std::string cert = "not set"; |
+ std::string public_key = "not set"; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetChannelID("verisign.com", |
- &expiration_time, |
- &private_key, |
- &cert, |
+ store.GetChannelID("verisign.com", &private_key, &public_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_EQ("not set", public_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_); |
+ EXPECT_EQ("b", helper.public_key_); |
} |
TEST(DefaultChannelIDStoreTest, TestDeleteAll) { |
@@ -259,17 +227,14 @@ TEST(DefaultChannelIDStoreTest, TestDeleteAll) { |
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"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -286,12 +251,10 @@ TEST(DefaultChannelIDStoreTest, TestAsyncGetAndDeleteAll) { |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
"verisign.com", |
base::Time(), |
- base::Time(), |
"a", "b")); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
"google.com", |
base::Time(), |
- base::Time(), |
"c", "d")); |
ChannelIDStore::ChannelIDList pre_channel_ids; |
@@ -315,13 +278,11 @@ TEST(DefaultChannelIDStoreTest, TestDelete) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
DefaultChannelIDStore store(persistent_store.get()); |
- base::Time expiration_time; |
- std::string private_key, cert; |
+ std::string private_key, public_key; |
EXPECT_EQ(0, store.GetChannelIDCount()); |
store.SetChannelID( |
"verisign.com", |
base::Time(), |
- base::Time(), |
"a", "b"); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -329,7 +290,6 @@ TEST(DefaultChannelIDStoreTest, TestDelete) { |
store.SetChannelID( |
"google.com", |
base::Time(), |
- base::Time(), |
"c", "d"); |
EXPECT_EQ(2, store.GetChannelIDCount()); |
@@ -339,27 +299,17 @@ 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", &private_key, &public_key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
+ EXPECT_EQ(OK, store.GetChannelID("google.com", &private_key, &public_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", &private_key, &public_key, |
base::Bind(&GetChannelIDCallbackNotCalled))); |
} |
@@ -368,12 +318,10 @@ TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
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")); |
DefaultChannelIDStore store(persistent_store.get()); |
int delete_finished = 0; |
@@ -382,20 +330,17 @@ TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
AsyncGetChannelIDHelper a_helper; |
AsyncGetChannelIDHelper b_helper; |
- base::Time expiration_time; |
std::string private_key; |
- std::string cert = "not set"; |
+ std::string public_key = "not set"; |
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", &private_key, &public_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", &private_key, &public_key, |
+ base::Bind(&AsyncGetChannelIDHelper::Callback, |
+ base::Unretained(&b_helper)))); |
EXPECT_EQ(0, delete_finished); |
EXPECT_FALSE(a_helper.called_); |
@@ -404,19 +349,17 @@ TEST(DefaultChannelIDStoreTest, TestAsyncDelete) { |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(1, delete_finished); |
EXPECT_EQ(1, store.GetChannelIDCount()); |
- EXPECT_EQ("not set", cert); |
+ EXPECT_EQ("not set", public_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_EQ("", a_helper.public_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_); |
+ EXPECT_EQ("d", b_helper.public_key_); |
} |
TEST(DefaultChannelIDStoreTest, TestGetAll) { |
@@ -427,22 +370,18 @@ TEST(DefaultChannelIDStoreTest, TestGetAll) { |
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"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -460,12 +399,10 @@ TEST(DefaultChannelIDStoreTest, TestInitializeFrom) { |
store.SetChannelID( |
"preexisting.com", |
base::Time(), |
- base::Time(), |
"a", "b"); |
store.SetChannelID( |
"both.com", |
base::Time(), |
- base::Time(), |
"c", "d"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -475,13 +412,11 @@ TEST(DefaultChannelIDStoreTest, TestInitializeFrom) { |
source_channel_ids.push_back(ChannelIDStore::ChannelID( |
"both.com", |
base::Time(), |
- 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")); |
store.InitializeFrom(source_channel_ids); |
EXPECT_EQ(3, store.GetChannelIDCount()); |
@@ -508,12 +443,10 @@ TEST(DefaultChannelIDStoreTest, TestAsyncInitializeFrom) { |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
"preexisting.com", |
base::Time(), |
- base::Time(), |
"a", "b")); |
persistent_store->AddChannelID(ChannelIDStore::ChannelID( |
"both.com", |
base::Time(), |
- base::Time(), |
"c", "d")); |
DefaultChannelIDStore store(persistent_store.get()); |
@@ -521,13 +454,11 @@ TEST(DefaultChannelIDStoreTest, TestAsyncInitializeFrom) { |
source_channel_ids.push_back(ChannelIDStore::ChannelID( |
"both.com", |
base::Time(), |
- 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")); |
store.InitializeFrom(source_channel_ids); |
EXPECT_EQ(0, store.GetChannelIDCount()); |