blob: e2e7410ba4f2bf9496f600e8cdd47fab6671bc3e [file] [log] [blame]
rspangler@google.com49fdf182009-10-10 00:57:34 +00001// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <string>
adlr@google.comc98a7ed2009-12-04 18:54:03 +00006#include <vector>
rspangler@google.com49fdf182009-10-10 00:57:34 +00007#include <glib.h>
8#include <gtest/gtest.h>
9#include "update_engine/action_pipe.h"
10#include "update_engine/update_check_action.h"
11#include "update_engine/mock_http_fetcher.h"
12#include "update_engine/omaha_hash_calculator.h"
13#include "update_engine/test_utils.h"
14
rspangler@google.com49fdf182009-10-10 00:57:34 +000015using std::string;
adlr@google.comc98a7ed2009-12-04 18:54:03 +000016using std::vector;
17
18namespace chromeos_update_engine {
rspangler@google.com49fdf182009-10-10 00:57:34 +000019
20class UpdateCheckActionTest : public ::testing::Test { };
21
22namespace {
23string GetNoUpdateResponse(const string& app_id) {
24 return string(
25 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
26 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
27 "appid=\"") + app_id + "\" status=\"ok\"><ping "
28 "status=\"ok\"/><updatecheck status=\"noupdate\"/></app></gupdate>";
29}
30
31string GetUpdateResponse(const string& app_id,
32 const string& display_version,
33 const string& more_info_url,
34 const string& prompt,
35 const string& codebase,
36 const string& hash,
37 const string& needsadmin,
38 const string& size) {
39 return string("<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
adlr@google.comc98a7ed2009-12-04 18:54:03 +000040 "xmlns=\"http://www.google.com/update2/response\" "
41 "protocol=\"2.0\"><app "
42 "appid=\"") + app_id + "\" status=\"ok\"><ping "
rspangler@google.com49fdf182009-10-10 00:57:34 +000043 "status=\"ok\"/><updatecheck DisplayVersion=\"" + display_version + "\" "
44 "MoreInfo=\"" + more_info_url + "\" Prompt=\"" + prompt + "\" "
45 "codebase=\"" + codebase + "\" "
46 "hash=\"" + hash + "\" needsadmin=\"" + needsadmin + "\" "
47 "size=\"" + size + "\" status=\"ok\"/></app></gupdate>";
48}
49
50class UpdateCheckActionTestProcessorDelegate : public ActionProcessorDelegate {
51 public:
52 UpdateCheckActionTestProcessorDelegate()
53 : loop_(NULL),
54 expected_success_(true) {}
55 virtual ~UpdateCheckActionTestProcessorDelegate() {
56 }
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -080057 virtual void ProcessingDone(const ActionProcessor* processor, bool success) {
rspangler@google.com49fdf182009-10-10 00:57:34 +000058 ASSERT_TRUE(loop_);
59 g_main_loop_quit(loop_);
60 }
61
adlr@google.comc98a7ed2009-12-04 18:54:03 +000062 virtual void ActionCompleted(ActionProcessor* processor,
63 AbstractAction* action,
rspangler@google.com49fdf182009-10-10 00:57:34 +000064 bool success) {
65 // make sure actions always succeed
adlr@google.comc98a7ed2009-12-04 18:54:03 +000066 if (action->Type() == UpdateCheckAction::StaticType())
rspangler@google.com49fdf182009-10-10 00:57:34 +000067 EXPECT_EQ(expected_success_, success);
68 else
69 EXPECT_TRUE(success);
70 }
71 GMainLoop *loop_;
72 bool expected_success_;
73};
74
75gboolean StartProcessorInRunLoop(gpointer data) {
76 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data);
77 processor->StartProcessing();
78 return FALSE;
79}
80
81} // namespace {}
82
83class OutputObjectCollectorAction;
84
85template<>
86class ActionTraits<OutputObjectCollectorAction> {
87 public:
88 // Does not take an object for input
89 typedef UpdateCheckResponse InputObjectType;
90 // On success, puts the output path on output
91 typedef NoneType OutputObjectType;
92};
93
94class OutputObjectCollectorAction : public Action<OutputObjectCollectorAction> {
95 public:
Andrew de los Reyes08c4e272010-04-15 14:02:17 -070096 OutputObjectCollectorAction() : has_input_object_(false) {}
rspangler@google.com49fdf182009-10-10 00:57:34 +000097 void PerformAction() {
98 // copy input object
99 has_input_object_ = HasInputObject();
100 if (has_input_object_)
101 update_check_response_ = GetInputObject();
102 processor_->ActionComplete(this, true);
103 }
104 // Should never be called
105 void TerminateProcessing() {
106 CHECK(false);
107 }
108 // Debugging/logging
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000109 static std::string StaticType() {
110 return "OutputObjectCollectorAction";
111 }
112 std::string Type() const { return StaticType(); }
rspangler@google.com49fdf182009-10-10 00:57:34 +0000113 bool has_input_object_;
114 UpdateCheckResponse update_check_response_;
115};
116
117// returns true iff an output response was obtained from the
118// UpdateCheckAction. out_response may be NULL.
119// out_post_data may be null; if non-null, the post-data received by the
120// mock HttpFetcher is returned.
121bool TestUpdateCheckAction(const UpdateCheckParams& params,
122 const string& http_response,
123 bool expected_success,
124 UpdateCheckResponse* out_response,
125 vector<char> *out_post_data) {
126 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
127 MockHttpFetcher *fetcher = new MockHttpFetcher(http_response.data(),
128 http_response.size());
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000129 ObjectFeederAction<UpdateCheckParams> feeder_action;
130 UpdateCheckAction action(fetcher); // takes ownership of fetcher
rspangler@google.com49fdf182009-10-10 00:57:34 +0000131 UpdateCheckActionTestProcessorDelegate delegate;
132 delegate.loop_ = loop;
133 delegate.expected_success_ = expected_success;
134 ActionProcessor processor;
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000135 feeder_action.set_obj(params);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000136 processor.set_delegate(&delegate);
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000137 processor.EnqueueAction(&feeder_action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000138 processor.EnqueueAction(&action);
139
140 OutputObjectCollectorAction collector_action;
141
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000142 BondActions(&feeder_action, &action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000143 BondActions(&action, &collector_action);
144 processor.EnqueueAction(&collector_action);
145
146 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
147 g_main_loop_run(loop);
148 g_main_loop_unref(loop);
149 if (collector_action.has_input_object_ && out_response)
150 *out_response = collector_action.update_check_response_;
151 if (out_post_data)
152 *out_post_data = fetcher->post_data();
153 return collector_action.has_input_object_;
154}
155
156TEST(UpdateCheckActionTest, NoUpdateTest) {
157 UpdateCheckParams params("", // machine_id
158 "", // user_id
159 UpdateCheckParams::kOsPlatform,
160 UpdateCheckParams::kOsVersion,
161 "", // os_sp
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700162 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000163 UpdateCheckParams::kAppId,
164 "0.1.0.0",
165 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700166 "unittest",
167 ""); // url
rspangler@google.com49fdf182009-10-10 00:57:34 +0000168 UpdateCheckResponse response;
169 ASSERT_TRUE(
170 TestUpdateCheckAction(params,
171 GetNoUpdateResponse(UpdateCheckParams::kAppId),
172 true,
173 &response,
174 NULL));
175 EXPECT_FALSE(response.update_exists);
176}
177
178TEST(UpdateCheckActionTest, ValidUpdateTest) {
179 UpdateCheckParams params("machine_id",
180 "user_id",
181 UpdateCheckParams::kOsPlatform,
182 UpdateCheckParams::kOsVersion,
183 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700184 "arm-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000185 UpdateCheckParams::kAppId,
186 "0.1.0.0",
187 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700188 "unittest_track",
189 ""); // url
rspangler@google.com49fdf182009-10-10 00:57:34 +0000190 UpdateCheckResponse response;
191 ASSERT_TRUE(
192 TestUpdateCheckAction(params,
193 GetUpdateResponse(UpdateCheckParams::kAppId,
194 "1.2.3.4", // version
195 "http://more/info",
196 "true", // prompt
197 "http://code/base", // dl url
198 "HASH1234=", // checksum
199 "false", // needs admin
200 "123"), // size
201 true,
202 &response,
203 NULL));
204 EXPECT_TRUE(response.update_exists);
205 EXPECT_EQ("1.2.3.4", response.display_version);
206 EXPECT_EQ("http://code/base", response.codebase);
207 EXPECT_EQ("http://more/info", response.more_info_url);
208 EXPECT_EQ("HASH1234=", response.hash);
209 EXPECT_EQ(123, response.size);
210 EXPECT_FALSE(response.needs_admin);
211 EXPECT_TRUE(response.prompt);
212}
213
214TEST(UpdateCheckActionTest, NoOutputPipeTest) {
215 UpdateCheckParams params("", // machine_id
216 "", // usr_id
217 UpdateCheckParams::kOsPlatform,
218 UpdateCheckParams::kOsVersion,
219 "", // os_sp
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700220 "", // os_board
rspangler@google.com49fdf182009-10-10 00:57:34 +0000221 UpdateCheckParams::kAppId,
222 "0.1.0.0",
223 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700224 "unittest",
225 ""); // url
rspangler@google.com49fdf182009-10-10 00:57:34 +0000226 const string http_response(GetNoUpdateResponse(UpdateCheckParams::kAppId));
227
228 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
229
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000230 ObjectFeederAction<UpdateCheckParams> feeder_action;
231 feeder_action.set_obj(params);
232 UpdateCheckAction action(new MockHttpFetcher(http_response.data(),
rspangler@google.com49fdf182009-10-10 00:57:34 +0000233 http_response.size()));
234 UpdateCheckActionTestProcessorDelegate delegate;
235 delegate.loop_ = loop;
236 ActionProcessor processor;
237 processor.set_delegate(&delegate);
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000238 processor.EnqueueAction(&feeder_action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000239 processor.EnqueueAction(&action);
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000240 BondActions(&feeder_action, &action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000241
242 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
243 g_main_loop_run(loop);
244 g_main_loop_unref(loop);
245 EXPECT_FALSE(processor.IsRunning());
246}
247
248TEST(UpdateCheckActionTest, InvalidXmlTest) {
249 UpdateCheckParams params("machine_id",
250 "user_id",
251 UpdateCheckParams::kOsPlatform,
252 UpdateCheckParams::kOsVersion,
253 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700254 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000255 UpdateCheckParams::kAppId,
256 "0.1.0.0",
257 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700258 "unittest_track",
259 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000260 UpdateCheckResponse response;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700261 ASSERT_FALSE(
rspangler@google.com49fdf182009-10-10 00:57:34 +0000262 TestUpdateCheckAction(params,
263 "invalid xml>",
264 false,
265 &response,
266 NULL));
267 EXPECT_FALSE(response.update_exists);
268}
269
270TEST(UpdateCheckActionTest, MissingStatusTest) {
271 UpdateCheckParams params("machine_id",
272 "user_id",
273 UpdateCheckParams::kOsPlatform,
274 UpdateCheckParams::kOsVersion,
275 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700276 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000277 UpdateCheckParams::kAppId,
278 "0.1.0.0",
279 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700280 "unittest_track",
281 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000282 UpdateCheckResponse response;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700283 ASSERT_FALSE(TestUpdateCheckAction(
rspangler@google.com49fdf182009-10-10 00:57:34 +0000284 params,
285 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
286 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
287 "appid=\"foo\" status=\"ok\"><ping "
288 "status=\"ok\"/><updatecheck/></app></gupdate>",
289 false,
290 &response,
291 NULL));
292 EXPECT_FALSE(response.update_exists);
293}
294
295TEST(UpdateCheckActionTest, InvalidStatusTest) {
296 UpdateCheckParams params("machine_id",
297 "user_id",
298 UpdateCheckParams::kOsPlatform,
299 UpdateCheckParams::kOsVersion,
300 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700301 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000302 UpdateCheckParams::kAppId,
303 "0.1.0.0",
304 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700305 "unittest_track",
306 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000307 UpdateCheckResponse response;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700308 ASSERT_FALSE(TestUpdateCheckAction(
rspangler@google.com49fdf182009-10-10 00:57:34 +0000309 params,
310 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
311 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
312 "appid=\"foo\" status=\"ok\"><ping "
313 "status=\"ok\"/><updatecheck status=\"foo\"/></app></gupdate>",
314 false,
315 &response,
316 NULL));
317 EXPECT_FALSE(response.update_exists);
318}
319
320TEST(UpdateCheckActionTest, MissingNodesetTest) {
321 UpdateCheckParams params("machine_id",
322 "user_id",
323 UpdateCheckParams::kOsPlatform,
324 UpdateCheckParams::kOsVersion,
325 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700326 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000327 UpdateCheckParams::kAppId,
328 "0.1.0.0",
329 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700330 "unittest_track",
331 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000332 UpdateCheckResponse response;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700333 ASSERT_FALSE(TestUpdateCheckAction(
rspangler@google.com49fdf182009-10-10 00:57:34 +0000334 params,
335 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
336 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
337 "appid=\"foo\" status=\"ok\"><ping "
338 "status=\"ok\"/></app></gupdate>",
339 false,
340 &response,
341 NULL));
342 EXPECT_FALSE(response.update_exists);
343}
344
345TEST(UpdateCheckActionTest, MissingFieldTest) {
346 UpdateCheckParams params("machine_id",
347 "user_id",
348 UpdateCheckParams::kOsPlatform,
349 UpdateCheckParams::kOsVersion,
350 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700351 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000352 UpdateCheckParams::kAppId,
353 "0.1.0.0",
354 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700355 "unittest_track",
356 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000357 UpdateCheckResponse response;
358 ASSERT_TRUE(TestUpdateCheckAction(params,
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000359 string("<?xml version=\"1.0\" "
360 "encoding=\"UTF-8\"?><gupdate "
361 "xmlns=\"http://www.google.com/"
362 "update2/response\" "
363 "protocol=\"2.0\"><app appid=\"") +
364 UpdateCheckParams::kAppId
365 + "\" status=\"ok\"><ping "
366 "status=\"ok\"/><updatecheck "
367 "DisplayVersion=\"1.2.3.4\" "
368 "Prompt=\"false\" "
369 "codebase=\"http://code/base\" "
370 "hash=\"HASH1234=\" needsadmin=\"true\" "
371 "size=\"123\" "
372 "status=\"ok\"/></app></gupdate>",
373 true,
374 &response,
375 NULL));
rspangler@google.com49fdf182009-10-10 00:57:34 +0000376 EXPECT_TRUE(response.update_exists);
377 EXPECT_EQ("1.2.3.4", response.display_version);
378 EXPECT_EQ("http://code/base", response.codebase);
379 EXPECT_EQ("", response.more_info_url);
380 EXPECT_EQ("HASH1234=", response.hash);
381 EXPECT_EQ(123, response.size);
382 EXPECT_TRUE(response.needs_admin);
383 EXPECT_FALSE(response.prompt);
384}
385
386namespace {
387class TerminateEarlyTestProcessorDelegate : public ActionProcessorDelegate {
388 public:
389 void ProcessingStopped(const ActionProcessor* processor) {
390 ASSERT_TRUE(loop_);
391 g_main_loop_quit(loop_);
392 }
393 GMainLoop *loop_;
394};
395
396gboolean TerminateTransferTestStarter(gpointer data) {
397 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data);
398 processor->StartProcessing();
399 CHECK(processor->IsRunning());
400 processor->StopProcessing();
401 return FALSE;
402}
403} // namespace {}
404
405TEST(UpdateCheckActionTest, TerminateTransferTest) {
406 UpdateCheckParams params("", // machine_id
407 "", // usr_id
408 UpdateCheckParams::kOsPlatform,
409 UpdateCheckParams::kOsVersion,
410 "", // os_sp
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700411 "", // os_board
rspangler@google.com49fdf182009-10-10 00:57:34 +0000412 UpdateCheckParams::kAppId,
413 "0.1.0.0",
414 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700415 "unittest",
416 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000417 string http_response("doesn't matter");
418 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
419
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000420 ObjectFeederAction<UpdateCheckParams> feeder_action;
421 feeder_action.set_obj(params);
422 UpdateCheckAction action(new MockHttpFetcher(http_response.data(),
rspangler@google.com49fdf182009-10-10 00:57:34 +0000423 http_response.size()));
424 TerminateEarlyTestProcessorDelegate delegate;
425 delegate.loop_ = loop;
426 ActionProcessor processor;
427 processor.set_delegate(&delegate);
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000428 processor.EnqueueAction(&feeder_action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000429 processor.EnqueueAction(&action);
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000430 BondActions(&feeder_action, &action);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000431
432 g_timeout_add(0, &TerminateTransferTestStarter, &processor);
433 g_main_loop_run(loop);
434 g_main_loop_unref(loop);
435}
436
437TEST(UpdateCheckActionTest, XmlEncodeTest) {
438 EXPECT_EQ("ab", XmlEncode("ab"));
439 EXPECT_EQ("a&lt;b", XmlEncode("a<b"));
440 EXPECT_EQ("foo-&#x3A9;", XmlEncode("foo-\xce\xa9"));
441 EXPECT_EQ("&lt;&amp;&gt;", XmlEncode("<&>"));
442 EXPECT_EQ("&amp;lt;&amp;amp;&amp;gt;", XmlEncode("&lt;&amp;&gt;"));
443
444 vector<char> post_data;
445
446 // Make sure XML Encode is being called on the params
447 UpdateCheckParams params("testthemachine<id",
448 "testtheuser_id&lt;",
449 UpdateCheckParams::kOsPlatform,
450 UpdateCheckParams::kOsVersion,
451 "testtheservice_pack>",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700452 "x86 generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000453 UpdateCheckParams::kAppId,
454 "0.1.0.0",
455 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700456 "unittest_track",
457 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000458 UpdateCheckResponse response;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700459 ASSERT_FALSE(
rspangler@google.com49fdf182009-10-10 00:57:34 +0000460 TestUpdateCheckAction(params,
461 "invalid xml>",
462 false,
463 &response,
464 &post_data));
465 // convert post_data to string
466 string post_str(&post_data[0], post_data.size());
467 EXPECT_NE(post_str.find("testthemachine&lt;id"), string::npos);
468 EXPECT_EQ(post_str.find("testthemachine<id"), string::npos);
469 EXPECT_NE(post_str.find("testtheuser_id&amp;lt;"), string::npos);
470 EXPECT_EQ(post_str.find("testtheuser_id&lt;"), string::npos);
471 EXPECT_NE(post_str.find("testtheservice_pack&gt;"), string::npos);
472 EXPECT_EQ(post_str.find("testtheservice_pack>"), string::npos);
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700473 EXPECT_NE(post_str.find("x86 generic"), string::npos);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000474}
475
476TEST(UpdateCheckActionTest, XmlDecodeTest) {
477 UpdateCheckParams params("machine_id",
478 "user_id",
479 UpdateCheckParams::kOsPlatform,
480 UpdateCheckParams::kOsVersion,
481 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700482 "x86-generic",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000483 UpdateCheckParams::kAppId,
484 "0.1.0.0",
485 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700486 "unittest_track",
487 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000488 UpdateCheckResponse response;
489 ASSERT_TRUE(
490 TestUpdateCheckAction(params,
491 GetUpdateResponse(UpdateCheckParams::kAppId,
492 "1.2.3.4", // version
493 "testthe&lt;url", // more info
494 "true", // prompt
495 "testthe&amp;codebase", // dl url
496 "HASH1234=", // checksum
497 "false", // needs admin
498 "123"), // size
499 true,
500 &response,
501 NULL));
502
503 EXPECT_EQ(response.more_info_url, "testthe<url");
504 EXPECT_EQ(response.codebase, "testthe&codebase");
505}
506
507TEST(UpdateCheckActionTest, ParseIntTest) {
508 UpdateCheckParams params("machine_id",
509 "user_id",
510 UpdateCheckParams::kOsPlatform,
511 UpdateCheckParams::kOsVersion,
512 "service_pack",
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700513 "the_board",
rspangler@google.com49fdf182009-10-10 00:57:34 +0000514 UpdateCheckParams::kAppId,
515 "0.1.0.0",
516 "en-US",
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700517 "unittest_track",
518 "http://url");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000519 UpdateCheckResponse response;
520 ASSERT_TRUE(
521 TestUpdateCheckAction(params,
522 GetUpdateResponse(UpdateCheckParams::kAppId,
523 "1.2.3.4", // version
524 "theurl", // more info
525 "true", // prompt
526 "thecodebase", // dl url
527 "HASH1234=", // checksum
528 "false", // needs admin
529 // overflows int32:
530 "123123123123123"), // size
531 true,
532 &response,
533 NULL));
534
535 EXPECT_EQ(response.size, 123123123123123ll);
536}
537
538} // namespace chromeos_update_engine