Files
@ abc29122c7f2
Branch filter:
Location: kallithea/kallithea/tests/functional/test_admin_repo_groups.py
abc29122c7f2
6.4 KiB
text/x-python
repo group: introduce editing of owner
The repo group owner concept was only partially implemented. Owners were shown
in the repo group listing, but couldn't be changed. Users owning repo groups
couldn't be deleted, with no other solution than deleting owned repo groups.
This also fixes the existing broken update_repo_group API, which tried to use
unimplemented functionality.
The repo group owner concept was only partially implemented. Owners were shown
in the repo group listing, but couldn't be changed. Users owning repo groups
couldn't be deleted, with no other solution than deleting owned repo groups.
This also fixes the existing broken update_repo_group API, which tried to use
unimplemented functionality.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | from kallithea.model import db, meta
from kallithea.model.repo_group import RepoGroupModel
from kallithea.tests import base
from kallithea.tests.fixture import Fixture
fixture = Fixture()
class TestRepoGroupsController(base.TestController):
def test_index(self):
self.log_user()
response = self.app.get(base.url('repos_groups'))
response.mustcontain('"records": []')
def test_new(self):
self.log_user()
response = self.app.get(base.url('new_repos_group'))
def test_create(self):
self.log_user()
group_name = 'foo'
# creation with form error
response = self.app.post(base.url('repos_groups'),
{'group_name': group_name,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
response.mustcontain('<!-- for: group_description -->')
# creation
response = self.app.post(base.url('repos_groups'),
{'group_name': group_name,
'group_description': 'lala',
'parent_group_id': '-1',
'group_copy_permissions': 'True',
'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Created repository group %s' % group_name)
# edit form
response = self.app.get(base.url('edit_repo_group', group_name=group_name))
response.mustcontain('>lala<')
# edit with form error
response = self.app.post(base.url('update_repos_group', group_name=group_name),
{'group_name': group_name,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
response.mustcontain('<!-- for: group_description -->')
# edit
response = self.app.post(base.url('update_repos_group', group_name=group_name),
{'group_name': group_name,
'owner': base.TEST_USER_REGULAR2_LOGIN,
'group_description': 'lolo',
'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Updated repository group %s' % group_name)
response = response.follow()
response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
response.mustcontain(no='<!-- for: group_description -->')
response.mustcontain('>lolo<')
# listing
response = self.app.get(base.url('repos_groups'))
response.mustcontain('raw_name": "%s"' % group_name)
# show
response = self.app.get(base.url('repos_group', group_name=group_name))
response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name)
# show ignores extra trailing slashes in the URL
response = self.app.get(base.url('repos_group', group_name='%s//' % group_name))
response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name)
# delete
response = self.app.post(base.url('delete_repo_group', group_name=group_name),
{'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Removed repository group %s' % group_name)
def test_new_by_regular_user(self):
self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
response = self.app.get(base.url('new_repos_group'), status=403)
def test_case_insensitivity(self):
self.log_user()
group_name = 'newgroup'
response = self.app.post(base.url('repos_groups'),
fixture._get_repo_group_create_params(group_name=group_name,
_session_csrf_secret_token=self.session_csrf_secret_token()))
# try to create repo group with swapped case
swapped_group_name = group_name.swapcase()
response = self.app.post(base.url('repos_groups'),
fixture._get_repo_group_create_params(group_name=swapped_group_name,
_session_csrf_secret_token=self.session_csrf_secret_token()))
response.mustcontain('already exists')
RepoGroupModel().delete(group_name)
meta.Session().commit()
def test_subgroup_deletion(self):
self.log_user()
parent = None
parent_name = 'parent'
sub = None
sub_name = 'sub'
sub_path = 'parent/sub'
try:
# create parent group
assert db.RepoGroup.guess_instance(parent_name) is None
response = self.app.post(
base.url('repos_groups'),
fixture._get_repo_group_create_params(
group_name=parent_name,
_session_csrf_secret_token=self.session_csrf_secret_token()
)
)
parent = db.RepoGroup.guess_instance(parent_name)
assert parent is not None
# create sub group
assert db.RepoGroup.guess_instance(sub_path) is None
response = self.app.post(
base.url('repos_groups'),
fixture._get_repo_group_create_params(
group_name=sub_name,
parent_group_id=parent.group_id,
_session_csrf_secret_token=self.session_csrf_secret_token()
)
)
sub = db.RepoGroup.guess_instance(sub_path)
assert sub is not None
# delete sub group
response = self.app.post(
base.url('delete_repo_group', group_name=sub_path),
params={
'_session_csrf_secret_token': self.session_csrf_secret_token()
},
)
sub = db.RepoGroup.guess_instance(sub_path)
assert sub is None
finally:
if sub:
RepoGroupModel().delete(sub)
if parent:
RepoGroupModel().delete(parent)
meta.Session().commit()
|