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

Unified Diff: components/sync/core_impl/sync_manager_impl_unittest.cc

Issue 2278333002: Supplimentary identifier for passwords specific (Closed)
Patch Set: adressed cmments Created 4 years, 4 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 | « no previous file | components/sync/protocol/password_specifics.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/core_impl/sync_manager_impl_unittest.cc
diff --git a/components/sync/core_impl/sync_manager_impl_unittest.cc b/components/sync/core_impl/sync_manager_impl_unittest.cc
index 3c0f595bfdfc1ae8b52905ef0f3ea2978250d215..58c08452b4cf51f1d1b4ca7c270eda0b556cb4e3 100644
--- a/components/sync/core_impl/sync_manager_impl_unittest.cc
+++ b/components/sync/core_impl/sync_manager_impl_unittest.cc
@@ -222,6 +222,10 @@ int GetTotalNodeCount(UserShare* share, int64_t root) {
return node.GetTotalNodeCount();
}
+const char kUrl[] = "example.com";
+const char kPasswordValue[] = "secret";
+const char kClientTag[] = "tag";
+
} // namespace
class SyncApiTest : public testing::Test {
@@ -518,10 +522,10 @@ TEST_F(SyncApiTest, WriteAndReadPassword) {
WriteNode password_node(&trans);
WriteNode::InitUniqueByCreationResult result =
- password_node.InitUniqueByCreation(PASSWORDS, root_node, "foo");
+ password_node.InitUniqueByCreation(PASSWORDS, root_node, kClientTag);
EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
sync_pb::PasswordSpecificsData data;
- data.set_password_value("secret");
+ data.set_password_value(kPasswordValue);
password_node.SetPasswordSpecifics(data);
}
{
@@ -529,10 +533,54 @@ TEST_F(SyncApiTest, WriteAndReadPassword) {
ReadNode password_node(&trans);
EXPECT_EQ(BaseNode::INIT_OK,
- password_node.InitByClientTagLookup(PASSWORDS, "foo"));
+ password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
const sync_pb::PasswordSpecificsData& data =
password_node.GetPasswordSpecifics();
- EXPECT_EQ("secret", data.password_value());
+ EXPECT_EQ(kPasswordValue, data.password_value());
+ // Check that nothing has appeared in the unencrypted field.
+ EXPECT_FALSE(password_node.GetEntitySpecifics()
+ .password()
+ .has_unencrypted_metadata());
+ }
+}
+
+TEST_F(SyncApiTest, WriteDoesntChangeUnencryptedPasswordMetadata) {
Nicolas Zea 2016/08/26 23:47:01 What's the purpose of this test? Just that the met
melandory 2016/08/26 23:59:47 Fixed. My idea was to have test for persisting of
+ KeyParams params = {"localhost", "username", "passphrase"};
+ {
+ ReadTransaction trans(FROM_HERE, user_share());
+ trans.GetCryptographer()->AddKey(params);
+ }
+ {
+ WriteTransaction trans(FROM_HERE, user_share());
+ ReadNode root_node(&trans);
+ root_node.InitByRootLookup();
+
+ WriteNode password_node(&trans);
+ WriteNode::InitUniqueByCreationResult result =
+ password_node.InitUniqueByCreation(PASSWORDS, root_node, kClientTag);
+ EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
+ sync_pb::EntitySpecifics entity_specifics;
+ sync_pb::PasswordSpecifics* password_specifics =
+ entity_specifics.mutable_password();
+ password_specifics->mutable_unencrypted_metadata()->set_url(kUrl);
+ password_node.SetEntitySpecifics(entity_specifics);
+ sync_pb::PasswordSpecificsData data;
+ data.set_password_value(kPasswordValue);
+ password_node.SetPasswordSpecifics(data);
+ }
+ {
+ ReadTransaction trans(FROM_HERE, user_share());
+
+ ReadNode password_node(&trans);
+ EXPECT_EQ(BaseNode::INIT_OK,
+ password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
+ const sync_pb::PasswordSpecificsData& data =
+ password_node.GetPasswordSpecifics();
+ EXPECT_EQ(kUrl, password_node.GetEntitySpecifics()
+ .password()
+ .unencrypted_metadata()
+ .url());
+ EXPECT_EQ(kPasswordValue, data.password_value());
}
}
@@ -2064,22 +2112,25 @@ TEST_F(SyncManagerTest, UpdatePasswordSetPasswordSpecifics) {
// Passwords have their own handling for encryption. Verify setting a new
// passphrase updates the data.
Nicolas Zea 2016/08/26 23:47:01 nit: mention that it also clears the metadata
melandory 2016/08/26 23:59:47 Done.
TEST_F(SyncManagerTest, UpdatePasswordNewPassphrase) {
- std::string client_tag = "title";
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
sync_pb::EntitySpecifics entity_specifics;
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
Cryptographer* cryptographer = trans.GetCryptographer();
sync_pb::PasswordSpecificsData data;
- data.set_password_value("secret");
+ data.set_password_value(kPasswordValue);
+ entity_specifics.mutable_password()
+ ->mutable_unencrypted_metadata()
+ ->set_url(kUrl);
cryptographer->Encrypt(
data, entity_specifics.mutable_password()->mutable_encrypted());
}
- MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag,
- syncable::GenerateSyncableHash(PASSWORDS, client_tag),
+ EXPECT_TRUE(entity_specifics.password().has_unencrypted_metadata());
+ MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, kClientTag,
+ syncable::GenerateSyncableHash(PASSWORDS, kClientTag),
entity_specifics);
// New node shouldn't start off unsynced.
- EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag));
+ EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
// Set a new passphrase. Should set is_unsynced.
testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
@@ -2087,7 +2138,21 @@ TEST_F(SyncManagerTest, UpdatePasswordNewPassphrase) {
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
ExpectPassphraseAcceptance();
SetCustomPassphraseAndCheck("new_passphrase");
- EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, client_tag));
+ {
+ ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
+ Cryptographer* cryptographer = trans.GetCryptographer();
+ EXPECT_TRUE(cryptographer->is_ready());
+ ReadNode password_node(&trans);
+ EXPECT_EQ(BaseNode::INIT_OK,
+ password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
+ const sync_pb::PasswordSpecificsData& data =
+ password_node.GetPasswordSpecifics();
+ EXPECT_EQ(kPasswordValue, data.password_value());
+ EXPECT_FALSE(password_node.GetEntitySpecifics()
+ .password()
+ .has_unencrypted_metadata());
+ }
+ EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
}
// Passwords have their own handling for encryption. Verify it does not result
« no previous file with comments | « no previous file | components/sync/protocol/password_specifics.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698