update_engine: Include quick_fix_build_token in updatecheck request body
Get the value of the new device policy which is included in
AutoUpdateSettings as quick_fix_build_token, and include it
in the update request body if value is set.
BUG=chromium:932465
TEST=./build_packages --board=amd64-generic && \
cros_run_unit_tests --board=amd64-generic --packages update_engine
Cq-Depend: chromium:1571634
Change-Id: Iaca35a08d973616a058864a11896ef9305d00174
Reviewed-on: https://chromium-review.googlesource.com/1581519
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Askar Aitzhan <askaraitzhan@google.com>
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 14fad38..16819f8 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -188,6 +188,7 @@
void P2PEnabledInteractiveStart();
void P2PEnabledStartingFailsStart();
void P2PEnabledHousekeepingFailsStart();
+ void UpdateToQuickFixBuildStart();
void ResetRollbackHappenedStart(bool is_consumer,
bool is_policy_available,
bool expected_reset);
@@ -461,23 +462,23 @@
namespace {
// Actions that will be built as part of an update check.
-const string kUpdateActionTypes[] = { // NOLINT(runtime/string)
- OmahaRequestAction::StaticType(),
- OmahaResponseHandlerAction::StaticType(),
- UpdateBootFlagsAction::StaticType(),
- OmahaRequestAction::StaticType(),
- DownloadAction::StaticType(),
- OmahaRequestAction::StaticType(),
- FilesystemVerifierAction::StaticType(),
- PostinstallRunnerAction::StaticType(),
- OmahaRequestAction::StaticType()};
+vector<string> GetUpdateActionTypes() {
+ return {OmahaRequestAction::StaticType(),
+ OmahaResponseHandlerAction::StaticType(),
+ UpdateBootFlagsAction::StaticType(),
+ OmahaRequestAction::StaticType(),
+ DownloadAction::StaticType(),
+ OmahaRequestAction::StaticType(),
+ FilesystemVerifierAction::StaticType(),
+ PostinstallRunnerAction::StaticType(),
+ OmahaRequestAction::StaticType()};
+}
// Actions that will be built as part of a user-initiated rollback.
-const string kRollbackActionTypes[] = {
- // NOLINT(runtime/string)
- InstallPlanAction::StaticType(),
- PostinstallRunnerAction::StaticType(),
-};
+vector<string> GetRollbackActionTypes() {
+ return {InstallPlanAction::StaticType(),
+ PostinstallRunnerAction::StaticType()};
+}
const StagingSchedule kValidStagingSchedule = {
{4, 10}, {10, 40}, {19, 70}, {26, 100}};
@@ -498,10 +499,10 @@
{
InSequence s;
- for (size_t i = 0; i < arraysize(kUpdateActionTypes); ++i) {
+ for (const auto& update_action_type : GetUpdateActionTypes()) {
EXPECT_CALL(*processor_,
EnqueueAction(Pointee(
- Property(&AbstractAction::Type, kUpdateActionTypes[i]))));
+ Property(&AbstractAction::Type, update_action_type))));
}
EXPECT_CALL(*processor_, StartProcessing());
}
@@ -557,10 +558,10 @@
if (is_rollback_allowed) {
InSequence s;
- for (size_t i = 0; i < arraysize(kRollbackActionTypes); ++i) {
+ for (const auto& rollback_action_type : GetRollbackActionTypes()) {
EXPECT_CALL(*processor_,
- EnqueueAction(Pointee(Property(&AbstractAction::Type,
- kRollbackActionTypes[i]))));
+ EnqueueAction(Pointee(
+ Property(&AbstractAction::Type, rollback_action_type))));
}
EXPECT_CALL(*processor_, StartProcessing());
@@ -1582,4 +1583,29 @@
attempter_.ProcessingDone(nullptr, ErrorCode::kSuccess);
}
+void UpdateAttempterTest::UpdateToQuickFixBuildStart() {
+ // Tests that checks if device_quick_fix_build_token arrives when
+ // policy is set.
+ const char kToken[] = "some_token";
+
+ auto device_policy = std::make_unique<policy::MockDevicePolicy>();
+ fake_system_state_.set_device_policy(device_policy.get());
+
+ EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*device_policy, GetDeviceQuickFixBuildToken(_))
+ .WillOnce(DoAll(SetArgPointee<0>(string(kToken)), Return(true)));
+ attempter_.policy_provider_.reset(
+ new policy::PolicyProvider(std::move(device_policy)));
+ attempter_.Update("", "", "", "", false, false, 0, false, false);
+
+ ScheduleQuitMainLoop();
+}
+
+TEST_F(UpdateAttempterTest, UpdateToQuickFixBuildStart) {
+ loop_.PostTask(FROM_HERE,
+ base::Bind(&UpdateAttempterTest::UpdateToQuickFixBuildStart,
+ base::Unretained(this)));
+ loop_.Run();
+}
+
} // namespace chromeos_update_engine