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

Unified Diff: sync/util/cryptographer_unittest.cc

Issue 10540149: [Sync] Persist keystore key across restarts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« sync/util/cryptographer.cc ('K') | « sync/util/cryptographer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/util/cryptographer_unittest.cc
diff --git a/sync/util/cryptographer_unittest.cc b/sync/util/cryptographer_unittest.cc
index c999916cedaead3625b91133db037dedafe6e468..a6334399d89a1ea30becf7518b75a6d0f21469f0 100644
--- a/sync/util/cryptographer_unittest.cc
+++ b/sync/util/cryptographer_unittest.cc
@@ -149,6 +149,19 @@ TEST_F(SyncCryptographerTest, AddKeySetsDefault) {
EXPECT_EQ(encrypted3.key_name(), encrypted4.key_name());
}
+// Ensure setting the keystore key works and doesn't modify the default nigori.
+TEST_F(SyncCryptographerTest, SetKeystore) {
+ EXPECT_FALSE(cryptographer_.is_initialized());
+ EXPECT_FALSE(cryptographer_.HasKeystoreKey());
+
+ EXPECT_FALSE(cryptographer_.SetKeystoreKey(""));
+ EXPECT_FALSE(cryptographer_.HasKeystoreKey());
+
+ EXPECT_TRUE(cryptographer_.SetKeystoreKey("keystore_key"));
+ EXPECT_TRUE(cryptographer_.HasKeystoreKey());
+ EXPECT_FALSE(cryptographer_.is_initialized());
+}
+
// Crashes, Bug 55178.
#if defined(OS_WIN)
#define MAYBE_EncryptExportDecrypt DISABLED_EncryptExportDecrypt
@@ -222,6 +235,24 @@ TEST_F(SyncCryptographerTest, MAYBE_PackUnpack) {
EXPECT_EQ(expected_mac, mac_key);
}
+// Test that bootstrapping the keystore key works and doesn't affect the default
+// nigori.
+TEST_F(SyncCryptographerTest, BootstrapKeystore) {
+ std::string token;
+ cryptographer_.GetKeystoreKeyBootstrapToken(&token);
+ EXPECT_TRUE(token.empty());
+
+ cryptographer_.SetKeystoreKey("keystore_key");
+ cryptographer_.GetKeystoreKeyBootstrapToken(&token);
+ EXPECT_FALSE(token.empty());
+
+ Cryptographer cryptographer2(&encryptor_);
+ EXPECT_FALSE(cryptographer2.HasKeystoreKey());
+ cryptographer2.BootstrapKeystoreKey(token);
+ EXPECT_TRUE(cryptographer2.HasKeystoreKey());
+ EXPECT_FALSE(cryptographer2.is_initialized());
+}
+
TEST_F(SyncCryptographerTest, NigoriEncryptionTypes) {
Cryptographer cryptographer2(&encryptor_);
sync_pb::NigoriSpecifics nigori;
« sync/util/cryptographer.cc ('K') | « sync/util/cryptographer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698