You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/09/28 20:34:23 UTC

[1/2] allura git commit: [#7946] ticket:846 Don't insert redundant csrf input in admin modals

Repository: allura
Updated Branches:
  refs/heads/master f3bd36c6b -> aa6e158b6


[#7946] ticket:846 Don't insert redundant csrf input in admin modals


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

Branch: refs/heads/master
Commit: aa6e158b6443d7e59ee69c4fc2b3b6305afac5d0
Parents: 367525f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 22 16:23:08 2015 +0300
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Mon Sep 28 14:33:47 2015 -0400

----------------------------------------------------------------------
 Allura/allura/lib/widgets/resources/js/admin_modal.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/aa6e158b/Allura/allura/lib/widgets/resources/js/admin_modal.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/admin_modal.js b/Allura/allura/lib/widgets/resources/js/admin_modal.js
index 41a5264..b1a521d 100644
--- a/Allura/allura/lib/widgets/resources/js/admin_modal.js
+++ b/Allura/allura/lib/widgets/resources/js/admin_modal.js
@@ -17,8 +17,6 @@
        under the License.
 */
 $(function() {
-    var cval = $.cookie('_session_id');
-    var csrf_input = $('<input name="_session_id" type="hidden" value="'+cval+'">');
     var $popup_title = $('#admin_modal_title');
     var $popup_contents = $('#admin_modal_contents');
     $('a.admin_modal').click(function () {
@@ -28,7 +26,12 @@ $(function() {
         $.get(link.href, function (data) {
             $popup_title.html($(link).html());
             $popup_contents.html(data);
-            $popup_contents.find('form').append(csrf_input);
+            var csrf_exists = $popup_contents.find('form > input[name="_session_id"]').length;
+            if (!csrf_exists) {
+              var cval = $.cookie('_session_id');
+              var csrf_input = $('<input name="_session_id" type="hidden" value="'+cval+'">');
+              $popup_contents.find('form').append(csrf_input);
+            }
         });
     });
 });


[2/2] allura git commit: [#7946] ticket:846 Add test for chat's configure

Posted by he...@apache.org.
[#7946] ticket:846 Add test for chat's configure

It actually passes, cause turns out problem is in js, but can be still
useful in the future.


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

Branch: refs/heads/master
Commit: 367525f0eb942179dc7d728333a32fa5bde1564a
Parents: f3bd36c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Sep 22 16:21:16 2015 +0300
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Mon Sep 28 14:33:47 2015 -0400

----------------------------------------------------------------------
 .../forgechat/tests/functional/test_root.py     | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/367525f0/ForgeChat/forgechat/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/tests/functional/test_root.py b/ForgeChat/forgechat/tests/functional/test_root.py
index 013176c..49b824d 100644
--- a/ForgeChat/forgechat/tests/functional/test_root.py
+++ b/ForgeChat/forgechat/tests/functional/test_root.py
@@ -15,7 +15,16 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import json
+from datadiff.tools import assert_equal
+
 from alluratest.controller import TestController
+from allura.tests.decorators import with_tool
+
+from forgechat import model as CM
+
+
+with_chat = with_tool('test', 'Chat', 'chat', 'Chat')
 
 
 class TestRootController(TestController):
@@ -23,3 +32,16 @@ class TestRootController(TestController):
     def test_root_index(self):
         response = self.app.get('/chat/').follow()
         assert 'Log for' in response
+
+    @with_chat
+    def test_admin_configure(self):
+        self.app.get('/')  # establish session
+        data = {'channel': 'test channel',
+                '_session_id': self.app.cookies['_session_id']}
+        ch = CM.ChatChannel.query.get()
+        assert_equal(ch.channel, '')
+        resp = self.app.post('/p/test/admin/chat/configure', data)
+        expected = {'status': 'ok', 'message': 'Chat options updated'}
+        assert_equal(json.loads(self.webflash(resp)), expected)
+        ch = CM.ChatChannel.query.get()
+        assert_equal(ch.channel, 'test channel')