Mercurial > kallithea
annotate rhodecode/tests/functional/test_forks.py @ 3141:a45191e7c7bb beta
access control: fix owner checks - they were always true
The lambda expressions seems to be left over from something else. They were no
longer executed and thus always evaluated to true.
Some of the functions also failed if they were executed.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 02 Jan 2013 13:56:44 +0100 |
parents | d2d35cf2b351 |
children | f4ce9416cbd5 |
rev | line source |
---|---|
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 from rhodecode.tests import * |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 from rhodecode.model.db import Repository |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
4 from rhodecode.model.repo import RepoModel |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
5 from rhodecode.model.user import UserModel |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
6 from rhodecode.model.meta import Session |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
7 |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 class TestForksController(TestController): |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
11 def setUp(self): |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
12 self.username = u'forkuser' |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
13 self.password = u'qweqwe' |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
14 self.u1 = UserModel().create_or_update( |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
15 username=self.username, password=self.password, |
2513
388843a3a3c0
Updated create_or_update method to not change API key when password is not updated
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
16 email=u'fork_king@rhodecode.org', firstname=u'u1', lastname=u'u1' |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
17 ) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
18 Session().commit() |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
19 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
20 def tearDown(self): |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
21 Session().delete(self.u1) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
22 Session().commit() |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
23 |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 def test_index(self): |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 self.log_user() |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 repo_name = HG_REPO |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 response = self.app.get(url(controller='forks', action='forks', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 repo_name=repo_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 self.assertTrue("""There are no forks yet""" in response.body) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
32 def test_no_permissions_to_fork(self): |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
33 usr = self.log_user(TEST_USER_REGULAR_LOGIN, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
34 TEST_USER_REGULAR_PASS)['user_id'] |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
35 user_model = UserModel() |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
36 user_model.revoke_perm(usr, 'hg.fork.repository') |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
37 user_model.grant_perm(usr, 'hg.fork.none') |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
38 u = UserModel().get(usr) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
39 u.inherit_default_permissions = False |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
40 Session().commit() |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
41 # try create a fork |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
42 repo_name = HG_REPO |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
43 self.app.post(url(controller='forks', action='fork_create', |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
44 repo_name=repo_name), {}, status=403) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
45 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
46 def test_index_with_fork_hg(self): |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 self.log_user() |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 # create a fork |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 fork_name = HG_FORK |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 description = 'fork of vcs test' |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 repo_name = HG_REPO |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
53 org_repo = Repository.get_by_repo_name(repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
54 response = self.app.post(url(controller='forks', |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 action='fork_create', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 repo_name=repo_name), |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
57 {'repo_name': fork_name, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
58 'repo_group': '', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
59 'fork_parent_id': org_repo.repo_id, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
60 'repo_type': 'hg', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
61 'description': description, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
62 'private': 'False', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
63 'landing_rev': 'tip'}) |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 response = self.app.get(url(controller='forks', action='forks', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 repo_name=repo_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
68 response.mustcontain( |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
69 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
70 ) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
71 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
72 #remove this fork |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
73 response = self.app.delete(url('repo', repo_name=fork_name)) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
74 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
75 def test_index_with_fork_git(self): |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
76 self.log_user() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
77 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
78 # create a fork |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
79 fork_name = GIT_FORK |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
80 description = 'fork of vcs test' |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
81 repo_name = GIT_REPO |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
82 org_repo = Repository.get_by_repo_name(repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
83 response = self.app.post(url(controller='forks', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
84 action='fork_create', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
85 repo_name=repo_name), |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
86 {'repo_name': fork_name, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
87 'repo_group': '', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
88 'fork_parent_id': org_repo.repo_id, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
89 'repo_type': 'git', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
90 'description': description, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
91 'private': 'False', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
92 'landing_rev': 'tip'}) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
93 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
94 response = self.app.get(url(controller='forks', action='forks', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
95 repo_name=repo_name)) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
96 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
97 response.mustcontain( |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
98 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
99 ) |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 #remove this fork |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 response = self.app.delete(url('repo', repo_name=fork_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
104 def test_z_fork_create(self): |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
105 self.log_user() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
106 fork_name = HG_FORK |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
107 description = 'fork of vcs test' |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
108 repo_name = HG_REPO |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
109 org_repo = Repository.get_by_repo_name(repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
110 response = self.app.post(url(controller='forks', action='fork_create', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
111 repo_name=repo_name), |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
112 {'repo_name':fork_name, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
113 'repo_group':'', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
114 'fork_parent_id':org_repo.repo_id, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
115 'repo_type':'hg', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
116 'description':description, |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
117 'private':'False', |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
118 'landing_rev': 'tip'}) |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
119 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
120 #test if we have a message that fork is ok |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
121 self.checkSessionFlash(response, |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2176
diff
changeset
|
122 'forked %s repository as %s' % (repo_name, fork_name)) |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
123 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
124 #test if the fork was created in the database |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
125 fork_repo = Session().query(Repository)\ |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
126 .filter(Repository.repo_name == fork_name).one() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
127 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
128 self.assertEqual(fork_repo.repo_name, fork_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
129 self.assertEqual(fork_repo.fork.repo_name, repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
130 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
131 #test if fork is visible in the list ? |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
132 response = response.follow() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
133 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
134 response = self.app.get(url(controller='summary', action='index', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
135 repo_name=fork_name)) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
136 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
137 self.assertTrue('Fork of %s' % repo_name in response.body) |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
138 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
139 def test_zz_fork_permission_page(self): |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
140 usr = self.log_user(self.username, self.password)['user_id'] |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
141 repo_name = HG_REPO |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
142 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
143 forks = Session().query(Repository)\ |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
144 .filter(Repository.fork_id != None)\ |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
145 .all() |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
146 self.assertEqual(1, len(forks)) |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
147 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
148 # set read permissions for this |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
149 RepoModel().grant_user_permission(repo=forks[0], |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
150 user=usr, |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
151 perm='repository.read') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
152 Session().commit() |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
153 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
154 response = self.app.get(url(controller='forks', action='forks', |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
155 repo_name=repo_name)) |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
156 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
157 response.mustcontain('<div style="padding:5px 3px 3px 42px;">fork of vcs test</div>') |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
158 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
159 def test_zzz_fork_permission_page(self): |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
160 usr = self.log_user(self.username, self.password)['user_id'] |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
161 repo_name = HG_REPO |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
162 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
163 forks = Session().query(Repository)\ |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
164 .filter(Repository.fork_id != None)\ |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
165 .all() |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
166 self.assertEqual(1, len(forks)) |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
167 |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
168 # set none |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
169 RepoModel().grant_user_permission(repo=forks[0], |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
170 user=usr, perm='repository.none') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2513
diff
changeset
|
171 Session().commit() |
2176
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
172 # fork shouldn't be there |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
173 response = self.app.get(url(controller='forks', action='forks', |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
174 repo_name=repo_name)) |
162bf5c978f8
fixed missing permissions check on forks page
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
175 response.mustcontain('There are no forks yet') |