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

Unified Diff: components/sync/base/nigori_unittest.cc

Issue 2813453004: [sync] Fix decryption failure caused by missing user_key (Closed)
Patch Set: Restore derivation check, add tests Created 3 years, 8 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 | « components/sync/base/nigori.cc ('k') | components/sync/engine_impl/model_type_worker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/base/nigori_unittest.cc
diff --git a/components/sync/base/nigori_unittest.cc b/components/sync/base/nigori_unittest.cc
index 09bbcd75a4039044752a160cee2b5edcaea56335..4dd0e22585a47257e8fd4c3e48d645f9fb74038b 100644
--- a/components/sync/base/nigori_unittest.cc
+++ b/components/sync/base/nigori_unittest.cc
@@ -126,12 +126,13 @@ TEST(SyncNigoriTest, ExportImport) {
Nigori nigori1;
EXPECT_TRUE(nigori1.InitByDerivation("example.com", "username", "password"));
+ std::string user_key;
std::string encryption_key;
std::string mac_key;
- EXPECT_TRUE(nigori1.ExportKeys(&encryption_key, &mac_key));
+ EXPECT_TRUE(nigori1.ExportKeys(&user_key, &encryption_key, &mac_key));
Nigori nigori2;
- EXPECT_TRUE(nigori2.InitByImport(encryption_key, mac_key));
+ EXPECT_TRUE(nigori2.InitByImport(user_key, encryption_key, mac_key));
std::string original("test");
std::string plaintext;
@@ -151,5 +152,30 @@ TEST(SyncNigoriTest, ExportImport) {
EXPECT_EQ(permuted1, permuted2);
}
+TEST(SyncNigoriTest, InitByDerivationSetsUserKey) {
+ Nigori nigori;
+ EXPECT_TRUE(nigori.InitByDerivation("example.com", "username", "password"));
+
+ std::string user_key = "";
+ std::string encryption_key;
+ std::string mac_key;
+ EXPECT_TRUE(nigori.ExportKeys(&user_key, &encryption_key, &mac_key));
+
+ EXPECT_NE(user_key, "");
+}
+
+TEST(SyncNigoriTest, InitByImportToleratesEmptyUserKey) {
+ Nigori nigori1;
+ EXPECT_TRUE(nigori1.InitByDerivation("example.com", "username", "password"));
+
+ std::string user_key;
+ std::string encryption_key;
+ std::string mac_key;
+ EXPECT_TRUE(nigori1.ExportKeys(&user_key, &encryption_key, &mac_key));
+
+ Nigori nigori2;
+ EXPECT_TRUE(nigori2.InitByImport("", encryption_key, mac_key));
+}
+
} // anonymous namespace
} // namespace syncer
« no previous file with comments | « components/sync/base/nigori.cc ('k') | components/sync/engine_impl/model_type_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698