From 3a37fa5dae249996ae0f7d6f00644e74c543c888 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 13 2017 13:25:11 +0000 Subject: [PATCH 1/2] Only check the blacklist if there is no namespace It only makes sense to check the black list if there is no namespace attached to the project as otherwise there is no risk of URL conflict then. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 8c3c503..6731d21 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1197,8 +1197,8 @@ def new_project(session, user, name, blacklist, allowed_prefix, ignore_existing_repo=False): ''' Create a new project based on the information provided. ''' - if name in blacklist or ( - namespace and '%s/%s' % (namespace, name) in blacklist): + if (not namespace and name in blacklist) \ + or (namespace and '%s/%s' % (namespace, name) in blacklist): raise pagure.exceptions.ProjectBlackListedException( 'No project "%s" are allowed to be created due to potential ' 'conflicts in URLs with pagure itself' % name From 53abe13380e0f288ca917875d1ad9742839e4031 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 13 2017 13:30:05 +0000 Subject: [PATCH 2/2] Fix the unit-tests, no need to create projects that we do not use --- diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 27de057..6f5d2cc 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -374,7 +374,6 @@ class PagureFlaskApiProjecttests(tests.Modeltests): """ Test the api_new_project method of the flask api. """ p_gga.return_value = True - tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session)