| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import commands | 6 import commands |
| 7 import glob | 7 import glob |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| 11 import unittest | 11 import unittest |
| 12 | 12 |
| 13 import pyauto_functional # Must import before pyauto | 13 import pyauto_functional # Must import before pyauto |
| 14 import pyauto | 14 import pyauto |
| 15 | 15 |
| 16 class CodesignTest(pyauto.PyUITest): | 16 class CodesignTest(pyauto.PyUITest): |
| 17 """Test if the build is code signed""" | 17 """Test if the build is code signed""" |
| 18 | 18 |
| 19 def testCodeSign(self): | 19 def testCodeSign(self): |
| 20 """Check the app for codesign and bail out if it's non-branded.""" | 20 """Check the app for codesign and bail out if it's non-branded.""" |
| 21 browser_info = self.GetBrowserInfo() | 21 browser_info = self.GetBrowserInfo() |
| 22 | 22 |
| 23 # bail out if not a branded build | 23 # bail out if not a branded build |
| 24 if browser_info['properties']['branding'] != 'Google Chrome': | 24 if browser_info['properties']['branding'] != 'Google Chrome': |
| 25 return | 25 return |
| 26 | 26 |
| 27 # TODO: Add functionality for other operating systems (see crbug.com/47902) | 27 # TODO: Add functionality for other operating systems (see crbug.com/47902) |
| 28 if self.IsMac(): | 28 if self.IsMac(): |
| 29 self._macCodeSign(browser_info) | 29 self._MacCodeSign(browser_info) |
| 30 | 30 |
| 31 def _MacCodeSign(self, browser_info): | 31 def _MacCodeSign(self, browser_info): |
| 32 valid_text = 'valid on disk' | 32 valid_text = 'valid on disk' |
| 33 app_name = 'Google Chrome.app' | 33 app_name = 'Google Chrome.app' |
| 34 | 34 |
| 35 # Codesign of the app @ xcodebuild/Release/Google Chrome.app/ | 35 # Codesign of the app @ xcodebuild/Release/Google Chrome.app/ |
| 36 app_path = browser_info['child_process_path'] | 36 app_path = browser_info['child_process_path'] |
| 37 app_path = app_path[:app_path.find(app_name)] | 37 app_path = app_path[:app_path.find(app_name)] |
| 38 app_path = app_path + app_name | 38 app_path = app_path + app_name |
| 39 self.assertTrue(valid_text in self._checkCodeSign(app_path)) | 39 self.assertTrue(valid_text in self._checkCodeSign(app_path)) |
| 40 | 40 |
| 41 # Codesign of the frameWork | 41 # Codesign of the frameWork |
| 42 framework_path = glob.glob(os.path.join(app_path, 'Contents', 'Versions', | 42 framework_path = glob.glob(os.path.join(app_path, 'Contents', 'Versions', |
| 43 '*.*.*.*'))[0] | 43 '*.*.*.*'))[0] |
| 44 framework_path = os.path.join(framework_path, | 44 framework_path = os.path.join(framework_path, |
| 45 'Google Chrome Framework.framework') | 45 'Google Chrome Framework.framework') |
| 46 self.assertTrue(valid_text in self._checkCodeSign(framework_path)) | 46 self.assertTrue(valid_text in self._checkCodeSign(framework_path)) |
| 47 | 47 |
| 48 def _checkCodeSign(self, file_path): | 48 def _checkCodeSign(self, file_path): |
| 49 """Return the output of the codesign""" | 49 """Return the output of the codesign""" |
| 50 return commands.getoutput('codesign -vvv "%s"' % file_path) | 50 return commands.getoutput('codesign -vvv "%s"' % file_path) |
| 51 | 51 |
| 52 | 52 |
| 53 if __name__ == '__main__': | 53 if __name__ == '__main__': |
| 54 pyauto_functional.Main() | 54 pyauto_functional.Main() |
| OLD | NEW |