| 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..fded13abfa6126fe8a1d1bffde2ecc84d1942063 100644
|
| --- a/chrome/browser/metrics/variations/variations_seed_store_unittest.cc
|
| +++ b/chrome/browser/metrics/variations/variations_seed_store_unittest.cc
|
| @@ -126,6 +126,55 @@ 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);
|
| +
|
| + variations::VariationsSeed loaded_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);
|
| + seed_store.LoadSeed(&loaded_seed);
|
| + std::string invalid_signature;
|
| + // Valid signature.
|
| + EXPECT_FALSE(seed_store.GetInvalidSignature(&invalid_signature));
|
| +
|
| + prefs.SetString(prefs::kVariationsSeedSignature,
|
| + base64_seed_signature_invalid);
|
| + seed_store.LoadSeed(&loaded_seed);
|
| + // Invalid signature, so we should get the signature itself.
|
| + EXPECT_TRUE(seed_store.GetInvalidSignature(&invalid_signature));
|
| + EXPECT_EQ(invalid_signature, base64_seed_signature_invalid);
|
| +
|
| + prefs.SetString(prefs::kVariationsSeedSignature, std::string());
|
| + seed_store.LoadSeed(&loaded_seed);
|
| + // Empty signature, not considered invalid.
|
| + EXPECT_FALSE(seed_store.GetInvalidSignature(&invalid_signature));
|
| +}
|
| +
|
| TEST(VariationsSeedStoreTest, StoreSeedData) {
|
| const variations::VariationsSeed seed = CreateTestSeed();
|
| const std::string serialized_seed = SerializeSeed(seed);
|
|
|