You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/03 23:57:50 UTC
[20/50] git commit: [#6179] ignore the u/ prefix of user-projects so
that a 15-char username can have their user project created successfully
[#6179] ignore the u/ prefix of user-projects so that a 15-char username can have their user project created successfully
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f7461097
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f7461097
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f7461097
Branch: refs/heads/db/6007
Commit: f7461097b15347cb3ae196fd0e486844d017e381
Parents: 5c8db54
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Apr 30 18:16:50 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Apr 30 18:16:50 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 4 ++-
Allura/allura/tests/test_plugin.py | 40 +++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f7461097/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index b7722d2..02aae3a 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -464,7 +464,9 @@ class ProjectRegistrationProvider(object):
self.rate_limit(user, neighborhood)
- if not h.re_project_name.match(shortname.replace('/', '')):
+ if user_project and shortname.startswith('u/'):
+ shortname = shortname.replace('u/', '', 1)
+ if not h.re_project_name.match(shortname):
raise ValueError('Invalid project shortname: %s' % shortname)
p = M.Project.query.get(shortname=shortname, neighborhood_id=neighborhood._id)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f7461097/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
new file mode 100644
index 0000000..6e1a07a
--- /dev/null
+++ b/Allura/allura/tests/test_plugin.py
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from nose.tools import assert_equals
+from mock import MagicMock, patch
+
+from allura import model as M
+from allura.lib.utils import TruthyCallable
+from allura.lib.plugin import ProjectRegistrationProvider
+
+
+class TestProjectRegistrationProvider(object):
+
+ @patch('allura.lib.security.has_access')
+ def test_validate_project_15char_user(self, has_access):
+ has_access.return_value = TruthyCallable(lambda: True)
+ provider = ProjectRegistrationProvider()
+ nbhd = M.Neighborhood()
+ provider.validate_project(
+ neighborhood=nbhd,
+ shortname='u/' + ('a' * 15),
+ project_name='15 char username',
+ user=MagicMock(),
+ user_project=True,
+ private_project=False,
+ )
\ No newline at end of file