def sign_multi(file_path, endpoint, guid): """Sign the internal extensions from a multi-package XPI (if any).""" log.info('Signing multi-package file {0}'.format(file_path)) # Extract the multi-package to a temp folder. folder = tempfile.mkdtemp() try: extract_xpi(file_path, folder) xpis = glob.glob(os.path.join(folder, u'*.xpi')) cert_serial_nums = [] # The certificate serial numbers for the XPIs. for xpi in xpis: xpi_info = parse_xpi(xpi, check=False) if xpi_info['type'] == amo.ADDON_EXTENSION: # Sign the internal extensions in place. cert_serial_nums.append(call_signing(xpi, endpoint, guid)) # Repackage (re-zip) the multi-package. # We only want the (unique) temporary file name. with tempfile.NamedTemporaryFile() as temp_file: temp_filename = temp_file.name shutil.make_archive(temp_filename, format='zip', root_dir=folder) # Now overwrite the current multi-package xpi with the repackaged one. # Note that shutil.make_archive automatically added a '.zip' to the end # of the base_name provided as first argument. shutil.move(u'{0}.zip'.format(temp_filename), file_path) return u'\n'.join([unicode(num) for num in cert_serial_nums]) finally: amo.utils.rm_local_tmp_dir(folder)
def test_bump_version_in_package_json(file_obj): with amo.tests.copy_file( 'apps/files/fixtures/files/new-format-0.0.1.xpi', file_obj.file_path): utils.update_version_number(file_obj, '0.0.1.1-signed') parsed = utils.parse_xpi(file_obj.file_path) assert parsed['version'] == '0.0.1.1-signed'
def test_bump_version_in_package_json(self): with amo.tests.copy_file( 'apps/files/fixtures/files/new-format-0.0.1.xpi', self.file_.file_path): tasks.bump_version_number(self.file_) parsed = parse_xpi(self.file_.file_path) assert parsed['version'] == '0.0.1.1-signed'
def sign_multi(file_path, endpoint, guid): """Sign the internal extensions from a multi-package XPI (if any).""" log.info("Signing multi-package file {0}".format(file_path)) # Extract the multi-package to a temp folder. folder = tempfile.mkdtemp() try: extract_xpi(file_path, folder) xpis = glob.glob(os.path.join(folder, u"*.xpi")) cert_serial_nums = [] # The certificate serial numbers for the XPIs. for xpi in xpis: xpi_info = parse_xpi(xpi, check=False) if xpi_info["type"] == amo.ADDON_EXTENSION: # Sign the internal extensions in place. cert_serial_nums.append(call_signing(xpi, endpoint, guid)) # Repackage (re-zip) the multi-package. # We only want the (unique) temporary file name. with tempfile.NamedTemporaryFile() as temp_file: temp_filename = temp_file.name shutil.make_archive(temp_filename, format="zip", root_dir=folder) # Now overwrite the current multi-package xpi with the repackaged one. # Note that shutil.make_archive automatically added a '.zip' to the end # of the base_name provided as first argument. shutil.move(u"{0}.zip".format(temp_filename), file_path) return u"\n".join([unicode(num) for num in cert_serial_nums]) finally: amo.utils.rm_local_tmp_dir(folder)
def test_parse_xpi(): """Fire.fm can sometimes give us errors. Let's prevent that.""" firefm = os.path.join(settings.ROOT, 'apps/files/fixtures/files/firefm.xpi') rdf = parse_xpi(open(firefm)) eq_(rdf['name'], 'Fire.fm')
def test_bump_version_in_alt_install_rdf(file_obj): with amo.tests.copy_file('apps/files/fixtures/files/alt-rdf.xpi', file_obj.file_path): utils.update_version_number(file_obj, '2.1.106.1-signed') parsed = utils.parse_xpi(file_obj.file_path) assert parsed['version'] == '2.1.106.1-signed'
def test_bump_version_in_alt_install_rdf(self): with amo.tests.copy_file('apps/files/fixtures/files/alt-rdf.xpi', self.file_.file_path): tasks.bump_version_number(self.file_) parsed = parse_xpi(self.file_.file_path) assert parsed['version'] == '2.1.106.1-signed'
def test_bump_version_in_package_json(file_obj): with amo.tests.copy_file('apps/files/fixtures/files/new-format-0.0.1.xpi', file_obj.file_path): utils.update_version_number(file_obj, '0.0.1.1-signed') parsed = utils.parse_xpi(file_obj.file_path) assert parsed['version'] == '0.0.1.1-signed'
def test_bump_version_in_install_rdf(self): with amo.tests.copy_file('apps/files/fixtures/files/jetpack.xpi', self.file1.file_path): tasks.bump_version_number(self.file1) parsed = parse_xpi(self.file1.file_path) assert parsed['version'] == '1.3.1'
def test_parse_xpi(): """Fire.fm can sometimes give us errors. Let's prevent that.""" firefm = os.path.join(settings.ROOT, "apps/files/fixtures/files/firefm.xpi") rdf = parse_xpi(firefm) eq_(rdf["name"], "Fire.fm")
def test_bump_version_in_install_rdf(self): with amo.tests.copy_file("apps/files/fixtures/files/jetpack.xpi", self.file_.file_path): tasks.bump_version_number(self.file_) parsed = parse_xpi(self.file_.file_path) assert parsed["version"] == "1.3.1-signed"