Add extra requirements when testing update payloads.
In order to verify that real Chrome OS devices with test
images are actually sending valid Omaha Requests that will get served
an update in the field, we need to check for additional items
(hardware_class and track being set). Since there are non-Chrome OS
devices that can use the devserver, we only enforce this for devices
that interact with the devserver through a devserver proxy i.e. started
with --remote. This is only used in our automated tests.
BUG=chromium:344939
TEST=Unittests which cover this functionality.
Change-Id: I201df9ac5bf5d571b5368137e50fcc397a82befd
Reviewed-on: https://chromium-review.googlesource.com/193979
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index 7451e38..13c1f2c 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -30,8 +30,19 @@
<event eventresult="%(event_result)d" eventtype="%(event_type)d" />
</client_test>"""
+# Test request with additional fields needed for full Omaha protocol.
+_FULL_TEST_REQUEST = """
+<client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(client)s" protocol="3.0">
+ <app version="%(version)s" track="%(track)s" board="%(board)s"
+ hardware_class="Test Device" />
+ <updatecheck />
+ <event eventresult="%(event_result)d" eventtype="%(event_type)d" />
+</client_test>"""
+
#pylint: disable=W0212
class AutoupdateTest(mox.MoxTestBase):
+ """Tests for the autoupdate.Autoupdate class."""
+
def setUp(self):
mox.MoxTestBase.setUp(self)
self.mox.StubOutWithMock(common_util, 'GetFileSize')
@@ -50,7 +61,7 @@
self.test_dict = {
'client': 'ChromeOSUpdateEngine-1.0',
'version': 'ForcedUpdate',
- 'track': 'unused_var',
+ 'track': 'test-channel',
'board': self.test_board,
'event_result': 2,
'event_type': 3
@@ -313,7 +324,8 @@
payload_path=remote_payload_path,
remote_payload=True)
- test_data = _TEST_REQUEST % self.test_dict
+ incomplete_test_data = _TEST_REQUEST % self.test_dict
+ complete_test_data = _FULL_TEST_REQUEST % self.test_dict
au_mock._GetRemotePayloadAttrs(remote_url).AndReturn(
autoupdate.UpdateMetadata(self.sha1, self.sha256, self.size, False,
@@ -323,7 +335,11 @@
'3.0', False).AndReturn(self.payload)
self.mox.ReplayAll()
- self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
+ # This should fail because of missing fields.
+ self.assertRaises(common_util.DevServerHTTPError,
+ au_mock.HandleUpdatePing, incomplete_test_data)
+ # This should have enough information.
+ self.assertEqual(au_mock.HandleUpdatePing(complete_test_data), self.payload)
self.mox.VerifyAll()