Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic backport of pull request #3052 #3098

Merged
merged 1 commit into from Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions bodhi/server/config.py
Expand Up @@ -526,7 +526,14 @@ class BodhiConfig(dict):
'validator': six.text_type},
'openid_template': {
'value': '{username}.id.fedoraproject.org',
<<<<<<< HEAD
'validator': six.text_type},
=======
'validator': str},
'pagure_flatpak_namespace': {
'value': 'modules',
'validator': str},
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
'pagure_url': {
'value': 'https://src.fedoraproject.org/pagure/',
'validator': _validate_tls_url},
Expand Down
7 changes: 6 additions & 1 deletion bodhi/server/models.py
Expand Up @@ -1100,11 +1100,16 @@ def get_pkg_committers_from_pagure(self):
"""
pagure_url = config.get('pagure_url')
# Pagure uses plural names for its namespaces such as "rpms" except for
# container. Flatpaks build directly from the 'modules' namespace
# container. Flatpaks were moved from 'modules' to 'flatpaks' - hence
# a config setting.
if self.type.name == 'container':
namespace = self.type.name
elif self.type.name == 'flatpak':
<<<<<<< HEAD
namespace = 'modules'
=======
namespace = config.get('pagure_flatpak_namespace')
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
else:
namespace = self.type.name + 's'
package_pagure_url = '{0}/api/0/{1}/{2}?expand_group=1'.format(
Expand Down
28 changes: 25 additions & 3 deletions bodhi/tests/server/test_models.py
Expand Up @@ -1052,9 +1052,8 @@ class TestFlatpakPackage(ModelTest, unittest.TestCase):
klass = model.FlatpakPackage
attrs = dict(name=u"flatpak-runtime")

@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure(self, http_session):
"""Ensure correct return value from get_pkg_committers_from_pagure()."""
def patch_http_session(self, http_session, namespace):
"""Patch in the correct pagure API result for the particular flatpaks namespace."""
json_output = {
"access_groups": {
"admin": [],
Expand All @@ -1073,7 +1072,11 @@ def test_get_pkg_committers_from_pagure(self, http_session):
"custom_keys": [],
"date_created": "1494947106",
"description": "Flatpak Runtime",
<<<<<<< HEAD
"fullname": "modules/flatpak-runtime",
=======
"fullname": namespace + "/flatpak-runtime",
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
"group_details": {},
"id": 2,
"milestones": {},
Expand All @@ -1090,6 +1093,25 @@ def test_get_pkg_committers_from_pagure(self, http_session):
http_session.get.return_value.json.return_value = json_output
http_session.get.return_value.status_code = 200

@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure_modules(self, http_session):
"""Ensure correct return value from get_pkg_committers_from_pagure()."""
self.patch_http_session(http_session, namespace='modules')

rv = self.obj.get_pkg_committers_from_pagure()

self.assertEqual(rv, (['otaylor'], []))
http_session.get.assert_called_once_with(
('https://src.fedoraproject.org/pagure/api/0/modules/flatpak-runtime'
'?expand_group=1'),
timeout=60)

@mock.patch.dict('bodhi.server.config.config', {'pagure_flatpak_namespace': 'flatpaks'})
@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure_flatpaks(self, http_session):
"""Check that the pagure_flatpak_namespace config key works."""
self.patch_http_session(http_session, namespace='flatpaks')

rv = self.obj.get_pkg_committers_from_pagure()

self.assertEqual(rv, (['otaylor'], []))
Expand Down
4 changes: 4 additions & 0 deletions production.ini
Expand Up @@ -367,6 +367,10 @@ use = egg:bodhi-server
##
# pagure_url = https://src.fedoraproject.org/pagure/

# This is the namespace where we expect to find the git sources for a Flatpak.
# The default - 'modules' instead of 'flatpaks' - is for backward compatibility
# pagure_flatpak_namespace = modules

##
## Product Definition Center (PDC)
##
Expand Down