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

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: Fix rebase Created 8 years, 5 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 | « sync/util/cryptographer.cc ('k') | sync/util/get_session_name.cc » ('j') | 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 d729311299582b8d3ec5e81ef75bafb736e91d89..01190e9865fa1c200a83ac1016be32f670551e66 100644
--- a/sync/util/cryptographer_unittest.cc
+++ b/sync/util/cryptographer_unittest.cc
@@ -147,6 +147,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
@@ -220,6 +233,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;
« no previous file with comments | « sync/util/cryptographer.cc ('k') | sync/util/get_session_name.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698