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_action_unittest.cc b/omaha_request_action_unittest.cc
index 91de9d4..e13d10e 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -84,6 +84,7 @@
const char kTestAppId[] = "test-app-id";
const char kTestAppId2[] = "test-app2-id";
const char kTestAppIdSkipUpdatecheck[] = "test-app-id-skip-updatecheck";
+const char kTestSessionId[] = "12341234-1234-1234-1234-1234123412341234";
// This is a helper struct to allow unit tests build an update response with the
// values they care about.
@@ -296,6 +297,8 @@
fetcher->GetHeader("X-Goog-Update-Interactivity"));
EXPECT_EQ(kTestAppId, fetcher->GetHeader("X-Goog-Update-AppId"));
EXPECT_NE("", fetcher->GetHeader("X-Goog-Update-Updater"));
+ EXPECT_EQ(kTestSessionId,
+ fetcher->GetHeader("X-Goog-Update-SessionId"));
}
post_data_ = fetcher->post_data();
} else if (action->Type() ==
@@ -327,6 +330,7 @@
metrics::CheckResult expected_check_result;
metrics::CheckReaction expected_check_reaction;
metrics::DownloadErrorCode expected_download_error_code;
+ string session_id;
};
class OmahaRequestActionTest : public ::testing::Test {
@@ -366,6 +370,7 @@
.expected_check_result = metrics::CheckResult::kUpdateAvailable,
.expected_check_reaction = metrics::CheckReaction::kUpdating,
.expected_download_error_code = metrics::DownloadErrorCode::kUnset,
+ .session_id = kTestSessionId,
};
}
@@ -439,8 +444,12 @@
// are not using the default request_params_.
EXPECT_EQ(&request_params_, fake_system_state_.request_params());
- auto omaha_request_action = std::make_unique<OmahaRequestAction>(
- &fake_system_state_, nullptr, std::move(fetcher), tuc_params_.ping_only);
+ auto omaha_request_action =
+ std::make_unique<OmahaRequestAction>(&fake_system_state_,
+ nullptr,
+ std::move(fetcher),
+ tuc_params_.ping_only,
+ tuc_params_.session_id);
auto mock_policy_provider =
std::make_unique<NiceMock<policy::MockPolicyProvider>>();
@@ -510,7 +519,8 @@
event,
std::make_unique<MockHttpFetcher>(
http_response.data(), http_response.size(), nullptr),
- false);
+ false,
+ "");
ActionProcessor processor;
processor.set_delegate(&delegate_);
processor.EnqueueAction(std::move(action));
@@ -1311,7 +1321,8 @@
nullptr,
std::make_unique<MockHttpFetcher>(
http_response.data(), http_response.size(), nullptr),
- false);
+ false,
+ "");
ActionProcessor processor;
processor.set_delegate(&delegate_);
processor.EnqueueAction(std::move(action));
@@ -1445,7 +1456,8 @@
nullptr,
std::make_unique<MockHttpFetcher>(
http_response.data(), http_response.size(), nullptr),
- false);
+ false,
+ "");
TerminateEarlyTestProcessorDelegate delegate;
ActionProcessor processor;
processor.set_delegate(&delegate);
@@ -1580,7 +1592,8 @@
nullptr,
std::make_unique<MockHttpFetcher>(
http_response.data(), http_response.size(), nullptr),
- false);
+ false,
+ "");
EXPECT_FALSE(update_check_action.IsEvent());
OmahaRequestAction event_action(
@@ -1588,7 +1601,8 @@
new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
std::make_unique<MockHttpFetcher>(
http_response.data(), http_response.size(), nullptr),
- false);
+ false,
+ "");
EXPECT_TRUE(event_action.IsEvent());
}