Only accept cohort in app that matches product id.
The system app also has cohort data but it's empty, and it overwrites
the one in product app.
We don't really care about the cohort for system app, so ignore them.
Bug: 65414782
Test: unittests
Change-Id: Ie4b6f93563ec5a8d76e22e23a863ba7e04b9f119
(cherry picked from commit 8fd11a1907bb7a33678d3c38443eedfcf3e8e1e6)
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 7e38956..409165c 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -144,8 +144,9 @@
(disable_p2p_for_sharing ? "DisableP2PForSharing=\"true\" " : "") +
"/></actions></manifest></updatecheck></app>" +
(multi_app
- ? "<app appid=\"" + app_id2 +
- "\"><updatecheck status=\"ok\"><urls><url codebase=\"" +
+ ? "<app appid=\"" + app_id2 + "\"" +
+ (include_cohorts ? " cohort=\"cohort2\"" : "") +
+ "><updatecheck status=\"ok\"><urls><url codebase=\"" +
codebase2 + "\"/></urls><manifest version=\"" + version2 +
"\"><packages>"
"<package name=\"package3\" size=\"333\" "
@@ -1182,6 +1183,37 @@
EXPECT_EQ(fake_update_response_.cohortname, value);
}
+TEST_F(OmahaRequestActionTest, MultiAppCohortTest) {
+ OmahaResponse response;
+ OmahaRequestParams params = request_params_;
+ fake_update_response_.multi_app = true;
+ fake_update_response_.include_cohorts = true;
+ fake_update_response_.cohort = "s/154454/8479665";
+ fake_update_response_.cohorthint = "please-put-me-on-beta";
+ fake_update_response_.cohortname = "stable";
+
+ ASSERT_TRUE(TestUpdateCheck(¶ms,
+ fake_update_response_.GetUpdateResponse(),
+ -1,
+ false, // ping_only
+ ErrorCode::kSuccess,
+ metrics::CheckResult::kUpdateAvailable,
+ metrics::CheckReaction::kUpdating,
+ metrics::DownloadErrorCode::kUnset,
+ &response,
+ nullptr));
+
+ string value;
+ EXPECT_TRUE(fake_prefs_.GetString(kPrefsOmahaCohort, &value));
+ EXPECT_EQ(fake_update_response_.cohort, value);
+
+ EXPECT_TRUE(fake_prefs_.GetString(kPrefsOmahaCohortHint, &value));
+ EXPECT_EQ(fake_update_response_.cohorthint, value);
+
+ EXPECT_TRUE(fake_prefs_.GetString(kPrefsOmahaCohortName, &value));
+ EXPECT_EQ(fake_update_response_.cohortname, value);
+}
+
TEST_F(OmahaRequestActionTest, NoOutputPipeTest) {
const string http_response(fake_update_response_.GetNoUpdateResponse());