Parent: [5d77f6] (diff)

Child: [bea16d] (diff)

Download this file

test_roles.py    29 lines (25 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pylons import c, g
from alluratest.controller import setup_basic_test, setup_global_objects
from allura import model as M
from allura.lib import security
from allura.lib import helpers as h
def setUp():
setup_basic_test()
setup_global_objects()
h.set_context('test', neighborhood='Projects')
c.project.install_app('blog', 'blog')
g.set_app('blog')
def test_role_assignments():
admin = M.User.by_username('test-admin')
user = M.User.by_username('test-user')
anon = M.User.anonymous()
def check_access(perm):
pred = security.has_access(c.app, perm)
return pred(user=admin), pred(user=user), pred(user=anon)
assert check_access('configure') == (True, False, False)
assert check_access('read') == (True, True, True)
assert check_access('write') == (True, False, False)
assert check_access('unmoderated_post') == (True, True, False)
assert check_access('post') == (True, True, False)
assert check_access('moderate') == (True, False, False)
assert check_access('admin') == (True, False, False)