blob: 903af5188ab33df28b80c786664cc058e901b71a [file] [log] [blame]
Luis Hector Chaveza1518052018-06-14 15:19:341#!/usr/bin/env python2
2# -*- coding: utf-8 -*-
Chris Sosa0356d3b2010-09-16 22:46:223# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Unit tests for autoupdate.py."""
8
Don Garrettfb15e322016-06-22 02:12:089from __future__ import print_function
10
Dale Curtisc9aaf3a2011-08-09 22:47:4011import json
Chris Sosa0356d3b2010-09-16 22:46:2212import os
Chris Sosa6a3697f2013-01-30 00:44:4313import shutil
Chris Sosa7c931362010-10-12 02:49:0114import socket
joychen121fc9b2013-08-02 21:30:3015import tempfile
Chris Sosa0356d3b2010-09-16 22:46:2216import unittest
Chris Sosa0356d3b2010-09-16 22:46:2217
Gilad Arnoldabb352e2012-09-23 08:24:2718import cherrypy
19import mox
20
Chris Sosa0356d3b2010-09-16 22:46:2221import autoupdate
Chris Sosa52148582012-11-15 23:35:5822import autoupdate_lib
Gilad Arnold55a2a372012-10-02 16:46:3223import common_util
joychen7c2054a2013-07-25 18:14:0724import devserver_constants as constants
joychen121fc9b2013-08-02 21:30:3025import xbuddy
Chris Sosa0356d3b2010-09-16 22:46:2226
Gilad Arnoldabb352e2012-09-23 08:24:2727
Chris Sosa0356d3b2010-09-16 22:46:2228_TEST_REQUEST = """
Chris Sosa52148582012-11-15 23:35:5829<client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(client)s" protocol="3.0">
30 <app version="%(version)s" track="%(track)s" board="%(board)s" />
31 <updatecheck />
32 <event eventresult="%(event_result)d" eventtype="%(event_type)d" />
Chris Sosa0356d3b2010-09-16 22:46:2233</client_test>"""
34
Chris Sosa4b951602014-04-10 03:26:0735# Test request with additional fields needed for full Omaha protocol.
36_FULL_TEST_REQUEST = """
37<client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(client)s" protocol="3.0">
38 <app version="%(version)s" track="%(track)s" board="%(board)s"
39 hardware_class="Test Device" />
40 <updatecheck />
41 <event eventresult="%(event_result)d" eventtype="%(event_type)d" />
42</client_test>"""
43
Chris Sosa6a3697f2013-01-30 00:44:4344#pylint: disable=W0212
Chris Sosa0356d3b2010-09-16 22:46:2245class AutoupdateTest(mox.MoxTestBase):
Chris Sosa4b951602014-04-10 03:26:0746 """Tests for the autoupdate.Autoupdate class."""
47
Chris Sosa0356d3b2010-09-16 22:46:2248 def setUp(self):
49 mox.MoxTestBase.setUp(self)
Gilad Arnold55a2a372012-10-02 16:46:3250 self.mox.StubOutWithMock(common_util, 'GetFileSize')
51 self.mox.StubOutWithMock(common_util, 'GetFileSha1')
52 self.mox.StubOutWithMock(common_util, 'GetFileSha256')
Chris Sosac4e87842013-08-17 01:04:1453 self.mox.StubOutWithMock(common_util, 'IsInsideChroot')
Chris Sosa52148582012-11-15 23:35:5854 self.mox.StubOutWithMock(autoupdate_lib, 'GetUpdateResponse')
Gilad Arnold0c9c8602012-10-03 06:58:5855 self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetRemotePayloadAttrs')
Chris Sosa7c931362010-10-12 02:49:0156 self.port = 8080
Chris Sosa0356d3b2010-09-16 22:46:2257 self.test_board = 'test-board'
joychen121fc9b2013-08-02 21:30:3058 self.build_root = tempfile.mkdtemp('autoupdate_build_root')
Chris Sosa0356d3b2010-09-16 22:46:2259 self.latest_dir = '12345_af_12-a1'
60 self.latest_verision = '12345_af_12'
joychen121fc9b2013-08-02 21:30:3061 self.static_image_dir = tempfile.mkdtemp('autoupdate_static_dir')
Chris Sosa7c931362010-10-12 02:49:0162 self.hostname = '%s:%s' % (socket.gethostname(), self.port)
Dale Curtisc9aaf3a2011-08-09 22:47:4063 self.test_dict = {
64 'client': 'ChromeOSUpdateEngine-1.0',
65 'version': 'ForcedUpdate',
Chris Sosa4b951602014-04-10 03:26:0766 'track': 'test-channel',
Dale Curtisc9aaf3a2011-08-09 22:47:4067 'board': self.test_board,
68 'event_result': 2,
69 'event_type': 3
70 }
Chris Sosa0356d3b2010-09-16 22:46:2271 self.test_data = _TEST_REQUEST % self.test_dict
Gilad Arnold0c9c8602012-10-03 06:58:5872 self.sha1 = 12345
Chris Sosa0356d3b2010-09-16 22:46:2273 self.size = 54321
74 self.url = 'http://%s/static/update.gz' % self.hostname
75 self.payload = 'My payload'
Chris Sosaa387a872010-09-29 18:51:3676 self.sha256 = 'SHA LA LA'
Chris Sosa54555862010-10-26 00:26:1777 cherrypy.request.base = 'http://%s' % self.hostname
joychen121fc9b2013-08-02 21:30:3078 common_util.MkDirP(self.static_image_dir)
79 self._xbuddy = xbuddy.XBuddy(False,
joychen121fc9b2013-08-02 21:30:3080 static_dir=self.static_image_dir)
81 self.mox.StubOutWithMock(xbuddy.XBuddy, '_GetArtifact')
Chris Sosa6a3697f2013-01-30 00:44:4382
83 def tearDown(self):
joychen121fc9b2013-08-02 21:30:3084 shutil.rmtree(self.build_root)
Chris Sosa6a3697f2013-01-30 00:44:4385 shutil.rmtree(self.static_image_dir)
Chris Sosa54555862010-10-26 00:26:1786
Gilad Arnold0c9c8602012-10-03 06:58:5887 def _DummyAutoupdateConstructor(self, **kwargs):
Chris Sosa0356d3b2010-09-16 22:46:2288 """Creates a dummy autoupdater. Used to avoid using constructor."""
joychen121fc9b2013-08-02 21:30:3089 dummy = autoupdate.Autoupdate(self._xbuddy,
Chris Sosa7c931362010-10-12 02:49:0190 static_dir=self.static_image_dir,
Gilad Arnold0c9c8602012-10-03 06:58:5891 **kwargs)
Chris Sosa0356d3b2010-09-16 22:46:2292 return dummy
93
Chris Sosa744e1472011-09-08 02:32:5094 def testGetRightSignedDeltaPayloadDir(self):
95 """Test that our directory is what we expect it to be for signed updates."""
Gilad Arnold55a2a372012-10-02 16:46:3296 self.mox.StubOutWithMock(common_util, 'GetFileMd5')
Chris Sosa744e1472011-09-08 02:32:5097 key_path = 'test_key_path'
98 src_image = 'test_src_image'
99 target_image = 'test_target_image'
Gilad Arnold55a2a372012-10-02 16:46:32100 src_hash = '12345'
101 target_hash = '67890'
102 key_hash = 'abcde'
Chris Sosa744e1472011-09-08 02:32:50103
Gilad Arnold55a2a372012-10-02 16:46:32104 common_util.GetFileMd5(src_image).AndReturn(src_hash)
105 common_util.GetFileMd5(target_image).AndReturn(target_hash)
106 common_util.GetFileMd5(key_path).AndReturn(key_hash)
Chris Sosa744e1472011-09-08 02:32:50107
108 self.mox.ReplayAll()
109 au_mock = self._DummyAutoupdateConstructor()
110 au_mock.private_key = key_path
111 update_dir = au_mock.FindCachedUpdateImageSubDir(src_image, target_image)
Scott Zawalski16954532012-03-20 19:31:36112 self.assertEqual(os.path.basename(update_dir),
Gabe Black70994862014-09-05 07:50:58113 '%s_%s+%s' % (src_hash, target_hash, key_hash))
Chris Sosa744e1472011-09-08 02:32:50114 self.mox.VerifyAll()
115
joychen121fc9b2013-08-02 21:30:30116 def testGenerateLatestUpdateImage(self):
117 """Test default behavior in response to plain update call."""
118 latest_label = os.path.join(self.test_board, self.latest_dir)
119 # Generate a fake latest image
120 latest_image_dir = os.path.join(self.static_image_dir, latest_label)
121 common_util.MkDirP(latest_image_dir)
122 image = os.path.join(latest_image_dir, constants.TEST_IMAGE_FILE)
123 with open(image, 'w') as fh:
124 fh.write('')
125
Don Garrettf90edf02010-11-17 01:36:14126 self.mox.StubOutWithMock(autoupdate.Autoupdate,
127 'GenerateUpdateImageWithCache')
Chris Sosa6a3697f2013-01-30 00:44:43128 au_mock = self._DummyAutoupdateConstructor()
joychen121fc9b2013-08-02 21:30:30129
Chris Sosac4e87842013-08-17 01:04:14130 common_util.IsInsideChroot().AndReturn(True)
Bertrand SIMONNETb3ddc292015-05-01 00:26:02131 self._xbuddy._GetArtifact(
132 [''], board=self.test_board, lookup_only=True, image_dir=None,
133 version=None).AndReturn((latest_label, constants.TEST_IMAGE_FILE))
joychen121fc9b2013-08-02 21:30:30134
Chris Sosa6a3697f2013-01-30 00:44:43135 au_mock.GenerateUpdateImageWithCache(
joychen121fc9b2013-08-02 21:30:30136 os.path.join(self.static_image_dir, self.test_board, self.latest_dir,
Chris Sosa75490802013-10-01 00:21:45137 constants.TEST_IMAGE_FILE)).AndReturn('update.gz')
Chris Sosa0356d3b2010-09-16 22:46:22138
139 self.mox.ReplayAll()
joychen121fc9b2013-08-02 21:30:30140 test_data = _TEST_REQUEST % self.test_dict
141 self.assertTrue(au_mock.HandleUpdatePing(test_data))
Chris Sosa0356d3b2010-09-16 22:46:22142 self.mox.VerifyAll()
143
144 def testHandleUpdatePingForForcedImage(self):
joychen121fc9b2013-08-02 21:30:30145 """Test update response to having a forced image."""
Don Garrettf90edf02010-11-17 01:36:14146 self.mox.StubOutWithMock(autoupdate.Autoupdate,
147 'GenerateUpdateImageWithCache')
Chris Sosa6a3697f2013-01-30 00:44:43148 self.mox.StubOutWithMock(autoupdate.Autoupdate, '_StoreMetadataToFile')
149 au_mock = self._DummyAutoupdateConstructor()
Chris Sosa0356d3b2010-09-16 22:46:22150 test_data = _TEST_REQUEST % self.test_dict
151
joychen121fc9b2013-08-02 21:30:30152 # Generate a fake image
153 forced_image_dir = '/tmp/path_to_force/'
154 forced_image = forced_image_dir + constants.IMAGE_FILE
155 common_util.MkDirP(forced_image_dir)
156 with open(forced_image, 'w') as fh:
Chris Sosa6a3697f2013-01-30 00:44:43157 fh.write('')
158
joychen18737f32013-08-17 00:18:12159 cache_image_dir = os.path.join(self.static_image_dir, 'cache')
joychen121fc9b2013-08-02 21:30:30160
161 # Mock out GenerateUpdateImageWithCache to make an update file in cache
Chris Sosa75490802013-10-01 00:21:45162 def mock_fn(_image):
Don Garrettfb15e322016-06-22 02:12:08163 print('mock_fn')
joychen121fc9b2013-08-02 21:30:30164 # No good way to introduce an update file during execution.
Chris Sosa75490802013-10-01 00:21:45165 cache_dir = os.path.join(self.static_image_dir, 'cache')
joychen121fc9b2013-08-02 21:30:30166 common_util.MkDirP(cache_dir)
167 update_image = os.path.join(cache_dir, constants.UPDATE_FILE)
168 with open(update_image, 'w') as fh:
169 fh.write('')
David Zeuthen52ccd012013-10-31 19:58:26170 metadata_hash = os.path.join(cache_dir, constants.METADATA_HASH_FILE)
171 with open(metadata_hash, 'w') as fh:
172 fh.write('')
joychen121fc9b2013-08-02 21:30:30173
Chris Sosac4e87842013-08-17 01:04:14174 common_util.IsInsideChroot().AndReturn(True)
Chris Sosa75490802013-10-01 00:21:45175 au_mock.GenerateUpdateImageWithCache(forced_image).WithSideEffects(
joychen121fc9b2013-08-02 21:30:30176 mock_fn).AndReturn('cache')
177
Gilad Arnold55a2a372012-10-02 16:46:32178 common_util.GetFileSha1(os.path.join(
joychen121fc9b2013-08-02 21:30:30179 cache_image_dir, 'update.gz')).AndReturn(self.sha1)
Gilad Arnold55a2a372012-10-02 16:46:32180 common_util.GetFileSha256(os.path.join(
joychen121fc9b2013-08-02 21:30:30181 cache_image_dir, 'update.gz')).AndReturn(self.sha256)
Gilad Arnold55a2a372012-10-02 16:46:32182 common_util.GetFileSize(os.path.join(
joychen121fc9b2013-08-02 21:30:30183 cache_image_dir, 'update.gz')).AndReturn(self.size)
184 au_mock._StoreMetadataToFile(cache_image_dir,
Chris Sosa6a3697f2013-01-30 00:44:43185 mox.IsA(autoupdate.UpdateMetadata))
joychen121fc9b2013-08-02 21:30:30186 forced_url = 'http://%s/static/%s/update.gz' % (self.hostname,
joychen18737f32013-08-17 00:18:12187 'cache')
Chris Sosa52148582012-11-15 23:35:58188 autoupdate_lib.GetUpdateResponse(
David Zeuthen52ccd012013-10-31 19:58:26189 self.sha1, self.sha256, self.size, forced_url, False, 0, None, None,
Luis Hector Chaveza1518052018-06-14 15:19:34190 u'3.0', '', False).AndReturn(self.payload)
Chris Sosa0356d3b2010-09-16 22:46:22191
192 self.mox.ReplayAll()
joychen121fc9b2013-08-02 21:30:30193 au_mock.forced_image = forced_image
Chris Sosa0356d3b2010-09-16 22:46:22194 self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
195 self.mox.VerifyAll()
196
joychendbfe6c92013-08-17 03:03:49197 def testHandleForcePregenerateXBuddy(self):
198 """Check pregenerating an xbuddy path.
199
200 A forced image that starts with 'xbuddy:' uses the following path to
201 obtain an update.
202 """
203 self.mox.StubOutWithMock(autoupdate.Autoupdate,
204 'GetUpdateForLabel')
205 au_mock = self._DummyAutoupdateConstructor()
206 au_mock.forced_image = "xbuddy:b/v/a"
207
Don Garrettfb15e322016-06-22 02:12:08208 self._xbuddy._GetArtifact(
209 ['b', 'v', 'a'],
Gabe Black77f3c202014-09-05 07:43:36210 image_dir=None).AndReturn(('label', constants.TEST_IMAGE_FILE))
joychen365a5742013-08-21 17:41:18211
joychendbfe6c92013-08-17 03:03:49212 au_mock.GetUpdateForLabel(
213 autoupdate.FORCED_UPDATE, 'b/v/a').AndReturn('p')
214 self.mox.ReplayAll()
215
216 au_mock.PreGenerateUpdate()
217 self.mox.VerifyAll()
218
Don Garrett0ad09372010-12-07 00:20:30219 def testChangeUrlPort(self):
220 r = autoupdate._ChangeUrlPort('http://fuzzy:8080/static', 8085)
221 self.assertEqual(r, 'http://fuzzy:8085/static')
222
223 r = autoupdate._ChangeUrlPort('http://fuzzy/static', 8085)
224 self.assertEqual(r, 'http://fuzzy:8085/static')
225
226 r = autoupdate._ChangeUrlPort('ftp://fuzzy/static', 8085)
227 self.assertEqual(r, 'ftp://fuzzy:8085/static')
228
229 r = autoupdate._ChangeUrlPort('ftp://fuzzy', 8085)
230 self.assertEqual(r, 'ftp://fuzzy:8085')
231
Dale Curtisc9aaf3a2011-08-09 22:47:40232 def testHandleHostInfoPing(self):
233 au_mock = self._DummyAutoupdateConstructor()
234 self.assertRaises(AssertionError, au_mock.HandleHostInfoPing, None)
235
Gilad Arnold286a0062012-01-12 21:47:02236 # Setup fake host_infos entry and ensure it comes back to us in one piece.
Dale Curtisc9aaf3a2011-08-09 22:47:40237 test_ip = '1.2.3.4'
Gilad Arnold286a0062012-01-12 21:47:02238 au_mock.host_infos.GetInitHostInfo(test_ip).attrs = self.test_dict
Dale Curtisc9aaf3a2011-08-09 22:47:40239 self.assertEqual(
240 json.loads(au_mock.HandleHostInfoPing(test_ip)), self.test_dict)
241
242 def testHandleSetUpdatePing(self):
243 au_mock = self._DummyAutoupdateConstructor()
244 test_ip = '1.2.3.4'
245 test_label = 'test/old-update'
246 self.assertRaises(
247 AssertionError, au_mock.HandleSetUpdatePing, test_ip, None)
248 self.assertRaises(
249 AssertionError, au_mock.HandleSetUpdatePing, None, test_label)
250 self.assertRaises(
251 AssertionError, au_mock.HandleSetUpdatePing, None, None)
252
253 au_mock.HandleSetUpdatePing(test_ip, test_label)
254 self.assertEqual(
Chris Sosa1885d032012-11-30 01:07:27255 au_mock.host_infos.GetHostInfo(test_ip).attrs['forced_update_label'],
Gilad Arnold286a0062012-01-12 21:47:02256 test_label)
Dale Curtisc9aaf3a2011-08-09 22:47:40257
258 def testHandleUpdatePingWithSetUpdate(self):
joychen7c2054a2013-07-25 18:14:07259 """If update is set, it should use the update found in that directory."""
Chris Sosa6a3697f2013-01-30 00:44:43260 self.mox.StubOutWithMock(autoupdate.Autoupdate, '_StoreMetadataToFile')
261 au_mock = self._DummyAutoupdateConstructor()
Dale Curtisc9aaf3a2011-08-09 22:47:40262
263 test_data = _TEST_REQUEST % self.test_dict
264 test_label = 'new_update-test/the-new-update'
265 new_image_dir = os.path.join(self.static_image_dir, test_label)
266 new_url = self.url.replace('update.gz', test_label + '/update.gz')
267
Chris Sosa6a3697f2013-01-30 00:44:43268 # Generate a fake payload.
joychen121fc9b2013-08-02 21:30:30269 common_util.MkDirP(new_image_dir)
joychen7c2054a2013-07-25 18:14:07270 update_gz = os.path.join(new_image_dir, constants.UPDATE_FILE)
Chris Sosa6a3697f2013-01-30 00:44:43271 with open(update_gz, 'w') as fh:
272 fh.write('')
David Zeuthen52ccd012013-10-31 19:58:26273 metadata_hash = os.path.join(new_image_dir, constants.METADATA_HASH_FILE)
274 with open(metadata_hash, 'w') as fh:
275 fh.write('')
Chris Sosa6a3697f2013-01-30 00:44:43276
Gilad Arnold55a2a372012-10-02 16:46:32277 common_util.GetFileSha1(os.path.join(
Gilad Arnold0c9c8602012-10-03 06:58:58278 new_image_dir, 'update.gz')).AndReturn(self.sha1)
Gilad Arnold55a2a372012-10-02 16:46:32279 common_util.GetFileSha256(os.path.join(
Dale Curtisc9aaf3a2011-08-09 22:47:40280 new_image_dir, 'update.gz')).AndReturn(self.sha256)
Gilad Arnold55a2a372012-10-02 16:46:32281 common_util.GetFileSize(os.path.join(
Dale Curtisc9aaf3a2011-08-09 22:47:40282 new_image_dir, 'update.gz')).AndReturn(self.size)
Chris Sosa6a3697f2013-01-30 00:44:43283 au_mock._StoreMetadataToFile(new_image_dir,
284 mox.IsA(autoupdate.UpdateMetadata))
Chris Sosa52148582012-11-15 23:35:58285 autoupdate_lib.GetUpdateResponse(
David Zeuthen52ccd012013-10-31 19:58:26286 self.sha1, self.sha256, self.size, new_url, False, 0, None, None,
Luis Hector Chaveza1518052018-06-14 15:19:34287 u'3.0', '', False).AndReturn(self.payload)
Dale Curtisc9aaf3a2011-08-09 22:47:40288
289 self.mox.ReplayAll()
Dale Curtisc9aaf3a2011-08-09 22:47:40290 au_mock.HandleSetUpdatePing('127.0.0.1', test_label)
291 self.assertEqual(
Gilad Arnold286a0062012-01-12 21:47:02292 au_mock.host_infos.GetHostInfo('127.0.0.1').
Chris Sosa1885d032012-11-30 01:07:27293 attrs['forced_update_label'],
Gilad Arnold286a0062012-01-12 21:47:02294 test_label)
Dale Curtisc9aaf3a2011-08-09 22:47:40295 self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
Don Garrettfb15e322016-06-22 02:12:08296 self.assertFalse(
297 'forced_update_label' in
Gilad Arnold286a0062012-01-12 21:47:02298 au_mock.host_infos.GetHostInfo('127.0.0.1').attrs)
Dale Curtisc9aaf3a2011-08-09 22:47:40299
Daniel Erat8a0bc4a2011-09-30 15:52:52300 def testGetVersionFromDir(self):
301 au = self._DummyAutoupdateConstructor()
302
303 # New-style version number.
304 self.assertEqual(
305 au._GetVersionFromDir('/foo/x86-alex/R16-1102.0.2011_09_30_0806-a1'),
306 '1102.0.2011_09_30_0806')
307
Daniel Erat8a0bc4a2011-09-30 15:52:52308 def testCanUpdate(self):
309 au = self._DummyAutoupdateConstructor()
310
311 # When both the client and the server have new-style versions, we should
312 # just compare the tokens directly.
313 self.assertTrue(
314 au._CanUpdate('1098.0.2011_09_28_1635', '1098.0.2011_09_30_0806'))
315 self.assertTrue(
316 au._CanUpdate('1098.0.2011_09_28_1635', '1100.0.2011_09_26_0000'))
317 self.assertFalse(
318 au._CanUpdate('1098.0.2011_09_28_1635', '1098.0.2011_09_26_0000'))
319 self.assertFalse(
320 au._CanUpdate('1098.0.2011_09_28_1635', '1096.0.2011_09_30_0000'))
321
Gilad Arnold0c9c8602012-10-03 06:58:58322 def testHandleUpdatePingRemotePayload(self):
323 remote_urlbase = 'http://remotehost:6666'
324 remote_payload_path = 'static/path/to/update.gz'
325 remote_url = '/'.join([remote_urlbase, remote_payload_path, 'update.gz'])
Chris Sosa6a3697f2013-01-30 00:44:43326 au_mock = self._DummyAutoupdateConstructor(urlbase=remote_urlbase,
327 payload_path=remote_payload_path,
328 remote_payload=True)
Gilad Arnold0c9c8602012-10-03 06:58:58329
Chris Sosa4b951602014-04-10 03:26:07330 incomplete_test_data = _TEST_REQUEST % self.test_dict
331 complete_test_data = _FULL_TEST_REQUEST % self.test_dict
Gilad Arnold0c9c8602012-10-03 06:58:58332
Chris Sosa6a3697f2013-01-30 00:44:43333 au_mock._GetRemotePayloadAttrs(remote_url).AndReturn(
David Zeuthen52ccd012013-10-31 19:58:26334 autoupdate.UpdateMetadata(self.sha1, self.sha256, self.size, False,
335 0, ''))
Chris Sosa52148582012-11-15 23:35:58336 autoupdate_lib.GetUpdateResponse(
David Zeuthen52ccd012013-10-31 19:58:26337 self.sha1, self.sha256, self.size, remote_url, False, 0, None, None,
Luis Hector Chaveza1518052018-06-14 15:19:34338 u'3.0', '', False).AndReturn(self.payload)
Gilad Arnold0c9c8602012-10-03 06:58:58339
340 self.mox.ReplayAll()
Chris Sosa4b951602014-04-10 03:26:07341 # This should fail because of missing fields.
342 self.assertRaises(common_util.DevServerHTTPError,
343 au_mock.HandleUpdatePing, incomplete_test_data)
344 # This should have enough information.
345 self.assertEqual(au_mock.HandleUpdatePing(complete_test_data), self.payload)
Gilad Arnold0c9c8602012-10-03 06:58:58346 self.mox.VerifyAll()
347
Chris Sosa0356d3b2010-09-16 22:46:22348
Gilad Arnoldc65330c2012-09-20 22:17:48349if __name__ == '__main__':
350 unittest.main()