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

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: merge master 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
« no previous file with comments | « delta_performer.cc ('k') | download_action.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_public_verify_failure =
454 signature_test != kSignatureNone && 454 signature_test == kSignatureNone ||
455 signature_test != kSignatureGeneratedShellBadKey; 455 signature_test == kSignatureGeneratedShellBadKey;
456 EXPECT_EQ(expect_verify_success, 456 bool public_verify_failure = false;
457 performer.VerifyPayload( 457 EXPECT_TRUE(performer.VerifyPayload(
458 kUnittestPublicKeyPath, 458 kUnittestPublicKeyPath,
459 OmahaHashCalculator::OmahaHashOfData(delta), 459 OmahaHashCalculator::OmahaHashOfData(delta),
460 delta.size())); 460 delta.size(),
461 &public_verify_failure));
462 EXPECT_EQ(expect_public_verify_failure, public_verify_failure);
461 EXPECT_TRUE(performer.VerifyPayload( 463 EXPECT_TRUE(performer.VerifyPayload(
462 "/public/key/does/not/exists", 464 "/public/key/does/not/exists",
463 OmahaHashCalculator::OmahaHashOfData(delta), 465 OmahaHashCalculator::OmahaHashOfData(delta),
464 delta.size())); 466 delta.size(),
467 NULL));
465 468
466 uint64_t new_kernel_size; 469 uint64_t new_kernel_size;
467 vector<char> new_kernel_hash; 470 vector<char> new_kernel_hash;
468 uint64_t new_rootfs_size; 471 uint64_t new_rootfs_size;
469 vector<char> new_rootfs_hash; 472 vector<char> new_rootfs_hash;
470 EXPECT_TRUE(performer.GetNewPartitionInfo(&new_kernel_size, 473 EXPECT_TRUE(performer.GetNewPartitionInfo(&new_kernel_size,
471 &new_kernel_hash, 474 &new_kernel_hash,
472 &new_rootfs_size, 475 &new_rootfs_size,
473 &new_rootfs_hash)); 476 &new_rootfs_hash));
474 EXPECT_EQ(4096, new_kernel_size); 477 EXPECT_EQ(4096, new_kernel_size);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 op.clear_src_extents(); 542 op.clear_src_extents();
540 *(op.add_src_extents()) = ExtentForRange(5, 3); 543 *(op.add_src_extents()) = ExtentForRange(5, 3);
541 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 544 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
542 *(op.add_dst_extents()) = ExtentForRange(20, 6); 545 *(op.add_dst_extents()) = ExtentForRange(20, 6);
543 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); 546 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op));
544 *(op.add_src_extents()) = ExtentForRange(19, 2); 547 *(op.add_src_extents()) = ExtentForRange(19, 2);
545 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); 548 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op));
546 } 549 }
547 550
548 } // namespace chromeos_update_engine 551 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « delta_performer.cc ('k') | download_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698