update_engine: Make the ChromeOS/AOSP Omaha Client transmit sessionid.
As per Omaha's protocol specification, ChromeOS/AOSP
needs to transmit the 'sessionid` attribute in the request.
The format of the 'sessionid' attribute is sent as GUID version 4.
The sessionid is kept throughout the entirety of the update flow.
1. When the <updatecheck> (pings/download/updates) is done, the pings
to Omaha will send empty sessionids.
2. If there is a schedule error/issue and a new update is scheduled, a
new sessionid will be applied.
3. During errors/issues, the same sessionid will be used.
4. All new <updatechecks> will start with a fresh sessionid.
BUG=chromium:940515
TEST=cros_workon_make --board=octopus update_engine --test
TEST=/usr/bin/update_engine_client --check_for_update # after bouncing update-engine + check /var/log/update_engine.log. 'sessionid'
attribute will be in the omaha request.
Change-Id: If4d29b630e3ab1b547606ef1c5fb06cc7a9cd61f
Reviewed-on: https://chromium-review.googlesource.com/1658422
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Ready: Jae Hoon Kim <kimjae@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_builder_xml_unittest.cc b/omaha_request_builder_xml_unittest.cc
index 23abebb..4375bed 100644
--- a/omaha_request_builder_xml_unittest.cc
+++ b/omaha_request_builder_xml_unittest.cc
@@ -90,7 +90,8 @@
0,
0,
0,
- fake_system_state_.prefs()};
+ fake_system_state_.prefs(),
+ ""};
const string request_xml = omaha_request.GetRequest();
const string key = "requestid";
const string request_id =
@@ -100,4 +101,28 @@
EXPECT_TRUE(base::IsValidGUID(request_id));
}
+TEST_F(OmahaRequestBuilderXmlTest, GetRequestXmlSessionIdTest) {
+ const string gen_session_id = base::GenerateGUID();
+ OmahaEvent omaha_event;
+ OmahaRequestParams omaha_request_params{&fake_system_state_};
+ OmahaRequestBuilderXml omaha_request{&omaha_event,
+ &omaha_request_params,
+ false,
+ false,
+ 0,
+ 0,
+ 0,
+ fake_system_state_.prefs(),
+ gen_session_id};
+ const string request_xml = omaha_request.GetRequest();
+ const string key = "sessionid";
+ const string session_id =
+ FindAttributeKeyValueInXml(request_xml, key, kGuidSize);
+ // A valid |session_id| is either a GUID version 4 or empty string.
+ if (!session_id.empty()) {
+ EXPECT_TRUE(base::IsValidGUID(session_id));
+ }
+ EXPECT_EQ(gen_session_id, session_id);
+}
+
} // namespace chromeos_update_engine