p2p: Use p2p for updates
This is the main patch for enabling use of p2p for consuming and/or
sharing updates via p2p. Refer to the ddoc and other documentation for
how this works.
BUG=chromium:260426,chromium:273110
TEST=New unit tests + unit tests pass + manual testing
Change-Id: I6bc3bddae1e041ccc176969a651396e8e89cb3f0
Reviewed-on: https://chromium-review.googlesource.com/64829
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index c3efb8b..9624b41 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -362,4 +362,29 @@
ASSERT_TRUE(utils::RecursiveUnlinkDir(test_dir));
}
+TEST_F(OmahaResponseHandlerActionTest, P2PUrlIsUsedAndHashChecksMandatory) {
+ OmahaResponse in;
+ in.update_exists = true;
+ in.version = "a.b.c.d";
+ in.payload_urls.push_back("https://would.not/cause/hash/checks");
+ in.more_info_url = "http://more/info";
+ in.hash = "HASHj+";
+ in.size = 12;
+
+ MockSystemState mock_system_state;
+ OmahaRequestParams params(&mock_system_state);
+ mock_system_state.set_request_params(¶ms);
+
+ string p2p_url = "http://9.8.7.6/p2p";
+ params.set_p2p_url(p2p_url);
+ params.set_use_p2p_for_downloading(true);
+
+ InstallPlan install_plan;
+ EXPECT_TRUE(DoTestCommon(&mock_system_state, in, "/dev/sda5", "",
+ &install_plan));
+ EXPECT_EQ(in.hash, install_plan.payload_hash);
+ EXPECT_EQ(install_plan.download_url, p2p_url);
+ EXPECT_TRUE(install_plan.hash_checks_mandatory);
+}
+
} // namespace chromeos_update_engine