From a86084746d17c75051f20c2822a5ff418f47b806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kadl=C4=8D=C3=ADk?= Date: Tue, 2 May 2017 11:29:47 +0200 Subject: [PATCH] Rename ALLOW_CUSTOM_URLS to ALLOW_CUSTOM_SCMURLS --- conf/config.py | 2 +- module_build_service/config.py | 2 +- module_build_service/views.py | 2 +- tests/test_views/test_views.py | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/config.py b/conf/config.py index 42f600c2..c7584fe2 100644 --- a/conf/config.py +++ b/conf/config.py @@ -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 diff --git a/module_build_service/config.py b/module_build_service/config.py index cbd407bc..56e8241c 100644 --- a/module_build_service/config.py +++ b/module_build_service/config.py @@ -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.'}, diff --git a/module_build_service/views.py b/module_build_service/views.py index c79a528a..1a7d6880 100644 --- a/module_build_service/views.py +++ b/module_build_service/views.py @@ -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) diff --git a/tests/test_views/test_views.py b/tests/test_views/test_views.py index 57bbbe79..39e2fbad 100644 --- a/tests/test_views/test_views.py +++ b/tests/test_views/test_views.py @@ -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)