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

Unified Diff: omaha_response_handler_action_unittest.cc

Issue 6574009: If a public key is present, disallow old style full payloads. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: Created 9 years, 10 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 | « omaha_response_handler_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: omaha_response_handler_action_unittest.cc
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 7f1ee15989b07c9487e0d87231deee017747636a..4a60315d9898a07143aaaec75132b36b16ae280a 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -23,6 +23,7 @@ class OmahaResponseHandlerActionTest : public ::testing::Test {
// If out is non-NULL, it's set w/ the response from the action.
bool DoTest(const OmahaResponse& in,
const string& boot_dev,
+ bool test_key,
InstallPlan* out);
};
@@ -58,6 +59,7 @@ const string kLongName =
bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
const string& boot_dev,
+ bool test_key,
InstallPlan* out) {
ActionProcessor processor;
OmahaResponseHandlerActionProcessorDelegate delegate;
@@ -71,6 +73,9 @@ bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
.WillOnce(Return(true));
}
OmahaResponseHandlerAction response_handler_action(&prefs);
+ if (test_key) {
+ response_handler_action.set_key_path("/dev/null");
+ }
response_handler_action.set_boot_device(boot_dev);
BondActions(&feeder_action, &response_handler_action);
ObjectCollectorAction<InstallPlan> collector_action;
@@ -84,7 +89,9 @@ bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
if (out)
*out = collector_action.object();
EXPECT_TRUE(delegate.code_set_);
- return delegate.code_ == kActionCodeSuccess;
+ ActionExitCode expected_code = test_key ?
+ kActionCodeSignedDeltaPayloadExpectedError : kActionCodeSuccess;
+ return delegate.code_ == expected_code;
}
TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
@@ -103,7 +110,7 @@ TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
in.is_delta = false;
in.deadline = "20101020";
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
+ EXPECT_TRUE(DoTest(in, "/dev/sda3", false, &install_plan));
EXPECT_TRUE(install_plan.is_full_update);
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
@@ -131,7 +138,7 @@ TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
in.prompt = true;
in.is_delta = true;
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda5", &install_plan));
+ EXPECT_TRUE(DoTest(in, "/dev/sda5", false, &install_plan));
EXPECT_FALSE(install_plan.is_full_update);
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
@@ -154,7 +161,7 @@ TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
in.is_delta = false;
in.deadline = "some-deadline";
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
+ EXPECT_TRUE(DoTest(in, "/dev/sda3", false, &install_plan));
EXPECT_TRUE(install_plan.is_full_update);
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
@@ -167,11 +174,20 @@ TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
}
}
+TEST_F(OmahaResponseHandlerActionTest, PublicKeyOldStyleTest) {
+ OmahaResponse in;
+ in.update_exists = true;
+ in.codebase = "http://foo/the_update_a.b.c.d.tgz";
+ in.is_delta = false;
+ InstallPlan install_plan;
+ EXPECT_TRUE(DoTest(in, "/dev/sda3", true, &install_plan));
+}
+
TEST_F(OmahaResponseHandlerActionTest, NoUpdatesTest) {
OmahaResponse in;
in.update_exists = false;
InstallPlan install_plan;
- EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan));
+ EXPECT_FALSE(DoTest(in, "/dev/sda1", false, &install_plan));
EXPECT_FALSE(install_plan.is_full_update);
EXPECT_EQ("", install_plan.download_url);
EXPECT_EQ("", install_plan.download_hash);
« no previous file with comments | « omaha_response_handler_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698