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

Unified Diff: delta_performer_unittest.cc

Issue 6265001: AU: Add support for signing of update payloads after they're generated. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: rename function Created 9 years, 11 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
« no previous file with comments | « delta_performer.cc ('k') | payload_signer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: delta_performer_unittest.cc
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index 51299fb06fd7b2439d671ec5911f02b3a725bdd9..0d71a6edf5a26732eaa768a81de09defbeb7051b 100755
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -92,8 +92,11 @@ bool WriteSparseFile(const string& path, off_t size) {
TEST_AND_RETURN_FALSE_ERRNO(return_code == 0);
return true;
}
+} // namespace {}
-void DoSmallImageTest(bool full_kernel, bool full_rootfs, bool noop) {
+namespace {
+void DoSmallImageTest(bool full_kernel, bool full_rootfs, bool noop,
+ bool post_sign) {
string a_img, b_img;
EXPECT_TRUE(utils::MakeTempFile("/tmp/a_img.XXXXXX", &a_img, NULL));
ScopedPathUnlinker a_img_unlinker(a_img);
@@ -208,7 +211,33 @@ void DoSmallImageTest(bool full_kernel, bool full_rootfs, bool noop) {
full_kernel ? "" : old_kernel,
new_kernel,
delta_path,
- kUnittestPrivateKeyPath));
+ post_sign ? "" : kUnittestPrivateKeyPath));
+ }
+
+ if (post_sign) {
+ int signature_size;
+ {
+ const vector<char> data(1, 'x');
+ vector<char> hash;
+ ASSERT_TRUE(OmahaHashCalculator::RawHashOfData(data, &hash));
+ vector<char> signature;
+ ASSERT_TRUE(PayloadSigner::SignHash(hash,
+ kUnittestPrivateKeyPath,
+ &signature));
+ signature_size = signature.size();
+ }
+
+ vector<char> hash;
+ ASSERT_TRUE(PayloadSigner::HashPayloadForSigning(delta_path,
+ signature_size,
+ &hash));
+ vector<char> signature;
+ ASSERT_TRUE(PayloadSigner::SignHash(hash,
+ kUnittestPrivateKeyPath,
+ &signature));
+ ASSERT_TRUE(PayloadSigner::AddSignatureToPayload(delta_path,
+ signature,
+ delta_path));
}
// Read delta into memory.
@@ -351,19 +380,23 @@ void DoSmallImageTest(bool full_kernel, bool full_rootfs, bool noop) {
}
TEST(DeltaPerformerTest, RunAsRootSmallImageTest) {
- DoSmallImageTest(false, false, false);
+ DoSmallImageTest(false, false, false, false);
}
TEST(DeltaPerformerTest, RunAsRootFullKernelSmallImageTest) {
- DoSmallImageTest(true, false, false);
+ DoSmallImageTest(true, false, false, false);
}
TEST(DeltaPerformerTest, RunAsRootFullSmallImageTest) {
- DoSmallImageTest(true, true, false);
+ DoSmallImageTest(true, true, false, false);
}
TEST(DeltaPerformerTest, RunAsRootNoopSmallImageTest) {
- DoSmallImageTest(false, false, true);
+ DoSmallImageTest(false, false, true, false);
+}
+
+TEST(DeltaPerformerTest, RunAsRootSmallImagePostSignTest) {
+ DoSmallImageTest(false, false, false, true);
}
TEST(DeltaPerformerTest, BadDeltaMagicTest) {
« no previous file with comments | « delta_performer.cc ('k') | payload_signer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698