Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/services/test/client_config_svc_test.py b/services/test/client_config_svc_test.py
index d8a305e..fbcd2f9 100644
--- a/services/test/client_config_svc_test.py
+++ b/services/test/client_config_svc_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2016 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 """Tests for the client config service."""
 from __future__ import print_function
@@ -9,6 +8,8 @@
 from __future__ import absolute_import
 
 import base64
+import binascii
+import six
 import unittest
 
 from services import client_config_svc
@@ -20,33 +21,39 @@
     def __init__(self, content):
       self.content = content
 
+  def testProcessResponse_InvalidContent(self):
+    r = self.FakeResponse('')
+    with self.assertRaises(AttributeError):
+      client_config_svc._process_response(r)
+
   def testProcessResponse_InvalidJSON(self):
-    r = self.FakeResponse('}{')
+    r = self.FakeResponse(b')]}\'}{')
     with self.assertRaises(ValueError):
       client_config_svc._process_response(r)
 
   def testProcessResponse_NoContent(self):
-    r = self.FakeResponse('{"wrong-key": "some-value"}')
+    r = self.FakeResponse(b')]}\'{"wrong-key": "some-value"}')
     with self.assertRaises(KeyError):
       client_config_svc._process_response(r)
 
   def testProcessResponse_NotB64(self):
     # 'asd' is not a valid base64-encoded string.
-    r = self.FakeResponse('{"content": "asd"}')
-    with self.assertRaises(TypeError):
+    r = self.FakeResponse(b')]}\'{"rawContent": "asd"}')
+    with self.assertRaises(binascii.Error):
       client_config_svc._process_response(r)
 
   def testProcessResponse_NotProto(self):
     # 'asdf' is a valid base64-encoded string.
-    r = self.FakeResponse('{"content": "asdf"}')
-    with self.assertRaises(Exception):
+    r = self.FakeResponse(b')]}\'{"rawContent": "asdf"}')
+    with self.assertRaises(UnicodeDecodeError):
       client_config_svc._process_response(r)
 
   def testProcessResponse_Success(self):
-    with open(client_config_svc.CONFIG_FILE_PATH) as f:
-      r = self.FakeResponse('{"content": "%s"}' % base64.b64encode(f.read()))
+    with open(client_config_svc.CONFIG_FILE_PATH, 'rb') as f:
+      r = self.FakeResponse(
+          b')]}\'{"rawContent": "%s"}' % base64.b64encode(f.read()))
     c = client_config_svc._process_response(r)
-    assert '123456789.apps.googleusercontent.com' in c
+    assert b'123456789.apps.googleusercontent.com' in c
 
 
 class ClientConfigServiceTest(unittest.TestCase):