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

Side by Side Diff: delta_performer_unittest.cc

Issue 6778029: AU: detect failure when using public key verification (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 <sys/mount.h> 5 #include <sys/mount.h>
6 #include <inttypes.h> 6 #include <inttypes.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 CompareFilesByBlock(old_kernel, new_kernel); 444 CompareFilesByBlock(old_kernel, new_kernel);
445 CompareFilesByBlock(a_img, b_img); 445 CompareFilesByBlock(a_img, b_img);
446 446
447 vector<char> updated_kernel_partition; 447 vector<char> updated_kernel_partition;
448 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition)); 448 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition));
449 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string, 449 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string,
450 strlen(new_data_string))); 450 strlen(new_data_string)));
451 451
452 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath)); 452 EXPECT_TRUE(utils::FileExists(kUnittestPublicKeyPath));
453 bool expect_verify_success = 453 const bool expect_verify_success =
454 signature_test != kSignatureNone && 454 signature_test != kSignatureNone;
455 signature_test != kSignatureGeneratedShellBadKey; 455 const bool expect_public_verify_failure =
456 signature_test == kSignatureGeneratedShellBadKey;
457 bool public_verify_failure = false;
456 EXPECT_EQ(expect_verify_success, 458 EXPECT_EQ(expect_verify_success,
457 performer.VerifyPayload( 459 performer.VerifyPayload(
458 kUnittestPublicKeyPath, 460 kUnittestPublicKeyPath,
459 OmahaHashCalculator::OmahaHashOfData(delta), 461 OmahaHashCalculator::OmahaHashOfData(delta),
460 delta.size())); 462 delta.size(),
463 &public_verify_failure));
464 EXPECT_EQ(expect_public_verify_failure, public_verify_failure);
461 EXPECT_TRUE(performer.VerifyPayload( 465 EXPECT_TRUE(performer.VerifyPayload(
462 "/public/key/does/not/exists", 466 "/public/key/does/not/exists",
463 OmahaHashCalculator::OmahaHashOfData(delta), 467 OmahaHashCalculator::OmahaHashOfData(delta),
464 delta.size())); 468 delta.size(),
469 NULL));
465 470
466 uint64_t new_kernel_size; 471 uint64_t new_kernel_size;
467 vector<char> new_kernel_hash; 472 vector<char> new_kernel_hash;
468 uint64_t new_rootfs_size; 473 uint64_t new_rootfs_size;
469 vector<char> new_rootfs_hash; 474 vector<char> new_rootfs_hash;
470 EXPECT_TRUE(performer.GetNewPartitionInfo(&new_kernel_size, 475 EXPECT_TRUE(performer.GetNewPartitionInfo(&new_kernel_size,
471 &new_kernel_hash, 476 &new_kernel_hash,
472 &new_rootfs_size, 477 &new_rootfs_size,
473 &new_rootfs_hash)); 478 &new_rootfs_hash));
474 EXPECT_EQ(4096, new_kernel_size); 479 EXPECT_EQ(4096, new_kernel_size);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 op.clear_src_extents(); 544 op.clear_src_extents();
540 *(op.add_src_extents()) = ExtentForRange(5, 3); 545 *(op.add_src_extents()) = ExtentForRange(5, 3);
541 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 546 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
542 *(op.add_dst_extents()) = ExtentForRange(20, 6); 547 *(op.add_dst_extents()) = ExtentForRange(20, 6);
543 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 548 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
544 *(op.add_src_extents()) = ExtentForRange(19, 2); 549 *(op.add_src_extents()) = ExtentForRange(19, 2);
545 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); 550 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op));
546 } 551 }
547 552
548 } // namespace chromeos_update_engine 553 } // namespace chromeos_update_engine
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698