Switch to unified view

a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
...
...
290
290
291
    def test_default_lookup(self):
291
    def test_default_lookup(self):
292
        # Make sure that default _lookup() throws 404
292
        # Make sure that default _lookup() throws 404
293
        self.app.get('/auth/foobar', status=404)
293
        self.app.get('/auth/foobar', status=404)
294
294
295
    @td.with_svn
296
    def test_refresh_repo(self):
297
        r = self.app.get('/auth/refresh_repo')
298
        assert_equal(r.body, 'No repo specified')
299
300
        r = self.app.get('/auth/refresh_repo/p/gbalksdfh')
301
        assert_equal(r.body, 'No project at /p/gbalksdfh')
302
303
        r = self.app.get('/auth/refresh_repo/p/test')
304
        assert_equal(r.body, '/p/test does not include a repo mount point')
305
306
        r = self.app.get('/auth/refresh_repo/p/test/blah/')
307
        assert_equal(r.body, 'Cannot find repo at /p/test/blah')
308
309
        r = self.app.get('/auth/refresh_repo/p/test/src/')
310
        assert_equal(r.body, '<Repository /tmp/svn/p/test/src> refresh queued.\n')
311
312
class TestUserPermissions(TestController):
295
class TestUserPermissions(TestController):
313
    allow = dict(allow_read=True, allow_write=True, allow_create=True)
296
    allow = dict(allow_read=True, allow_write=True, allow_create=True)
314
    read = dict(allow_read=True, allow_write=False, allow_create=False)
297
    read = dict(allow_read=True, allow_write=False, allow_create=False)
315
    disallow = dict(allow_read=False, allow_write=False, allow_create=False)
298
    disallow = dict(allow_read=False, allow_write=False, allow_create=False)
316
299
317
    def test_unknown_project(self):
318
        r = self._check_repo('/git/foo/bar', status=404)
319
320
    def test_unknown_app(self):
321
        r = self._check_repo('/git/test/bar')
322
        assert r == self.disallow, r
323
324
    @td.with_svn
300
    @td.with_hg
325
    def test_repo_write(self):
326
        r = self._check_repo('/git/test/src.git')
327
        assert r == self.allow, r
328
        r = self._check_repo('/git/test/src')
329
        assert r == self.allow, r
330
331
    @td.with_svn
332
    def test_subdir(self):
333
        r = self._check_repo('/git/test/src.git/foo')
334
        assert r == self.allow, r
335
        r = self._check_repo('/git/test/src/foo')
336
        assert r == self.allow, r
337
338
    @td.with_svn
339
    def test_neighborhood(self):
340
        r = self._check_repo('/git/test.p/src.git')
341
        assert r == self.allow, r
342
343
    @td.with_svn
344
    def test_repo_read(self):
345
        r = self._check_repo(
346
            '/git/test.p/src.git',
347
            username='test-user')
348
        assert r == self.read, r
349
350
    def test_unknown_user(self):
351
        r = self._check_repo(
352
            '/git/test.p/src.git',
353
            username='test-usera',
354
            status=404)
355
356
    def _check_repo(self, path, username='test-admin', **kw):
357
        url = '/auth/repo_permissions'
358
        r = self.app.get(url, params=dict(
359
                repo_path=path,
360
                username=username), **kw)
361
        try:
362
            return r.json
363
        except:
364
            return r
365
366
    @td.with_repos
367
    def test_list_repos(self):
301
    def test_list_repos(self):
368
        r = self.app.get('/auth/repo_permissions', params=dict(username='test-admin'), status=200)
302
        r = self.app.get('/auth/repo_permissions', params=dict(username='test-admin'), status=200)
369
        assert_equal(json.loads(r.body), {"allow_write": [
303
        assert_equal(json.loads(r.body), {"allow_write": [
370
            '/git/test/src-git',
371
            '/hg/test/src-hg',
304
            '/hg/test/src-hg',
372
            '/svn/test/src',
373
        ]})
305
        ]})