OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/variations/variations_seed_store.h" | 5 #include "components/variations/variations_seed_store.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "components/prefs/testing_pref_service.h" | 10 #include "components/prefs/testing_pref_service.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 // If there's no signature, the corresponding result should be returned. | 323 // If there's no signature, the corresponding result should be returned. |
324 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_MISSING, | 324 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_MISSING, |
325 seed_store.VerifySeedSignature(seed_data, std::string())); | 325 seed_store.VerifySeedSignature(seed_data, std::string())); |
326 | 326 |
327 // Using non-base64 encoded value as signature (e.g. seed data) should fail. | 327 // Using non-base64 encoded value as signature (e.g. seed data) should fail. |
328 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, | 328 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_DECODE_FAILED, |
329 seed_store.VerifySeedSignature(seed_data, seed_data)); | 329 seed_store.VerifySeedSignature(seed_data, seed_data)); |
330 | 330 |
331 // Using a different signature (e.g. the base64 seed data) should fail. | 331 // Using a different signature (e.g. the base64 seed data) should fail. |
332 #if defined(USE_OPENSSL) | |
333 // OpenSSL doesn't distinguish signature decode failure from the | 332 // OpenSSL doesn't distinguish signature decode failure from the |
334 // signature not matching. | 333 // signature not matching. |
335 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 334 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
336 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); | 335 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); |
337 #else | |
338 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE, | |
339 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); | |
340 #endif | |
341 | 336 |
342 // Using a different seed should not match the signature. | 337 // Using a different seed should not match the signature. |
343 seed_data[0] = 'x'; | 338 seed_data[0] = 'x'; |
344 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 339 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
345 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); | 340 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); |
346 } | 341 } |
347 | 342 |
348 TEST(VariationsSeedStoreTest, ApplyDeltaPatch) { | 343 TEST(VariationsSeedStoreTest, ApplyDeltaPatch) { |
349 // Sample seeds and the server produced delta between them to verify that the | 344 // Sample seeds and the server produced delta between them to verify that the |
350 // client code is able to decode the deltas produced by the server. | 345 // client code is able to decode the deltas produced by the server. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 &response_date, &is_gzip_compressed); | 408 &response_date, &is_gzip_compressed); |
414 EXPECT_EQ("", seed_data); | 409 EXPECT_EQ("", seed_data); |
415 EXPECT_EQ("", seed_signature); | 410 EXPECT_EQ("", seed_signature); |
416 EXPECT_EQ("", seed_country); | 411 EXPECT_EQ("", seed_country); |
417 EXPECT_EQ("", response_date); | 412 EXPECT_EQ("", response_date); |
418 EXPECT_FALSE(is_gzip_compressed); | 413 EXPECT_FALSE(is_gzip_compressed); |
419 } | 414 } |
420 #endif // OS_ANDROID | 415 #endif // OS_ANDROID |
421 | 416 |
422 } // namespace variations | 417 } // namespace variations |
OLD | NEW |