コード例 #1
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_conflict(self):
        user = UserFactory(
            roles=[Role.find("developer"),
                   Role.find("package_admin")])
        db.session.commit()

        architectures = [
            Architecture.find("88f628x"),
            Architecture.find("cedarview")
        ]
        build = BuildFactory.build(architectures=architectures)
        with create_spk(build) as spk:
            self.assert201(
                self.client.post(
                    url_for("api.packages"),
                    headers=authorization_header(user),
                    data=spk.read(),
                ))
            spk.seek(0)
            response = self.client.post(
                url_for("api.packages"),
                headers=authorization_header(user),
                data=spk.read(),
            )
        self.assert409(response)
        self.assertIn(
            "Conflicting architectures: 88f628x, cedarview",
            response.data.decode(response.charset),
        )
コード例 #2
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_minimum(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build) as spk:
            self.assert201(self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                            data=spk.read()))
        self.assertBuildInserted(Build.query.one(), build, user)
コード例 #3
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_signed(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build, signature='signature') as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Package contains a signature', response.data.decode(response.charset))
コード例 #4
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_invalid_spk(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build) as spk:
            spk.seek(100)
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Invalid SPK', response.data.decode(response.charset))
コード例 #5
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_wrong_version(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info['version'] = '1.2.3~4'
        with create_spk(build, info=info) as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Invalid version', response.data.decode(response.charset))
コード例 #6
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_wrong_description_language(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info['description_zzz'] = 'description_zzz'
        with create_spk(build, info=info) as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown INFO description language', response.data.decode(response.charset))
コード例 #7
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_not_startable(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build(version__startable=False)
        with create_spk(build) as spk:
            self.assert201(
                self.client.post(url_for('api.packages'),
                                 headers=authorization_header(user),
                                 data=spk.read()))
        self.assertBuildInserted(Build.query.one(), build, user)
コード例 #8
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_conflict(self):
        user = UserFactory(roles=[Role.find('developer'), Role.find('package_admin')])
        db.session.commit()

        architectures = [Architecture.find('88f628x'), Architecture.find('cedarview')]
        build = BuildFactory.build(architectures=architectures)
        with create_spk(build) as spk:
            self.assert201(self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                            data=spk.read()))
            spk.seek(0)
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert409(response)
        self.assertIn('Conflicting architectures: 88f628x, cedarview', response.data.decode(response.charset))
コード例 #9
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_invalid_spk(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build) as spk:
            spk.seek(100)
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Invalid SPK', response.data.decode(response.charset))
コード例 #10
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_signed(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build, signature='signature') as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Package contains a signature',
                      response.data.decode(response.charset))
コード例 #11
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_icons_in_both(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        with create_spk(build, with_package_icons=True,
                        with_info_icons=True) as spk:
            self.assert201(
                self.client.post(url_for('api.packages'),
                                 headers=authorization_header(user),
                                 data=spk.read()))
        self.assertBuildInserted(Build.query.one(), build, user)
コード例 #12
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_upgrade_wizard(self):
        user = UserFactory(
            roles=[Role.find("developer"),
                   Role.find("package_admin")])
        db.session.commit()

        build = BuildFactory.build(version__upgrade_wizard=True)
        with create_spk(build) as spk:
            self.assert201(
                self.client.post(
                    url_for("api.packages"),
                    headers=authorization_header(user),
                    data=spk.read(),
                ))
        self.assertBuildInserted(Build.query.one(), build, user)
コード例 #13
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_no_data(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        response = self.client.post(url_for('api.packages'), headers=authorization_header(user))
        self.assert400(response)
        self.assertIn('No data to process', response.data.decode(response.charset))
コード例 #14
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_wrong_version(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info['version'] = '1.2.3~4'
        with create_spk(build, info=info) as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Invalid version',
                      response.data.decode(response.charset))
コード例 #15
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_wrong_description_language(self):
        user = UserFactory(
            roles=[Role.find('developer'),
                   Role.find('package_admin')])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info['description_zzz'] = 'description_zzz'
        with create_spk(build, info=info) as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown INFO description language',
                      response.data.decode(response.charset))
コード例 #16
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_new_package_not_author_not_maintainer_user(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        with create_spk(BuildFactory.build()) as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert403(response)
        self.assertIn('Insufficient permissions to create new packages', response.data.decode(response.charset))
コード例 #17
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_wrong_version(self):
        user = UserFactory(
            roles=[Role.find("developer"),
                   Role.find("package_admin")])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info["version"] = "1.2.3~4"
        with create_spk(build, info=info) as spk:
            response = self.client.post(
                url_for("api.packages"),
                headers=authorization_header(user),
                data=spk.read(),
            )
        self.assert422(response)
        self.assertIn("Invalid version",
                      response.data.decode(response.charset))
コード例 #18
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_wrong_displayname_language(self):
        user = UserFactory(
            roles=[Role.find("developer"),
                   Role.find("package_admin")])
        db.session.commit()

        build = BuildFactory.build()
        info = create_info(build)
        info["displayname_zzz"] = "displayname_zzz"
        with create_spk(build, info=info) as spk:
            response = self.client.post(
                url_for("api.packages"),
                headers=authorization_header(user),
                data=spk.read(),
            )
        self.assert422(response)
        self.assertIn("Unknown INFO displayname language",
                      response.data.decode(response.charset))
コード例 #19
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_no_data(self):
        user = UserFactory(roles=[Role.find("developer")])
        db.session.commit()

        response = self.client.post(url_for("api.packages"),
                                    headers=authorization_header(user))
        self.assert400(response)
        self.assertIn("No data to process",
                      response.data.decode(response.charset))
コード例 #20
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_existing_package_maintainer_user(self):
        user = UserFactory(roles=[Role.find('developer')])
        package = PackageFactory(maintainers=[user])
        db.session.commit()

        build = BuildFactory.build(version__package=package)
        db.session.expire(package)
        with create_spk(build) as spk:
            self.assert201(self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                            data=spk.read()))
コード例 #21
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_unknown_architecture(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        build = BuildFactory.build(architectures=[Architecture(code='newarch')])
        with create_spk(build) as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown architecture: newarch', response.data.decode(response.charset))
コード例 #22
0
ファイル: test_api.py プロジェクト: Cbrdiv/spkrepo
    def test_post_unknown_firmware(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        build = BuildFactory.build(firmware=Firmware(version='1.0', build=421))
        with create_spk(build) as spk:
            response = self.client.post(url_for('api.packages'), headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown firmware', response.data.decode(response.charset))
コード例 #23
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_new_package_not_author_not_maintainer_user(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        with create_spk(BuildFactory.build()) as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert403(response)
        self.assertIn('Insufficient permissions to create new packages',
                      response.data.decode(response.charset))
コード例 #24
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_unknown_firmware(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        build = BuildFactory.build(firmware=Firmware(version='1.0', build=421))
        with create_spk(build) as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown firmware',
                      response.data.decode(response.charset))
コード例 #25
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_existing_package_maintainer_user(self):
        user = UserFactory(roles=[Role.find('developer')])
        package = PackageFactory(maintainers=[user])
        db.session.commit()

        build = BuildFactory.build(version__package=package)
        db.session.expire(package)
        with create_spk(build) as spk:
            self.assert201(
                self.client.post(url_for('api.packages'),
                                 headers=authorization_header(user),
                                 data=spk.read()))
コード例 #26
0
ファイル: test_api.py プロジェクト: xbl3/spkrepo
    def test_post_unknown_architecture(self):
        user = UserFactory(roles=[Role.find('developer')])
        db.session.commit()

        build = BuildFactory.build(
            architectures=[Architecture(code='newarch')])
        with create_spk(build) as spk:
            response = self.client.post(url_for('api.packages'),
                                        headers=authorization_header(user),
                                        data=spk.read())
        self.assert422(response)
        self.assertIn('Unknown architecture: newarch',
                      response.data.decode(response.charset))
コード例 #27
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_invalid_firmware(self):
        user = UserFactory(roles=[Role.find("developer")])
        db.session.commit()

        build = BuildFactory.build(firmware=Firmware(version="1.0", build=42))
        with create_spk(build) as spk:
            response = self.client.post(
                url_for("api.packages"),
                headers=authorization_header(user),
                data=spk.read(),
            )
        self.assert422(response)
        self.assertIn("Invalid firmware",
                      response.data.decode(response.charset))
コード例 #28
0
ファイル: test_api.py プロジェクト: ymartin59/spkrepo
    def test_post_existing_package_not_author_not_maintainer_user(self):
        user = UserFactory(roles=[Role.find("developer")])
        package = PackageFactory()
        db.session.commit()

        with create_spk(BuildFactory.build(version__package=package)) as spk:
            response = self.client.post(
                url_for("api.packages"),
                headers=authorization_header(user),
                data=spk.read(),
            )
        self.assert403(response)
        self.assertIn(
            "Insufficient permissions on this package",
            response.data.decode(response.charset),
        )