blob: f822357d979517c99052a3fac872a2481076221f [file] [log] [blame]
Darin Petkova4a8a8c2010-07-15 22:21:12 -07001// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
Darin Petkov6a5b3222010-07-13 14:55:28 -07002// 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>
6#include <vector>
Darin Petkov0dc8e9a2010-07-14 14:51:57 -07007
Darin Petkov6a5b3222010-07-13 14:55:28 -07008#include <glib.h>
Darin Petkov0dc8e9a2010-07-14 14:51:57 -07009
10#include "base/string_util.h"
Darin Petkov1cbd78f2010-07-29 12:38:34 -070011#include "base/time.h"
Darin Petkov0dc8e9a2010-07-14 14:51:57 -070012#include "gtest/gtest.h"
Darin Petkov6a5b3222010-07-13 14:55:28 -070013#include "update_engine/action_pipe.h"
14#include "update_engine/mock_http_fetcher.h"
15#include "update_engine/omaha_hash_calculator.h"
16#include "update_engine/omaha_request_action.h"
Darin Petkova4a8a8c2010-07-15 22:21:12 -070017#include "update_engine/omaha_request_params.h"
Darin Petkov1cbd78f2010-07-29 12:38:34 -070018#include "update_engine/prefs_mock.h"
Darin Petkov6a5b3222010-07-13 14:55:28 -070019#include "update_engine/test_utils.h"
20
Darin Petkov1cbd78f2010-07-29 12:38:34 -070021using base::Time;
22using base::TimeDelta;
Darin Petkov6a5b3222010-07-13 14:55:28 -070023using std::string;
24using std::vector;
Darin Petkov1cbd78f2010-07-29 12:38:34 -070025using testing::_;
26using testing::AllOf;
27using testing::Ge;
28using testing::Le;
29using testing::Return;
30using testing::SetArgumentPointee;
Darin Petkov6a5b3222010-07-13 14:55:28 -070031
32namespace chromeos_update_engine {
33
34class OmahaRequestActionTest : public ::testing::Test { };
35
36namespace {
Darin Petkov1cbd78f2010-07-29 12:38:34 -070037const OmahaRequestParams kDefaultTestParams(
Darin Petkov1cbd78f2010-07-29 12:38:34 -070038 OmahaRequestParams::kOsPlatform,
39 OmahaRequestParams::kOsVersion,
40 "service_pack",
41 "x86-generic",
42 OmahaRequestParams::kAppId,
43 "0.1.0.0",
44 "en-US",
45 "unittest",
Darin Petkovfbb40092010-07-29 17:05:50 -070046 "OEM MODEL 09235 7471",
Darin Petkov1cbd78f2010-07-29 12:38:34 -070047 false, // delta okay
48 "http://url");
49
Darin Petkov6a5b3222010-07-13 14:55:28 -070050string GetNoUpdateResponse(const string& app_id) {
51 return string(
52 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
53 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
54 "appid=\"") + app_id + "\" status=\"ok\"><ping "
55 "status=\"ok\"/><updatecheck status=\"noupdate\"/></app></gupdate>";
56}
57
58string GetUpdateResponse(const string& app_id,
59 const string& display_version,
60 const string& more_info_url,
61 const string& prompt,
62 const string& codebase,
63 const string& hash,
64 const string& needsadmin,
Darin Petkov6c118642010-10-21 12:06:30 -070065 const string& size,
66 const string& deadline) {
Darin Petkov6a5b3222010-07-13 14:55:28 -070067 return string("<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
68 "xmlns=\"http://www.google.com/update2/response\" "
69 "protocol=\"2.0\"><app "
70 "appid=\"") + app_id + "\" status=\"ok\"><ping "
71 "status=\"ok\"/><updatecheck DisplayVersion=\"" + display_version + "\" "
72 "MoreInfo=\"" + more_info_url + "\" Prompt=\"" + prompt + "\" "
Andrew de los Reyes3270f742010-07-15 22:28:14 -070073 "IsDelta=\"true\" "
Darin Petkovd22cb292010-09-29 10:02:29 -070074 "codebase=\"" + codebase + "\" hash=\"not-applicable\" "
75 "sha256=\"" + hash + "\" needsadmin=\"" + needsadmin + "\" "
Darin Petkov6c118642010-10-21 12:06:30 -070076 "size=\"" + size + "\" deadline=\"" + deadline +
77 "\" status=\"ok\"/></app></gupdate>";
Darin Petkov6a5b3222010-07-13 14:55:28 -070078}
79
80class OmahaRequestActionTestProcessorDelegate : public ActionProcessorDelegate {
81 public:
82 OmahaRequestActionTestProcessorDelegate()
83 : loop_(NULL),
Darin Petkovc1a8b422010-07-19 11:34:49 -070084 expected_code_(kActionCodeSuccess) {}
Darin Petkov6a5b3222010-07-13 14:55:28 -070085 virtual ~OmahaRequestActionTestProcessorDelegate() {
86 }
Darin Petkovc1a8b422010-07-19 11:34:49 -070087 virtual void ProcessingDone(const ActionProcessor* processor,
88 ActionExitCode code) {
Darin Petkov6a5b3222010-07-13 14:55:28 -070089 ASSERT_TRUE(loop_);
90 g_main_loop_quit(loop_);
91 }
92
93 virtual void ActionCompleted(ActionProcessor* processor,
94 AbstractAction* action,
Darin Petkovc1a8b422010-07-19 11:34:49 -070095 ActionExitCode code) {
Darin Petkov6a5b3222010-07-13 14:55:28 -070096 // make sure actions always succeed
97 if (action->Type() == OmahaRequestAction::StaticType())
Darin Petkovc1a8b422010-07-19 11:34:49 -070098 EXPECT_EQ(expected_code_, code);
Darin Petkov6a5b3222010-07-13 14:55:28 -070099 else
Darin Petkovc1a8b422010-07-19 11:34:49 -0700100 EXPECT_EQ(kActionCodeSuccess, code);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700101 }
102 GMainLoop *loop_;
Darin Petkovc1a8b422010-07-19 11:34:49 -0700103 ActionExitCode expected_code_;
Darin Petkov6a5b3222010-07-13 14:55:28 -0700104};
105
106gboolean StartProcessorInRunLoop(gpointer data) {
107 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data);
108 processor->StartProcessing();
109 return FALSE;
110}
Darin Petkov6a5b3222010-07-13 14:55:28 -0700111} // namespace {}
112
113class OutputObjectCollectorAction;
114
115template<>
116class ActionTraits<OutputObjectCollectorAction> {
117 public:
118 // Does not take an object for input
119 typedef OmahaResponse InputObjectType;
120 // On success, puts the output path on output
121 typedef NoneType OutputObjectType;
122};
123
124class OutputObjectCollectorAction : public Action<OutputObjectCollectorAction> {
125 public:
126 OutputObjectCollectorAction() : has_input_object_(false) {}
127 void PerformAction() {
128 // copy input object
129 has_input_object_ = HasInputObject();
130 if (has_input_object_)
131 omaha_response_ = GetInputObject();
Darin Petkovc1a8b422010-07-19 11:34:49 -0700132 processor_->ActionComplete(this, kActionCodeSuccess);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700133 }
134 // Should never be called
135 void TerminateProcessing() {
136 CHECK(false);
137 }
138 // Debugging/logging
139 static std::string StaticType() {
140 return "OutputObjectCollectorAction";
141 }
142 std::string Type() const { return StaticType(); }
143 bool has_input_object_;
144 OmahaResponse omaha_response_;
145};
146
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700147// Returns true iff an output response was obtained from the
148// OmahaRequestAction. |prefs| may be NULL, in which case a local
149// PrefsMock is used. out_response may be NULL. out_post_data may be
150// null; if non-null, the post-data received by the mock HttpFetcher
151// is returned.
152bool TestUpdateCheck(PrefsInterface* prefs,
153 const OmahaRequestParams& params,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700154 const string& http_response,
Darin Petkovc1a8b422010-07-19 11:34:49 -0700155 ActionExitCode expected_code,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700156 OmahaResponse* out_response,
157 vector<char>* out_post_data) {
158 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
159 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(),
Darin Petkov6a5b3222010-07-13 14:55:28 -0700160 http_response.size());
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700161 PrefsMock local_prefs;
162 OmahaRequestAction action(prefs ? prefs : &local_prefs,
163 params,
164 NULL,
165 fetcher);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700166 OmahaRequestActionTestProcessorDelegate delegate;
167 delegate.loop_ = loop;
Darin Petkovc1a8b422010-07-19 11:34:49 -0700168 delegate.expected_code_ = expected_code;
Darin Petkova4a8a8c2010-07-15 22:21:12 -0700169
Darin Petkov6a5b3222010-07-13 14:55:28 -0700170 ActionProcessor processor;
Darin Petkov6a5b3222010-07-13 14:55:28 -0700171 processor.set_delegate(&delegate);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700172 processor.EnqueueAction(&action);
173
174 OutputObjectCollectorAction collector_action;
Darin Petkov6a5b3222010-07-13 14:55:28 -0700175 BondActions(&action, &collector_action);
176 processor.EnqueueAction(&collector_action);
177
178 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
179 g_main_loop_run(loop);
180 g_main_loop_unref(loop);
181 if (collector_action.has_input_object_ && out_response)
182 *out_response = collector_action.omaha_response_;
183 if (out_post_data)
184 *out_post_data = fetcher->post_data();
185 return collector_action.has_input_object_;
186}
187
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700188// Tests Event requests -- they should always succeed. |out_post_data|
189// may be null; if non-null, the post-data received by the mock
190// HttpFetcher is returned.
191void TestEvent(const OmahaRequestParams& params,
192 OmahaEvent* event,
193 const string& http_response,
194 vector<char>* out_post_data) {
195 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
196 MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(),
197 http_response.size());
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700198 PrefsMock prefs;
199 OmahaRequestAction action(&prefs, params, event, fetcher);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700200 OmahaRequestActionTestProcessorDelegate delegate;
201 delegate.loop_ = loop;
202 ActionProcessor processor;
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700203 processor.set_delegate(&delegate);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700204 processor.EnqueueAction(&action);
205
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700206 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
207 g_main_loop_run(loop);
208 g_main_loop_unref(loop);
209 if (out_post_data)
210 *out_post_data = fetcher->post_data();
211}
212
Darin Petkov6a5b3222010-07-13 14:55:28 -0700213TEST(OmahaRequestActionTest, NoUpdateTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700214 OmahaResponse response;
215 ASSERT_TRUE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700216 TestUpdateCheck(NULL, // prefs
217 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700218 GetNoUpdateResponse(OmahaRequestParams::kAppId),
Darin Petkovc1a8b422010-07-19 11:34:49 -0700219 kActionCodeSuccess,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700220 &response,
221 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700222 EXPECT_FALSE(response.update_exists);
223}
224
225TEST(OmahaRequestActionTest, ValidUpdateTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700226 OmahaResponse response;
227 ASSERT_TRUE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700228 TestUpdateCheck(NULL, // prefs
229 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700230 GetUpdateResponse(OmahaRequestParams::kAppId,
231 "1.2.3.4", // version
232 "http://more/info",
233 "true", // prompt
234 "http://code/base", // dl url
235 "HASH1234=", // checksum
236 "false", // needs admin
Darin Petkov6c118642010-10-21 12:06:30 -0700237 "123", // size
238 "20101020"), // deadline
Darin Petkovc1a8b422010-07-19 11:34:49 -0700239 kActionCodeSuccess,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700240 &response,
241 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700242 EXPECT_TRUE(response.update_exists);
243 EXPECT_EQ("1.2.3.4", response.display_version);
244 EXPECT_EQ("http://code/base", response.codebase);
245 EXPECT_EQ("http://more/info", response.more_info_url);
Andrew de los Reyes3270f742010-07-15 22:28:14 -0700246 EXPECT_TRUE(response.is_delta);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700247 EXPECT_EQ("HASH1234=", response.hash);
248 EXPECT_EQ(123, response.size);
249 EXPECT_FALSE(response.needs_admin);
250 EXPECT_TRUE(response.prompt);
Darin Petkov6c118642010-10-21 12:06:30 -0700251 EXPECT_EQ("20101020", response.deadline);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700252}
253
254TEST(OmahaRequestActionTest, NoOutputPipeTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700255 const string http_response(GetNoUpdateResponse(OmahaRequestParams::kAppId));
256
257 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
258
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700259 PrefsMock prefs;
260 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700261 new MockHttpFetcher(http_response.data(),
Darin Petkov6a5b3222010-07-13 14:55:28 -0700262 http_response.size()));
263 OmahaRequestActionTestProcessorDelegate delegate;
264 delegate.loop_ = loop;
265 ActionProcessor processor;
266 processor.set_delegate(&delegate);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700267 processor.EnqueueAction(&action);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700268
269 g_timeout_add(0, &StartProcessorInRunLoop, &processor);
270 g_main_loop_run(loop);
271 g_main_loop_unref(loop);
272 EXPECT_FALSE(processor.IsRunning());
273}
274
275TEST(OmahaRequestActionTest, InvalidXmlTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700276 OmahaResponse response;
277 ASSERT_FALSE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700278 TestUpdateCheck(NULL, // prefs
279 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700280 "invalid xml>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700281 kActionCodeError,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700282 &response,
283 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700284 EXPECT_FALSE(response.update_exists);
285}
286
287TEST(OmahaRequestActionTest, MissingStatusTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700288 OmahaResponse response;
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700289 ASSERT_FALSE(TestUpdateCheck(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700290 NULL, // prefs
291 kDefaultTestParams,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700292 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
293 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
294 "appid=\"foo\" status=\"ok\"><ping "
295 "status=\"ok\"/><updatecheck/></app></gupdate>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700296 kActionCodeError,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700297 &response,
298 NULL));
299 EXPECT_FALSE(response.update_exists);
300}
301
302TEST(OmahaRequestActionTest, InvalidStatusTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700303 OmahaResponse response;
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700304 ASSERT_FALSE(TestUpdateCheck(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700305 NULL, // prefs
306 kDefaultTestParams,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700307 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
308 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
309 "appid=\"foo\" status=\"ok\"><ping "
310 "status=\"ok\"/><updatecheck status=\"foo\"/></app></gupdate>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700311 kActionCodeError,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700312 &response,
313 NULL));
314 EXPECT_FALSE(response.update_exists);
315}
316
317TEST(OmahaRequestActionTest, MissingNodesetTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700318 OmahaResponse response;
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700319 ASSERT_FALSE(TestUpdateCheck(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700320 NULL, // prefs
321 kDefaultTestParams,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700322 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
323 "xmlns=\"http://www.google.com/update2/response\" protocol=\"2.0\"><app "
324 "appid=\"foo\" status=\"ok\"><ping "
325 "status=\"ok\"/></app></gupdate>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700326 kActionCodeError,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700327 &response,
328 NULL));
329 EXPECT_FALSE(response.update_exists);
330}
331
332TEST(OmahaRequestActionTest, MissingFieldTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700333 OmahaResponse response;
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700334 ASSERT_TRUE(TestUpdateCheck(NULL, // prefs
335 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700336 string("<?xml version=\"1.0\" "
337 "encoding=\"UTF-8\"?><gupdate "
338 "xmlns=\"http://www.google.com/"
339 "update2/response\" "
340 "protocol=\"2.0\"><app appid=\"") +
341 OmahaRequestParams::kAppId
342 + "\" status=\"ok\"><ping "
343 "status=\"ok\"/><updatecheck "
344 "DisplayVersion=\"1.2.3.4\" "
345 "Prompt=\"false\" "
Darin Petkovd22cb292010-09-29 10:02:29 -0700346 "codebase=\"http://code/base\" hash=\"foo\" "
347 "sha256=\"HASH1234=\" needsadmin=\"true\" "
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700348 "size=\"123\" "
349 "status=\"ok\"/></app></gupdate>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700350 kActionCodeSuccess,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700351 &response,
352 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700353 EXPECT_TRUE(response.update_exists);
354 EXPECT_EQ("1.2.3.4", response.display_version);
355 EXPECT_EQ("http://code/base", response.codebase);
356 EXPECT_EQ("", response.more_info_url);
Andrew de los Reyes3270f742010-07-15 22:28:14 -0700357 EXPECT_FALSE(response.is_delta);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700358 EXPECT_EQ("HASH1234=", response.hash);
359 EXPECT_EQ(123, response.size);
360 EXPECT_TRUE(response.needs_admin);
361 EXPECT_FALSE(response.prompt);
Darin Petkov6c118642010-10-21 12:06:30 -0700362 EXPECT_TRUE(response.deadline.empty());
Darin Petkov6a5b3222010-07-13 14:55:28 -0700363}
364
365namespace {
366class TerminateEarlyTestProcessorDelegate : public ActionProcessorDelegate {
367 public:
368 void ProcessingStopped(const ActionProcessor* processor) {
369 ASSERT_TRUE(loop_);
370 g_main_loop_quit(loop_);
371 }
372 GMainLoop *loop_;
373};
374
375gboolean TerminateTransferTestStarter(gpointer data) {
376 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data);
377 processor->StartProcessing();
378 CHECK(processor->IsRunning());
379 processor->StopProcessing();
380 return FALSE;
381}
382} // namespace {}
383
384TEST(OmahaRequestActionTest, TerminateTransferTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700385 string http_response("doesn't matter");
386 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
387
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700388 PrefsMock prefs;
389 OmahaRequestAction action(&prefs, kDefaultTestParams, NULL,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700390 new MockHttpFetcher(http_response.data(),
Darin Petkov6a5b3222010-07-13 14:55:28 -0700391 http_response.size()));
392 TerminateEarlyTestProcessorDelegate delegate;
393 delegate.loop_ = loop;
394 ActionProcessor processor;
395 processor.set_delegate(&delegate);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700396 processor.EnqueueAction(&action);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700397
398 g_timeout_add(0, &TerminateTransferTestStarter, &processor);
399 g_main_loop_run(loop);
400 g_main_loop_unref(loop);
401}
402
403TEST(OmahaRequestActionTest, XmlEncodeTest) {
404 EXPECT_EQ("ab", XmlEncode("ab"));
405 EXPECT_EQ("a&lt;b", XmlEncode("a<b"));
406 EXPECT_EQ("foo-&#x3A9;", XmlEncode("foo-\xce\xa9"));
407 EXPECT_EQ("&lt;&amp;&gt;", XmlEncode("<&>"));
408 EXPECT_EQ("&amp;lt;&amp;amp;&amp;gt;", XmlEncode("&lt;&amp;&gt;"));
409
410 vector<char> post_data;
411
412 // Make sure XML Encode is being called on the params
Darin Petkov84c763c2010-07-29 16:27:58 -0700413 OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
Darin Petkov6a5b3222010-07-13 14:55:28 -0700414 OmahaRequestParams::kOsVersion,
415 "testtheservice_pack>",
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700416 "x86 generic<id",
Darin Petkov6a5b3222010-07-13 14:55:28 -0700417 OmahaRequestParams::kAppId,
418 "0.1.0.0",
419 "en-US",
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700420 "unittest_track&lt;",
Darin Petkovfbb40092010-07-29 17:05:50 -0700421 "<OEM MODEL>",
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700422 false, // delta okay
Darin Petkov6a5b3222010-07-13 14:55:28 -0700423 "http://url");
424 OmahaResponse response;
425 ASSERT_FALSE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700426 TestUpdateCheck(NULL, // prefs
427 params,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700428 "invalid xml>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700429 kActionCodeError,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700430 &response,
431 &post_data));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700432 // convert post_data to string
433 string post_str(&post_data[0], post_data.size());
Darin Petkov6a5b3222010-07-13 14:55:28 -0700434 EXPECT_NE(post_str.find("testtheservice_pack&gt;"), string::npos);
435 EXPECT_EQ(post_str.find("testtheservice_pack>"), string::npos);
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700436 EXPECT_NE(post_str.find("x86 generic&lt;id"), string::npos);
437 EXPECT_EQ(post_str.find("x86 generic<id"), string::npos);
438 EXPECT_NE(post_str.find("unittest_track&amp;lt;"), string::npos);
439 EXPECT_EQ(post_str.find("unittest_track&lt;"), string::npos);
Darin Petkovfbb40092010-07-29 17:05:50 -0700440 EXPECT_NE(post_str.find("&lt;OEM MODEL&gt;"), string::npos);
441 EXPECT_EQ(post_str.find("<OEM MODEL>"), string::npos);
Darin Petkov6a5b3222010-07-13 14:55:28 -0700442}
443
444TEST(OmahaRequestActionTest, XmlDecodeTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700445 OmahaResponse response;
446 ASSERT_TRUE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700447 TestUpdateCheck(NULL, // prefs
448 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700449 GetUpdateResponse(OmahaRequestParams::kAppId,
450 "1.2.3.4", // version
451 "testthe&lt;url", // more info
452 "true", // prompt
453 "testthe&amp;codebase", // dl url
454 "HASH1234=", // checksum
455 "false", // needs admin
Darin Petkov6c118642010-10-21 12:06:30 -0700456 "123", // size
457 "&lt;20110101"), // deadline
Darin Petkovc1a8b422010-07-19 11:34:49 -0700458 kActionCodeSuccess,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700459 &response,
460 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700461
462 EXPECT_EQ(response.more_info_url, "testthe<url");
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700463 EXPECT_EQ(response.codebase, "testthe&codebase");
Darin Petkov6c118642010-10-21 12:06:30 -0700464 EXPECT_EQ(response.deadline, "<20110101");
Darin Petkov6a5b3222010-07-13 14:55:28 -0700465}
466
467TEST(OmahaRequestActionTest, ParseIntTest) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700468 OmahaResponse response;
469 ASSERT_TRUE(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700470 TestUpdateCheck(NULL, // prefs
471 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700472 GetUpdateResponse(OmahaRequestParams::kAppId,
473 "1.2.3.4", // version
474 "theurl", // more info
475 "true", // prompt
476 "thecodebase", // dl url
477 "HASH1234=", // checksum
478 "false", // needs admin
479 // overflows int32:
Darin Petkov6c118642010-10-21 12:06:30 -0700480 "123123123123123", // size
481 "deadline"),
Darin Petkovc1a8b422010-07-19 11:34:49 -0700482 kActionCodeSuccess,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700483 &response,
484 NULL));
Darin Petkov6a5b3222010-07-13 14:55:28 -0700485
486 EXPECT_EQ(response.size, 123123123123123ll);
487}
488
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700489TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
490 vector<char> post_data;
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700491 ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
492 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700493 "invalid xml>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700494 kActionCodeError,
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700495 NULL, // response
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700496 &post_data));
497 // convert post_data to string
498 string post_str(&post_data[0], post_data.size());
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700499 EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n"
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700500 " <o:updatecheck></o:updatecheck>\n"),
501 string::npos);
Darin Petkovfbb40092010-07-29 17:05:50 -0700502 EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""),
503 string::npos);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700504 EXPECT_EQ(post_str.find("o:event"), string::npos);
505}
506
Darin Petkove17f86b2010-07-20 09:12:01 -0700507TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) {
508 vector<char> post_data;
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700509 TestEvent(kDefaultTestParams,
Darin Petkove17f86b2010-07-20 09:12:01 -0700510 new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted),
511 "invalid xml>",
512 &post_data);
513 // convert post_data to string
514 string post_str(&post_data[0], post_data.size());
515 string expected_event = StringPrintf(
516 " <o:event eventtype=\"%d\" eventresult=\"%d\"></o:event>\n",
517 OmahaEvent::kTypeUpdateDownloadStarted,
518 OmahaEvent::kResultSuccess);
519 EXPECT_NE(post_str.find(expected_event), string::npos);
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700520 EXPECT_EQ(post_str.find("o:ping"), string::npos);
Darin Petkove17f86b2010-07-20 09:12:01 -0700521 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
522}
523
524TEST(OmahaRequestActionTest, FormatErrorEventOutputTest) {
525 vector<char> post_data;
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700526 TestEvent(kDefaultTestParams,
Darin Petkove17f86b2010-07-20 09:12:01 -0700527 new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
528 OmahaEvent::kResultError,
529 kActionCodeError),
530 "invalid xml>",
531 &post_data);
532 // convert post_data to string
533 string post_str(&post_data[0], post_data.size());
534 string expected_event = StringPrintf(
535 " <o:event eventtype=\"%d\" eventresult=\"%d\" "
536 "errorcode=\"%d\"></o:event>\n",
537 OmahaEvent::kTypeDownloadComplete,
538 OmahaEvent::kResultError,
539 kActionCodeError);
540 EXPECT_NE(post_str.find(expected_event), string::npos);
541 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
542}
543
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700544TEST(OmahaRequestActionTest, FormatEventOutputTest) {
545 vector<char> post_data;
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700546 TestEvent(kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700547 new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
548 OmahaEvent::kResultError,
Darin Petkove17f86b2010-07-20 09:12:01 -0700549 kActionCodeError),
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700550 "invalid xml>",
551 &post_data);
552 // convert post_data to string
553 string post_str(&post_data[0], post_data.size());
554 string expected_event = StringPrintf(
555 " <o:event eventtype=\"%d\" eventresult=\"%d\" "
556 "errorcode=\"%d\"></o:event>\n",
557 OmahaEvent::kTypeDownloadComplete,
558 OmahaEvent::kResultError,
Darin Petkove17f86b2010-07-20 09:12:01 -0700559 kActionCodeError);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700560 EXPECT_NE(post_str.find(expected_event), string::npos);
561 EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
562}
563
564TEST(OmahaRequestActionTest, IsEventTest) {
565 string http_response("doesn't matter");
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700566 PrefsMock prefs;
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700567 OmahaRequestAction update_check_action(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700568 &prefs,
569 kDefaultTestParams,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700570 NULL,
571 new MockHttpFetcher(http_response.data(),
572 http_response.size()));
573 EXPECT_FALSE(update_check_action.IsEvent());
574
575 OmahaRequestAction event_action(
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700576 &prefs,
577 kDefaultTestParams,
Darin Petkove17f86b2010-07-20 09:12:01 -0700578 new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700579 new MockHttpFetcher(http_response.data(),
580 http_response.size()));
581 EXPECT_TRUE(event_action.IsEvent());
582}
583
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700584TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) {
585 for (int i = 0; i < 2; i++) {
586 bool delta_okay = i == 1;
587 const char* delta_okay_str = delta_okay ? "true" : "false";
588 vector<char> post_data;
Darin Petkov84c763c2010-07-29 16:27:58 -0700589 OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700590 OmahaRequestParams::kOsVersion,
591 "service_pack",
592 "x86-generic",
593 OmahaRequestParams::kAppId,
594 "0.1.0.0",
595 "en-US",
596 "unittest_track",
Darin Petkovfbb40092010-07-29 17:05:50 -0700597 "OEM MODEL REV 1234",
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700598 delta_okay,
599 "http://url");
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700600 ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
601 params,
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700602 "invalid xml>",
Darin Petkovc1a8b422010-07-19 11:34:49 -0700603 kActionCodeError,
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700604 NULL,
605 &post_data));
606 // convert post_data to string
607 string post_str(&post_data[0], post_data.size());
608 EXPECT_NE(post_str.find(StringPrintf(" delta_okay=\"%s\"", delta_okay_str)),
609 string::npos)
610 << "i = " << i;
611 }
612}
613
Darin Petkove17f86b2010-07-20 09:12:01 -0700614TEST(OmahaRequestActionTest, OmahaEventTest) {
615 OmahaEvent default_event;
616 EXPECT_EQ(OmahaEvent::kTypeUnknown, default_event.type);
617 EXPECT_EQ(OmahaEvent::kResultError, default_event.result);
618 EXPECT_EQ(kActionCodeError, default_event.error_code);
619
620 OmahaEvent success_event(OmahaEvent::kTypeUpdateDownloadStarted);
621 EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadStarted, success_event.type);
622 EXPECT_EQ(OmahaEvent::kResultSuccess, success_event.result);
623 EXPECT_EQ(kActionCodeSuccess, success_event.error_code);
624
625 OmahaEvent error_event(OmahaEvent::kTypeUpdateDownloadFinished,
626 OmahaEvent::kResultError,
627 kActionCodeError);
628 EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadFinished, error_event.type);
629 EXPECT_EQ(OmahaEvent::kResultError, error_event.result);
630 EXPECT_EQ(kActionCodeError, error_event.error_code);
631}
632
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700633TEST(OmahaRequestActionTest, PingTest) {
634 PrefsMock prefs;
635 // Add a few hours to the day difference to test no rounding, etc.
636 int64_t five_days_ago =
637 (Time::Now() - TimeDelta::FromHours(5 * 24 + 13)).ToInternalValue();
638 int64_t six_days_ago =
639 (Time::Now() - TimeDelta::FromHours(6 * 24 + 11)).ToInternalValue();
640 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
641 .WillOnce(DoAll(SetArgumentPointee<1>(six_days_ago), Return(true)));
642 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
643 .WillOnce(DoAll(SetArgumentPointee<1>(five_days_ago), Return(true)));
644 vector<char> post_data;
645 ASSERT_TRUE(
646 TestUpdateCheck(&prefs,
647 kDefaultTestParams,
648 GetNoUpdateResponse(OmahaRequestParams::kAppId),
649 kActionCodeSuccess,
650 NULL,
651 &post_data));
652 string post_str(&post_data[0], post_data.size());
653 EXPECT_NE(post_str.find("<o:ping a=\"6\" r=\"5\"></o:ping>"), string::npos);
654}
655
656TEST(OmahaRequestActionTest, ActivePingTest) {
657 PrefsMock prefs;
658 int64_t three_days_ago =
659 (Time::Now() - TimeDelta::FromHours(3 * 24 + 12)).ToInternalValue();
660 int64_t now = Time::Now().ToInternalValue();
661 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
662 .WillOnce(DoAll(SetArgumentPointee<1>(three_days_ago), Return(true)));
663 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
664 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true)));
665 vector<char> post_data;
666 ASSERT_TRUE(
667 TestUpdateCheck(&prefs,
668 kDefaultTestParams,
669 GetNoUpdateResponse(OmahaRequestParams::kAppId),
670 kActionCodeSuccess,
671 NULL,
672 &post_data));
673 string post_str(&post_data[0], post_data.size());
674 EXPECT_NE(post_str.find("<o:ping a=\"3\"></o:ping>"), string::npos);
675}
676
677TEST(OmahaRequestActionTest, RollCallPingTest) {
678 PrefsMock prefs;
679 int64_t four_days_ago =
680 (Time::Now() - TimeDelta::FromHours(4 * 24)).ToInternalValue();
681 int64_t now = Time::Now().ToInternalValue();
682 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
683 .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true)));
684 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
685 .WillOnce(DoAll(SetArgumentPointee<1>(four_days_ago), Return(true)));
686 vector<char> post_data;
687 ASSERT_TRUE(
688 TestUpdateCheck(&prefs,
689 kDefaultTestParams,
690 GetNoUpdateResponse(OmahaRequestParams::kAppId),
691 kActionCodeSuccess,
692 NULL,
693 &post_data));
694 string post_str(&post_data[0], post_data.size());
695 EXPECT_NE(post_str.find("<o:ping r=\"4\"></o:ping>\n"), string::npos);
696}
697
698TEST(OmahaRequestActionTest, NoPingTest) {
699 PrefsMock prefs;
700 int64_t one_hour_ago =
701 (Time::Now() - TimeDelta::FromHours(1)).ToInternalValue();
702 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
703 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true)));
704 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
705 .WillOnce(DoAll(SetArgumentPointee<1>(one_hour_ago), Return(true)));
706 EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay, _)).Times(0);
707 EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0);
708 vector<char> post_data;
709 ASSERT_TRUE(
710 TestUpdateCheck(&prefs,
711 kDefaultTestParams,
712 GetNoUpdateResponse(OmahaRequestParams::kAppId),
713 kActionCodeSuccess,
714 NULL,
715 &post_data));
716 string post_str(&post_data[0], post_data.size());
717 EXPECT_EQ(post_str.find("o:ping"), string::npos);
718}
719
720TEST(OmahaRequestActionTest, BackInTimePingTest) {
721 PrefsMock prefs;
722 int64_t future =
723 (Time::Now() + TimeDelta::FromHours(3 * 24 + 4)).ToInternalValue();
724 EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
725 .WillOnce(DoAll(SetArgumentPointee<1>(future), Return(true)));
726 EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
727 .WillOnce(DoAll(SetArgumentPointee<1>(future), Return(true)));
728 EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay, _))
729 .WillOnce(Return(true));
730 EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _))
731 .WillOnce(Return(true));
732 vector<char> post_data;
733 ASSERT_TRUE(
734 TestUpdateCheck(&prefs,
735 kDefaultTestParams,
736 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
737 "xmlns=\"http://www.google.com/update2/response\" "
738 "protocol=\"2.0\"><daystart elapsed_seconds=\"100\"/>"
739 "<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
740 "<updatecheck status=\"noupdate\"/></app></gupdate>",
741 kActionCodeSuccess,
742 NULL,
743 &post_data));
744 string post_str(&post_data[0], post_data.size());
745 EXPECT_EQ(post_str.find("o:ping"), string::npos);
746}
747
748TEST(OmahaRequestActionTest, LastPingDayUpdateTest) {
749 // This test checks that the action updates the last ping day to now
Darin Petkov84c763c2010-07-29 16:27:58 -0700750 // minus 200 seconds with a slack of 5 seconds. Therefore, the test
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700751 // may fail if it runs for longer than 5 seconds. It shouldn't run
752 // that long though.
753 int64_t midnight =
754 (Time::Now() - TimeDelta::FromSeconds(200)).ToInternalValue();
755 int64_t midnight_slack =
756 (Time::Now() - TimeDelta::FromSeconds(195)).ToInternalValue();
757 PrefsMock prefs;
758 EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay,
759 AllOf(Ge(midnight), Le(midnight_slack))))
760 .WillOnce(Return(true));
761 EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay,
762 AllOf(Ge(midnight), Le(midnight_slack))))
763 .WillOnce(Return(true));
764 ASSERT_TRUE(
765 TestUpdateCheck(&prefs,
766 kDefaultTestParams,
767 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
768 "xmlns=\"http://www.google.com/update2/response\" "
769 "protocol=\"2.0\"><daystart elapsed_seconds=\"200\"/>"
770 "<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
771 "<updatecheck status=\"noupdate\"/></app></gupdate>",
772 kActionCodeSuccess,
773 NULL,
774 NULL));
775}
776
777TEST(OmahaRequestActionTest, NoElapsedSecondsTest) {
778 PrefsMock prefs;
779 EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay, _)).Times(0);
780 EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0);
781 ASSERT_TRUE(
782 TestUpdateCheck(&prefs,
783 kDefaultTestParams,
784 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
785 "xmlns=\"http://www.google.com/update2/response\" "
786 "protocol=\"2.0\"><daystart blah=\"200\"/>"
787 "<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
788 "<updatecheck status=\"noupdate\"/></app></gupdate>",
789 kActionCodeSuccess,
790 NULL,
791 NULL));
792}
793
794TEST(OmahaRequestActionTest, BadElapsedSecondsTest) {
795 PrefsMock prefs;
796 EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay, _)).Times(0);
797 EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0);
798 ASSERT_TRUE(
799 TestUpdateCheck(&prefs,
800 kDefaultTestParams,
801 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><gupdate "
802 "xmlns=\"http://www.google.com/update2/response\" "
803 "protocol=\"2.0\"><daystart elapsed_seconds=\"x\"/>"
804 "<app appid=\"foo\" status=\"ok\"><ping status=\"ok\"/>"
805 "<updatecheck status=\"noupdate\"/></app></gupdate>",
806 kActionCodeSuccess,
807 NULL,
808 NULL));
809}
810
Darin Petkov84c763c2010-07-29 16:27:58 -0700811TEST(OmahaRequestActionTest, NoUniqueIDTest) {
812 vector<char> post_data;
813 ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
814 kDefaultTestParams,
815 "invalid xml>",
816 kActionCodeError,
817 NULL, // response
818 &post_data));
819 // convert post_data to string
820 string post_str(&post_data[0], post_data.size());
821 EXPECT_EQ(post_str.find("machineid="), string::npos);
822 EXPECT_EQ(post_str.find("userid="), string::npos);
823}
824
Darin Petkov6a5b3222010-07-13 14:55:28 -0700825} // namespace chromeos_update_engine