Ejemplo n.º 1
0
    def test_pkg_src_perm(self):
        repo1 = Repository(name='repo1')
        repo1.save()
        repo1.uploaders.add(self.user1)
        repo1.uploaders.add(self.user3)
        repo1.save()

        repo2 = Repository(name='repo2')
        repo2.save()
        repo2.uploaders.add(self.user2)
        repo2.uploaders.add(self.user3)
        repo2.save()

        series1 = Series(name='series1', base_ubuntu_series_id='precise', repository=repo1)
        series1.save()

        series2 = Series(name='series2', base_ubuntu_series_id='precise', repository=repo2)
        series2.save()

        pkg_src = PackageSource(code_url='scheme://foo/bar', packaging_url='scheme://foo/bar', flavor='OpenStack')
        pkg_src.save()

        sub1 = Subscription(target_series=series1, source=pkg_src, counter=1)
        sub1.save()
        sub2 = Subscription(target_series=series2, source=pkg_src, counter=1)
        sub2.save()
        self.assertFalse(pkg_src.can_modify(self.user1), 'User1 can modify repository')
        self.assertFalse(pkg_src.can_modify(self.user2), 'User2 can modify repository')
        self.assertTrue(pkg_src.can_modify(self.user3), 'User3 cannot modify repository')
        self.assertTrue(pkg_src.can_modify(self.superuser), 'Super user cannot modify repository')
Ejemplo n.º 2
0
    def test_series_perm(self):
        repo = Repository(name='repo1')
        repo.save()
        repo.uploaders.add(self.user1)
        repo.save()

        series = Series(name='series1', base_ubuntu_series_id='precise', repository=repo)
        series.save()

        self.assertTrue(series.can_modify(self.user1), 'User1 cannot modify repository')
        self.assertFalse(series.can_modify(self.user2), 'User2 can modify repository')
        self.assertTrue(series.can_modify(self.superuser), 'Super user cannot modify repository')
Ejemplo n.º 3
0
    def test_series_perm(self):
        repo = Repository(name='repo1')
        repo.save()
        repo.uploaders.add(self.user1)
        repo.save()

        series = Series(name='series1',
                        base_ubuntu_series_id='precise',
                        repository=repo)
        series.save()

        self.assertTrue(series.can_modify(self.user1),
                        'User1 cannot modify repository')
        self.assertFalse(series.can_modify(self.user2),
                         'User2 can modify repository')
        self.assertTrue(series.can_modify(self.superuser),
                        'Super user cannot modify repository')
Ejemplo n.º 4
0
    def test_pkg_src_perm(self):
        repo1 = Repository(name='repo1')
        repo1.save()
        repo1.uploaders.add(self.user1)
        repo1.uploaders.add(self.user3)
        repo1.save()

        repo2 = Repository(name='repo2')
        repo2.save()
        repo2.uploaders.add(self.user2)
        repo2.uploaders.add(self.user3)
        repo2.save()

        series1 = Series(name='series1',
                         base_ubuntu_series_id='precise',
                         repository=repo1)
        series1.save()

        series2 = Series(name='series2',
                         base_ubuntu_series_id='precise',
                         repository=repo2)
        series2.save()

        pkg_src = PackageSource(code_url='scheme://foo/bar',
                                packaging_url='scheme://foo/bar',
                                flavor='OpenStack')
        pkg_src.save()

        sub1 = Subscription(target_series=series1, source=pkg_src, counter=1)
        sub1.save()
        sub2 = Subscription(target_series=series2, source=pkg_src, counter=1)
        sub2.save()
        self.assertFalse(pkg_src.can_modify(self.user1),
                         'User1 can modify repository')
        self.assertFalse(pkg_src.can_modify(self.user2),
                         'User2 can modify repository')
        self.assertTrue(pkg_src.can_modify(self.user3),
                        'User3 cannot modify repository')
        self.assertTrue(pkg_src.can_modify(self.superuser),
                        'Super user cannot modify repository')