blob: 7abcf7c0c57c7cd51d333dfbc6288786797191c8 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2020 The Chromium Authors
Adam Norbergc7ab1c52021-01-19 21:05:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "testing/gtest/include/gtest/gtest.h"
6
Adam Norbergc7ab1c52021-01-19 21:05:217#include <string>
8#include <vector>
9
10#include "base/files/file_path.h"
Joshua Pawlicki34aacc12021-08-24 21:22:2111#include "base/memory/scoped_refptr.h"
S. Ganesh5b7c6a72022-05-21 01:20:5612#include "base/values.h"
Noah Rose Ledesma38b7be12022-09-26 19:15:3413#include "build/build_config.h"
Adam Norbergc7ab1c52021-01-19 21:05:2114#include "chrome/updater/constants.h"
15#include "chrome/updater/external_constants.h"
16#include "chrome/updater/external_constants_builder.h"
Joshua Pawlicki58a597ed2021-06-10 17:00:5217#include "chrome/updater/external_constants_default.h"
Adam Norbergc7ab1c52021-01-19 21:05:2118#include "chrome/updater/external_constants_override.h"
Sorin Jianu86d1ef62022-10-06 22:16:0219#include "chrome/updater/test_scope.h"
Adam Norbergc7ab1c52021-01-19 21:05:2120#include "chrome/updater/updater_branding.h"
Sorin Jianu045977302022-12-07 15:01:1221#include "chrome/updater/util/unittest_util.h"
Noah Rose Ledesmafc9b3652022-11-12 02:10:4922#include "chrome/updater/util/util.h"
Anton Bikineev46bbb972021-05-15 17:53:5323#include "third_party/abseil-cpp/absl/types/optional.h"
Adam Norbergc7ab1c52021-01-19 21:05:2124#include "url/gurl.h"
25
26namespace updater {
Adam Norbergc7ab1c52021-01-19 21:05:2127
28class ExternalConstantsBuilderTests : public ::testing::Test {
29 protected:
Sorin Jianu86d1ef62022-10-06 22:16:0230 void SetUp() override {
31 EXPECT_TRUE(
32 test::DeleteFileAndEmptyParentDirectories(overrides_file_path_));
33 }
34 void TearDown() override {
35 EXPECT_TRUE(
36 test::DeleteFileAndEmptyParentDirectories(overrides_file_path_));
37 }
38
39 private:
40 // This test runs non-elevated.
41 const absl::optional<base::FilePath> overrides_file_path_ =
Joshua Pawlicki3185e6a2023-02-07 19:32:3142 GetOverrideFilePath(UpdaterScope::kUser);
Adam Norbergc7ab1c52021-01-19 21:05:2143};
44
Adam Norbergc7ab1c52021-01-19 21:05:2145TEST_F(ExternalConstantsBuilderTests, TestOverridingNothing) {
46 EXPECT_TRUE(ExternalConstantsBuilder().Overwrite());
47
Joshua Pawlicki34aacc12021-08-24 21:22:2148 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:2149 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:5250 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:2151
52 EXPECT_TRUE(verifier->UseCUP());
53
54 std::vector<GURL> urls = verifier->UpdateURL();
55 ASSERT_EQ(urls.size(), 1ul);
56 EXPECT_EQ(urls[0], GURL(UPDATE_CHECK_URL));
57
58 EXPECT_EQ(verifier->InitialDelay(), kInitialDelay);
Noah Rose Ledesmad391ac332022-12-13 21:09:0659 EXPECT_EQ(verifier->ServerKeepAliveTime(), kServerKeepAliveTime);
S. Ganesh5b7c6a72022-05-21 01:20:5660 EXPECT_EQ(verifier->GroupPolicies().size(), 0U);
Adam Norbergc7ab1c52021-01-19 21:05:2161}
62
63TEST_F(ExternalConstantsBuilderTests, TestOverridingEverything) {
Matt Menkeb1732aac2022-06-02 13:48:0364 base::Value::Dict group_policies;
65 group_policies.Set("a", 1);
66 group_policies.Set("b", 2);
S. Ganesh5b7c6a72022-05-21 01:20:5667
Adam Norbergc7ab1c52021-01-19 21:05:2168 ExternalConstantsBuilder builder;
69 builder.SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
Xiaoling Bao616a5352023-04-03 22:00:5870 .SetCrashUploadURL("https://crash.example.com")
71 .SetDeviceManagementURL("https://dm.example.com")
Adam Norbergc7ab1c52021-01-19 21:05:2172 .SetUseCUP(false)
Noah Rose Ledesmad391ac332022-12-13 21:09:0673 .SetInitialDelay(base::Seconds(123))
74 .SetServerKeepAliveTime(base::Seconds(2))
S. Ganesh5b7c6a72022-05-21 01:20:5675 .SetGroupPolicies(group_policies);
Adam Norbergc7ab1c52021-01-19 21:05:2176 EXPECT_TRUE(builder.Overwrite());
77
Joshua Pawlicki34aacc12021-08-24 21:22:2178 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:2179 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:5280 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:2181
82 EXPECT_FALSE(verifier->UseCUP());
83
84 std::vector<GURL> urls = verifier->UpdateURL();
85 ASSERT_EQ(urls.size(), 1ul);
86 EXPECT_EQ(urls[0], GURL("https://www.example.com"));
87
Xiaoling Bao616a5352023-04-03 22:00:5888 EXPECT_EQ(verifier->CrashUploadURL(), GURL("https://crash.example.com"));
89 EXPECT_EQ(verifier->DeviceManagementURL(), GURL("https://dm.example.com"));
Noah Rose Ledesmad391ac332022-12-13 21:09:0690 EXPECT_EQ(verifier->InitialDelay(), base::Seconds(123));
91 EXPECT_EQ(verifier->ServerKeepAliveTime(), base::Seconds(2));
S. Ganesh5b7c6a72022-05-21 01:20:5692 EXPECT_EQ(verifier->GroupPolicies().size(), 2U);
Adam Norbergc7ab1c52021-01-19 21:05:2193}
94
95TEST_F(ExternalConstantsBuilderTests, TestPartialOverrideWithMultipleURLs) {
96 ExternalConstantsBuilder builder;
97 EXPECT_TRUE(builder
98 .SetUpdateURL(std::vector<std::string>{
99 "https://www.google.com", "https://www.example.com"})
100 .Overwrite());
101
Joshua Pawlicki34aacc12021-08-24 21:22:21102 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:21103 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:52104 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:21105
106 EXPECT_TRUE(verifier->UseCUP());
107
108 std::vector<GURL> urls = verifier->UpdateURL();
109 ASSERT_EQ(urls.size(), 2ul);
110 EXPECT_EQ(urls[0], GURL("https://www.google.com"));
111 EXPECT_EQ(urls[1], GURL("https://www.example.com"));
112
Xiaoling Bao616a5352023-04-03 22:00:58113 EXPECT_EQ(verifier->CrashUploadURL(), GURL(CRASH_UPLOAD_URL));
114 EXPECT_EQ(verifier->DeviceManagementURL(),
115 GURL(DEVICE_MANAGEMENT_SERVER_URL));
Adam Norbergc7ab1c52021-01-19 21:05:21116 EXPECT_EQ(verifier->InitialDelay(), kInitialDelay);
Noah Rose Ledesmad391ac332022-12-13 21:09:06117 EXPECT_EQ(verifier->ServerKeepAliveTime(), kServerKeepAliveTime);
S. Ganesh5b7c6a72022-05-21 01:20:56118 EXPECT_EQ(verifier->GroupPolicies().size(), 0U);
Adam Norbergc7ab1c52021-01-19 21:05:21119}
120
121TEST_F(ExternalConstantsBuilderTests, TestClearedEverything) {
122 ExternalConstantsBuilder builder;
123 EXPECT_TRUE(builder
124 .SetUpdateURL(std::vector<std::string>{
125 "https://www.google.com", "https://www.example.com"})
Xiaoling Bao616a5352023-04-03 22:00:58126 .SetCrashUploadURL("https://crash.example.com")
127 .SetDeviceManagementURL("https://dm.example.com")
Adam Norbergc7ab1c52021-01-19 21:05:21128 .SetUseCUP(false)
Noah Rose Ledesmad391ac332022-12-13 21:09:06129 .SetInitialDelay(base::Seconds(123.4))
Adam Norbergc7ab1c52021-01-19 21:05:21130 .ClearUpdateURL()
Xiaoling Bao616a5352023-04-03 22:00:58131 .ClearCrashUploadURL()
132 .ClearDeviceManagementURL()
Adam Norbergc7ab1c52021-01-19 21:05:21133 .ClearUseCUP()
134 .ClearInitialDelay()
Mila Green59389f12021-02-03 20:52:32135 .ClearServerKeepAliveSeconds()
S. Ganesh5b7c6a72022-05-21 01:20:56136 .ClearGroupPolicies()
Adam Norbergc7ab1c52021-01-19 21:05:21137 .Overwrite());
138
Joshua Pawlicki34aacc12021-08-24 21:22:21139 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:21140 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:52141 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:21142 EXPECT_TRUE(verifier->UseCUP());
143
144 std::vector<GURL> urls = verifier->UpdateURL();
145 ASSERT_EQ(urls.size(), 1ul);
146 EXPECT_EQ(urls[0], GURL(UPDATE_CHECK_URL));
147
Xiaoling Bao616a5352023-04-03 22:00:58148 EXPECT_EQ(verifier->CrashUploadURL(), GURL(CRASH_UPLOAD_URL));
149 EXPECT_EQ(verifier->DeviceManagementURL(),
150 GURL(DEVICE_MANAGEMENT_SERVER_URL));
Adam Norbergc7ab1c52021-01-19 21:05:21151 EXPECT_EQ(verifier->InitialDelay(), kInitialDelay);
Noah Rose Ledesmad391ac332022-12-13 21:09:06152 EXPECT_EQ(verifier->ServerKeepAliveTime(), kServerKeepAliveTime);
S. Ganesh5b7c6a72022-05-21 01:20:56153 EXPECT_EQ(verifier->GroupPolicies().size(), 0U);
Adam Norbergc7ab1c52021-01-19 21:05:21154}
155
156TEST_F(ExternalConstantsBuilderTests, TestOverSet) {
Matt Menkeb1732aac2022-06-02 13:48:03157 base::Value::Dict group_policies;
158 group_policies.Set("a", 1);
S. Ganesh5b7c6a72022-05-21 01:20:56159
Adam Norbergc7ab1c52021-01-19 21:05:21160 EXPECT_TRUE(
161 ExternalConstantsBuilder()
162 .SetUpdateURL(std::vector<std::string>{"https://www.google.com"})
Xiaoling Bao616a5352023-04-03 22:00:58163 .SetCrashUploadURL("https://crash.google.com")
164 .SetDeviceManagementURL("https://dm.google.com")
Adam Norbergc7ab1c52021-01-19 21:05:21165 .SetUseCUP(true)
Noah Rose Ledesmad391ac332022-12-13 21:09:06166 .SetInitialDelay(base::Seconds(123.4))
167 .SetServerKeepAliveTime(base::Seconds(2))
S. Ganesh5b7c6a72022-05-21 01:20:56168 .SetGroupPolicies(group_policies)
Adam Norbergc7ab1c52021-01-19 21:05:21169 .SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
Xiaoling Bao616a5352023-04-03 22:00:58170 .SetCrashUploadURL("https://crash.example.com")
171 .SetDeviceManagementURL("https://dm.example.com")
Adam Norbergc7ab1c52021-01-19 21:05:21172 .SetUseCUP(false)
Noah Rose Ledesmad391ac332022-12-13 21:09:06173 .SetInitialDelay(base::Seconds(937.6))
174 .SetServerKeepAliveTime(base::Seconds(3))
Adam Norbergc7ab1c52021-01-19 21:05:21175 .Overwrite());
176
177 // Only the second set of values should be observed.
Joshua Pawlicki34aacc12021-08-24 21:22:21178 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:21179 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:52180 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:21181 EXPECT_FALSE(verifier->UseCUP());
182
183 std::vector<GURL> urls = verifier->UpdateURL();
184 ASSERT_EQ(urls.size(), 1ul);
185 EXPECT_EQ(urls[0], GURL("https://www.example.com"));
186
Xiaoling Bao616a5352023-04-03 22:00:58187 EXPECT_EQ(verifier->CrashUploadURL(), GURL("https://crash.example.com"));
188 EXPECT_EQ(verifier->DeviceManagementURL(), GURL("https://dm.example.com"));
Noah Rose Ledesmad391ac332022-12-13 21:09:06189 EXPECT_EQ(verifier->InitialDelay(), base::Seconds(937.6));
190 EXPECT_EQ(verifier->ServerKeepAliveTime(), base::Seconds(3));
S. Ganesh5b7c6a72022-05-21 01:20:56191 EXPECT_EQ(verifier->GroupPolicies().size(), 1U);
Adam Norbergc7ab1c52021-01-19 21:05:21192}
193
194TEST_F(ExternalConstantsBuilderTests, TestReuseBuilder) {
195 ExternalConstantsBuilder builder;
S. Ganesh5b7c6a72022-05-21 01:20:56196
Matt Menkeb1732aac2022-06-02 13:48:03197 base::Value::Dict group_policies;
198 group_policies.Set("a", 1);
199 group_policies.Set("b", 2);
S. Ganesh5b7c6a72022-05-21 01:20:56200
Adam Norbergc7ab1c52021-01-19 21:05:21201 EXPECT_TRUE(
202 builder.SetUpdateURL(std::vector<std::string>{"https://www.google.com"})
Xiaoling Bao616a5352023-04-03 22:00:58203 .SetCrashUploadURL("https://crash.google.com")
204 .SetDeviceManagementURL("https://dm.google.com")
Adam Norbergc7ab1c52021-01-19 21:05:21205 .SetUseCUP(false)
Noah Rose Ledesmad391ac332022-12-13 21:09:06206 .SetInitialDelay(base::Seconds(123.4))
207 .SetServerKeepAliveTime(base::Seconds(3))
Adam Norbergc7ab1c52021-01-19 21:05:21208 .SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
S. Ganesh5b7c6a72022-05-21 01:20:56209 .SetGroupPolicies(group_policies)
Adam Norbergc7ab1c52021-01-19 21:05:21210 .Overwrite());
211
Joshua Pawlicki34aacc12021-08-24 21:22:21212 scoped_refptr<ExternalConstantsOverrider> verifier =
Adam Norbergc7ab1c52021-01-19 21:05:21213 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:52214 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:21215
216 EXPECT_FALSE(verifier->UseCUP());
217
218 std::vector<GURL> urls = verifier->UpdateURL();
219 ASSERT_EQ(urls.size(), 1ul);
220 EXPECT_EQ(urls[0], GURL("https://www.example.com"));
221
Xiaoling Bao616a5352023-04-03 22:00:58222 EXPECT_EQ(verifier->CrashUploadURL(), GURL("https://crash.google.com"));
223 EXPECT_EQ(verifier->DeviceManagementURL(), GURL("https://dm.google.com"));
Noah Rose Ledesmad391ac332022-12-13 21:09:06224 EXPECT_EQ(verifier->InitialDelay(), base::Seconds(123.4));
225 EXPECT_EQ(verifier->ServerKeepAliveTime(), base::Seconds(3));
S. Ganesh5b7c6a72022-05-21 01:20:56226 EXPECT_EQ(verifier->GroupPolicies().size(), 2U);
227
Matt Menkeb1732aac2022-06-02 13:48:03228 base::Value::Dict group_policies2;
229 group_policies2.Set("b", 2);
Adam Norbergc7ab1c52021-01-19 21:05:21230
231 // But now we can use the builder again:
Noah Rose Ledesmad391ac332022-12-13 21:09:06232 EXPECT_TRUE(builder.SetInitialDelay(base::Seconds(92.3))
233 .SetServerKeepAliveTime(base::Seconds(4))
Mila Green59389f12021-02-03 20:52:32234 .ClearUpdateURL()
Xiaoling Bao616a5352023-04-03 22:00:58235 .ClearCrashUploadURL()
236 .ClearDeviceManagementURL()
S. Ganesh5b7c6a72022-05-21 01:20:56237 .SetGroupPolicies(group_policies2)
Mila Green59389f12021-02-03 20:52:32238 .Overwrite());
Adam Norbergc7ab1c52021-01-19 21:05:21239
240 // We need a new overrider to verify because it only loads once.
Joshua Pawlicki34aacc12021-08-24 21:22:21241 scoped_refptr<ExternalConstantsOverrider> verifier2 =
Adam Norbergc7ab1c52021-01-19 21:05:21242 ExternalConstantsOverrider::FromDefaultJSONFile(
Joshua Pawlicki58a597ed2021-06-10 17:00:52243 CreateDefaultExternalConstants());
Adam Norbergc7ab1c52021-01-19 21:05:21244
245 EXPECT_FALSE(verifier2->UseCUP()); // Not updated, value should be retained.
246
247 std::vector<GURL> urls2 = verifier2->UpdateURL();
248 ASSERT_EQ(urls2.size(), 1ul);
249 EXPECT_EQ(urls2[0], GURL(UPDATE_CHECK_URL)); // Cleared; should be default.
250
Xiaoling Bao616a5352023-04-03 22:00:58251 EXPECT_EQ(verifier2->CrashUploadURL(), GURL(CRASH_UPLOAD_URL));
252 EXPECT_EQ(verifier2->DeviceManagementURL(),
253 GURL(DEVICE_MANAGEMENT_SERVER_URL));
Mila Green1cb26962021-01-21 01:00:00254 EXPECT_EQ(verifier2->InitialDelay(),
Noah Rose Ledesmad391ac332022-12-13 21:09:06255 base::Seconds(92.3)); // Updated; update should be seen.
256 EXPECT_EQ(verifier2->ServerKeepAliveTime(), base::Seconds(4));
S. Ganesh5b7c6a72022-05-21 01:20:56257 EXPECT_EQ(verifier2->GroupPolicies().size(), 1U);
258}
259
260TEST_F(ExternalConstantsBuilderTests, TestModify) {
261 ExternalConstantsBuilder builder;
262
Matt Menkeb1732aac2022-06-02 13:48:03263 base::Value::Dict group_policies;
264 group_policies.Set("a", 1);
265 group_policies.Set("b", 2);
S. Ganesh5b7c6a72022-05-21 01:20:56266
267 EXPECT_TRUE(
268 builder.SetUpdateURL(std::vector<std::string>{"https://www.google.com"})
Xiaoling Bao616a5352023-04-03 22:00:58269 .SetCrashUploadURL("https://crash.google.com")
270 .SetDeviceManagementURL("https://dm.google.com")
S. Ganesh5b7c6a72022-05-21 01:20:56271 .SetUseCUP(false)
Noah Rose Ledesmad391ac332022-12-13 21:09:06272 .SetInitialDelay(base::Seconds(123.4))
273 .SetServerKeepAliveTime(base::Seconds(3))
S. Ganesh5b7c6a72022-05-21 01:20:56274 .SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
Xiaoling Bao616a5352023-04-03 22:00:58275 .SetCrashUploadURL("https://crash.example.com")
276 .SetDeviceManagementURL("https://dm.example.com")
S. Ganesh5b7c6a72022-05-21 01:20:56277 .SetGroupPolicies(group_policies)
278 .Overwrite());
279
280 scoped_refptr<ExternalConstantsOverrider> verifier =
281 ExternalConstantsOverrider::FromDefaultJSONFile(
282 CreateDefaultExternalConstants());
283
284 EXPECT_FALSE(verifier->UseCUP());
285
286 std::vector<GURL> urls = verifier->UpdateURL();
287 ASSERT_EQ(urls.size(), 1ul);
288 EXPECT_EQ(urls[0], GURL("https://www.example.com"));
289
Xiaoling Bao616a5352023-04-03 22:00:58290 EXPECT_EQ(verifier->CrashUploadURL(), GURL("https://crash.example.com"));
291 EXPECT_EQ(verifier->DeviceManagementURL(), GURL("https://dm.example.com"));
Noah Rose Ledesmad391ac332022-12-13 21:09:06292 EXPECT_EQ(verifier->InitialDelay(), base::Seconds(123.4));
293 EXPECT_EQ(verifier->ServerKeepAliveTime(), base::Seconds(3));
S. Ganesh5b7c6a72022-05-21 01:20:56294 EXPECT_EQ(verifier->GroupPolicies().size(), 2U);
295
296 // Now we use a new builder to modify just the group policies.
297 ExternalConstantsBuilder builder2;
298
Matt Menkeb1732aac2022-06-02 13:48:03299 base::Value::Dict group_policies2;
300 group_policies2.Set("b", 2);
S. Ganesh5b7c6a72022-05-21 01:20:56301
302 EXPECT_TRUE(builder2.SetGroupPolicies(group_policies2).Modify());
303
304 // We need a new overrider to verify because it only loads once.
305 scoped_refptr<ExternalConstantsOverrider> verifier2 =
306 ExternalConstantsOverrider::FromDefaultJSONFile(
307 CreateDefaultExternalConstants());
308
309 // Only the group policies are different.
310 EXPECT_EQ(verifier2->GroupPolicies().size(), 1U);
311
312 // All the values below are unchanged.
313 EXPECT_FALSE(verifier2->UseCUP());
314 urls = verifier2->UpdateURL();
315 ASSERT_EQ(urls.size(), 1ul);
316 EXPECT_EQ(urls[0], GURL("https://www.example.com"));
Xiaoling Bao616a5352023-04-03 22:00:58317 EXPECT_EQ(verifier2->CrashUploadURL(), GURL("https://crash.example.com"));
318 EXPECT_EQ(verifier2->DeviceManagementURL(), GURL("https://dm.example.com"));
Noah Rose Ledesmad391ac332022-12-13 21:09:06319 EXPECT_EQ(verifier2->InitialDelay(), base::Seconds(123.4));
320 EXPECT_EQ(verifier2->ServerKeepAliveTime(), base::Seconds(3));
Adam Norbergc7ab1c52021-01-19 21:05:21321}
Adam Norbergc7ab1c52021-01-19 21:05:21322
323} // namespace updater