update_engine: Parse and supply EOL date for Chrome
From Omaha, the optional field |_eol_date| is to indicate the EOL of a
device. Chrome side will leverage these values to display a
notification. The value for |_eol_date| should be an integer value
indicating the days from Unix Epoch date.
If |_eol_date| does not exist in the Omaha response or have non-integer
values, the default will fallback to |kEolDateInvalid|.
BUG=chromium:998983
TEST=FEATURES="test" emerge-$B update_engine update_engine-client system_api
TEST=test_that -b $B $IP autoupdate_EOL
TEST=test_that -b $B $IP autoupdate_EOL.approaching_eol
TEST=test_that -b $B $IP autoupdate_EOL.future_eol
Cq-Depend:chromium:1783596, chromium:1811116
Change-Id: I2b1063873118ccf8fe22ba09a5961e27aa980c7b
Reviewed-on: https://chromium-review.googlesource.com/1783897
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 0e74353..4aff897 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -18,6 +18,7 @@
#include <stdint.h>
+#include <limits>
#include <memory>
#include <unordered_set>
@@ -48,6 +49,7 @@
#include "update_engine/mock_p2p_manager.h"
#include "update_engine/mock_payload_state.h"
#include "update_engine/mock_service_observer.h"
+#include "update_engine/omaha_utils.h"
#include "update_engine/payload_consumer/filesystem_verifier_action.h"
#include "update_engine/payload_consumer/install_plan.h"
#include "update_engine/payload_consumer/payload_constants.h"
@@ -2244,4 +2246,36 @@
EXPECT_TRUE(status.is_enterprise_rollback);
}
+TEST_F(UpdateAttempterTest, FutureEolTest) {
+ EolDate eol_date = std::numeric_limits<int64_t>::max();
+ EXPECT_CALL(*prefs_, GetString(kPrefsOmahaEolDate, _))
+ .WillOnce(
+ DoAll(SetArgPointee<1>(EolDateToString(eol_date)), Return(true)));
+
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_EQ(eol_date, status.eol_date);
+}
+
+TEST_F(UpdateAttempterTest, PastEolTest) {
+ EolDate eol_date = 1;
+ EXPECT_CALL(*prefs_, GetString(kPrefsOmahaEolDate, _))
+ .WillOnce(
+ DoAll(SetArgPointee<1>(EolDateToString(eol_date)), Return(true)));
+
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_EQ(eol_date, status.eol_date);
+}
+
+TEST_F(UpdateAttempterTest, FailedEolTest) {
+ EolDate eol_date = kEolDateInvalid;
+ EXPECT_CALL(*prefs_, GetString(kPrefsOmahaEolDate, _))
+ .WillOnce(Return(false));
+
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_EQ(eol_date, status.eol_date);
+}
+
} // namespace chromeos_update_engine