You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/25 00:31:09 UTC

[44/50] git commit: [#4370] ticket:322 Test for REST API permissions

[#4370] ticket:322 Test for REST API permissions


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

Branch: refs/heads/cj/5655
Commit: 3207e959ac1e12e98e6b55f3b6475d0e103b3a9e
Parents: 54cca78
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 24 09:43:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 20:02:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_rest.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3207e959/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index aaba26b..68f769f 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -19,9 +19,12 @@
 
 from datetime import datetime, timedelta
 
+from nose.tools import assert_equal
+
 from allura.tests import decorators as td
 from alluratest.controller import TestRestApiBase
 from allura.lib import helpers as h
+from allura import model as M
 
 class TestRestHome(TestRestApiBase):
 
@@ -77,3 +80,19 @@ class TestRestHome(TestRestApiBase):
         assert r.status_int == 200
         assert r.json['title'].encode('utf-8') == 'tést', r.json
 
+    @td.with_wiki
+    def test_deny_access(self):
+        wiki = M.Project.query.get(shortname='test').app_instance('wiki')
+        anon_read_perm = M.ACE.allow(M.ProjectRole.by_name('*anonymous')._id, 'read')
+        auth_read_perm = M.ACE.allow(M.ProjectRole.by_name('*authenticated')._id, 'read')
+        acl = wiki.config.acl
+        if anon_read_perm in acl:
+            acl.remove(anon_read_perm)
+        if auth_read_perm in acl:
+            acl.remove(auth_read_perm)
+        self.app.get('/rest/p/test/wiki/Home/',
+                     extra_environ={'username': '*anonymous'},
+                     status=401)
+        self.app.get('/rest/p/test/wiki/Home/',
+                     extra_environ={'username': 'test-user-0'},
+                     status=401)