mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-11-29 23:54:58 +08:00
Rename ALLOW_CUSTOM_URLS to ALLOW_CUSTOM_SCMURLS
This commit is contained in:
@@ -47,7 +47,7 @@ class BaseConfiguration(object):
|
||||
# and be in the build state at a time. Set this to 0 for no restrictions
|
||||
NUM_CONSECUTIVE_BUILDS = 5
|
||||
|
||||
ALLOW_CUSTOM_URLS = False
|
||||
ALLOW_CUSTOM_SCMURLS = False
|
||||
|
||||
RPMS_DEFAULT_REPOSITORY = 'git://pkgs.fedoraproject.org/rpms/'
|
||||
RPMS_ALLOW_REPOSITORY = False
|
||||
|
||||
@@ -171,7 +171,7 @@ class Config(object):
|
||||
'type': list,
|
||||
'default': ['module'],
|
||||
'desc': 'List of allowed koji tag prefixes.'},
|
||||
'allow_custom_urls': {
|
||||
'allow_custom_scmurls': {
|
||||
'type': bool,
|
||||
'default': False,
|
||||
'desc': 'Allow custom scmurls.'},
|
||||
|
||||
@@ -196,7 +196,7 @@ class SCMHandler(BaseHandler):
|
||||
|
||||
url = self.data["scmurl"]
|
||||
allowed_prefix = any(url.startswith(prefix) for prefix in conf.scmurls)
|
||||
if not conf.allow_custom_urls and not allowed_prefix:
|
||||
if not conf.allow_custom_scmurls and not allowed_prefix:
|
||||
log.error("The submitted scmurl %r is not allowed" % url)
|
||||
raise Forbidden("The submitted scmurl %s is not allowed" % url)
|
||||
|
||||
|
||||
@@ -747,8 +747,8 @@ class TestViews(unittest.TestCase):
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
@patch("module_build_service.config.Config.allow_custom_urls", new_callable=PropertyMock)
|
||||
def test_submit_custom_scmurl(self, allow_custom_urls, mocked_scm, mocked_get_user):
|
||||
@patch("module_build_service.config.Config.allow_custom_scmurls", new_callable=PropertyMock)
|
||||
def test_submit_custom_scmurl(self, allow_custom_scmurls, mocked_scm, mocked_get_user):
|
||||
MockedSCM(mocked_scm, 'testmodule', 'testmodule.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4')
|
||||
|
||||
@@ -756,13 +756,13 @@ class TestViews(unittest.TestCase):
|
||||
return self.client.post('/module-build-service/1/module-builds/', data=json.dumps(
|
||||
{'branch': 'master', 'scmurl': scmurl}))
|
||||
|
||||
allow_custom_urls.return_value = False
|
||||
allow_custom_scmurls.return_value = False
|
||||
res1 = submit('git://some.custom.url.org/modules/testmodule.git?#68931c9')
|
||||
data = json.loads(res1.data)
|
||||
self.assertEquals(data['status'], 403)
|
||||
self.assertTrue(data['message'].startswith('The submitted scmurl'))
|
||||
self.assertTrue(data['message'].endswith('is not allowed'))
|
||||
|
||||
allow_custom_urls.return_value = True
|
||||
allow_custom_scmurls.return_value = True
|
||||
res2 = submit('git://some.custom.url.org/modules/testmodule.git?#68931c9')
|
||||
self.assertEquals(res2.status_code, 201)
|
||||
|
||||
Reference in New Issue
Block a user