Exemplo n.º 1
0
    def test_packager_package(self):
        """ Test the api_packager_package function.  """

        output = self.app.get('/api/packager/package/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            })

        output = self.app.get('/api/packager/package/pingou/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            })

        output = self.app.get('/api/packager/package/?packagername=pingou')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            })

        create_package_acl2(self.session)

        output = self.app.get('/api/packager/package/pingou/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(
            sorted(output.keys()),
            ['co-maintained', 'output', 'point of contact', 'watch'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(len(output['co-maintained']), 1)
        self.assertEqual(len(output['point of contact']), 2)
        self.assertEqual(len(output['watch']), 2)

        self.assertEqual(output['co-maintained'][0]['name'], 'geany')
        self.assertEqual(output['point of contact'][0]['name'], 'fedocal')
        self.assertEqual(output['point of contact'][1]['name'], 'guake')
        self.assertEqual(output['watch'][0]['name'], 'fedocal')
        self.assertEqual(output['watch'][1]['name'], 'guake')
Exemplo n.º 2
0
    def test_api_bugzilla_group(self):
        """ Test the api_bugzilla function. """
        create_package_acl2(self.session)
        self.set_group_acls()

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)
        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|pingou||group::infra-sig,pingou
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        expected = {
            u'bugzillaAcls': {
                'Fedora': {
                    "fedocal": {
                        "owner": "pingou",
                        "cclist": {
                            "groups": ["@infra-sig"],
                            "people": ["pingou"]
                        },
                        "qacontact": None,
                        "summary": "A web-based calendar for Fedora"
                    },
                    'geany': {
                        'owner': '@gtk-sig',
                        'cclist': {
                            'groups': [],
                            'people': []
                        },
                        'qacontact': None,
                        'summary': 'A fast and lightweight IDE using '
                        'GTK2'
                    },
                    'guake': {
                        'owner': 'pingou',
                        'cclist': {
                            'groups': [],
                            'people': ['spot']
                        },
                        'qacontact': None,
                        'summary': 'Top down terminal for GNOME'
                    }
                }
            },
            'title': 'Fedora Package Database -- Bugzilla ACLs'
        }
        data = json.loads(output.data)
        self.assertEqual(data, expected)
Exemplo n.º 3
0
    def test_api_bugzilla_group(self):
        """ Test the api_bugzilla function. """
        create_package_acl2(self.session)
        self.set_group_acls()

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)
        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|pingou||group::infra-sig,pingou
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        expected = {
            u'bugzillaAcls': {
                'Fedora': {
                    "fedocal": {
                        "owner": "pingou",
                        "cclist": {
                            "groups": ["@infra-sig"],
                            "people": ["pingou"]
                        },
                        "qacontact": None,
                        "summary": "A web-based calendar for Fedora"
                    },
                    'geany': {
                        'owner': '@gtk-sig',
                        'cclist': {
                            'groups': [],
                            'people': []
                        },
                        'qacontact': None,
                        'summary': 'A fast and lightweight IDE using '
                        'GTK2'
                    },
                    'guake': {
                        'owner': 'pingou',
                        'cclist': {
                            'groups': [],
                            'people': ['spot']
                        },
                        'qacontact': None,
                        'summary': 'Top down terminal for GNOME'
                    }
                }
            },
            'title': 'Fedora Package Database -- Bugzilla ACLs'
        }
        data = json.loads(output.data)
        self.assertEqual(data, expected)
Exemplo n.º 4
0
    def test_api_vcs_filled(self):
        """ Test the api_vcs function with a filled database. """
        # Filled DB
        create_package_acl2(self.session)

        output = self.app.get('/api/vcs/')
        self.assertEqual(output.status_code, 200)

        expected = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager, | rpms/geany/f18
avail | @provenpackager,@gtk-sig,pingou | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master
avail | @provenpackager, | rpms/offlineimap/master"""
        self.assertEqual(output.data, expected)

        # Including the EOL'd el4 collection
        expected2 = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager, | rpms/geany/f18
avail | @provenpackager,@gtk-sig,pingou | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master
avail | @provenpackager, | rpms/offlineimap/el4
avail | @provenpackager, | rpms/offlineimap/master"""

        output = self.app.get('/api/vcs/?eol=True')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected2)

        output = self.app.get('/api/vcs/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        print output.data

        expected = {
            "packageAcls": {
                "fedocal": {
                    "f17": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": [
                                "pingou"
                            ]
                        }
                    },
                    "f18": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": [
                                "pingou"
                            ]
                        }
                    }
                },
                "geany": {
                    "f18": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": []
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": [
                                "provenpackager",
                                "gtk-sig"
                            ],
                            "people": [
                                "pingou"
                            ]
                        }
                    }
                },
                "guake": {
                    "f18": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": [
                                "pingou"
                            ]
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": [
                                "pingou",
                                "spot"
                            ]
                        }
                    }
                },
                "offlineimap": {
                    "master": {
                        "commit": {
                            "groups": [
                                "provenpackager"
                            ],
                            "people": []
                        }
                    }
                }
            },
            "title": "Fedora Package Database -- VCS ACLs"
        }

        self.assertEqual(data, expected)
Exemplo n.º 5
0
    def test_packager_acl(self):
        """ Test the api_packager_acl function.  """

        output = self.app.get('/api/packager/acl/')
        self.assertEqual(output.status_code, 500)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "output": "notok",
                "error": "Invalid request",
                "page": 1,
                "page_total": 1
            })

        output = self.app.get('/api/packager/acl/pingou/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "output": "notok",
                "error": 'No ACL found for this user',
                "page": 1,
                "page_total": 1
            })

        output = self.app.get('/api/packager/acl/?packagername=pingou')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data, {
                "output": "notok",
                "error": 'No ACL found for this user',
                "page": 1,
                "page_total": 1
            })

        create_package_acl2(self.session)

        output = self.app.get('/api/packager/acl/pingou/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 11)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set([
                'critpath', 'collection', 'package', 'status_change',
                'point_of_contact', 'status'
            ]))
        self.assertEqual(
            set(output['acls'][0]['packagelist']['package'].keys()),
            set([
                u'upstream_url', u'name', u'namespace', u'review_url',
                u'status', u'creation_date', u'summary', u'acls',
                u'description', u'monitor', u'koschei_monitor'
            ]))

        self.assertEqual(
            sorted(output['acls'][0]['packagelist']['collection'].keys()),
            sorted([
                'allow_retire', 'branchname', 'date_created', 'date_updated',
                'dist_tag', 'koji_name', 'name', 'status', 'version'
            ]))
        self.assertEqual(output['acls'][0]['packagelist']['package']['name'],
                         'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get('/api/packager/acl/?packagername=pingou')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 11)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set([
                'critpath', 'package', 'status_change', 'collection',
                'point_of_contact', 'status'
            ]))
        self.assertEqual(output['acls'][0]['packagelist']['package']['name'],
                         'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 6)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set([
                'critpath', 'package', 'status_change', 'collection',
                'point_of_contact', 'status'
            ]))
        self.assertEqual(output['acls'][0]['packagelist']['package']['name'],
                         'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commits')
        self.assertEqual(output.status_code, 500)
        output = json.loads(output.data)
        self.assertEqual(sorted(output.keys()), ['error', 'output'])
        self.assertEqual(output['output'], 'notok')
        self.assertEqual(output['error'],
                         'Invalid request, "commits" is an invalid acl')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&count=True')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(sorted(output.keys()),
                         ['acls_count', 'output', 'page', 'page_total'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['acls_count'], 6)
        self.assertEqual(output['page'], 1)
        self.assertEqual(output['page_total'], 1)

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&poc=1')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 3)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set([
                'critpath', 'package', 'status_change', 'collection',
                'point_of_contact', 'status'
            ]))
        self.assertEqual(output['acls'][0]['packagelist']['package']['name'],
                         'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&poc=False')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 3)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set([
                'critpath', 'package', 'status_change', 'collection',
                'point_of_contact', 'status'
            ]))
        self.assertEqual(output['acls'][0]['packagelist']['package']['name'],
                         'geany')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'master')
        self.assertEqual(output['acls'][1]['packagelist']['package']['name'],
                         'fedocal')
        self.assertEqual(
            output['acls'][1]['packagelist']['collection']['branchname'],
            'master')
Exemplo n.º 6
0
    def test_packager_acl(self):
        """ Test the api_packager_acl function.  """

        output = self.app.get('/api/packager/acl/')
        self.assertEqual(output.status_code, 500)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "notok",
                "error": "Invalid request",
                "page": 1,
                "page_total": 1
            }
        )

        output = self.app.get('/api/packager/acl/pingou/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "notok",
                "error": 'No ACL found for this user',
                "page": 1,
                "page_total": 1
            }
        )

        output = self.app.get('/api/packager/acl/?packagername=pingou')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "notok",
                "error": 'No ACL found for this user',
                "page": 1,
                "page_total": 1
            }
        )

        create_package_acl2(self.session)

        output = self.app.get('/api/packager/acl/pingou/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 11)
        self.assertEqual(
            set(output['acls'][0].keys()),
            set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set(['critpath', 'collection', 'package', 'status_change',
                 'point_of_contact', 'status']))
        self.assertEqual(
            set(output['acls'][0]['packagelist']['package'].keys()),
            set([u'upstream_url', u'name', u'review_url',
                 u'status', u'creation_date', u'summary',
                 u'acls', u'description']))
        self.assertEqual(
            set(output['acls'][0]['packagelist']['collection'].keys()),
            set([u'branchname', u'version', u'name', u'status',
                 u'dist_tag', u'koji_name']))
        self.assertEqual(
            output['acls'][0]['packagelist']['package']['name'], 'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get('/api/packager/acl/?packagername=pingou')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 11)
        self.assertEqual(set(output['acls'][0].keys()),
                         set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set(['critpath', 'package', 'status_change', 'collection',
                 'point_of_contact', 'status']))
        self.assertEqual(
            output['acls'][0]['packagelist']['package']['name'], 'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 6)
        self.assertEqual(
            set(output['acls'][0].keys()),
            set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set(['critpath', 'package', 'status_change', 'collection',
                 'point_of_contact', 'status']))
        self.assertEqual(
            output['acls'][0]['packagelist']['package']['name'], 'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commits')
        self.assertEqual(output.status_code, 500)
        output = json.loads(output.data)
        self.assertEqual(sorted(output.keys()),
                         ['error', 'output'])
        self.assertEqual(output['output'], 'notok')
        self.assertEqual(
            output['error'],
            'Invalid request, "commits" is an invalid acl')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&count=True')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(sorted(output.keys()),
                         ['acls_count', 'output', 'page', 'page_total'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['acls_count'], 6)
        self.assertEqual(output['page'], 1)
        self.assertEqual(output['page_total'], 1)

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&poc=1')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 3)
        self.assertEqual(
            set(output['acls'][0].keys()),
            set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set(['critpath', 'package', 'status_change', 'collection',
                 'point_of_contact', 'status']))
        self.assertEqual(
            output['acls'][0]['packagelist']['package']['name'], 'guake')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'f18')

        output = self.app.get(
            '/api/packager/acl/?packagername=pingou&acls=commit&poc=False')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['page_total', 'output', 'acls', 'page'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(output['page_total'], 1)
        self.assertEqual(len(output['acls']), 3)
        self.assertEqual(
            set(output['acls'][0].keys()),
            set(['status', 'fas_name', 'packagelist', 'acl']))
        self.assertEqual(
            set(output['acls'][0]['packagelist'].keys()),
            set(['critpath', 'package', 'status_change', 'collection',
                 'point_of_contact', 'status']))
        self.assertEqual(
            output['acls'][0]['packagelist']['package']['name'], 'geany')
        self.assertEqual(
            output['acls'][0]['packagelist']['collection']['branchname'],
            'master')
        self.assertEqual(
            output['acls'][1]['packagelist']['package']['name'], 'fedocal')
        self.assertEqual(
            output['acls'][1]['packagelist']['collection']['branchname'],
            'master')
Exemplo n.º 7
0
    def test_packager_package(self):
        """ Test the api_packager_package function.  """

        output = self.app.get('/api/packager/package/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            }
        )

        output = self.app.get('/api/packager/package/pingou/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            }
        )

        output = self.app.get('/api/packager/package/?packagername=pingou')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "co-maintained": [],
                "error": "No ACLs found for that user",
                "output": "notok",
                "point of contact": [],
                "watch": []
            }
        )

        create_package_acl2(self.session)

        output = self.app.get('/api/packager/package/pingou/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(
            sorted(output.keys()),
            ['co-maintained',  'output', 'point of contact', 'watch'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(len(output['co-maintained']), 1)
        self.assertEqual(len(output['point of contact']), 2)
        self.assertEqual(len(output['watch']), 2)

        self.assertEqual(output['co-maintained'][0]['name'], 'geany')
        self.assertEqual(output['point of contact'][0]['name'], 'fedocal')
        self.assertEqual(output['point of contact'][1]['name'], 'guake')
        self.assertEqual(output['watch'][0]['name'], 'fedocal')
        self.assertEqual(output['watch'][1]['name'], 'guake')
Exemplo n.º 8
0
    def test_api_vcs_filled(self):
        """ Test the api_vcs function with a filled database. """
        # Filled DB
        create_package_acl2(self.session)

        output = self.app.get('/api/vcs/')
        self.assertEqual(output.status_code, 200)

        expected = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager,pingou,toshio | rpms/fedocal/master
avail | @provenpackager,@gtk-sig,pingou | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?eol=True')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'packageAcls': {
                u'guake': {
                    u'f18': {
                        u'commit': {
                            u'groups': [u'provenpackager'],
                            u'people': [u'pingou']
                        }
                    },
                    u'master': {
                        u'commit': {
                            u'groups': [u'provenpackager'],
                            u'people': [u'pingou', u'spot']
                        }
                    }
                },
                u'geany': {
                    u'master': {
                        u'commit': {
                            u'groups': [u'provenpackager', u'gtk-sig'],
                            u'people': ['pingou']
                        }
                    }
                },
                "fedocal": {
                    "f18": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou", "toshio"]
                        }
                    },
                    "f17": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    }
                }
            },
            u'title': u'Fedora Package Database -- VCS ACLs'}

        self.assertEqual(data, expected)
Exemplo n.º 9
0
    def test_api_vcs_filled(self):
        """ Test the api_vcs function with a filled database. """
        # Filled DB
        create_package_acl2(self.session)

        output = self.app.get('/api/vcs/')
        self.assertEqual(output.status_code, 200)

        expected = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager, | rpms/geany/f18
avail | @provenpackager,@gtk-sig,pingou | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master
avail | @provenpackager, | rpms/offlineimap/master"""
        self.assertEqual(output.data, expected)

        # Including the EOL'd el4 collection
        expected2 = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager, | rpms/geany/f18
avail | @provenpackager,@gtk-sig,pingou | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master
avail | @provenpackager, | rpms/offlineimap/el4
avail | @provenpackager, | rpms/offlineimap/master"""

        output = self.app.get('/api/vcs/?eol=True')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected2)

        output = self.app.get('/api/vcs/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            "packageAcls": {
                "fedocal": {
                    "f17": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    },
                    "f18": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    }
                },
                "geany": {
                    "f18": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": []
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": ["provenpackager", "gtk-sig"],
                            "people": ["pingou"]
                        }
                    }
                },
                "guake": {
                    "f18": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou", "spot"]
                        }
                    }
                },
                "offlineimap": {
                    "master": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": []
                        }
                    }
                }
            },
            "title": "Fedora Package Database -- VCS ACLs"
        }

        self.assertEqual(data, expected)
Exemplo n.º 10
0
    def test_get_acl_packager(self):
        """ Test the get_acl_packager function of PackageListingAcl.
        """

        acls = model.PackageListingAcl.get_acl_packager(self.session, 'pingou')
        self.assertEqual(0, len(acls))

        create_package_acl2(self.session)

        acls = model.PackageListingAcl.get_acl_packager(self.session, 'pingou')
        self.assertEqual(11, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(acl[0].packagelist.package.name in
                            ['guake', 'geany', 'fedocal'])
            self.assertTrue(acl[0].packagelist.collection.branchname in
                            ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(self.session,
                                                        'pingou',
                                                        eol=True)
        self.assertEqual(110, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(acl[0].packagelist.package.name in
                            ['guake', 'geany', 'fedocal'])
            self.assertTrue(acl[0].packagelist.collection.branchname in
                            ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(self.session,
                                                        'pingou',
                                                        poc=True)
        self.assertEqual(7, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(acl[0].packagelist.package.name in
                            ['guake', 'geany', 'fedocal'])
            self.assertTrue(acl[0].packagelist.collection.branchname in
                            ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(self.session,
                                                        'pingou',
                                                        poc=False)
        self.assertEqual(4, len(acls))
        self.assertEqual(acls[0][0].packagelist.package.name, 'geany')
        self.assertEqual(acls[0][0].packagelist.collection.branchname,
                         'master')
        self.assertEqual(acls[0][0].acl, 'commit')
        self.assertEqual(acls[1][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[1][0].packagelist.collection.branchname,
                         'master')
        self.assertEqual(acls[1][0].acl, 'commit')
        self.assertEqual(acls[2][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[2][0].packagelist.collection.branchname, 'f18')
        self.assertEqual(acls[2][0].acl, 'commit')
        self.assertEqual(acls[3][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[3][0].packagelist.collection.branchname, 'f18')
        self.assertEqual(acls[3][0].acl, 'watchbugzilla')

        acls = model.PackageListingAcl.get_acl_packager(self.session,
                                                        'toshio',
                                                        poc=True)
        self.assertEqual(0, len(acls))
    def test_get_acl_packager(self):
        """ Test the get_acl_packager function of PackageListingAcl.
        """

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou')
        self.assertEqual(0, len(acls))

        create_package_acl2(self.session)

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou')
        self.assertEqual(11, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(
                acl[0].packagelist.package.name in
                ['guake', 'geany', 'fedocal'])
            self.assertTrue(
                acl[0].packagelist.collection.branchname
                in ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou', eol=True)
        self.assertEqual(99, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(
                acl[0].packagelist.package.name in
                ['guake', 'geany', 'fedocal'])
            self.assertTrue(
                acl[0].packagelist.collection.branchname
                in ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou', poc=True)
        self.assertEqual(7, len(acls))
        for acl in acls:
            self.assertEqual(acl[0].fas_name, 'pingou')
            self.assertTrue(
                acl[0].acl in ['commit', 'watchcommits', 'watchbugzilla'])
            self.assertTrue(
                acl[0].packagelist.package.name in
                ['guake', 'geany', 'fedocal'])
            self.assertTrue(
                acl[0].packagelist.collection.branchname
                in ['f17', 'f18', 'master'])

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou', poc=False)
        self.assertEqual(4, len(acls))
        self.assertEqual(acls[0][0].packagelist.package.name, 'geany')
        self.assertEqual(acls[0][0].packagelist.collection.branchname, 'master')
        self.assertEqual(acls[0][0].acl, 'commit')
        self.assertEqual(acls[1][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[1][0].packagelist.collection.branchname, 'master')
        self.assertEqual(acls[1][0].acl, 'commit')
        self.assertEqual(acls[2][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[2][0].packagelist.collection.branchname, 'f18')
        self.assertEqual(acls[2][0].acl, 'commit')
        self.assertEqual(acls[3][0].packagelist.package.name, 'fedocal')
        self.assertEqual(acls[3][0].packagelist.collection.branchname, 'f18')
        self.assertEqual(acls[3][0].acl, 'watchbugzilla')

        acls = model.PackageListingAcl.get_acl_packager(
            self.session, 'toshio', poc=True)
        self.assertEqual(0, len(acls))
Exemplo n.º 12
0
    def test_api_bugzilla_filled(self):
        """ Test the api_bugzilla function with a filled database. """
        # Fill the DB
        create_package_acl2(self.session)

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|orphan||pingou,toshio
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'bugzillaAcls': {
                u'Fedora': [
                    {
                        "fedocal": {
                            "owner": "orphan",
                            "cclist": {
                                "groups": [],
                                "people": ["pingou", 'toshio']
                            },
                            "qacontact": None,
                            "summary": "A web-based calendar for Fedora"
                        }
                    },
                    {
                        u'geany': {
                            u'owner': u'@gtk-sig',
                            u'cclist': {
                                u'groups': [],
                                u'people': []
                            },
                            u'qacontact': None,
                            u'summary': u'A fast and lightweight IDE using '
                            'GTK2'
                        }
                    },
                    {
                        u'guake': {
                            u'owner': u'pingou',
                            u'cclist': {
                                u'groups': [],
                                u'people': [u'spot']
                            },
                            u'qacontact': None,
                            u'summary': u'Top down terminal for GNOME'
                        }
                    },
                ]
            },
            u'title': u'Fedora Package Database -- Bugzilla ACLs'
        }

        self.assertEqual(data, expected)

        # Filter for a collection
        output = self.app.get('/api/bugzilla/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

"""
        self.assertEqual(output.data, expected)
Exemplo n.º 13
0
    def test_api_vcs_filled(self):
        """ Test the api_vcs function with a filled database. """
        # Filled DB
        create_package_acl2(self.session)

        output = self.app.get('/api/vcs/')
        self.assertEqual(output.status_code, 200)

        expected = """# VCS ACLs
# avail|@groups,users|rpms/Package/branch

avail | @provenpackager,pingou | rpms/fedocal/f17
avail | @provenpackager,pingou | rpms/fedocal/f18
avail | @provenpackager,pingou,toshio | rpms/fedocal/master
avail | @provenpackager,@gtk-sig, | rpms/geany/master
avail | @provenpackager,pingou | rpms/guake/f18
avail | @provenpackager,pingou,spot | rpms/guake/master"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/vcs/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'packageAcls': {
                u'guake': {
                    u'f18': {
                        u'commit': {
                            u'groups': [u'provenpackager'],
                            u'people': [u'pingou']
                        }
                    },
                    u'master': {
                        u'commit': {
                            u'groups': [u'provenpackager'],
                            u'people': [u'pingou', u'spot']
                        }
                    }
                },
                u'geany': {
                    u'master': {
                        u'commit': {
                            u'groups': [u'provenpackager', u'gtk-sig'],
                            u'people': []
                        }
                    }
                },
                "fedocal": {
                    "f18": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    },
                    "master": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou", "toshio"]
                        }
                    },
                    "f17": {
                        "commit": {
                            "groups": ["provenpackager"],
                            "people": ["pingou"]
                        }
                    }
                }
            },
            u'title': u'Fedora Package Database -- VCS ACLs'
        }

        self.assertEqual(data, expected)
Exemplo n.º 14
0
    def test_api_bugzilla_filled_docker(self):
        """ Test the api_bugzilla function with a filled database with
        namespaces. """
        # Fill the DB
        create_package_acl2(self.session)
        create_docker_packages(self.session)

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|pingou||pingou
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot
Fedora Docker|cockpit|Server Management GUI|puiterwijk||group::gtk-sig,pingou
Fedora Docker|fedocal|A web-based calendar for Fedora|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'bugzillaAcls': {
                'Fedora': {
                    "fedocal": {
                        "owner": "pingou",
                        "cclist": {
                            "groups": [],
                            "people": ["pingou"]
                        },
                        "qacontact": None,
                        "summary": "A web-based calendar for Fedora"
                    },
                    'geany': {
                        'owner': '@gtk-sig',
                        'cclist': {
                            'groups': [],
                            'people': []
                        },
                        'qacontact': None,
                        'summary': 'A fast and lightweight IDE using '
                        'GTK2'
                    },
                    'guake': {
                        'owner': 'pingou',
                        'cclist': {
                            'groups': [],
                            'people': ['spot']
                        },
                        'qacontact': None,
                        'summary': 'Top down terminal for GNOME'
                    }
                },
                "Fedora Docker": {
                    "cockpit": {
                        "cclist": {
                            "groups": ["@gtk-sig"],
                            "people": ["pingou"]
                        },
                        "owner": "puiterwijk",
                        "qacontact": None,
                        "summary": "Server Management GUI"
                    },
                    "fedocal": {
                        "cclist": {
                            "groups": [],
                            "people": ["spot"]
                        },
                        "owner": "pingou",
                        "qacontact": None,
                        "summary": "A web-based calendar for Fedora"
                    }
                }
            },
            'title': 'Fedora Package Database -- Bugzilla ACLs'
        }
        self.assertEqual(data, expected)

        # Filter for a collection
        output = self.app.get('/api/bugzilla/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

"""
        self.assertEqual(output.data, expected)
Exemplo n.º 15
0
    def test_api_bugzilla_filled(self):
        """ Test the api_bugzilla function with a filled database. """
        # Fill the DB
        create_package_acl2(self.session)

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|orphan||pingou,toshio
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'bugzillaAcls': {
                u'Fedora': [
                    {
                        "fedocal": {
                            "owner": "orphan",
                            "cclist": {
                                "groups": [],
                                "people": ["pingou", 'toshio']
                            },
                            "qacontact": None,
                            "summary": "A web-based calendar for Fedora"
                        }
                    },
                    {
                        u'geany': {
                            u'owner': u'@gtk-sig',
                            u'cclist': {
                                u'groups': [],
                                u'people': []
                            },
                            u'qacontact': None,
                            u'summary': u'A fast and lightweight IDE using '
                            'GTK2'
                        }
                    },
                    {
                        u'guake': {
                            u'owner': u'pingou',
                            u'cclist': {
                                u'groups': [],
                                u'people': [u'spot']
                            },
                            u'qacontact': None,
                            u'summary': u'Top down terminal for GNOME'
                        }
                    },
                ]
            },
            u'title': u'Fedora Package Database -- Bugzilla ACLs'
        }

        self.assertEqual(data, expected)

        # Filter for a collection
        output = self.app.get('/api/bugzilla/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

"""
        self.assertEqual(output.data, expected)
Exemplo n.º 16
0
    def test_api_bugzilla_filled_docker(self):
        """ Test the api_bugzilla function with a filled database with
        namespaces. """
        # Fill the DB
        create_package_acl2(self.session)
        create_docker_packages(self.session)

        output = self.app.get('/api/bugzilla/')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

Fedora|fedocal|A web-based calendar for Fedora|pingou||pingou
Fedora|geany|A fast and lightweight IDE using GTK2|group::gtk-sig||
Fedora|guake|Top down terminal for GNOME|pingou||spot
Fedora Docker|cockpit|Server Management GUI|puiterwijk||group::gtk-sig,pingou
Fedora Docker|fedocal|A web-based calendar for Fedora|pingou||spot"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/bugzilla/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'bugzillaAcls': {
                'Fedora': {
                    "fedocal": {
                        "owner": "pingou",
                        "cclist": {
                            "groups": [],
                            "people": ["pingou"]
                        },
                        "qacontact": None,
                        "summary": "A web-based calendar for Fedora"
                    },
                    'geany': {
                        'owner': '@gtk-sig',
                        'cclist': {
                            'groups': [],
                            'people': []
                        },
                        'qacontact': None,
                        'summary': 'A fast and lightweight IDE using '
                        'GTK2'
                    },
                    'guake': {
                        'owner': 'pingou',
                        'cclist': {
                            'groups': [],
                            'people': ['spot']
                        },
                        'qacontact': None,
                        'summary': 'Top down terminal for GNOME'
                    }
                },
                "Fedora Docker": {
                  "cockpit": {
                    "cclist": {
                      "groups": [
                        "@gtk-sig"
                      ],
                      "people": ["pingou"]
                    },
                    "owner": "puiterwijk",
                    "qacontact": None,
                    "summary": "Server Management GUI"
                  },
                  "fedocal": {
                    "cclist": {
                      "groups": [],
                      "people": [
                        "spot"
                      ]
                    },
                    "owner": "pingou",
                    "qacontact": None,
                    "summary": "A web-based calendar for Fedora"
                  }
                }
            },
            'title': 'Fedora Package Database -- Bugzilla ACLs'
        }
        self.assertEqual(data, expected)

        # Filter for a collection
        output = self.app.get('/api/bugzilla/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = """# Package Database VCS Acls
# Text Format
# Collection|Package|Description|Owner|Initial QA|Initial CCList
# Backslashes (\) are escaped as \u005c Pipes (|) are escaped as \u007c

"""
        self.assertEqual(output.data, expected)