update_engine: Restructure Omaha response processing

The current implementation of response processing is out of order. There
is no way to know the exact information we process from
response. Also we need to move into json based request and response and
this prepares for that. This CL moves all the response parsing logic
into a unified function. This function can be later interfaced and
implemented for other data structures.

Also there is a logic change in this CL where we set the outgoing
object's manifest version for install responses as the version that came
from the response, not the one we send into the request. Its better to
follow what the server sends rather than blindly change the version that
what we think should be. We don't really use the version for any
verification anyway so its better to be this way.

BUG=b:172219380
TEST=cros_workon_make --board reef --test update_engine

Change-Id: I7f4116d786323c045a1f86ee3d83940cc846b3e8
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2543815
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/cros/omaha_request_action_unittest.cc b/cros/omaha_request_action_unittest.cc
index 89648eb..01be1a8 100644
--- a/cros/omaha_request_action_unittest.cc
+++ b/cros/omaha_request_action_unittest.cc
@@ -242,7 +242,6 @@
   string app_id = kTestAppId;
   string app_id2 = kTestAppId2;
   string app_id_skip_updatecheck = kTestAppIdSkipUpdatecheck;
-  string current_version = kCurrentVersion;
   string version = "1.2.3.4";
   string version2 = "2.3.4.5";
   string more_info_url = "http://more/info";
@@ -2874,7 +2873,7 @@
   ASSERT_TRUE(TestUpdateCheck());
 
   EXPECT_TRUE(response_.update_exists);
-  EXPECT_EQ(fake_update_response_.current_version, response_.version);
+  EXPECT_EQ(fake_update_response_.version, response_.version);
 }
 
 TEST_F(OmahaRequestActionTest, UpdateWithDlcTest) {
@@ -3040,7 +3039,7 @@
 TEST_F(OmahaRequestActionTest, PersistEolDateTest) {
   tuc_params_.http_response =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
-      "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">"
+      "protocol=\"3.0\"><app appid=\"test-app-id\" status=\"ok\">"
       "<ping status=\"ok\"/><updatecheck status=\"noupdate\" "
       "_eol_date=\"200\" _foo=\"bar\"/></app></response>";
   tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable;
@@ -3057,7 +3056,7 @@
 TEST_F(OmahaRequestActionTest, PersistEolMissingDateTest) {
   tuc_params_.http_response =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
-      "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">"
+      "protocol=\"3.0\"><app appid=\"test-app-id\" status=\"ok\">"
       "<ping status=\"ok\"/><updatecheck status=\"noupdate\" "
       "_foo=\"bar\"/></app></response>";
   tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable;
@@ -3077,7 +3076,7 @@
 TEST_F(OmahaRequestActionTest, PersistEolBadDateTest) {
   tuc_params_.http_response =
       "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response "
-      "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">"
+      "protocol=\"3.0\"><app appid=\"test-app-id\" status=\"ok\">"
       "<ping status=\"ok\"/><updatecheck status=\"noupdate\" "
       "_eol_date=\"bad\" foo=\"bar\"/></app></response>";
   tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable;