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

Unified Diff: chrome/browser/metrics/variations/variations_seed_store_unittest.cc

Issue 646733002: Added incident report for variations seed signature mismatch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabled testing of signature verification on mobile. Created 6 years, 2 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
Index: chrome/browser/metrics/variations/variations_seed_store_unittest.cc
diff --git a/chrome/browser/metrics/variations/variations_seed_store_unittest.cc b/chrome/browser/metrics/variations/variations_seed_store_unittest.cc
index 6f42c807bf3360a0ef55cdc61ad66638707468b4..886dd4bbca6f8c53302600a770d2fa8941c9209a 100644
--- a/chrome/browser/metrics/variations/variations_seed_store_unittest.cc
+++ b/chrome/browser/metrics/variations/variations_seed_store_unittest.cc
@@ -126,6 +126,60 @@ TEST(VariationsSeedStoreTest, LoadSeed) {
EXPECT_FALSE(seed_store.LoadSeed(&loaded_seed));
}
+TEST(VariationsSeedStoreTest, GetInvalidSignature) {
+ const variations::VariationsSeed seed = CreateTestSeed();
+ std::string seed_hash;
+ const std::string base64_seed = SerializeSeedBase64(seed, &seed_hash);
+
+ TestingPrefServiceSimple prefs;
+ VariationsSeedStore::RegisterPrefs(prefs.registry());
+ prefs.SetString(prefs::kVariationsSeed, base64_seed);
+
+ // The below seed and signature pair were generated using the server's
+ // private key.
+ const std::string base64_seed_data =
+ "CigxZDI5NDY0ZmIzZDc4ZmYxNTU2ZTViNTUxYzY0NDdjYmM3NGU1ZmQwEr0BCh9VTUEtVW5p"
+ "Zm9ybWl0eS1UcmlhbC0xMC1QZXJjZW50GICckqUFOAFCB2RlZmF1bHRKCwoHZGVmYXVsdBAB"
+ "SgwKCGdyb3VwXzAxEAFKDAoIZ3JvdXBfMDIQAUoMCghncm91cF8wMxABSgwKCGdyb3VwXzA0"
+ "EAFKDAoIZ3JvdXBfMDUQAUoMCghncm91cF8wNhABSgwKCGdyb3VwXzA3EAFKDAoIZ3JvdXBf"
+ "MDgQAUoMCghncm91cF8wORAB";
+ const std::string base64_seed_signature =
+ "MEQCIDD1IVxjzWYncun+9IGzqYjZvqxxujQEayJULTlbTGA/AiAr0oVmEgVUQZBYq5VLOSvy"
+ "96JkMYgzTkHPwbv7K/CmgA==";
+ const std::string base64_seed_signature_invalid =
+ "AEQCIDD1IVxjzWYncun+9IGzqYjZvqxxujQEayJULTlbTGA/AiAr0oVmEgVUQZBYq5VLOSvy"
+ "96JkMYgzTkHPwbv7K/CmgA==";
+
+ // Set seed and valid signature in prefs.
+ prefs.SetString(prefs::kVariationsSeed, base64_seed_data);
+ prefs.SetString(prefs::kVariationsSeedSignature, base64_seed_signature);
+
+ VariationsSeedStore seed_store(&prefs);
+ variations::VariationsSeed loaded_seed;
+ seed_store.LoadSeed(&loaded_seed);
+ std::string invalid_signature = seed_store.GetInvalidSignature();
+ // Valid signature so we get an empty string.
+ EXPECT_EQ(std::string(), invalid_signature);
+
+ prefs.SetString(prefs::kVariationsSeedSignature,
+ base64_seed_signature_invalid);
+ seed_store.LoadSeed(&loaded_seed);
+ // Invalid signature, so we should get the signature itself, except on mobile
+ // where we should get an empty string because verification is not enabled.
+ invalid_signature = seed_store.GetInvalidSignature();
+#if defined(OS_IOS) || defined(OS_ANDROID)
+ EXPECT_EQ(std::string(), invalid_signature);
+#else
+ EXPECT_EQ(base64_seed_signature_invalid, invalid_signature);
+#endif
+
+ prefs.SetString(prefs::kVariationsSeedSignature, std::string());
+ seed_store.LoadSeed(&loaded_seed);
+ invalid_signature = seed_store.GetInvalidSignature();
+ // Empty signature, not considered invalid.
+ EXPECT_EQ(std::string(), invalid_signature);
+}
+
TEST(VariationsSeedStoreTest, StoreSeedData) {
const variations::VariationsSeed seed = CreateTestSeed();
const std::string serialized_seed = SerializeSeed(seed);
« no previous file with comments | « chrome/browser/metrics/variations/variations_seed_store.cc ('k') | chrome/browser/metrics/variations/variations_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698