예제 #1
0
 def test_inject_ids(self, post):
     post().status_code = 200
     post().content = '{"zigbert.rsa": ""}'
     packaged.sign(self.version.pk)
     zf = zipfile.ZipFile(self.file.signed_file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #2
0
파일: tests.py 프로젝트: chilyashev/zamboni
 def test_inject_ids(self, post):
     post().status_code = 200
     post().content = '{"zigbert.rsa": ""}'
     packaged.sign(self.version.pk)
     zf = zipfile.ZipFile(self.file.signed_file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #3
0
 def test_sign_reviewer(self, sign_app):
     packaged.sign(self.version.pk, reviewer=True)
     assert sign_app.called
     ids = json.loads(sign_app.call_args[0][2])
     eq_(ids['id'], 'reviewer-{guid}-{version_id}'.format(
         guid=self.app.guid, version_id=self.version.pk))
     eq_(ids['version'], self.version.pk)
예제 #4
0
 def test_no_server_full(self):
     with self.settings(SIGNING_SERVER=''):
         packaged.sign(self.version)
     # Make sure the files weren't signed.
     assert not self.file1.is_signed
     assert not self.file2.is_signed
     assert not self.file1.cert_serial_num
     assert not self.file2.cert_serial_num
예제 #5
0
 def test_no_server_full(self):
     with self.settings(SIGNING_SERVER=''):
         packaged.sign(self.version)
     # Make sure the files weren't signed.
     assert not is_signed(self.file1.file_path)
     assert not is_signed(self.file2.file_path)
     assert not self.file1.cert_serial_num
     assert not self.file2.cert_serial_num
예제 #6
0
 def test_inject_ids_replace(self, sign):
     zf = zipfile.ZipFile(self.file.file_path, mode='a')
     zf.writestr('META-INF/ids.json', '{}')
     zf.close()
     storage.open(self.file.signed_file_path, 'w')
     packaged.sign(self.version.pk, resign=True)
     zf = zipfile.ZipFile(self.file.file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #7
0
 def test_no_server_prelim(self):
     self.file1.update(status=amo.STATUS_LITE)
     self.file2.update(status=amo.STATUS_LITE)
     with self.settings(PRELIMINARY_SIGNING_SERVER=''):
         packaged.sign(self.version)
     # Make sure the files weren't signed.
     assert not self.file1.is_signed
     assert not self.file2.is_signed
     assert not self.file1.cert_serial_num
     assert not self.file2.cert_serial_num
예제 #8
0
 def test_no_server_prelim(self):
     self.file1.update(status=amo.STATUS_LITE)
     self.file2.update(status=amo.STATUS_LITE)
     with self.settings(PRELIMINARY_SIGNING_SERVER=''):
         packaged.sign(self.version)
     # Make sure the files weren't signed.
     assert not is_signed(self.file1.file_path)
     assert not is_signed(self.file2.file_path)
     assert not self.file1.cert_serial_num
     assert not self.file2.cert_serial_num
예제 #9
0
파일: tests.py 프로젝트: viczsaurav/olympia
 def test_inject_ids(self, post):
     """
     Checks correct signing of a package using fake data
     as returned by Trunion
     """
     post().status_code = 200
     post().content = '{"zigbert.rsa": ""}'
     packaged.sign(self.version.pk)
     zf = zipfile.ZipFile(self.file1.signed_file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #10
0
 def test_inject_ids(self, post):
     """
     Checks correct signing of a package using fake data
     as returned by Trunion
     """
     post().status_code = 200
     post().content = '{"zigbert.rsa": ""}'
     packaged.sign(self.version.pk)
     zf = zipfile.ZipFile(self.file1.signed_file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #11
0
 def test_sign_file(self):
     assert not self.file1.is_signed
     assert not self.file2.is_signed
     assert not self.file1.cert_serial_num
     assert not self.file2.cert_serial_num
     assert not self.file1.hash
     assert not self.file2.hash
     packaged.sign(self.version)
     assert self.file1.is_signed
     assert self.file2.is_signed
     assert self.file1.cert_serial_num
     assert self.file2.cert_serial_num
     assert self.file1.hash
     assert self.file2.hash
예제 #12
0
    def test_sign_consumer(self, sign_addon):
        file_list = packaged.sign(self.version.pk)
        assert sign_addon.called
        ids = json.loads(sign_addon.call_args[0][2])
        eq_(ids['id'], self.addon.guid)
        eq_(ids['version'], self.version.pk)

        file_list = dict(file_list)
        eq_(file_list[self.file1.pk], self.file1.signed_file_path)
        eq_(file_list[self.file2.pk], self.file2.signed_file_path)
예제 #13
0
    def handle(self, *args, **options):
        if len(args) == 0:  # Sign all the addons?
            raise CommandError(
                'Please provide at least one addon id to sign. If you want to '
                'sign them all, use the "process_addons --task sign_addons" '
                'management command.')

        addon_ids = [int(addon_id) for addon_id in args]
        to_sign = Version.objects.filter(addon_id__in=addon_ids)

        num_versions = to_sign.count()
        self.stdout.write('Starting the signing of %s versions' % num_versions)
        for version in to_sign:
            try:
                self.stdout.write('Signing version %s' % version.pk)
                sign(version)
            except SigningError as e:
                self.stderr.write('Error while signing version %s: %s' %
                                  (version.pk, e))
예제 #14
0
파일: tests.py 프로젝트: viczsaurav/olympia
    def test_sign_consumer(self, sign_addon):
        file_list = packaged.sign(self.version.pk)
        assert sign_addon.called
        ids = json.loads(sign_addon.call_args[0][2])
        eq_(ids['id'], self.addon.guid)
        eq_(ids['version'], self.version.pk)

        file_list = dict(file_list)
        eq_(file_list[self.file1.pk], self.file1.signed_file_path)
        eq_(file_list[self.file2.pk], self.file2.signed_file_path)
예제 #15
0
    def test_sign_reviewer(self, sign_addon):
        file_list = packaged.sign(self.version.pk, reviewer=True)
        assert sign_addon.called
        ids = json.loads(sign_addon.call_args[0][2])
        eq_(ids['id'], 'reviewer-{guid}-{version_id}'.format(
            guid=self.addon.guid, version_id=self.version.pk))
        eq_(ids['version'], self.version.pk)

        file_list = dict(file_list)
        eq_(file_list[self.file1.pk], self.file1.signed_reviewer_file_path)
        eq_(file_list[self.file2.pk], self.file2.signed_reviewer_file_path)
예제 #16
0
파일: tests.py 프로젝트: viczsaurav/olympia
    def test_sign_reviewer(self, sign_addon):
        file_list = packaged.sign(self.version.pk, reviewer=True)
        assert sign_addon.called
        ids = json.loads(sign_addon.call_args[0][2])
        eq_(
            ids['id'],
            'reviewer-{guid}-{version_id}'.format(guid=self.addon.guid,
                                                  version_id=self.version.pk))
        eq_(ids['version'], self.version.pk)

        file_list = dict(file_list)
        eq_(file_list[self.file1.pk], self.file1.signed_reviewer_file_path)
        eq_(file_list[self.file2.pk], self.file2.signed_reviewer_file_path)
예제 #17
0
파일: tests.py 프로젝트: jlongster/zamboni
    def test_inject_ids_replace(self, post):
        post().status_code = 200
        post().content = '{"zigbert.rsa": ""}'

        origz = zipfile.ZipFile(self.file.file_path, mode='r')
        original_contents = sorted([
            (zi.filename, origz.read(zi.filename))
            for zi in origz.infolist()])

        zf = zipfile.ZipFile(self.file.file_path, mode='a')
        zf.writestr('META-INF/ids.json', '{}')
        zf.close()

        packaged.sign(self.version.pk, resign=True)

        zf = zipfile.ZipFile(self.file.signed_file_path, mode='r')
        ids_data = zf.read('META-INF/ids.json')
        eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
        eq_([zi.filename for zi in zf.infolist()].count('META-INF/ids.json'),
            1)
        eq_(sorted([(zi.filename, zf.read(zi.filename))
                    for zi in zf.infolist()
                    if not zi.filename.startswith('META-INF')]),
            original_contents)
예제 #18
0
 def test_already_exists(self):
     storage.open(self.file.signed_file_path, 'w')
     assert packaged.sign(self.version.pk)
예제 #19
0
 def test_reviewer_server_inactive(self, _no_sign):
     with self.settings(SIGNED_APPS_REVIEWER_SERVER_ACTIVE=False):
         packaged.sign(self.version.pk, reviewer=True)
     assert _no_sign.called
예제 #20
0
 def test_not_packaged(self):
     self.app.update(is_packaged=False)
     packaged.sign(self.version.pk)
예제 #21
0
 def test_good(self):
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk))
예제 #22
0
 def test_reviewer_server_active(self):
     with self.settings(SIGNED_APPS_REVIEWER_SERVER_ACTIVE=True):
         packaged.sign(self.version.pk, reviewer=True)
예제 #23
0
 def test_no_file(self):
     [f.delete() for f in self.app.current_version.all_files]
     packaged.sign(self.version.pk)
예제 #24
0
 def test_resign_already_exists(self, sign_app):
     private_storage.open(self.file.signed_file_path, 'w')
     packaged.sign(self.version.pk, resign=True)
     assert sign_app.called
예제 #25
0
파일: tests.py 프로젝트: sarasan/zamboni
 def test_already_exists(self):
     storage.open(self.file.signed_file_path, 'w')
     assert packaged.sign(self.version.pk)
예제 #26
0
 def test_reviewer(self):
     # For the moment there is no real difference between reviewers
     # and users.
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk, True))
예제 #27
0
 def test_resign_already_exists(self, sign_addon):
     storage.open(self.file1.signed_file_path, 'w')
     storage.open(self.file2.signed_file_path, 'w')
     packaged.sign(self.version.pk, resign=True)
     assert sign_addon.called
예제 #28
0
파일: tests.py 프로젝트: sarasan/zamboni
 def test_good(self):
     self.setup_files()
     path = packaged.sign(self.version.pk)
     # TODO: This will change when we actually sign things.
     assert os.stat(path).st_size == (
             os.stat(self.file.file_path).st_size)
예제 #29
0
 def test_already_exists(self, sign_addon):
     with (storage.open(self.file1.signed_file_path, 'w') and
             storage.open(self.file2.signed_file_path, 'w')):
         assert packaged.sign(self.version.pk)
         assert not sign_addon.called
예제 #30
0
파일: tests.py 프로젝트: sarasan/zamboni
 def test_reviewer(self):
     self.setup_files()
     path = packaged.sign(self.version.pk, True)
     assert os.stat(path).st_size == (
             os.stat(self.file.file_path).st_size)
예제 #31
0
파일: models.py 프로젝트: flyun/zamboni
 def sign_if_packaged(self, version_pk, reviewer=False):
     if not self.is_packaged:
         return
     return packaged.sign(version_pk, reviewer=reviewer)
예제 #32
0
 def test_no_key(self):
     raise SkipTest('Keys ignored')
     key = self.sample_packaged_key() + '.nope'
     with self.settings(SIGNED_APPS_KEY=key):
         packaged.sign(self.version.pk)
예제 #33
0
 def sign_files(self):
     """Sign the files for this version."""
     return packaged.sign(self)
예제 #34
0
파일: tests.py 프로젝트: viczsaurav/olympia
 def test_already_exists(self, sign_addon):
     with (storage.open(self.file1.signed_file_path, 'w')
           and storage.open(self.file2.signed_file_path, 'w')):
         assert packaged.sign(self.version.pk)
         assert not sign_addon.called
예제 #35
0
 def test_not_app(self):
     self.app.update(type=amo.ADDON_EXTENSION)
     packaged.sign(self.version.pk)
예제 #36
0
 def test_already_exists(self, sign_app):
     with private_storage.open(self.file.signed_file_path, 'w') as f:
         f.write('.')
     assert packaged.sign(self.version.pk)
     assert not sign_app.called
예제 #37
0
 def test_already_exists(self, sign_app):
     storage.open(self.file.signed_file_path, 'w')
     assert packaged.sign(self.version.pk)
     assert not sign_app.called
예제 #38
0
 def test_sign_consumer(self, sign_app):
     packaged.sign(self.version.pk)
     assert sign_app.called
     ids = json.loads(sign_app.call_args[0][2])
     eq_(ids['id'], self.app.guid)
     eq_(ids['version'], self.version.pk)
예제 #39
0
 def sign_if_packaged(self, version_pk):
     if not self.is_packaged:
         return
     packaged.sign(version_pk)
예제 #40
0
 def test_server_active(self):
     with self.settings(SIGNED_APPS_SERVER_ACTIVE=True):
         packaged.sign(self.version.pk)
예제 #41
0
 def test_raises(self, xpisign):
     xpisign.side_effect = ValueError
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk))
예제 #42
0
 def test_server_inactive(self, _no_sign):
     with self.settings(SIGNED_APPS_SERVER_ACTIVE=False):
         packaged.sign(self.version.pk)
     assert _no_sign.called
예제 #43
0
 def test_already_exists(self, sign_app):
     storage.open(self.file.signed_file_path, 'w')
     assert packaged.sign(self.version.pk)
     assert not sign_app.called
예제 #44
0
 def test_not_app(self):
     self.app.update(type=amo.ADDON_EXTENSION)
     packaged.sign(self.version.pk)
예제 #45
0
 def test_inject_ids(self, sign):
     packaged.sign(self.version.pk)
     zf = zipfile.ZipFile(self.file.file_path, mode='r')
     ids_data = zf.read('META-INF/ids.json')
     eq_(sorted(json.loads(ids_data).keys()), ['id', 'version'])
예제 #46
0
 def test_no_file(self):
     [f.delete() for f in self.app.current_version.all_files]
     packaged.sign(self.version.pk)
예제 #47
0
 def test_reviewer(self):
     # For the moment there is no real difference between reviewers
     # and users.
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk, True))
예제 #48
0
 def test_server_active(self):
     with self.settings(SIGNED_APPS_SERVER_ACTIVE=True):
         packaged.sign(self.version.pk)
예제 #49
0
 def test_not_packaged(self):
     self.app.update(is_packaged=False)
     packaged.sign(self.version.pk)
예제 #50
0
 def test_good(self):
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk))
예제 #51
0
파일: tests.py 프로젝트: viczsaurav/olympia
 def test_resign_already_exists(self, sign_addon):
     storage.open(self.file1.signed_file_path, 'w')
     storage.open(self.file2.signed_file_path, 'w')
     packaged.sign(self.version.pk, resign=True)
     assert sign_addon.called
예제 #52
0
 def test_raises(self, xpisign):
     xpisign.side_effect = ValueError
     with self.settings(SIGNED_APPS_KEY=self.sample_packaged_key()):
         self.is_signed(packaged.sign(self.version.pk))
예제 #53
0
 def sign_if_packaged(self, version_pk, reviewer=False):
     if not self.is_packaged:
         return
     return packaged.sign(version_pk, reviewer=reviewer)