def extension_id(self):
     """Unique extension id of this extension."""
     if crx_id.HasPublicKey(self._path):
         # Calculate extension id from the public key.
         return crx_id.GetCRXAppID(os.path.realpath(self._path))
     else:
         # Calculate extension id based on the path on the presentation.device.
         return crx_id.GetCRXAppID(os.path.realpath(self._local_path),
                                   from_file_path=True,
                                   is_win_path=self._is_win)
Ejemplo n.º 2
0
    def testFromWindowsPath(self):
        self.assertEqual(
            crx_id.GetCRXAppID(r'D:\Documents\chrome\test_extension',
                               from_file_path=True,
                               is_win_path=True),
            'fegemedmbnhglnecjgbdhekaghkccplm')

        # Test drive letter normalization.
        k_win_path_id = 'aiinlcdagjihibappcdnnhcccdokjlaf'
        self.assertEqual(
            crx_id.GetCRXAppID(r'c:\temp_extension',
                               from_file_path=True,
                               is_win_path=True), k_win_path_id)
        self.assertEqual(
            crx_id.GetCRXAppID(r'C:\temp_extension',
                               from_file_path=True,
                               is_win_path=True), k_win_path_id)
Ejemplo n.º 3
0
 def testUnpackedHashAppId(self):
     """ Test the output generated for a canned, unpacked extension. """
     unpacked_test_manifest_path = os.path.join(self.CRX_ID_DIR,
                                                'manifest_with_key.json')
     temp_unpacked_crx = tempfile.mkdtemp()
     shutil.copy2(unpacked_test_manifest_path,
                  os.path.join(temp_unpacked_crx, 'manifest.json'))
     self.assertEqual(crx_id.GetCRXAppID(temp_unpacked_crx),
                      self.UNPACKED_APP_ID)
     self.assertEqual(crx_id.GetCRXHash(temp_unpacked_crx),
                      self.UNPACKED_HASH_BYTES)
     self.assertTrue(crx_id.HasPublicKey(temp_unpacked_crx))
     shutil.rmtree(temp_unpacked_crx)
Ejemplo n.º 4
0
 def testFromFilePath(self):
     """ Test calculation of extension id from file paths. """
     self.assertEqual(
         crx_id.GetCRXAppID('/tmp/temp_extension', from_file_path=True),
         'ajbbicncdkdlchpjplgjaglppbcbmaji')
Ejemplo n.º 5
0
 def testPackedHashAppId(self):
     """ Test the output generated for a canned, packed CRX. """
     self.assertEqual(crx_id.GetCRXAppID(self.PACKED_CRX),
                      self.PACKED_APP_ID)
     self.assertEqual(crx_id.GetCRXHash(self.PACKED_CRX),
                      self.PACKED_HASH_BYTES)