allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#7979] bypass phone validation on project import
Date Mon, 31 Aug 2015 18:42:18 GMT
Repository: allura
Updated Branches:
  refs/heads/db/7979 [created] 80f4f45bb


[#7979] bypass phone validation on project import


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/80f4f45b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/80f4f45b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/80f4f45b

Branch: refs/heads/db/7979
Commit: 80f4f45bb374242962a8715eaeda5931b8484e36
Parents: 79d3e27
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon Aug 31 18:40:36 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Aug 31 18:40:36 2015 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py                     |  6 +--
 ForgeImporters/forgeimporters/base.py           | 13 +++--
 .../trac/tests/functional/__init__.py           | 16 ++++++
 .../trac/tests/functional/test_trac.py          | 57 ++++++++++++++++++++
 4 files changed, 81 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/80f4f45b/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index be69b29..2270dcb 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -819,11 +819,9 @@ class ProjectRegistrationProvider(object):
             check_shortname = shortname.replace('u/', '', 1)
         else:
             check_shortname = shortname
-        self.shortname_validator.to_python(
-            check_shortname, neighborhood=neighborhood)
+        self.shortname_validator.to_python(check_shortname, neighborhood=neighborhood)
 
-        p = M.Project.query.get(
-            shortname=shortname, neighborhood_id=neighborhood._id)
+        p = M.Project.query.get(shortname=shortname, neighborhood_id=neighborhood._id)
         if p:
             raise forge_exc.ProjectConflict(
                 '%s already exists in nbhd %s' % (shortname, neighborhood._id))

http://git-wip-us.apache.org/repos/asf/allura/blob/80f4f45b/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 8cc7e72..25399ea 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -287,16 +287,15 @@ class ProjectImporter(BaseController):
         message indicating that some data will not be available immediately.
         """
         try:
-            c.project = self.neighborhood.register_project(
-                kw['project_shortname'],
-                project_name=kw['project_name'])
+            with h.push_config(config, **{'project.verify_phone': 'false'}):
+                c.project = self.neighborhood.register_project(
+                    kw['project_shortname'],
+                    project_name=kw['project_name'])
         except exceptions.ProjectOverlimitError:
-            flash(
-                "You have exceeded the maximum number of projects you are allowed to create",
'error')
+            flash("You have exceeded the maximum number of projects you are allowed to create",
'error')
             redirect('.')
         except exceptions.ProjectRatelimitError:
-            flash(
-                "Project creation rate limit exceeded.  Please try again later.", 'error')
+            flash("Project creation rate limit exceeded.  Please try again later.", 'error')
             redirect('.')
         except Exception:
             log.error('error registering project: %s',

http://git-wip-us.apache.org/repos/asf/allura/blob/80f4f45b/ForgeImporters/forgeimporters/trac/tests/functional/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tests/functional/__init__.py b/ForgeImporters/forgeimporters/trac/tests/functional/__init__.py
new file mode 100644
index 0000000..144e298
--- /dev/null
+++ b/ForgeImporters/forgeimporters/trac/tests/functional/__init__.py
@@ -0,0 +1,16 @@
+#       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.

http://git-wip-us.apache.org/repos/asf/allura/blob/80f4f45b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
new file mode 100644
index 0000000..b6a640c
--- /dev/null
+++ b/ForgeImporters/forgeimporters/trac/tests/functional/test_trac.py
@@ -0,0 +1,57 @@
+#       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 mock import patch, Mock
+from nose.tools import assert_equal
+from tg import config
+
+from allura.lib import helpers as h
+from allura.tests import TestController
+
+
+
+class TestTracImportController(TestController):
+
+    def test_index(self):
+        r = self.app.get('/p/import_project/trac/')
+        assert 'Trac URL' in r
+
+    def test_submit(self):
+        r = self.app.get('/p/import_project/trac/')
+        form = r.forms['project-import-form']
+        form['trac_url'] = 'http://example.com/trac'
+        form['project_name'] = 'My Project'
+        form['project_shortname'] = 'my-project'
+        form['user_map'] = '', ''
+
+        with patch('forgeimporters.trac.requests.head') as mock_head:
+            mock_head.return_value.status_code = 200  # so our 'trac_url' above is deemed
as an okay URL
+            r = form.submit()
+
+        assert r.status_int == 302 and '/p/my-project' in r.location, \
+            'Did not redirect as expected (status {} location {}).  Got a flash message:
{} and inline errors: {}'.format(
+                r.status_int,
+                getattr(r, 'location'),
+                self.webflash(r),
+                hasattr(r, 'html') and r.html.find('div', {'class': 'error'})
+            )
+
+
+    def test_import_with_phone_validation(self):
+        self.app.extra_environ = {'username': 'test-user'}
+        with h.push_config(config, **{'project.verify_phone': 'true'}):
+            self.test_submit()
\ No newline at end of file


Mime
View raw message