Support optional powerwash from Omaha response.
Will powerwash if 'Powerwash="true"' is set by Omaha.
Bug: 73969717
Test: update_engine_unittests
Change-Id: Ic7ba131f5c77cdb1ca28a69530f55bea4d27b0b5
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 6bc5ba2..9a01a13 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -143,6 +143,7 @@
(disable_p2p_for_downloading ? "DisableP2PForDownloading=\"true\" "
: "") +
(disable_p2p_for_sharing ? "DisableP2PForSharing=\"true\" " : "") +
+ (powerwash ? "Powerwash=\"true\" " : "") +
"/></actions></manifest></updatecheck></app>" +
(multi_app
? "<app appid=\"" + app_id2 + "\"" +
@@ -190,6 +191,8 @@
bool disable_p2p_for_downloading = false;
bool disable_p2p_for_sharing = false;
+ bool powerwash = false;
+
// Omaha cohorts settings.
bool include_cohorts = false;
string cohort = "";
@@ -558,6 +561,7 @@
EXPECT_EQ(true, response.packages[0].is_delta);
EXPECT_EQ(fake_update_response_.prompt == "true", response.prompt);
EXPECT_EQ(fake_update_response_.deadline, response.deadline);
+ EXPECT_FALSE(response.powerwash_required);
// Omaha cohort attributes are not set in the response, so they should not be
// persisted.
EXPECT_FALSE(fake_prefs_.Exists(kPrefsOmahaCohort));
@@ -726,6 +730,23 @@
EXPECT_EQ(false, response.packages[2].is_delta);
}
+TEST_F(OmahaRequestActionTest, PowerwashTest) {
+ OmahaResponse response;
+ fake_update_response_.powerwash = true;
+ ASSERT_TRUE(TestUpdateCheck(nullptr, // request_params
+ fake_update_response_.GetUpdateResponse(),
+ -1,
+ false, // ping_only
+ ErrorCode::kSuccess,
+ metrics::CheckResult::kUpdateAvailable,
+ metrics::CheckReaction::kUpdating,
+ metrics::DownloadErrorCode::kUnset,
+ &response,
+ nullptr));
+ EXPECT_TRUE(response.update_exists);
+ EXPECT_TRUE(response.powerwash_required);
+}
+
TEST_F(OmahaRequestActionTest, ExtraHeadersSentTest) {
const string http_response = "<?xml invalid response";
request_params_.set_interactive(true);