You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/05/04 19:36:46 UTC

[03/12] allura git commit: [#6107] ticket:748 Implemented rejecting messages when email posting is disabled

[#6107] ticket:748 Implemented rejecting messages when email posting is disabled


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

Branch: refs/heads/ib/6107
Commit: 5fb3693fcf95405320e2c1d184513d42e7e4bdac
Parents: 9732fbb
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Apr 24 23:31:06 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Apr 29 09:40:22 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/mail_tasks.py |  2 ++
 Allura/allura/tests/test_tasks.py | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5fb3693f/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 92c06e7..2547291 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -59,6 +59,8 @@ def route_email(
                     if not app.has_access(c.user, userpart):
                         log.info('Access denied for %s to mailbox %s',
                                  c.user, userpart)
+                    elif not c.app.config.options.get('AllowEmailPosting', True):
+                        log.info("Posting from email is not enabled")
                     else:
                         if msg['multipart']:
                             msg_hdrs = msg['headers']

http://git-wip-us.apache.org/repos/asf/allura/blob/5fb3693f/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 4ad311c..9cd7d26 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -124,7 +124,7 @@ class TestIndexTasks(unittest.TestCase):
     def test_add_projects(self):
         g.solr.db.clear()
         old_solr_size = len(g.solr.db)
-        projects = M.Project.query.find().all()        
+        projects = M.Project.query.find().all()
         index_tasks.add_projects.post([p._id for p in projects])
         M.MonQTask.run_ready()
         new_solr_size = len(g.solr.db)
@@ -457,6 +457,20 @@ I'm not here'''
                 message)
             assert_equal(hm.call_count, 0)
 
+    @td.with_tool('test', 'Tickets', 'bugs')
+    def test_email_posting_disabled(self):
+        message = 'Hello, world!'
+        import forgetracker
+        c.user = M.User.by_username('test-admin')
+        with mock.patch.object(forgetracker.tracker_main.ForgeTrackerApp, 'handle_message') as hm:
+            c.app.config.options = {'AllowEmailPosting': False}
+            mail_tasks.route_email(
+                '0.0.0.0',
+                c.user.email_addresses[0],
+                ['1@bugs.test.p.in.localhost'],
+                message)
+            assert_equal(hm.call_count, 0)
+
 
 class TestNotificationTasks(unittest.TestCase):