Switch to unified view

a/Allura/allura/controllers/test.py b/Allura/allura/controllers/test.py
...
...
12
12
13
import  ming.orm.ormsession
13
import  ming.orm.ormsession
14
14
15
import allura
15
import allura
16
from allura.lib.base import WsgiDispatchController
16
from allura.lib.base import WsgiDispatchController
17
from allura.lib.security import require, require_authenticated, has_project_access, has_artifact_access
17
from allura.lib.security import require, require_authenticated, require_access, has_access
18
from allura.lib import helpers as h
18
from allura.lib import helpers as h
19
from allura.lib import plugin
19
from allura.lib import plugin
20
from allura import model as M
20
from allura import model as M
21
from .root import RootController
21
from .root import RootController
22
from .project import ProjectController
22
from .project import ProjectController
...
...
55
        super(TestController, self).__init__()
55
        super(TestController, self).__init__()
56
56
57
    def _setup_request(self):
57
    def _setup_request(self):
58
        # This code fixes a race condition in our tests
58
        # This code fixes a race condition in our tests
59
        c.project = M.Project.query.get(shortname='test')
59
        c.project = M.Project.query.get(shortname='test')
60
        c.memoize_cache = {}
60
        count = 20
61
        count = 20
61
        while c.project is None:
62
        while c.project is None:
62
            import sys, time
63
            import sys, time
63
            time.sleep(0.5)
64
            time.sleep(0.5)
64
            log.warning('Project "test" not found, retrying...')
65
            log.warning('Project "test" not found, retrying...')
...
...
146
        require_authenticated()
147
        require_authenticated()
147
        return ''
148
        return ''
148
149
149
    @expose()
150
    @expose()
150
    def needs_project_access_fail(self):
151
    def needs_project_access_fail(self):
151
        require(has_project_access('no_such_permission'))
152
        require_access(c.project, 'no_such_permission')
152
        return ''
153
        return ''
153
154
154
    @expose()
155
    @expose()
155
    def needs_project_access_ok(self):
156
    def needs_project_access_ok(self):
156
        pred = has_project_access('read')
157
        pred = has_access(c.project, 'read')
157
        if not pred():
158
        if not pred():
158
            log.info('Inside needs_project_access, c.user = %s' % c.user)
159
            log.info('Inside needs_project_access, c.user = %s' % c.user)
159
        require(pred)
160
        require(pred)
160
        return ''
161
        return ''
161
162
162
    @expose()
163
    @expose()
163
    def needs_artifact_access_fail(self):
164
    def needs_artifact_access_fail(self):
164
        require(has_artifact_access('no_such_permission', self.page))
165
        require_access(self.page, 'no_such_permission')
165
        return ''
166
        return ''
166
167
167
    @expose()
168
    @expose()
168
    def needs_artifact_access_ok(self):
169
    def needs_artifact_access_ok(self):
169
        require(has_artifact_access('read', self.page))
170
        require_access(self.page, 'read')
170
        return ''
171
        return ''
171
172