Show More
@@ -25,7 +25,7 b' from __future__ import print_function' | |||||
25 | import sys |
|
25 | import sys | |
26 |
|
26 | |||
27 | import kallithea.bin.kallithea_cli_base as cli_base |
|
27 | import kallithea.bin.kallithea_cli_base as cli_base | |
28 | from kallithea.model.db import * |
|
28 | from kallithea.model.db import * # these names will be directly available in the IPython shell | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | @cli_base.register_command(config_file_initialize_app=True) |
|
31 | @cli_base.register_command(config_file_initialize_app=True) |
@@ -34,7 +34,7 b' from kallithea.model.repo_group import R' | |||||
34 | from kallithea.model.scm import ScmModel |
|
34 | from kallithea.model.scm import ScmModel | |
35 | from kallithea.model.user import UserModel |
|
35 | from kallithea.model.user import UserModel | |
36 | from kallithea.model.user_group import UserGroupModel |
|
36 | from kallithea.model.user_group import UserGroupModel | |
37 |
from kallithea.tests |
|
37 | from kallithea.tests import base | |
38 | from kallithea.tests.fixture import Fixture |
|
38 | from kallithea.tests.fixture import Fixture | |
39 |
|
39 | |||
40 |
|
40 | |||
@@ -75,15 +75,15 b' def api_call(test_obj, params):' | |||||
75 |
|
75 | |||
76 | ## helpers |
|
76 | ## helpers | |
77 | def make_user_group(name=TEST_USER_GROUP): |
|
77 | def make_user_group(name=TEST_USER_GROUP): | |
78 | gr = fixture.create_user_group(name, cur_user=TEST_USER_ADMIN_LOGIN) |
|
78 | gr = fixture.create_user_group(name, cur_user=base.TEST_USER_ADMIN_LOGIN) | |
79 | UserGroupModel().add_user_to_group(user_group=gr, |
|
79 | UserGroupModel().add_user_to_group(user_group=gr, | |
80 | user=TEST_USER_ADMIN_LOGIN) |
|
80 | user=base.TEST_USER_ADMIN_LOGIN) | |
81 | Session().commit() |
|
81 | Session().commit() | |
82 | return gr |
|
82 | return gr | |
83 |
|
83 | |||
84 |
|
84 | |||
85 | def make_repo_group(name=TEST_REPO_GROUP): |
|
85 | def make_repo_group(name=TEST_REPO_GROUP): | |
86 | gr = fixture.create_repo_group(name, cur_user=TEST_USER_ADMIN_LOGIN) |
|
86 | gr = fixture.create_repo_group(name, cur_user=base.TEST_USER_ADMIN_LOGIN) | |
87 | Session().commit() |
|
87 | Session().commit() | |
88 | return gr |
|
88 | return gr | |
89 |
|
89 | |||
@@ -94,7 +94,7 b' class _BaseTestApi(object):' | |||||
94 |
|
94 | |||
95 | @classmethod |
|
95 | @classmethod | |
96 | def setup_class(cls): |
|
96 | def setup_class(cls): | |
97 | cls.usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
97 | cls.usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
98 | cls.apikey = cls.usr.api_key |
|
98 | cls.apikey = cls.usr.api_key | |
99 | cls.test_user = UserModel().create_or_update( |
|
99 | cls.test_user = UserModel().create_or_update( | |
100 | username='test-api', |
|
100 | username='test-api', | |
@@ -230,10 +230,10 b' class _BaseTestApi(object):' | |||||
230 |
|
230 | |||
231 | def test_api_get_user(self): |
|
231 | def test_api_get_user(self): | |
232 | id_, params = _build_data(self.apikey, 'get_user', |
|
232 | id_, params = _build_data(self.apikey, 'get_user', | |
233 | userid=TEST_USER_ADMIN_LOGIN) |
|
233 | userid=base.TEST_USER_ADMIN_LOGIN) | |
234 | response = api_call(self, params) |
|
234 | response = api_call(self, params) | |
235 |
|
235 | |||
236 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
236 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
237 | ret = usr.get_api_data() |
|
237 | ret = usr.get_api_data() | |
238 | ret['permissions'] = AuthUser(dbuser=usr).permissions |
|
238 | ret['permissions'] = AuthUser(dbuser=usr).permissions | |
239 |
|
239 | |||
@@ -252,7 +252,7 b' class _BaseTestApi(object):' | |||||
252 | id_, params = _build_data(self.apikey, 'get_user') |
|
252 | id_, params = _build_data(self.apikey, 'get_user') | |
253 | response = api_call(self, params) |
|
253 | response = api_call(self, params) | |
254 |
|
254 | |||
255 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
255 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
256 | ret = usr.get_api_data() |
|
256 | ret = usr.get_api_data() | |
257 | ret['permissions'] = AuthUser(dbuser=usr).permissions |
|
257 | ret['permissions'] = AuthUser(dbuser=usr).permissions | |
258 |
|
258 | |||
@@ -394,22 +394,22 b' class _BaseTestApi(object):' | |||||
394 |
|
394 | |||
395 | def test_api_create_existing_user(self): |
|
395 | def test_api_create_existing_user(self): | |
396 | id_, params = _build_data(self.apikey, 'create_user', |
|
396 | id_, params = _build_data(self.apikey, 'create_user', | |
397 | username=TEST_USER_ADMIN_LOGIN, |
|
397 | username=base.TEST_USER_ADMIN_LOGIN, | |
398 | email='test@example.com', |
|
398 | email='test@example.com', | |
399 | password='trololo') |
|
399 | password='trololo') | |
400 | response = api_call(self, params) |
|
400 | response = api_call(self, params) | |
401 |
|
401 | |||
402 | expected = "user `%s` already exist" % TEST_USER_ADMIN_LOGIN |
|
402 | expected = "user `%s` already exist" % base.TEST_USER_ADMIN_LOGIN | |
403 | self._compare_error(id_, expected, given=response.body) |
|
403 | self._compare_error(id_, expected, given=response.body) | |
404 |
|
404 | |||
405 | def test_api_create_user_with_existing_email(self): |
|
405 | def test_api_create_user_with_existing_email(self): | |
406 | id_, params = _build_data(self.apikey, 'create_user', |
|
406 | id_, params = _build_data(self.apikey, 'create_user', | |
407 | username=TEST_USER_ADMIN_LOGIN + 'new', |
|
407 | username=base.TEST_USER_ADMIN_LOGIN + 'new', | |
408 | email=TEST_USER_REGULAR_EMAIL, |
|
408 | email=base.TEST_USER_REGULAR_EMAIL, | |
409 | password='trololo') |
|
409 | password='trololo') | |
410 | response = api_call(self, params) |
|
410 | response = api_call(self, params) | |
411 |
|
411 | |||
412 | expected = "email `%s` already exist" % TEST_USER_REGULAR_EMAIL |
|
412 | expected = "email `%s` already exist" % base.TEST_USER_REGULAR_EMAIL | |
413 | self._compare_error(id_, expected, given=response.body) |
|
413 | self._compare_error(id_, expected, given=response.body) | |
414 |
|
414 | |||
415 | def test_api_create_user(self): |
|
415 | def test_api_create_user(self): | |
@@ -525,7 +525,7 b' class _BaseTestApi(object):' | |||||
525 | expected = ret |
|
525 | expected = ret | |
526 | self._compare_error(id_, expected, given=response.body) |
|
526 | self._compare_error(id_, expected, given=response.body) | |
527 |
|
527 | |||
528 | @parametrize('name,expected', [ |
|
528 | @base.parametrize('name,expected', [ | |
529 | ('firstname', 'new_username'), |
|
529 | ('firstname', 'new_username'), | |
530 | ('lastname', 'new_username'), |
|
530 | ('lastname', 'new_username'), | |
531 | ('email', 'new_username'), |
|
531 | ('email', 'new_username'), | |
@@ -558,22 +558,22 b' class _BaseTestApi(object):' | |||||
558 | self._compare_ok(id_, expected, given=response.body) |
|
558 | self._compare_ok(id_, expected, given=response.body) | |
559 |
|
559 | |||
560 | def test_api_update_user_no_changed_params(self): |
|
560 | def test_api_update_user_no_changed_params(self): | |
561 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
561 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
562 | ret = jsonify(usr.get_api_data()) |
|
562 | ret = jsonify(usr.get_api_data()) | |
563 | id_, params = _build_data(self.apikey, 'update_user', |
|
563 | id_, params = _build_data(self.apikey, 'update_user', | |
564 | userid=TEST_USER_ADMIN_LOGIN) |
|
564 | userid=base.TEST_USER_ADMIN_LOGIN) | |
565 |
|
565 | |||
566 | response = api_call(self, params) |
|
566 | response = api_call(self, params) | |
567 | ret = { |
|
567 | ret = { | |
568 | 'msg': 'updated user ID:%s %s' % ( |
|
568 | 'msg': 'updated user ID:%s %s' % ( | |
569 | usr.user_id, TEST_USER_ADMIN_LOGIN), |
|
569 | usr.user_id, base.TEST_USER_ADMIN_LOGIN), | |
570 | 'user': ret |
|
570 | 'user': ret | |
571 | } |
|
571 | } | |
572 | expected = ret |
|
572 | expected = ret | |
573 | self._compare_ok(id_, expected, given=response.body) |
|
573 | self._compare_ok(id_, expected, given=response.body) | |
574 |
|
574 | |||
575 | def test_api_update_user_by_user_id(self): |
|
575 | def test_api_update_user_by_user_id(self): | |
576 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
576 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
577 | ret = jsonify(usr.get_api_data()) |
|
577 | ret = jsonify(usr.get_api_data()) | |
578 | id_, params = _build_data(self.apikey, 'update_user', |
|
578 | id_, params = _build_data(self.apikey, 'update_user', | |
579 | userid=usr.user_id) |
|
579 | userid=usr.user_id) | |
@@ -581,7 +581,7 b' class _BaseTestApi(object):' | |||||
581 | response = api_call(self, params) |
|
581 | response = api_call(self, params) | |
582 | ret = { |
|
582 | ret = { | |
583 | 'msg': 'updated user ID:%s %s' % ( |
|
583 | 'msg': 'updated user ID:%s %s' % ( | |
584 | usr.user_id, TEST_USER_ADMIN_LOGIN), |
|
584 | usr.user_id, base.TEST_USER_ADMIN_LOGIN), | |
585 | 'user': ret |
|
585 | 'user': ret | |
586 | } |
|
586 | } | |
587 | expected = ret |
|
587 | expected = ret | |
@@ -598,7 +598,7 b' class _BaseTestApi(object):' | |||||
598 |
|
598 | |||
599 | @mock.patch.object(UserModel, 'update_user', crash) |
|
599 | @mock.patch.object(UserModel, 'update_user', crash) | |
600 | def test_api_update_user_when_exception_happens(self): |
|
600 | def test_api_update_user_when_exception_happens(self): | |
601 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
601 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
602 | ret = jsonify(usr.get_api_data()) |
|
602 | ret = jsonify(usr.get_api_data()) | |
603 | id_, params = _build_data(self.apikey, 'update_user', |
|
603 | id_, params = _build_data(self.apikey, 'update_user', | |
604 | userid=usr.user_id) |
|
604 | userid=usr.user_id) | |
@@ -658,7 +658,7 b' class _BaseTestApi(object):' | |||||
658 | assert u"v0.2.0" in response.json[u'result'][u'tags'] |
|
658 | assert u"v0.2.0" in response.json[u'result'][u'tags'] | |
659 | assert u'pull_requests' in response.json[u'result'] |
|
659 | assert u'pull_requests' in response.json[u'result'] | |
660 |
|
660 | |||
661 | @parametrize('grant_perm', [ |
|
661 | @base.parametrize('grant_perm', [ | |
662 | ('repository.admin'), |
|
662 | ('repository.admin'), | |
663 | ('repository.write'), |
|
663 | ('repository.write'), | |
664 | ('repository.read'), |
|
664 | ('repository.read'), | |
@@ -755,7 +755,7 b' class _BaseTestApi(object):' | |||||
755 |
|
755 | |||
756 | self._compare_ok(id_, expected, given=response.body) |
|
756 | self._compare_ok(id_, expected, given=response.body) | |
757 |
|
757 | |||
758 | @parametrize('name,ret_type', [ |
|
758 | @base.parametrize('name,ret_type', [ | |
759 | ('all', 'all'), |
|
759 | ('all', 'all'), | |
760 | ('dirs', 'dirs'), |
|
760 | ('dirs', 'dirs'), | |
761 | ('files', 'files'), |
|
761 | ('files', 'files'), | |
@@ -810,7 +810,7 b' class _BaseTestApi(object):' | |||||
810 | % (','.join(sorted(['files', 'dirs', 'all'])))) |
|
810 | % (','.join(sorted(['files', 'dirs', 'all'])))) | |
811 | self._compare_error(id_, expected, given=response.body) |
|
811 | self._compare_error(id_, expected, given=response.body) | |
812 |
|
812 | |||
813 | @parametrize('name,ret_type,grant_perm', [ |
|
813 | @base.parametrize('name,ret_type,grant_perm', [ | |
814 | ('all', 'all', 'repository.write'), |
|
814 | ('all', 'all', 'repository.write'), | |
815 | ('dirs', 'dirs', 'repository.admin'), |
|
815 | ('dirs', 'dirs', 'repository.admin'), | |
816 | ('files', 'files', 'repository.read'), |
|
816 | ('files', 'files', 'repository.read'), | |
@@ -841,7 +841,7 b' class _BaseTestApi(object):' | |||||
841 | repo_name = u'api-repo' |
|
841 | repo_name = u'api-repo' | |
842 | id_, params = _build_data(self.apikey, 'create_repo', |
|
842 | id_, params = _build_data(self.apikey, 'create_repo', | |
843 | repo_name=repo_name, |
|
843 | repo_name=repo_name, | |
844 | owner=TEST_USER_ADMIN_LOGIN, |
|
844 | owner=base.TEST_USER_ADMIN_LOGIN, | |
845 | repo_type=self.REPO_TYPE, |
|
845 | repo_type=self.REPO_TYPE, | |
846 | ) |
|
846 | ) | |
847 | response = api_call(self, params) |
|
847 | response = api_call(self, params) | |
@@ -857,7 +857,7 b' class _BaseTestApi(object):' | |||||
857 | self._compare_ok(id_, expected, given=response.body) |
|
857 | self._compare_ok(id_, expected, given=response.body) | |
858 | fixture.destroy_repo(repo_name) |
|
858 | fixture.destroy_repo(repo_name) | |
859 |
|
859 | |||
860 | @parametrize('repo_name', [ |
|
860 | @base.parametrize('repo_name', [ | |
861 | u'', |
|
861 | u'', | |
862 | u'.', |
|
862 | u'.', | |
863 | u'..', |
|
863 | u'..', | |
@@ -868,7 +868,7 b' class _BaseTestApi(object):' | |||||
868 | def test_api_create_repo_bad_names(self, repo_name): |
|
868 | def test_api_create_repo_bad_names(self, repo_name): | |
869 | id_, params = _build_data(self.apikey, 'create_repo', |
|
869 | id_, params = _build_data(self.apikey, 'create_repo', | |
870 | repo_name=repo_name, |
|
870 | repo_name=repo_name, | |
871 | owner=TEST_USER_ADMIN_LOGIN, |
|
871 | owner=base.TEST_USER_ADMIN_LOGIN, | |
872 | repo_type=self.REPO_TYPE, |
|
872 | repo_type=self.REPO_TYPE, | |
873 | ) |
|
873 | ) | |
874 | response = api_call(self, params) |
|
874 | response = api_call(self, params) | |
@@ -883,11 +883,11 b' class _BaseTestApi(object):' | |||||
883 | def test_api_create_repo_clone_uri_local(self): |
|
883 | def test_api_create_repo_clone_uri_local(self): | |
884 | # cloning from local repos was a mis-feature - it would bypass access control |
|
884 | # cloning from local repos was a mis-feature - it would bypass access control | |
885 | # TODO: introduce other test coverage of actual remote cloning |
|
885 | # TODO: introduce other test coverage of actual remote cloning | |
886 | clone_uri = os.path.join(TESTS_TMP_PATH, self.REPO) |
|
886 | clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO) | |
887 | repo_name = u'api-repo' |
|
887 | repo_name = u'api-repo' | |
888 | id_, params = _build_data(self.apikey, 'create_repo', |
|
888 | id_, params = _build_data(self.apikey, 'create_repo', | |
889 | repo_name=repo_name, |
|
889 | repo_name=repo_name, | |
890 | owner=TEST_USER_ADMIN_LOGIN, |
|
890 | owner=base.TEST_USER_ADMIN_LOGIN, | |
891 | repo_type=self.REPO_TYPE, |
|
891 | repo_type=self.REPO_TYPE, | |
892 | clone_uri=clone_uri, |
|
892 | clone_uri=clone_uri, | |
893 | ) |
|
893 | ) | |
@@ -903,7 +903,7 b' class _BaseTestApi(object):' | |||||
903 | # repo creation can no longer also create repo group |
|
903 | # repo creation can no longer also create repo group | |
904 | id_, params = _build_data(self.apikey, 'create_repo', |
|
904 | id_, params = _build_data(self.apikey, 'create_repo', | |
905 | repo_name=repo_name, |
|
905 | repo_name=repo_name, | |
906 | owner=TEST_USER_ADMIN_LOGIN, |
|
906 | owner=base.TEST_USER_ADMIN_LOGIN, | |
907 | repo_type=self.REPO_TYPE,) |
|
907 | repo_type=self.REPO_TYPE,) | |
908 | response = api_call(self, params) |
|
908 | response = api_call(self, params) | |
909 | expected = u'repo group `%s` not found' % repo_group_name |
|
909 | expected = u'repo group `%s` not found' % repo_group_name | |
@@ -916,7 +916,7 b' class _BaseTestApi(object):' | |||||
916 |
|
916 | |||
917 | id_, params = _build_data(self.apikey, 'create_repo', |
|
917 | id_, params = _build_data(self.apikey, 'create_repo', | |
918 | repo_name=repo_name, |
|
918 | repo_name=repo_name, | |
919 | owner=TEST_USER_ADMIN_LOGIN, |
|
919 | owner=base.TEST_USER_ADMIN_LOGIN, | |
920 | repo_type=self.REPO_TYPE,) |
|
920 | repo_type=self.REPO_TYPE,) | |
921 | response = api_call(self, params) |
|
921 | response = api_call(self, params) | |
922 | expected = { |
|
922 | expected = { | |
@@ -1036,7 +1036,7 b' class _BaseTestApi(object):' | |||||
1036 | repo_name = self.REPO |
|
1036 | repo_name = self.REPO | |
1037 | id_, params = _build_data(self.apikey, 'create_repo', |
|
1037 | id_, params = _build_data(self.apikey, 'create_repo', | |
1038 | repo_name=repo_name, |
|
1038 | repo_name=repo_name, | |
1039 | owner=TEST_USER_ADMIN_LOGIN, |
|
1039 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1040 | repo_type=self.REPO_TYPE,) |
|
1040 | repo_type=self.REPO_TYPE,) | |
1041 | response = api_call(self, params) |
|
1041 | response = api_call(self, params) | |
1042 | expected = "repo `%s` already exist" % repo_name |
|
1042 | expected = "repo `%s` already exist" % repo_name | |
@@ -1048,7 +1048,7 b' class _BaseTestApi(object):' | |||||
1048 | repo_name = '%s/%s' % (group_name, 'could-be-outside') |
|
1048 | repo_name = '%s/%s' % (group_name, 'could-be-outside') | |
1049 | id_, params = _build_data(self.apikey, 'create_repo', |
|
1049 | id_, params = _build_data(self.apikey, 'create_repo', | |
1050 | repo_name=repo_name, |
|
1050 | repo_name=repo_name, | |
1051 | owner=TEST_USER_ADMIN_LOGIN, |
|
1051 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1052 | repo_type=self.REPO_TYPE,) |
|
1052 | repo_type=self.REPO_TYPE,) | |
1053 | response = api_call(self, params) |
|
1053 | response = api_call(self, params) | |
1054 | expected = u'repo group `%s` not found' % group_name |
|
1054 | expected = u'repo group `%s` not found' % group_name | |
@@ -1060,14 +1060,14 b' class _BaseTestApi(object):' | |||||
1060 | repo_name = u'api-repo' |
|
1060 | repo_name = u'api-repo' | |
1061 | id_, params = _build_data(self.apikey, 'create_repo', |
|
1061 | id_, params = _build_data(self.apikey, 'create_repo', | |
1062 | repo_name=repo_name, |
|
1062 | repo_name=repo_name, | |
1063 | owner=TEST_USER_ADMIN_LOGIN, |
|
1063 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1064 | repo_type=self.REPO_TYPE,) |
|
1064 | repo_type=self.REPO_TYPE,) | |
1065 | response = api_call(self, params) |
|
1065 | response = api_call(self, params) | |
1066 | expected = 'failed to create repository `%s`' % repo_name |
|
1066 | expected = 'failed to create repository `%s`' % repo_name | |
1067 | self._compare_error(id_, expected, given=response.body) |
|
1067 | self._compare_error(id_, expected, given=response.body) | |
1068 |
|
1068 | |||
1069 | @parametrize('changing_attr,updates', [ |
|
1069 | @base.parametrize('changing_attr,updates', [ | |
1070 | ('owner', {'owner': TEST_USER_REGULAR_LOGIN}), |
|
1070 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1071 | ('description', {'description': u'new description'}), |
|
1071 | ('description', {'description': u'new description'}), | |
1072 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1072 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1073 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control |
|
1073 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control | |
@@ -1106,8 +1106,8 b' class _BaseTestApi(object):' | |||||
1106 | if changing_attr == 'repo_group': |
|
1106 | if changing_attr == 'repo_group': | |
1107 | fixture.destroy_repo_group(updates['group']) |
|
1107 | fixture.destroy_repo_group(updates['group']) | |
1108 |
|
1108 | |||
1109 | @parametrize('changing_attr,updates', [ |
|
1109 | @base.parametrize('changing_attr,updates', [ | |
1110 | ('owner', {'owner': TEST_USER_REGULAR_LOGIN}), |
|
1110 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1111 | ('description', {'description': u'new description'}), |
|
1111 | ('description', {'description': u'new description'}), | |
1112 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1112 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1113 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control |
|
1113 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control | |
@@ -1180,7 +1180,7 b' class _BaseTestApi(object):' | |||||
1180 | repo_name = u'api_update_me' |
|
1180 | repo_name = u'api_update_me' | |
1181 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
1181 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
1182 | id_, params = _build_data(self.apikey, 'update_repo', |
|
1182 | id_, params = _build_data(self.apikey, 'update_repo', | |
1183 | repoid=repo_name, owner=TEST_USER_ADMIN_LOGIN,) |
|
1183 | repoid=repo_name, owner=base.TEST_USER_ADMIN_LOGIN,) | |
1184 | response = api_call(self, params) |
|
1184 | response = api_call(self, params) | |
1185 | try: |
|
1185 | try: | |
1186 | expected = 'failed to update repo `%s`' % repo_name |
|
1186 | expected = 'failed to update repo `%s`' % repo_name | |
@@ -1237,7 +1237,7 b' class _BaseTestApi(object):' | |||||
1237 | RepoModel().grant_user_permission(repo=repo_name, |
|
1237 | RepoModel().grant_user_permission(repo=repo_name, | |
1238 | user=self.TEST_USER_LOGIN, |
|
1238 | user=self.TEST_USER_LOGIN, | |
1239 | perm='repository.admin') |
|
1239 | perm='repository.admin') | |
1240 | updates = {'owner': TEST_USER_ADMIN_LOGIN} |
|
1240 | updates = {'owner': base.TEST_USER_ADMIN_LOGIN} | |
1241 | id_, params = _build_data(self.apikey_regular, 'update_repo', |
|
1241 | id_, params = _build_data(self.apikey_regular, 'update_repo', | |
1242 | repoid=repo_name, **updates) |
|
1242 | repoid=repo_name, **updates) | |
1243 | response = api_call(self, params) |
|
1243 | response = api_call(self, params) | |
@@ -1314,7 +1314,7 b' class _BaseTestApi(object):' | |||||
1314 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1314 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1315 | repoid=self.REPO, |
|
1315 | repoid=self.REPO, | |
1316 | fork_name=fork_name, |
|
1316 | fork_name=fork_name, | |
1317 | owner=TEST_USER_ADMIN_LOGIN, |
|
1317 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1318 | ) |
|
1318 | ) | |
1319 | response = api_call(self, params) |
|
1319 | response = api_call(self, params) | |
1320 |
|
1320 | |||
@@ -1328,7 +1328,7 b' class _BaseTestApi(object):' | |||||
1328 | self._compare_ok(id_, expected, given=response.body) |
|
1328 | self._compare_ok(id_, expected, given=response.body) | |
1329 | fixture.destroy_repo(fork_name) |
|
1329 | fixture.destroy_repo(fork_name) | |
1330 |
|
1330 | |||
1331 | @parametrize('fork_name', [ |
|
1331 | @base.parametrize('fork_name', [ | |
1332 | u'api-repo-fork', |
|
1332 | u'api-repo-fork', | |
1333 | u'%s/api-repo-fork' % TEST_REPO_GROUP, |
|
1333 | u'%s/api-repo-fork' % TEST_REPO_GROUP, | |
1334 | ]) |
|
1334 | ]) | |
@@ -1354,7 +1354,7 b' class _BaseTestApi(object):' | |||||
1354 | id_, params = _build_data(self.apikey_regular, 'fork_repo', |
|
1354 | id_, params = _build_data(self.apikey_regular, 'fork_repo', | |
1355 | repoid=self.REPO, |
|
1355 | repoid=self.REPO, | |
1356 | fork_name=fork_name, |
|
1356 | fork_name=fork_name, | |
1357 | owner=TEST_USER_ADMIN_LOGIN, |
|
1357 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1358 | ) |
|
1358 | ) | |
1359 | response = api_call(self, params) |
|
1359 | response = api_call(self, params) | |
1360 | expected = 'Only Kallithea admin can specify `owner` param' |
|
1360 | expected = 'Only Kallithea admin can specify `owner` param' | |
@@ -1380,7 +1380,7 b' class _BaseTestApi(object):' | |||||
1380 | perm='repository.read') |
|
1380 | perm='repository.read') | |
1381 | fixture.destroy_repo(fork_name) |
|
1381 | fixture.destroy_repo(fork_name) | |
1382 |
|
1382 | |||
1383 | @parametrize('name,perm', [ |
|
1383 | @base.parametrize('name,perm', [ | |
1384 | ('read', 'repository.read'), |
|
1384 | ('read', 'repository.read'), | |
1385 | ('write', 'repository.write'), |
|
1385 | ('write', 'repository.write'), | |
1386 | ('admin', 'repository.admin'), |
|
1386 | ('admin', 'repository.admin'), | |
@@ -1425,7 +1425,7 b' class _BaseTestApi(object):' | |||||
1425 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1425 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1426 | repoid=self.REPO, |
|
1426 | repoid=self.REPO, | |
1427 | fork_name=fork_name, |
|
1427 | fork_name=fork_name, | |
1428 | owner=TEST_USER_ADMIN_LOGIN, |
|
1428 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1429 | ) |
|
1429 | ) | |
1430 | response = api_call(self, params) |
|
1430 | response = api_call(self, params) | |
1431 |
|
1431 | |||
@@ -1440,7 +1440,7 b' class _BaseTestApi(object):' | |||||
1440 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1440 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1441 | repoid=self.REPO, |
|
1441 | repoid=self.REPO, | |
1442 | fork_name=fork_name, |
|
1442 | fork_name=fork_name, | |
1443 | owner=TEST_USER_ADMIN_LOGIN, |
|
1443 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1444 | ) |
|
1444 | ) | |
1445 | response = api_call(self, params) |
|
1445 | response = api_call(self, params) | |
1446 |
|
1446 | |||
@@ -1453,7 +1453,7 b' class _BaseTestApi(object):' | |||||
1453 | id_, params = _build_data(self.apikey, 'fork_repo', |
|
1453 | id_, params = _build_data(self.apikey, 'fork_repo', | |
1454 | repoid=self.REPO, |
|
1454 | repoid=self.REPO, | |
1455 | fork_name=fork_name, |
|
1455 | fork_name=fork_name, | |
1456 | owner=TEST_USER_ADMIN_LOGIN, |
|
1456 | owner=base.TEST_USER_ADMIN_LOGIN, | |
1457 | ) |
|
1457 | ) | |
1458 | response = api_call(self, params) |
|
1458 | response = api_call(self, params) | |
1459 |
|
1459 | |||
@@ -1529,10 +1529,10 b' class _BaseTestApi(object):' | |||||
1529 | expected = 'failed to create group `%s`' % group_name |
|
1529 | expected = 'failed to create group `%s`' % group_name | |
1530 | self._compare_error(id_, expected, given=response.body) |
|
1530 | self._compare_error(id_, expected, given=response.body) | |
1531 |
|
1531 | |||
1532 | @parametrize('changing_attr,updates', [ |
|
1532 | @base.parametrize('changing_attr,updates', [ | |
1533 | ('group_name', {'group_name': u'new_group_name'}), |
|
1533 | ('group_name', {'group_name': u'new_group_name'}), | |
1534 | ('group_name', {'group_name': u'test_group_for_update'}), |
|
1534 | ('group_name', {'group_name': u'test_group_for_update'}), | |
1535 | ('owner', {'owner': TEST_USER_REGULAR_LOGIN}), |
|
1535 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1536 | ('active', {'active': False}), |
|
1536 | ('active', {'active': False}), | |
1537 | ('active', {'active': True}), |
|
1537 | ('active', {'active': True}), | |
1538 | ]) |
|
1538 | ]) | |
@@ -1574,11 +1574,11 b' class _BaseTestApi(object):' | |||||
1574 | try: |
|
1574 | try: | |
1575 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', |
|
1575 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', | |
1576 | usergroupid=gr_name, |
|
1576 | usergroupid=gr_name, | |
1577 | userid=TEST_USER_ADMIN_LOGIN) |
|
1577 | userid=base.TEST_USER_ADMIN_LOGIN) | |
1578 | response = api_call(self, params) |
|
1578 | response = api_call(self, params) | |
1579 | expected = { |
|
1579 | expected = { | |
1580 | 'msg': 'added member `%s` to user group `%s`' % ( |
|
1580 | 'msg': 'added member `%s` to user group `%s`' % ( | |
1581 | TEST_USER_ADMIN_LOGIN, gr_name), |
|
1581 | base.TEST_USER_ADMIN_LOGIN, gr_name), | |
1582 | 'success': True |
|
1582 | 'success': True | |
1583 | } |
|
1583 | } | |
1584 | self._compare_ok(id_, expected, given=response.body) |
|
1584 | self._compare_ok(id_, expected, given=response.body) | |
@@ -1588,7 +1588,7 b' class _BaseTestApi(object):' | |||||
1588 | def test_api_add_user_to_user_group_that_doesnt_exist(self): |
|
1588 | def test_api_add_user_to_user_group_that_doesnt_exist(self): | |
1589 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', |
|
1589 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', | |
1590 | usergroupid='false-group', |
|
1590 | usergroupid='false-group', | |
1591 | userid=TEST_USER_ADMIN_LOGIN) |
|
1591 | userid=base.TEST_USER_ADMIN_LOGIN) | |
1592 | response = api_call(self, params) |
|
1592 | response = api_call(self, params) | |
1593 |
|
1593 | |||
1594 | expected = 'user group `%s` does not exist' % 'false-group' |
|
1594 | expected = 'user group `%s` does not exist' % 'false-group' | |
@@ -1601,7 +1601,7 b' class _BaseTestApi(object):' | |||||
1601 | try: |
|
1601 | try: | |
1602 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', |
|
1602 | id_, params = _build_data(self.apikey, 'add_user_to_user_group', | |
1603 | usergroupid=gr_name, |
|
1603 | usergroupid=gr_name, | |
1604 | userid=TEST_USER_ADMIN_LOGIN) |
|
1604 | userid=base.TEST_USER_ADMIN_LOGIN) | |
1605 | response = api_call(self, params) |
|
1605 | response = api_call(self, params) | |
1606 | expected = 'failed to add member to user group `%s`' % gr_name |
|
1606 | expected = 'failed to add member to user group `%s`' % gr_name | |
1607 | self._compare_error(id_, expected, given=response.body) |
|
1607 | self._compare_error(id_, expected, given=response.body) | |
@@ -1611,16 +1611,16 b' class _BaseTestApi(object):' | |||||
1611 | def test_api_remove_user_from_user_group(self): |
|
1611 | def test_api_remove_user_from_user_group(self): | |
1612 | gr_name = u'test_group_3' |
|
1612 | gr_name = u'test_group_3' | |
1613 | gr = fixture.create_user_group(gr_name) |
|
1613 | gr = fixture.create_user_group(gr_name) | |
1614 | UserGroupModel().add_user_to_group(gr, user=TEST_USER_ADMIN_LOGIN) |
|
1614 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) | |
1615 | Session().commit() |
|
1615 | Session().commit() | |
1616 | try: |
|
1616 | try: | |
1617 | id_, params = _build_data(self.apikey, 'remove_user_from_user_group', |
|
1617 | id_, params = _build_data(self.apikey, 'remove_user_from_user_group', | |
1618 | usergroupid=gr_name, |
|
1618 | usergroupid=gr_name, | |
1619 | userid=TEST_USER_ADMIN_LOGIN) |
|
1619 | userid=base.TEST_USER_ADMIN_LOGIN) | |
1620 | response = api_call(self, params) |
|
1620 | response = api_call(self, params) | |
1621 | expected = { |
|
1621 | expected = { | |
1622 | 'msg': 'removed member `%s` from user group `%s`' % ( |
|
1622 | 'msg': 'removed member `%s` from user group `%s`' % ( | |
1623 | TEST_USER_ADMIN_LOGIN, gr_name |
|
1623 | base.TEST_USER_ADMIN_LOGIN, gr_name | |
1624 | ), |
|
1624 | ), | |
1625 | 'success': True} |
|
1625 | 'success': True} | |
1626 | self._compare_ok(id_, expected, given=response.body) |
|
1626 | self._compare_ok(id_, expected, given=response.body) | |
@@ -1631,12 +1631,12 b' class _BaseTestApi(object):' | |||||
1631 | def test_api_remove_user_from_user_group_exception_occurred(self): |
|
1631 | def test_api_remove_user_from_user_group_exception_occurred(self): | |
1632 | gr_name = u'test_group_3' |
|
1632 | gr_name = u'test_group_3' | |
1633 | gr = fixture.create_user_group(gr_name) |
|
1633 | gr = fixture.create_user_group(gr_name) | |
1634 | UserGroupModel().add_user_to_group(gr, user=TEST_USER_ADMIN_LOGIN) |
|
1634 | UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN) | |
1635 | Session().commit() |
|
1635 | Session().commit() | |
1636 | try: |
|
1636 | try: | |
1637 | id_, params = _build_data(self.apikey, 'remove_user_from_user_group', |
|
1637 | id_, params = _build_data(self.apikey, 'remove_user_from_user_group', | |
1638 | usergroupid=gr_name, |
|
1638 | usergroupid=gr_name, | |
1639 | userid=TEST_USER_ADMIN_LOGIN) |
|
1639 | userid=base.TEST_USER_ADMIN_LOGIN) | |
1640 | response = api_call(self, params) |
|
1640 | response = api_call(self, params) | |
1641 | expected = 'failed to remove member from user group `%s`' % gr_name |
|
1641 | expected = 'failed to remove member from user group `%s`' % gr_name | |
1642 | self._compare_error(id_, expected, given=response.body) |
|
1642 | self._compare_error(id_, expected, given=response.body) | |
@@ -1693,7 +1693,7 b' class _BaseTestApi(object):' | |||||
1693 | finally: |
|
1693 | finally: | |
1694 | fixture.destroy_user_group(gr_name) |
|
1694 | fixture.destroy_user_group(gr_name) | |
1695 |
|
1695 | |||
1696 | @parametrize('name,perm', [ |
|
1696 | @base.parametrize('name,perm', [ | |
1697 | ('none', 'repository.none'), |
|
1697 | ('none', 'repository.none'), | |
1698 | ('read', 'repository.read'), |
|
1698 | ('read', 'repository.read'), | |
1699 | ('write', 'repository.write'), |
|
1699 | ('write', 'repository.write'), | |
@@ -1703,13 +1703,13 b' class _BaseTestApi(object):' | |||||
1703 | id_, params = _build_data(self.apikey, |
|
1703 | id_, params = _build_data(self.apikey, | |
1704 | 'grant_user_permission', |
|
1704 | 'grant_user_permission', | |
1705 | repoid=self.REPO, |
|
1705 | repoid=self.REPO, | |
1706 | userid=TEST_USER_ADMIN_LOGIN, |
|
1706 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1707 | perm=perm) |
|
1707 | perm=perm) | |
1708 | response = api_call(self, params) |
|
1708 | response = api_call(self, params) | |
1709 |
|
1709 | |||
1710 | ret = { |
|
1710 | ret = { | |
1711 | 'msg': 'Granted perm: `%s` for user: `%s` in repo: `%s`' % ( |
|
1711 | 'msg': 'Granted perm: `%s` for user: `%s` in repo: `%s`' % ( | |
1712 | perm, TEST_USER_ADMIN_LOGIN, self.REPO |
|
1712 | perm, base.TEST_USER_ADMIN_LOGIN, self.REPO | |
1713 | ), |
|
1713 | ), | |
1714 | 'success': True |
|
1714 | 'success': True | |
1715 | } |
|
1715 | } | |
@@ -1721,7 +1721,7 b' class _BaseTestApi(object):' | |||||
1721 | id_, params = _build_data(self.apikey, |
|
1721 | id_, params = _build_data(self.apikey, | |
1722 | 'grant_user_permission', |
|
1722 | 'grant_user_permission', | |
1723 | repoid=self.REPO, |
|
1723 | repoid=self.REPO, | |
1724 | userid=TEST_USER_ADMIN_LOGIN, |
|
1724 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1725 | perm=perm) |
|
1725 | perm=perm) | |
1726 | response = api_call(self, params) |
|
1726 | response = api_call(self, params) | |
1727 |
|
1727 | |||
@@ -1734,12 +1734,12 b' class _BaseTestApi(object):' | |||||
1734 | id_, params = _build_data(self.apikey, |
|
1734 | id_, params = _build_data(self.apikey, | |
1735 | 'grant_user_permission', |
|
1735 | 'grant_user_permission', | |
1736 | repoid=self.REPO, |
|
1736 | repoid=self.REPO, | |
1737 | userid=TEST_USER_ADMIN_LOGIN, |
|
1737 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1738 | perm=perm) |
|
1738 | perm=perm) | |
1739 | response = api_call(self, params) |
|
1739 | response = api_call(self, params) | |
1740 |
|
1740 | |||
1741 | expected = 'failed to edit permission for user: `%s` in repo: `%s`' % ( |
|
1741 | expected = 'failed to edit permission for user: `%s` in repo: `%s`' % ( | |
1742 | TEST_USER_ADMIN_LOGIN, self.REPO |
|
1742 | base.TEST_USER_ADMIN_LOGIN, self.REPO | |
1743 | ) |
|
1743 | ) | |
1744 | self._compare_error(id_, expected, given=response.body) |
|
1744 | self._compare_error(id_, expected, given=response.body) | |
1745 |
|
1745 | |||
@@ -1747,12 +1747,12 b' class _BaseTestApi(object):' | |||||
1747 | id_, params = _build_data(self.apikey, |
|
1747 | id_, params = _build_data(self.apikey, | |
1748 | 'revoke_user_permission', |
|
1748 | 'revoke_user_permission', | |
1749 | repoid=self.REPO, |
|
1749 | repoid=self.REPO, | |
1750 | userid=TEST_USER_ADMIN_LOGIN, ) |
|
1750 | userid=base.TEST_USER_ADMIN_LOGIN, ) | |
1751 | response = api_call(self, params) |
|
1751 | response = api_call(self, params) | |
1752 |
|
1752 | |||
1753 | expected = { |
|
1753 | expected = { | |
1754 | 'msg': 'Revoked perm for user: `%s` in repo: `%s`' % ( |
|
1754 | 'msg': 'Revoked perm for user: `%s` in repo: `%s`' % ( | |
1755 | TEST_USER_ADMIN_LOGIN, self.REPO |
|
1755 | base.TEST_USER_ADMIN_LOGIN, self.REPO | |
1756 | ), |
|
1756 | ), | |
1757 | 'success': True |
|
1757 | 'success': True | |
1758 | } |
|
1758 | } | |
@@ -1763,15 +1763,15 b' class _BaseTestApi(object):' | |||||
1763 | id_, params = _build_data(self.apikey, |
|
1763 | id_, params = _build_data(self.apikey, | |
1764 | 'revoke_user_permission', |
|
1764 | 'revoke_user_permission', | |
1765 | repoid=self.REPO, |
|
1765 | repoid=self.REPO, | |
1766 | userid=TEST_USER_ADMIN_LOGIN, ) |
|
1766 | userid=base.TEST_USER_ADMIN_LOGIN, ) | |
1767 | response = api_call(self, params) |
|
1767 | response = api_call(self, params) | |
1768 |
|
1768 | |||
1769 | expected = 'failed to edit permission for user: `%s` in repo: `%s`' % ( |
|
1769 | expected = 'failed to edit permission for user: `%s` in repo: `%s`' % ( | |
1770 | TEST_USER_ADMIN_LOGIN, self.REPO |
|
1770 | base.TEST_USER_ADMIN_LOGIN, self.REPO | |
1771 | ) |
|
1771 | ) | |
1772 | self._compare_error(id_, expected, given=response.body) |
|
1772 | self._compare_error(id_, expected, given=response.body) | |
1773 |
|
1773 | |||
1774 | @parametrize('name,perm', [ |
|
1774 | @base.parametrize('name,perm', [ | |
1775 | ('none', 'repository.none'), |
|
1775 | ('none', 'repository.none'), | |
1776 | ('read', 'repository.read'), |
|
1776 | ('read', 'repository.read'), | |
1777 | ('write', 'repository.write'), |
|
1777 | ('write', 'repository.write'), | |
@@ -1853,7 +1853,7 b' class _BaseTestApi(object):' | |||||
1853 | ) |
|
1853 | ) | |
1854 | self._compare_error(id_, expected, given=response.body) |
|
1854 | self._compare_error(id_, expected, given=response.body) | |
1855 |
|
1855 | |||
1856 | @parametrize('name,perm,apply_to_children', [ |
|
1856 | @base.parametrize('name,perm,apply_to_children', [ | |
1857 | ('none', 'group.none', 'none'), |
|
1857 | ('none', 'group.none', 'none'), | |
1858 | ('read', 'group.read', 'none'), |
|
1858 | ('read', 'group.read', 'none'), | |
1859 | ('write', 'group.write', 'none'), |
|
1859 | ('write', 'group.write', 'none'), | |
@@ -1878,20 +1878,20 b' class _BaseTestApi(object):' | |||||
1878 | id_, params = _build_data(self.apikey, |
|
1878 | id_, params = _build_data(self.apikey, | |
1879 | 'grant_user_permission_to_repo_group', |
|
1879 | 'grant_user_permission_to_repo_group', | |
1880 | repogroupid=TEST_REPO_GROUP, |
|
1880 | repogroupid=TEST_REPO_GROUP, | |
1881 | userid=TEST_USER_ADMIN_LOGIN, |
|
1881 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1882 | perm=perm, apply_to_children=apply_to_children) |
|
1882 | perm=perm, apply_to_children=apply_to_children) | |
1883 | response = api_call(self, params) |
|
1883 | response = api_call(self, params) | |
1884 |
|
1884 | |||
1885 | ret = { |
|
1885 | ret = { | |
1886 | 'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % ( |
|
1886 | 'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % ( | |
1887 | perm, apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
1887 | perm, apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
1888 | ), |
|
1888 | ), | |
1889 | 'success': True |
|
1889 | 'success': True | |
1890 | } |
|
1890 | } | |
1891 | expected = ret |
|
1891 | expected = ret | |
1892 | self._compare_ok(id_, expected, given=response.body) |
|
1892 | self._compare_ok(id_, expected, given=response.body) | |
1893 |
|
1893 | |||
1894 | @parametrize('name,perm,apply_to_children,grant_admin,access_ok', [ |
|
1894 | @base.parametrize('name,perm,apply_to_children,grant_admin,access_ok', [ | |
1895 | ('none_fails', 'group.none', 'none', False, False), |
|
1895 | ('none_fails', 'group.none', 'none', False, False), | |
1896 | ('read_fails', 'group.read', 'none', False, False), |
|
1896 | ('read_fails', 'group.read', 'none', False, False), | |
1897 | ('write_fails', 'group.write', 'none', False, False), |
|
1897 | ('write_fails', 'group.write', 'none', False, False), | |
@@ -1914,13 +1914,13 b' class _BaseTestApi(object):' | |||||
1914 | id_, params = _build_data(self.apikey_regular, |
|
1914 | id_, params = _build_data(self.apikey_regular, | |
1915 | 'grant_user_permission_to_repo_group', |
|
1915 | 'grant_user_permission_to_repo_group', | |
1916 | repogroupid=TEST_REPO_GROUP, |
|
1916 | repogroupid=TEST_REPO_GROUP, | |
1917 | userid=TEST_USER_ADMIN_LOGIN, |
|
1917 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1918 | perm=perm, apply_to_children=apply_to_children) |
|
1918 | perm=perm, apply_to_children=apply_to_children) | |
1919 | response = api_call(self, params) |
|
1919 | response = api_call(self, params) | |
1920 | if access_ok: |
|
1920 | if access_ok: | |
1921 | ret = { |
|
1921 | ret = { | |
1922 | 'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % ( |
|
1922 | 'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % ( | |
1923 | perm, apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
1923 | perm, apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
1924 | ), |
|
1924 | ), | |
1925 | 'success': True |
|
1925 | 'success': True | |
1926 | } |
|
1926 | } | |
@@ -1935,7 +1935,7 b' class _BaseTestApi(object):' | |||||
1935 | id_, params = _build_data(self.apikey, |
|
1935 | id_, params = _build_data(self.apikey, | |
1936 | 'grant_user_permission_to_repo_group', |
|
1936 | 'grant_user_permission_to_repo_group', | |
1937 | repogroupid=TEST_REPO_GROUP, |
|
1937 | repogroupid=TEST_REPO_GROUP, | |
1938 | userid=TEST_USER_ADMIN_LOGIN, |
|
1938 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1939 | perm=perm) |
|
1939 | perm=perm) | |
1940 | response = api_call(self, params) |
|
1940 | response = api_call(self, params) | |
1941 |
|
1941 | |||
@@ -1948,16 +1948,16 b' class _BaseTestApi(object):' | |||||
1948 | id_, params = _build_data(self.apikey, |
|
1948 | id_, params = _build_data(self.apikey, | |
1949 | 'grant_user_permission_to_repo_group', |
|
1949 | 'grant_user_permission_to_repo_group', | |
1950 | repogroupid=TEST_REPO_GROUP, |
|
1950 | repogroupid=TEST_REPO_GROUP, | |
1951 | userid=TEST_USER_ADMIN_LOGIN, |
|
1951 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1952 | perm=perm) |
|
1952 | perm=perm) | |
1953 | response = api_call(self, params) |
|
1953 | response = api_call(self, params) | |
1954 |
|
1954 | |||
1955 | expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % ( |
|
1955 | expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % ( | |
1956 | TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
1956 | base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
1957 | ) |
|
1957 | ) | |
1958 | self._compare_error(id_, expected, given=response.body) |
|
1958 | self._compare_error(id_, expected, given=response.body) | |
1959 |
|
1959 | |||
1960 | @parametrize('name,apply_to_children', [ |
|
1960 | @base.parametrize('name,apply_to_children', [ | |
1961 | ('none', 'none'), |
|
1961 | ('none', 'none'), | |
1962 | ('all', 'all'), |
|
1962 | ('all', 'all'), | |
1963 | ('repos', 'repos'), |
|
1963 | ('repos', 'repos'), | |
@@ -1965,26 +1965,26 b' class _BaseTestApi(object):' | |||||
1965 | ]) |
|
1965 | ]) | |
1966 | def test_api_revoke_user_permission_from_repo_group(self, name, apply_to_children): |
|
1966 | def test_api_revoke_user_permission_from_repo_group(self, name, apply_to_children): | |
1967 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, |
|
1967 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, | |
1968 | user=TEST_USER_ADMIN_LOGIN, |
|
1968 | user=base.TEST_USER_ADMIN_LOGIN, | |
1969 | perm='group.read',) |
|
1969 | perm='group.read',) | |
1970 | Session().commit() |
|
1970 | Session().commit() | |
1971 |
|
1971 | |||
1972 | id_, params = _build_data(self.apikey, |
|
1972 | id_, params = _build_data(self.apikey, | |
1973 | 'revoke_user_permission_from_repo_group', |
|
1973 | 'revoke_user_permission_from_repo_group', | |
1974 | repogroupid=TEST_REPO_GROUP, |
|
1974 | repogroupid=TEST_REPO_GROUP, | |
1975 | userid=TEST_USER_ADMIN_LOGIN, |
|
1975 | userid=base.TEST_USER_ADMIN_LOGIN, | |
1976 | apply_to_children=apply_to_children,) |
|
1976 | apply_to_children=apply_to_children,) | |
1977 | response = api_call(self, params) |
|
1977 | response = api_call(self, params) | |
1978 |
|
1978 | |||
1979 | expected = { |
|
1979 | expected = { | |
1980 | 'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % ( |
|
1980 | 'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % ( | |
1981 | apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
1981 | apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
1982 | ), |
|
1982 | ), | |
1983 | 'success': True |
|
1983 | 'success': True | |
1984 | } |
|
1984 | } | |
1985 | self._compare_ok(id_, expected, given=response.body) |
|
1985 | self._compare_ok(id_, expected, given=response.body) | |
1986 |
|
1986 | |||
1987 | @parametrize('name,apply_to_children,grant_admin,access_ok', [ |
|
1987 | @base.parametrize('name,apply_to_children,grant_admin,access_ok', [ | |
1988 | ('none', 'none', False, False), |
|
1988 | ('none', 'none', False, False), | |
1989 | ('all', 'all', False, False), |
|
1989 | ('all', 'all', False, False), | |
1990 | ('repos', 'repos', False, False), |
|
1990 | ('repos', 'repos', False, False), | |
@@ -1999,7 +1999,7 b' class _BaseTestApi(object):' | |||||
1999 | def test_api_revoke_user_permission_from_repo_group_by_regular_user( |
|
1999 | def test_api_revoke_user_permission_from_repo_group_by_regular_user( | |
2000 | self, name, apply_to_children, grant_admin, access_ok): |
|
2000 | self, name, apply_to_children, grant_admin, access_ok): | |
2001 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, |
|
2001 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, | |
2002 | user=TEST_USER_ADMIN_LOGIN, |
|
2002 | user=base.TEST_USER_ADMIN_LOGIN, | |
2003 | perm='group.read',) |
|
2003 | perm='group.read',) | |
2004 | Session().commit() |
|
2004 | Session().commit() | |
2005 |
|
2005 | |||
@@ -2012,13 +2012,13 b' class _BaseTestApi(object):' | |||||
2012 | id_, params = _build_data(self.apikey_regular, |
|
2012 | id_, params = _build_data(self.apikey_regular, | |
2013 | 'revoke_user_permission_from_repo_group', |
|
2013 | 'revoke_user_permission_from_repo_group', | |
2014 | repogroupid=TEST_REPO_GROUP, |
|
2014 | repogroupid=TEST_REPO_GROUP, | |
2015 | userid=TEST_USER_ADMIN_LOGIN, |
|
2015 | userid=base.TEST_USER_ADMIN_LOGIN, | |
2016 | apply_to_children=apply_to_children,) |
|
2016 | apply_to_children=apply_to_children,) | |
2017 | response = api_call(self, params) |
|
2017 | response = api_call(self, params) | |
2018 | if access_ok: |
|
2018 | if access_ok: | |
2019 | expected = { |
|
2019 | expected = { | |
2020 | 'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % ( |
|
2020 | 'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % ( | |
2021 | apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
2021 | apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
2022 | ), |
|
2022 | ), | |
2023 | 'success': True |
|
2023 | 'success': True | |
2024 | } |
|
2024 | } | |
@@ -2032,15 +2032,15 b' class _BaseTestApi(object):' | |||||
2032 | id_, params = _build_data(self.apikey, |
|
2032 | id_, params = _build_data(self.apikey, | |
2033 | 'revoke_user_permission_from_repo_group', |
|
2033 | 'revoke_user_permission_from_repo_group', | |
2034 | repogroupid=TEST_REPO_GROUP, |
|
2034 | repogroupid=TEST_REPO_GROUP, | |
2035 | userid=TEST_USER_ADMIN_LOGIN, ) |
|
2035 | userid=base.TEST_USER_ADMIN_LOGIN, ) | |
2036 | response = api_call(self, params) |
|
2036 | response = api_call(self, params) | |
2037 |
|
2037 | |||
2038 | expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % ( |
|
2038 | expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % ( | |
2039 | TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
2039 | base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
2040 | ) |
|
2040 | ) | |
2041 | self._compare_error(id_, expected, given=response.body) |
|
2041 | self._compare_error(id_, expected, given=response.body) | |
2042 |
|
2042 | |||
2043 | @parametrize('name,perm,apply_to_children', [ |
|
2043 | @base.parametrize('name,perm,apply_to_children', [ | |
2044 | ('none', 'group.none', 'none'), |
|
2044 | ('none', 'group.none', 'none'), | |
2045 | ('read', 'group.read', 'none'), |
|
2045 | ('read', 'group.read', 'none'), | |
2046 | ('write', 'group.write', 'none'), |
|
2046 | ('write', 'group.write', 'none'), | |
@@ -2079,7 +2079,7 b' class _BaseTestApi(object):' | |||||
2079 | expected = ret |
|
2079 | expected = ret | |
2080 | self._compare_ok(id_, expected, given=response.body) |
|
2080 | self._compare_ok(id_, expected, given=response.body) | |
2081 |
|
2081 | |||
2082 | @parametrize('name,perm,apply_to_children,grant_admin,access_ok', [ |
|
2082 | @base.parametrize('name,perm,apply_to_children,grant_admin,access_ok', [ | |
2083 | ('none_fails', 'group.none', 'none', False, False), |
|
2083 | ('none_fails', 'group.none', 'none', False, False), | |
2084 | ('read_fails', 'group.read', 'none', False, False), |
|
2084 | ('read_fails', 'group.read', 'none', False, False), | |
2085 | ('write_fails', 'group.write', 'none', False, False), |
|
2085 | ('write_fails', 'group.write', 'none', False, False), | |
@@ -2146,7 +2146,7 b' class _BaseTestApi(object):' | |||||
2146 | ) |
|
2146 | ) | |
2147 | self._compare_error(id_, expected, given=response.body) |
|
2147 | self._compare_error(id_, expected, given=response.body) | |
2148 |
|
2148 | |||
2149 | @parametrize('name,apply_to_children', [ |
|
2149 | @base.parametrize('name,apply_to_children', [ | |
2150 | ('none', 'none'), |
|
2150 | ('none', 'none'), | |
2151 | ('all', 'all'), |
|
2151 | ('all', 'all'), | |
2152 | ('repos', 'repos'), |
|
2152 | ('repos', 'repos'), | |
@@ -2172,7 +2172,7 b' class _BaseTestApi(object):' | |||||
2172 | } |
|
2172 | } | |
2173 | self._compare_ok(id_, expected, given=response.body) |
|
2173 | self._compare_ok(id_, expected, given=response.body) | |
2174 |
|
2174 | |||
2175 | @parametrize('name,apply_to_children,grant_admin,access_ok', [ |
|
2175 | @base.parametrize('name,apply_to_children,grant_admin,access_ok', [ | |
2176 | ('none', 'none', False, False), |
|
2176 | ('none', 'none', False, False), | |
2177 | ('all', 'all', False, False), |
|
2177 | ('all', 'all', False, False), | |
2178 | ('repos', 'repos', False, False), |
|
2178 | ('repos', 'repos', False, False), | |
@@ -2187,7 +2187,7 b' class _BaseTestApi(object):' | |||||
2187 | def test_api_revoke_user_group_permission_from_repo_group_by_regular_user( |
|
2187 | def test_api_revoke_user_group_permission_from_repo_group_by_regular_user( | |
2188 | self, name, apply_to_children, grant_admin, access_ok): |
|
2188 | self, name, apply_to_children, grant_admin, access_ok): | |
2189 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, |
|
2189 | RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP, | |
2190 | user=TEST_USER_ADMIN_LOGIN, |
|
2190 | user=base.TEST_USER_ADMIN_LOGIN, | |
2191 | perm='group.read',) |
|
2191 | perm='group.read',) | |
2192 | Session().commit() |
|
2192 | Session().commit() | |
2193 |
|
2193 | |||
@@ -2206,7 +2206,7 b' class _BaseTestApi(object):' | |||||
2206 | if access_ok: |
|
2206 | if access_ok: | |
2207 | expected = { |
|
2207 | expected = { | |
2208 | 'msg': 'Revoked perm (recursive:%s) for user group: `%s` in repo group: `%s`' % ( |
|
2208 | 'msg': 'Revoked perm (recursive:%s) for user group: `%s` in repo group: `%s`' % ( | |
2209 | apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP |
|
2209 | apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP | |
2210 | ), |
|
2210 | ), | |
2211 | 'success': True |
|
2211 | 'success': True | |
2212 | } |
|
2212 | } | |
@@ -2310,7 +2310,7 b' class _BaseTestApi(object):' | |||||
2310 |
|
2310 | |||
2311 | def test_api_get_gists_regular_user_with_different_userid(self): |
|
2311 | def test_api_get_gists_regular_user_with_different_userid(self): | |
2312 | id_, params = _build_data(self.apikey_regular, 'get_gists', |
|
2312 | id_, params = _build_data(self.apikey_regular, 'get_gists', | |
2313 | userid=TEST_USER_ADMIN_LOGIN) |
|
2313 | userid=base.TEST_USER_ADMIN_LOGIN) | |
2314 | response = api_call(self, params) |
|
2314 | response = api_call(self, params) | |
2315 | expected = 'userid is not the same as your user' |
|
2315 | expected = 'userid is not the same as your user' | |
2316 | self._compare_error(id_, expected, given=response.body) |
|
2316 | self._compare_error(id_, expected, given=response.body) | |
@@ -2501,10 +2501,10 b' class _BaseTestApi(object):' | |||||
2501 | "org_repo_url": "http://localhost:80/%s" % self.REPO, |
|
2501 | "org_repo_url": "http://localhost:80/%s" % self.REPO, | |
2502 | "org_ref_parts": ["branch", "stable", self.TEST_PR_SRC], |
|
2502 | "org_ref_parts": ["branch", "stable", self.TEST_PR_SRC], | |
2503 | "other_ref_parts": ["branch", "default", self.TEST_PR_DST], |
|
2503 | "other_ref_parts": ["branch", "default", self.TEST_PR_DST], | |
2504 | "comments": [{"username": TEST_USER_ADMIN_LOGIN, "text": "", |
|
2504 | "comments": [{"username": base.TEST_USER_ADMIN_LOGIN, "text": "", | |
2505 | "comment_id": pullrequest.comments[0].comment_id}], |
|
2505 | "comment_id": pullrequest.comments[0].comment_id}], | |
2506 | "owner": TEST_USER_ADMIN_LOGIN, |
|
2506 | "owner": base.TEST_USER_ADMIN_LOGIN, | |
2507 | "statuses": [{"status": "under_review", "reviewer": TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00"} for i in range(0, len(self.TEST_PR_REVISIONS))], |
|
2507 | "statuses": [{"status": "under_review", "reviewer": base.TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00"} for i in range(0, len(self.TEST_PR_REVISIONS))], | |
2508 | "title": "get test", |
|
2508 | "title": "get test", | |
2509 | "revisions": self.TEST_PR_REVISIONS, |
|
2509 | "revisions": self.TEST_PR_REVISIONS, | |
2510 | } |
|
2510 | } | |
@@ -2534,7 +2534,7 b' class _BaseTestApi(object):' | |||||
2534 | random_id = random.randrange(1, 9999) |
|
2534 | random_id = random.randrange(1, 9999) | |
2535 | params = json.dumps({ |
|
2535 | params = json.dumps({ | |
2536 | "id": random_id, |
|
2536 | "id": random_id, | |
2537 | "api_key": User.get_by_username(TEST_USER_REGULAR2_LOGIN).api_key, |
|
2537 | "api_key": User.get_by_username(base.TEST_USER_REGULAR2_LOGIN).api_key, | |
2538 | "method": "comment_pullrequest", |
|
2538 | "method": "comment_pullrequest", | |
2539 | "args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED}, |
|
2539 | "args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED}, | |
2540 | }) |
|
2540 | }) | |
@@ -2544,7 +2544,7 b' class _BaseTestApi(object):' | |||||
2544 | assert ChangesetStatus.STATUS_UNDER_REVIEW == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2] |
|
2544 | assert ChangesetStatus.STATUS_UNDER_REVIEW == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2] | |
2545 | params = json.dumps({ |
|
2545 | params = json.dumps({ | |
2546 | "id": random_id, |
|
2546 | "id": random_id, | |
2547 | "api_key": User.get_by_username(TEST_USER_REGULAR_LOGIN).api_key, |
|
2547 | "api_key": User.get_by_username(base.TEST_USER_REGULAR_LOGIN).api_key, | |
2548 | "method": "comment_pullrequest", |
|
2548 | "method": "comment_pullrequest", | |
2549 | "args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED}, |
|
2549 | "args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED}, | |
2550 | }) |
|
2550 | }) |
@@ -6,13 +6,13 b' from os.path import dirname' | |||||
6 | from kallithea.lib.utils2 import safe_unicode |
|
6 | from kallithea.lib.utils2 import safe_unicode | |
7 | from kallithea.model.db import UserLog |
|
7 | from kallithea.model.db import UserLog | |
8 | from kallithea.model.meta import Session |
|
8 | from kallithea.model.meta import Session | |
9 |
from kallithea.tests |
|
9 | from kallithea.tests import base | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures') |
|
12 | FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures') | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | class TestAdminController(TestController): |
|
15 | class TestAdminController(base.TestController): | |
16 |
|
16 | |||
17 | @classmethod |
|
17 | @classmethod | |
18 | def setup_class(cls): |
|
18 | def setup_class(cls): | |
@@ -52,105 +52,105 b' class TestAdminController(TestController' | |||||
52 |
|
52 | |||
53 | def test_index(self): |
|
53 | def test_index(self): | |
54 | self.log_user() |
|
54 | self.log_user() | |
55 | response = self.app.get(url(controller='admin/admin', action='index')) |
|
55 | response = self.app.get(base.url(controller='admin/admin', action='index')) | |
56 | response.mustcontain('Admin Journal') |
|
56 | response.mustcontain('Admin Journal') | |
57 |
|
57 | |||
58 | def test_filter_all_entries(self): |
|
58 | def test_filter_all_entries(self): | |
59 | self.log_user() |
|
59 | self.log_user() | |
60 | response = self.app.get(url(controller='admin/admin', action='index',)) |
|
60 | response = self.app.get(base.url(controller='admin/admin', action='index',)) | |
61 | response.mustcontain(' 2036 Entries') |
|
61 | response.mustcontain(' 2036 Entries') | |
62 |
|
62 | |||
63 | def test_filter_journal_filter_exact_match_on_repository(self): |
|
63 | def test_filter_journal_filter_exact_match_on_repository(self): | |
64 | self.log_user() |
|
64 | self.log_user() | |
65 | response = self.app.get(url(controller='admin/admin', action='index', |
|
65 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
66 | filter='repository:xxx')) |
|
66 | filter='repository:xxx')) | |
67 | response.mustcontain(' 3 Entries') |
|
67 | response.mustcontain(' 3 Entries') | |
68 |
|
68 | |||
69 | def test_filter_journal_filter_exact_match_on_repository_CamelCase(self): |
|
69 | def test_filter_journal_filter_exact_match_on_repository_CamelCase(self): | |
70 | self.log_user() |
|
70 | self.log_user() | |
71 | response = self.app.get(url(controller='admin/admin', action='index', |
|
71 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
72 | filter='repository:XxX')) |
|
72 | filter='repository:XxX')) | |
73 | response.mustcontain(' 3 Entries') |
|
73 | response.mustcontain(' 3 Entries') | |
74 |
|
74 | |||
75 | def test_filter_journal_filter_wildcard_on_repository(self): |
|
75 | def test_filter_journal_filter_wildcard_on_repository(self): | |
76 | self.log_user() |
|
76 | self.log_user() | |
77 | response = self.app.get(url(controller='admin/admin', action='index', |
|
77 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
78 | filter='repository:*test*')) |
|
78 | filter='repository:*test*')) | |
79 | response.mustcontain(' 862 Entries') |
|
79 | response.mustcontain(' 862 Entries') | |
80 |
|
80 | |||
81 | def test_filter_journal_filter_prefix_on_repository(self): |
|
81 | def test_filter_journal_filter_prefix_on_repository(self): | |
82 | self.log_user() |
|
82 | self.log_user() | |
83 | response = self.app.get(url(controller='admin/admin', action='index', |
|
83 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
84 | filter='repository:test*')) |
|
84 | filter='repository:test*')) | |
85 | response.mustcontain(' 257 Entries') |
|
85 | response.mustcontain(' 257 Entries') | |
86 |
|
86 | |||
87 | def test_filter_journal_filter_prefix_on_repository_CamelCase(self): |
|
87 | def test_filter_journal_filter_prefix_on_repository_CamelCase(self): | |
88 | self.log_user() |
|
88 | self.log_user() | |
89 | response = self.app.get(url(controller='admin/admin', action='index', |
|
89 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
90 | filter='repository:Test*')) |
|
90 | filter='repository:Test*')) | |
91 | response.mustcontain(' 257 Entries') |
|
91 | response.mustcontain(' 257 Entries') | |
92 |
|
92 | |||
93 | def test_filter_journal_filter_prefix_on_repository_and_user(self): |
|
93 | def test_filter_journal_filter_prefix_on_repository_and_user(self): | |
94 | self.log_user() |
|
94 | self.log_user() | |
95 | response = self.app.get(url(controller='admin/admin', action='index', |
|
95 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
96 | filter='repository:test* AND username:demo')) |
|
96 | filter='repository:test* AND username:demo')) | |
97 | response.mustcontain(' 130 Entries') |
|
97 | response.mustcontain(' 130 Entries') | |
98 |
|
98 | |||
99 | def test_filter_journal_filter_prefix_on_repository_or_other_repo(self): |
|
99 | def test_filter_journal_filter_prefix_on_repository_or_other_repo(self): | |
100 | self.log_user() |
|
100 | self.log_user() | |
101 | response = self.app.get(url(controller='admin/admin', action='index', |
|
101 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
102 | filter='repository:test* OR repository:xxx')) |
|
102 | filter='repository:test* OR repository:xxx')) | |
103 | response.mustcontain(' 260 Entries') # 257 + 3 |
|
103 | response.mustcontain(' 260 Entries') # 257 + 3 | |
104 |
|
104 | |||
105 | def test_filter_journal_filter_exact_match_on_username(self): |
|
105 | def test_filter_journal_filter_exact_match_on_username(self): | |
106 | self.log_user() |
|
106 | self.log_user() | |
107 | response = self.app.get(url(controller='admin/admin', action='index', |
|
107 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
108 | filter='username:demo')) |
|
108 | filter='username:demo')) | |
109 | response.mustcontain(' 1087 Entries') |
|
109 | response.mustcontain(' 1087 Entries') | |
110 |
|
110 | |||
111 | def test_filter_journal_filter_exact_match_on_username_camelCase(self): |
|
111 | def test_filter_journal_filter_exact_match_on_username_camelCase(self): | |
112 | self.log_user() |
|
112 | self.log_user() | |
113 | response = self.app.get(url(controller='admin/admin', action='index', |
|
113 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
114 | filter='username:DemO')) |
|
114 | filter='username:DemO')) | |
115 | response.mustcontain(' 1087 Entries') |
|
115 | response.mustcontain(' 1087 Entries') | |
116 |
|
116 | |||
117 | def test_filter_journal_filter_wildcard_on_username(self): |
|
117 | def test_filter_journal_filter_wildcard_on_username(self): | |
118 | self.log_user() |
|
118 | self.log_user() | |
119 | response = self.app.get(url(controller='admin/admin', action='index', |
|
119 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
120 | filter='username:*test*')) |
|
120 | filter='username:*test*')) | |
121 | response.mustcontain(' 100 Entries') |
|
121 | response.mustcontain(' 100 Entries') | |
122 |
|
122 | |||
123 | def test_filter_journal_filter_prefix_on_username(self): |
|
123 | def test_filter_journal_filter_prefix_on_username(self): | |
124 | self.log_user() |
|
124 | self.log_user() | |
125 | response = self.app.get(url(controller='admin/admin', action='index', |
|
125 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
126 | filter='username:demo*')) |
|
126 | filter='username:demo*')) | |
127 | response.mustcontain(' 1101 Entries') |
|
127 | response.mustcontain(' 1101 Entries') | |
128 |
|
128 | |||
129 | def test_filter_journal_filter_prefix_on_user_or_other_user(self): |
|
129 | def test_filter_journal_filter_prefix_on_user_or_other_user(self): | |
130 | self.log_user() |
|
130 | self.log_user() | |
131 | response = self.app.get(url(controller='admin/admin', action='index', |
|
131 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
132 | filter='username:demo OR username:volcan')) |
|
132 | filter='username:demo OR username:volcan')) | |
133 | response.mustcontain(' 1095 Entries') # 1087 + 8 |
|
133 | response.mustcontain(' 1095 Entries') # 1087 + 8 | |
134 |
|
134 | |||
135 | def test_filter_journal_filter_wildcard_on_action(self): |
|
135 | def test_filter_journal_filter_wildcard_on_action(self): | |
136 | self.log_user() |
|
136 | self.log_user() | |
137 | response = self.app.get(url(controller='admin/admin', action='index', |
|
137 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
138 | filter='action:*pull_request*')) |
|
138 | filter='action:*pull_request*')) | |
139 | response.mustcontain(' 187 Entries') |
|
139 | response.mustcontain(' 187 Entries') | |
140 |
|
140 | |||
141 | def test_filter_journal_filter_on_date(self): |
|
141 | def test_filter_journal_filter_on_date(self): | |
142 | self.log_user() |
|
142 | self.log_user() | |
143 | response = self.app.get(url(controller='admin/admin', action='index', |
|
143 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
144 | filter='date:20121010')) |
|
144 | filter='date:20121010')) | |
145 | response.mustcontain(' 47 Entries') |
|
145 | response.mustcontain(' 47 Entries') | |
146 |
|
146 | |||
147 | def test_filter_journal_filter_on_date_2(self): |
|
147 | def test_filter_journal_filter_on_date_2(self): | |
148 | self.log_user() |
|
148 | self.log_user() | |
149 | response = self.app.get(url(controller='admin/admin', action='index', |
|
149 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
150 | filter='date:20121020')) |
|
150 | filter='date:20121020')) | |
151 | response.mustcontain(' 17 Entries') |
|
151 | response.mustcontain(' 17 Entries') | |
152 |
|
152 | |||
153 | @parametrize('filter,hit', [ |
|
153 | @base.parametrize('filter,hit', [ | |
154 | #### "repository:" filtering |
|
154 | #### "repository:" filtering | |
155 | # "/" is used for grouping |
|
155 | # "/" is used for grouping | |
156 | ('repository:group/test', 4), |
|
156 | ('repository:group/test', 4), | |
@@ -189,7 +189,7 b' class TestAdminController(TestController' | |||||
189 | def test_filter_journal_filter_tokenization(self, filter, hit): |
|
189 | def test_filter_journal_filter_tokenization(self, filter, hit): | |
190 | self.log_user() |
|
190 | self.log_user() | |
191 |
|
191 | |||
192 | response = self.app.get(url(controller='admin/admin', action='index', |
|
192 | response = self.app.get(base.url(controller='admin/admin', action='index', | |
193 | filter=filter)) |
|
193 | filter=filter)) | |
194 | if hit != 1: |
|
194 | if hit != 1: | |
195 | response.mustcontain(' %s Entries' % hit) |
|
195 | response.mustcontain(' %s Entries' % hit) |
@@ -1,10 +1,10 b'' | |||||
1 | from kallithea.model.db import Setting |
|
1 | from kallithea.model.db import Setting | |
2 |
from kallithea.tests |
|
2 | from kallithea.tests import base | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | class TestAuthSettingsController(TestController): |
|
5 | class TestAuthSettingsController(base.TestController): | |
6 | def _enable_plugins(self, plugins_list): |
|
6 | def _enable_plugins(self, plugins_list): | |
7 | test_url = url(controller='admin/auth_settings', |
|
7 | test_url = base.url(controller='admin/auth_settings', | |
8 | action='auth_settings') |
|
8 | action='auth_settings') | |
9 | params={'auth_plugins': plugins_list, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
9 | params={'auth_plugins': plugins_list, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
10 |
|
10 | |||
@@ -17,11 +17,11 b' class TestAuthSettingsController(TestCon' | |||||
17 |
|
17 | |||
18 | def test_index(self): |
|
18 | def test_index(self): | |
19 | self.log_user() |
|
19 | self.log_user() | |
20 | response = self.app.get(url(controller='admin/auth_settings', |
|
20 | response = self.app.get(base.url(controller='admin/auth_settings', | |
21 | action='index')) |
|
21 | action='index')) | |
22 | response.mustcontain('Authentication Plugins') |
|
22 | response.mustcontain('Authentication Plugins') | |
23 |
|
23 | |||
24 | @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') |
|
24 | @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib') | |
25 | def test_ldap_save_settings(self): |
|
25 | def test_ldap_save_settings(self): | |
26 | self.log_user() |
|
26 | self.log_user() | |
27 |
|
27 | |||
@@ -41,7 +41,7 b' class TestAuthSettingsController(TestCon' | |||||
41 | 'auth_ldap_attr_lastname': 'tester', |
|
41 | 'auth_ldap_attr_lastname': 'tester', | |
42 | 'auth_ldap_attr_email': 'test@example.com'}) |
|
42 | 'auth_ldap_attr_email': 'test@example.com'}) | |
43 |
|
43 | |||
44 | test_url = url(controller='admin/auth_settings', |
|
44 | test_url = base.url(controller='admin/auth_settings', | |
45 | action='auth_settings') |
|
45 | action='auth_settings') | |
46 |
|
46 | |||
47 | response = self.app.post(url=test_url, params=params) |
|
47 | response = self.app.post(url=test_url, params=params) | |
@@ -50,7 +50,7 b' class TestAuthSettingsController(TestCon' | |||||
50 | new_settings = Setting.get_auth_settings() |
|
50 | new_settings = Setting.get_auth_settings() | |
51 | assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare' |
|
51 | assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare' | |
52 |
|
52 | |||
53 | @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') |
|
53 | @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib') | |
54 | def test_ldap_error_form_wrong_port_number(self): |
|
54 | def test_ldap_error_form_wrong_port_number(self): | |
55 | self.log_user() |
|
55 | self.log_user() | |
56 |
|
56 | |||
@@ -68,7 +68,7 b' class TestAuthSettingsController(TestCon' | |||||
68 | 'auth_ldap_attr_firstname': '', |
|
68 | 'auth_ldap_attr_firstname': '', | |
69 | 'auth_ldap_attr_lastname': '', |
|
69 | 'auth_ldap_attr_lastname': '', | |
70 | 'auth_ldap_attr_email': ''}) |
|
70 | 'auth_ldap_attr_email': ''}) | |
71 | test_url = url(controller='admin/auth_settings', |
|
71 | test_url = base.url(controller='admin/auth_settings', | |
72 | action='auth_settings') |
|
72 | action='auth_settings') | |
73 |
|
73 | |||
74 | response = self.app.post(url=test_url, params=params) |
|
74 | response = self.app.post(url=test_url, params=params) | |
@@ -76,7 +76,7 b' class TestAuthSettingsController(TestCon' | |||||
76 | response.mustcontain("""<span class="error-message">""" |
|
76 | response.mustcontain("""<span class="error-message">""" | |
77 | """Please enter a number</span>""") |
|
77 | """Please enter a number</span>""") | |
78 |
|
78 | |||
79 | @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') |
|
79 | @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib') | |
80 | def test_ldap_error_form(self): |
|
80 | def test_ldap_error_form(self): | |
81 | self.log_user() |
|
81 | self.log_user() | |
82 |
|
82 | |||
@@ -95,7 +95,7 b' class TestAuthSettingsController(TestCon' | |||||
95 | 'auth_ldap_attr_lastname': '', |
|
95 | 'auth_ldap_attr_lastname': '', | |
96 | 'auth_ldap_attr_email': ''}) |
|
96 | 'auth_ldap_attr_email': ''}) | |
97 |
|
97 | |||
98 | test_url = url(controller='admin/auth_settings', |
|
98 | test_url = base.url(controller='admin/auth_settings', | |
99 | action='auth_settings') |
|
99 | action='auth_settings') | |
100 |
|
100 | |||
101 | response = self.app.post(url=test_url, params=params) |
|
101 | response = self.app.post(url=test_url, params=params) | |
@@ -115,7 +115,7 b' class TestAuthSettingsController(TestCon' | |||||
115 | params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_container') |
|
115 | params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_container') | |
116 | params.update(settings) |
|
116 | params.update(settings) | |
117 |
|
117 | |||
118 | test_url = url(controller='admin/auth_settings', |
|
118 | test_url = base.url(controller='admin/auth_settings', | |
119 | action='auth_settings') |
|
119 | action='auth_settings') | |
120 |
|
120 | |||
121 | response = self.app.post(url=test_url, params=params) |
|
121 | response = self.app.post(url=test_url, params=params) | |
@@ -124,7 +124,7 b' class TestAuthSettingsController(TestCon' | |||||
124 |
|
124 | |||
125 | def _container_auth_verify_login(self, resulting_username, **get_kwargs): |
|
125 | def _container_auth_verify_login(self, resulting_username, **get_kwargs): | |
126 | response = self.app.get( |
|
126 | response = self.app.get( | |
127 | url=url(controller='admin/my_account', action='my_account'), |
|
127 | url=base.url(controller='admin/my_account', action='my_account'), | |
128 | **get_kwargs |
|
128 | **get_kwargs | |
129 | ) |
|
129 | ) | |
130 | response.mustcontain('My Account %s' % resulting_username) |
|
130 | response.mustcontain('My Account %s' % resulting_username) | |
@@ -153,7 +153,7 b' class TestAuthSettingsController(TestCon' | |||||
153 | auth_container_clean_username='False', |
|
153 | auth_container_clean_username='False', | |
154 | ) |
|
154 | ) | |
155 | response = self.app.get( |
|
155 | response = self.app.get( | |
156 | url=url(controller='admin/my_account', action='my_account'), |
|
156 | url=base.url(controller='admin/my_account', action='my_account'), | |
157 | extra_environ={'THE_USER_NAME': 'johnd', |
|
157 | extra_environ={'THE_USER_NAME': 'johnd', | |
158 | 'THE_USER_EMAIL': 'john@example.org', |
|
158 | 'THE_USER_EMAIL': 'john@example.org', | |
159 | 'THE_USER_FIRSTNAME': 'John', |
|
159 | 'THE_USER_FIRSTNAME': 'John', | |
@@ -216,7 +216,7 b' class TestAuthSettingsController(TestCon' | |||||
216 | auth_container_clean_username='True', |
|
216 | auth_container_clean_username='True', | |
217 | ) |
|
217 | ) | |
218 | response = self.app.get( |
|
218 | response = self.app.get( | |
219 | url=url(controller='admin/my_account', action='my_account'), |
|
219 | url=base.url(controller='admin/my_account', action='my_account'), | |
220 | extra_environ={'REMOTE_USER': 'john'}, |
|
220 | extra_environ={'REMOTE_USER': 'john'}, | |
221 | ) |
|
221 | ) | |
222 | assert b'Log Out' not in response.normal_body |
|
222 | assert b'Log Out' not in response.normal_body | |
@@ -232,7 +232,7 b' class TestAuthSettingsController(TestCon' | |||||
232 | 'auth_crowd_method': 'https', |
|
232 | 'auth_crowd_method': 'https', | |
233 | 'auth_crowd_app_name': 'xyzzy'}) |
|
233 | 'auth_crowd_app_name': 'xyzzy'}) | |
234 |
|
234 | |||
235 | test_url = url(controller='admin/auth_settings', |
|
235 | test_url = base.url(controller='admin/auth_settings', | |
236 | action='auth_settings') |
|
236 | action='auth_settings') | |
237 |
|
237 | |||
238 | response = self.app.post(url=test_url, params=params) |
|
238 | response = self.app.post(url=test_url, params=params) | |
@@ -241,7 +241,7 b' class TestAuthSettingsController(TestCon' | |||||
241 | new_settings = Setting.get_auth_settings() |
|
241 | new_settings = Setting.get_auth_settings() | |
242 | assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare' |
|
242 | assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare' | |
243 |
|
243 | |||
244 | @skipif(not pam_lib_installed, reason='skipping due to missing pam lib') |
|
244 | @base.skipif(not base.pam_lib_installed, reason='skipping due to missing pam lib') | |
245 | def test_pam_save_settings(self): |
|
245 | def test_pam_save_settings(self): | |
246 | self.log_user() |
|
246 | self.log_user() | |
247 |
|
247 | |||
@@ -249,7 +249,7 b' class TestAuthSettingsController(TestCon' | |||||
249 | params.update({'auth_pam_service': 'kallithea', |
|
249 | params.update({'auth_pam_service': 'kallithea', | |
250 | 'auth_pam_gecos': '^foo-.*'}) |
|
250 | 'auth_pam_gecos': '^foo-.*'}) | |
251 |
|
251 | |||
252 | test_url = url(controller='admin/auth_settings', |
|
252 | test_url = base.url(controller='admin/auth_settings', | |
253 | action='auth_settings') |
|
253 | action='auth_settings') | |
254 |
|
254 | |||
255 | response = self.app.post(url=test_url, params=params) |
|
255 | response = self.app.post(url=test_url, params=params) |
@@ -1,12 +1,12 b'' | |||||
1 | from kallithea.model.db import Setting |
|
1 | from kallithea.model.db import Setting | |
2 |
from kallithea.tests |
|
2 | from kallithea.tests import base | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | class TestDefaultsController(TestController): |
|
5 | class TestDefaultsController(base.TestController): | |
6 |
|
6 | |||
7 | def test_index(self): |
|
7 | def test_index(self): | |
8 | self.log_user() |
|
8 | self.log_user() | |
9 | response = self.app.get(url('defaults')) |
|
9 | response = self.app.get(base.url('defaults')) | |
10 | response.mustcontain('default_repo_private') |
|
10 | response.mustcontain('default_repo_private') | |
11 | response.mustcontain('default_repo_enable_statistics') |
|
11 | response.mustcontain('default_repo_enable_statistics') | |
12 | response.mustcontain('default_repo_enable_downloads') |
|
12 | response.mustcontain('default_repo_enable_downloads') | |
@@ -20,7 +20,7 b' class TestDefaultsController(TestControl' | |||||
20 | 'default_repo_type': 'hg', |
|
20 | 'default_repo_type': 'hg', | |
21 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
21 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
22 | } |
|
22 | } | |
23 | response = self.app.post(url('defaults_update', id='default'), params=params) |
|
23 | response = self.app.post(base.url('defaults_update', id='default'), params=params) | |
24 | self.checkSessionFlash(response, 'Default settings updated successfully') |
|
24 | self.checkSessionFlash(response, 'Default settings updated successfully') | |
25 |
|
25 | |||
26 | params.pop('_session_csrf_secret_token') |
|
26 | params.pop('_session_csrf_secret_token') | |
@@ -36,7 +36,7 b' class TestDefaultsController(TestControl' | |||||
36 | 'default_repo_type': 'git', |
|
36 | 'default_repo_type': 'git', | |
37 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
37 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
38 | } |
|
38 | } | |
39 | response = self.app.post(url('defaults_update', id='default'), params=params) |
|
39 | response = self.app.post(base.url('defaults_update', id='default'), params=params) | |
40 | self.checkSessionFlash(response, 'Default settings updated successfully') |
|
40 | self.checkSessionFlash(response, 'Default settings updated successfully') | |
41 |
|
41 | |||
42 | params.pop('_session_csrf_secret_token') |
|
42 | params.pop('_session_csrf_secret_token') |
@@ -1,24 +1,24 b'' | |||||
1 | from kallithea.model.db import Gist, User |
|
1 | from kallithea.model.db import Gist, User | |
2 | from kallithea.model.gist import GistModel |
|
2 | from kallithea.model.gist import GistModel | |
3 | from kallithea.model.meta import Session |
|
3 | from kallithea.model.meta import Session | |
4 |
from kallithea.tests |
|
4 | from kallithea.tests import base | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | def _create_gist(f_name, content='some gist', lifetime=-1, |
|
7 | def _create_gist(f_name, content='some gist', lifetime=-1, | |
8 | description=u'gist-desc', gist_type='public', |
|
8 | description=u'gist-desc', gist_type='public', | |
9 | owner=TEST_USER_ADMIN_LOGIN): |
|
9 | owner=base.TEST_USER_ADMIN_LOGIN): | |
10 | gist_mapping = { |
|
10 | gist_mapping = { | |
11 | f_name: {'content': content} |
|
11 | f_name: {'content': content} | |
12 | } |
|
12 | } | |
13 | owner = User.get_by_username(owner) |
|
13 | owner = User.get_by_username(owner) | |
14 | gist = GistModel().create(description, owner=owner, ip_addr=IP_ADDR, |
|
14 | gist = GistModel().create(description, owner=owner, ip_addr=base.IP_ADDR, | |
15 | gist_mapping=gist_mapping, gist_type=gist_type, |
|
15 | gist_mapping=gist_mapping, gist_type=gist_type, | |
16 | lifetime=lifetime) |
|
16 | lifetime=lifetime) | |
17 | Session().commit() |
|
17 | Session().commit() | |
18 | return gist |
|
18 | return gist | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | class TestGistsController(TestController): |
|
21 | class TestGistsController(base.TestController): | |
22 |
|
22 | |||
23 | def teardown_method(self, method): |
|
23 | def teardown_method(self, method): | |
24 | for g in Gist.query(): |
|
24 | for g in Gist.query(): | |
@@ -27,7 +27,7 b' class TestGistsController(TestController' | |||||
27 |
|
27 | |||
28 | def test_index(self): |
|
28 | def test_index(self): | |
29 | self.log_user() |
|
29 | self.log_user() | |
30 | response = self.app.get(url('gists')) |
|
30 | response = self.app.get(base.url('gists')) | |
31 | # Test response... |
|
31 | # Test response... | |
32 | response.mustcontain('There are no gists yet') |
|
32 | response.mustcontain('There are no gists yet') | |
33 |
|
33 | |||
@@ -35,7 +35,7 b' class TestGistsController(TestController' | |||||
35 | g2 = _create_gist('gist2', lifetime=1400).gist_access_id |
|
35 | g2 = _create_gist('gist2', lifetime=1400).gist_access_id | |
36 | g3 = _create_gist('gist3', description=u'gist3-desc').gist_access_id |
|
36 | g3 = _create_gist('gist3', description=u'gist3-desc').gist_access_id | |
37 | g4 = _create_gist('gist4', gist_type='private').gist_access_id |
|
37 | g4 = _create_gist('gist4', gist_type='private').gist_access_id | |
38 | response = self.app.get(url('gists')) |
|
38 | response = self.app.get(base.url('gists')) | |
39 | # Test response... |
|
39 | # Test response... | |
40 | response.mustcontain('gist: %s' % g1) |
|
40 | response.mustcontain('gist: %s' % g1) | |
41 | response.mustcontain('gist: %s' % g2) |
|
41 | response.mustcontain('gist: %s' % g2) | |
@@ -47,7 +47,7 b' class TestGistsController(TestController' | |||||
47 | def test_index_private_gists(self): |
|
47 | def test_index_private_gists(self): | |
48 | self.log_user() |
|
48 | self.log_user() | |
49 | gist = _create_gist('gist5', gist_type='private') |
|
49 | gist = _create_gist('gist5', gist_type='private') | |
50 | response = self.app.get(url('gists', private=1)) |
|
50 | response = self.app.get(base.url('gists', private=1)) | |
51 | # Test response... |
|
51 | # Test response... | |
52 |
|
52 | |||
53 | # and privates |
|
53 | # and privates | |
@@ -55,7 +55,7 b' class TestGistsController(TestController' | |||||
55 |
|
55 | |||
56 | def test_create_missing_description(self): |
|
56 | def test_create_missing_description(self): | |
57 | self.log_user() |
|
57 | self.log_user() | |
58 | response = self.app.post(url('gists'), |
|
58 | response = self.app.post(base.url('gists'), | |
59 | params={'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}, |
|
59 | params={'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}, | |
60 | status=200) |
|
60 | status=200) | |
61 |
|
61 | |||
@@ -63,7 +63,7 b' class TestGistsController(TestController' | |||||
63 |
|
63 | |||
64 | def test_create(self): |
|
64 | def test_create(self): | |
65 | self.log_user() |
|
65 | self.log_user() | |
66 | response = self.app.post(url('gists'), |
|
66 | response = self.app.post(base.url('gists'), | |
67 | params={'lifetime': -1, |
|
67 | params={'lifetime': -1, | |
68 | 'content': 'gist test', |
|
68 | 'content': 'gist test', | |
69 | 'filename': 'foo', |
|
69 | 'filename': 'foo', | |
@@ -77,7 +77,7 b' class TestGistsController(TestController' | |||||
77 |
|
77 | |||
78 | def test_create_with_path_with_dirs(self): |
|
78 | def test_create_with_path_with_dirs(self): | |
79 | self.log_user() |
|
79 | self.log_user() | |
80 | response = self.app.post(url('gists'), |
|
80 | response = self.app.post(base.url('gists'), | |
81 | params={'lifetime': -1, |
|
81 | params={'lifetime': -1, | |
82 | 'content': 'gist test', |
|
82 | 'content': 'gist test', | |
83 | 'filename': '/home/foo', |
|
83 | 'filename': '/home/foo', | |
@@ -92,11 +92,11 b' class TestGistsController(TestController' | |||||
92 | gist.gist_expires = 0 # 1970 |
|
92 | gist.gist_expires = 0 # 1970 | |
93 | Session().commit() |
|
93 | Session().commit() | |
94 |
|
94 | |||
95 | response = self.app.get(url('gist', gist_id=gist.gist_access_id), status=404) |
|
95 | response = self.app.get(base.url('gist', gist_id=gist.gist_access_id), status=404) | |
96 |
|
96 | |||
97 | def test_create_private(self): |
|
97 | def test_create_private(self): | |
98 | self.log_user() |
|
98 | self.log_user() | |
99 | response = self.app.post(url('gists'), |
|
99 | response = self.app.post(base.url('gists'), | |
100 | params={'lifetime': -1, |
|
100 | params={'lifetime': -1, | |
101 | 'content': 'private gist test', |
|
101 | 'content': 'private gist test', | |
102 | 'filename': 'private-foo', |
|
102 | 'filename': 'private-foo', | |
@@ -110,7 +110,7 b' class TestGistsController(TestController' | |||||
110 |
|
110 | |||
111 | def test_create_with_description(self): |
|
111 | def test_create_with_description(self): | |
112 | self.log_user() |
|
112 | self.log_user() | |
113 | response = self.app.post(url('gists'), |
|
113 | response = self.app.post(base.url('gists'), | |
114 | params={'lifetime': -1, |
|
114 | params={'lifetime': -1, | |
115 | 'content': 'gist test', |
|
115 | 'content': 'gist test', | |
116 | 'filename': 'foo-desc', |
|
116 | 'filename': 'foo-desc', | |
@@ -126,46 +126,46 b' class TestGistsController(TestController' | |||||
126 |
|
126 | |||
127 | def test_new(self): |
|
127 | def test_new(self): | |
128 | self.log_user() |
|
128 | self.log_user() | |
129 | response = self.app.get(url('new_gist')) |
|
129 | response = self.app.get(base.url('new_gist')) | |
130 |
|
130 | |||
131 | def test_delete(self): |
|
131 | def test_delete(self): | |
132 | self.log_user() |
|
132 | self.log_user() | |
133 | gist = _create_gist('delete-me') |
|
133 | gist = _create_gist('delete-me') | |
134 | response = self.app.post(url('gist_delete', gist_id=gist.gist_id), |
|
134 | response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id), | |
135 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
135 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
136 |
|
136 | |||
137 | def test_delete_normal_user_his_gist(self): |
|
137 | def test_delete_normal_user_his_gist(self): | |
138 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
138 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
139 | gist = _create_gist('delete-me', owner=TEST_USER_REGULAR_LOGIN) |
|
139 | gist = _create_gist('delete-me', owner=base.TEST_USER_REGULAR_LOGIN) | |
140 | response = self.app.post(url('gist_delete', gist_id=gist.gist_id), |
|
140 | response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id), | |
141 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
141 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
142 |
|
142 | |||
143 | def test_delete_normal_user_not_his_own_gist(self): |
|
143 | def test_delete_normal_user_not_his_own_gist(self): | |
144 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
144 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
145 | gist = _create_gist('delete-me') |
|
145 | gist = _create_gist('delete-me') | |
146 | response = self.app.post(url('gist_delete', gist_id=gist.gist_id), status=403, |
|
146 | response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id), status=403, | |
147 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
147 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
148 |
|
148 | |||
149 | def test_show(self): |
|
149 | def test_show(self): | |
150 | gist = _create_gist('gist-show-me') |
|
150 | gist = _create_gist('gist-show-me') | |
151 | response = self.app.get(url('gist', gist_id=gist.gist_access_id)) |
|
151 | response = self.app.get(base.url('gist', gist_id=gist.gist_access_id)) | |
152 | response.mustcontain('added file: gist-show-me<') |
|
152 | response.mustcontain('added file: gist-show-me<') | |
153 | response.mustcontain('%s - created' % TEST_USER_ADMIN_LOGIN) |
|
153 | response.mustcontain('%s - created' % base.TEST_USER_ADMIN_LOGIN) | |
154 | response.mustcontain('gist-desc') |
|
154 | response.mustcontain('gist-desc') | |
155 | response.mustcontain('<div class="label label-success">Public Gist</div>') |
|
155 | response.mustcontain('<div class="label label-success">Public Gist</div>') | |
156 |
|
156 | |||
157 | def test_show_as_raw(self): |
|
157 | def test_show_as_raw(self): | |
158 | gist = _create_gist('gist-show-me', content='GIST CONTENT') |
|
158 | gist = _create_gist('gist-show-me', content='GIST CONTENT') | |
159 | response = self.app.get(url('formatted_gist', |
|
159 | response = self.app.get(base.url('formatted_gist', | |
160 | gist_id=gist.gist_access_id, format='raw')) |
|
160 | gist_id=gist.gist_access_id, format='raw')) | |
161 | assert response.body == b'GIST CONTENT' |
|
161 | assert response.body == b'GIST CONTENT' | |
162 |
|
162 | |||
163 | def test_show_as_raw_individual_file(self): |
|
163 | def test_show_as_raw_individual_file(self): | |
164 | gist = _create_gist('gist-show-me-raw', content='GIST BODY') |
|
164 | gist = _create_gist('gist-show-me-raw', content='GIST BODY') | |
165 | response = self.app.get(url('formatted_gist_file', |
|
165 | response = self.app.get(base.url('formatted_gist_file', | |
166 | gist_id=gist.gist_access_id, format='raw', |
|
166 | gist_id=gist.gist_access_id, format='raw', | |
167 | revision='tip', f_path='gist-show-me-raw')) |
|
167 | revision='tip', f_path='gist-show-me-raw')) | |
168 | assert response.body == b'GIST BODY' |
|
168 | assert response.body == b'GIST BODY' | |
169 |
|
169 | |||
170 | def test_edit(self): |
|
170 | def test_edit(self): | |
171 | response = self.app.get(url('edit_gist', gist_id=1)) |
|
171 | response = self.app.get(base.url('edit_gist', gist_id=1)) |
@@ -1,17 +1,17 b'' | |||||
1 | from kallithea.model.db import User, UserIpMap |
|
1 | from kallithea.model.db import User, UserIpMap | |
2 |
from kallithea.tests |
|
2 | from kallithea.tests import base | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | class TestAdminPermissionsController(TestController): |
|
5 | class TestAdminPermissionsController(base.TestController): | |
6 |
|
6 | |||
7 | def test_index(self): |
|
7 | def test_index(self): | |
8 | self.log_user() |
|
8 | self.log_user() | |
9 | response = self.app.get(url('admin_permissions')) |
|
9 | response = self.app.get(base.url('admin_permissions')) | |
10 | # Test response... |
|
10 | # Test response... | |
11 |
|
11 | |||
12 | def test_index_ips(self): |
|
12 | def test_index_ips(self): | |
13 | self.log_user() |
|
13 | self.log_user() | |
14 | response = self.app.get(url('admin_permissions_ips')) |
|
14 | response = self.app.get(base.url('admin_permissions_ips')) | |
15 | # Test response... |
|
15 | # Test response... | |
16 | response.mustcontain('All IP addresses are allowed') |
|
16 | response.mustcontain('All IP addresses are allowed') | |
17 |
|
17 | |||
@@ -21,61 +21,61 b' class TestAdminPermissionsController(Tes' | |||||
21 |
|
21 | |||
22 | # Add IP and verify it is shown in UI and both gives access and rejects |
|
22 | # Add IP and verify it is shown in UI and both gives access and rejects | |
23 |
|
23 | |||
24 | response = self.app.post(url('edit_user_ips_update', id=default_user_id), |
|
24 | response = self.app.post(base.url('edit_user_ips_update', id=default_user_id), | |
25 | params=dict(new_ip='0.0.0.0/24', |
|
25 | params=dict(new_ip='0.0.0.0/24', | |
26 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
26 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
27 | invalidate_all_caches() |
|
27 | base.invalidate_all_caches() | |
28 | response = self.app.get(url('admin_permissions_ips'), |
|
28 | response = self.app.get(base.url('admin_permissions_ips'), | |
29 | extra_environ={'REMOTE_ADDR': '0.0.0.1'}) |
|
29 | extra_environ={'REMOTE_ADDR': '0.0.0.1'}) | |
30 | response.mustcontain('0.0.0.0/24') |
|
30 | response.mustcontain('0.0.0.0/24') | |
31 | response.mustcontain('0.0.0.0 - 0.0.0.255') |
|
31 | response.mustcontain('0.0.0.0 - 0.0.0.255') | |
32 |
|
32 | |||
33 | response = self.app.get(url('admin_permissions_ips'), |
|
33 | response = self.app.get(base.url('admin_permissions_ips'), | |
34 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403) |
|
34 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403) | |
35 |
|
35 | |||
36 | # Add another IP and verify previously rejected now works |
|
36 | # Add another IP and verify previously rejected now works | |
37 |
|
37 | |||
38 | response = self.app.post(url('edit_user_ips_update', id=default_user_id), |
|
38 | response = self.app.post(base.url('edit_user_ips_update', id=default_user_id), | |
39 | params=dict(new_ip='0.0.1.0/24', |
|
39 | params=dict(new_ip='0.0.1.0/24', | |
40 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
40 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
41 | invalidate_all_caches() |
|
41 | base.invalidate_all_caches() | |
42 |
|
42 | |||
43 | response = self.app.get(url('admin_permissions_ips'), |
|
43 | response = self.app.get(base.url('admin_permissions_ips'), | |
44 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}) |
|
44 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}) | |
45 |
|
45 | |||
46 | # Delete latest IP and verify same IP is rejected again |
|
46 | # Delete latest IP and verify same IP is rejected again | |
47 |
|
47 | |||
48 | x = UserIpMap.query().filter_by(ip_addr='0.0.1.0/24').first() |
|
48 | x = UserIpMap.query().filter_by(ip_addr='0.0.1.0/24').first() | |
49 | response = self.app.post(url('edit_user_ips_delete', id=default_user_id), |
|
49 | response = self.app.post(base.url('edit_user_ips_delete', id=default_user_id), | |
50 | params=dict(del_ip_id=x.ip_id, |
|
50 | params=dict(del_ip_id=x.ip_id, | |
51 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
51 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
52 | invalidate_all_caches() |
|
52 | base.invalidate_all_caches() | |
53 |
|
53 | |||
54 | response = self.app.get(url('admin_permissions_ips'), |
|
54 | response = self.app.get(base.url('admin_permissions_ips'), | |
55 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403) |
|
55 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403) | |
56 |
|
56 | |||
57 | # Delete first IP and verify unlimited access again |
|
57 | # Delete first IP and verify unlimited access again | |
58 |
|
58 | |||
59 | x = UserIpMap.query().filter_by(ip_addr='0.0.0.0/24').first() |
|
59 | x = UserIpMap.query().filter_by(ip_addr='0.0.0.0/24').first() | |
60 | response = self.app.post(url('edit_user_ips_delete', id=default_user_id), |
|
60 | response = self.app.post(base.url('edit_user_ips_delete', id=default_user_id), | |
61 | params=dict(del_ip_id=x.ip_id, |
|
61 | params=dict(del_ip_id=x.ip_id, | |
62 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
62 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
63 | invalidate_all_caches() |
|
63 | base.invalidate_all_caches() | |
64 |
|
64 | |||
65 | response = self.app.get(url('admin_permissions_ips'), |
|
65 | response = self.app.get(base.url('admin_permissions_ips'), | |
66 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}) |
|
66 | extra_environ={'REMOTE_ADDR': '0.0.1.1'}) | |
67 |
|
67 | |||
68 | def test_index_overview(self): |
|
68 | def test_index_overview(self): | |
69 | self.log_user() |
|
69 | self.log_user() | |
70 | response = self.app.get(url('admin_permissions_perms')) |
|
70 | response = self.app.get(base.url('admin_permissions_perms')) | |
71 | # Test response... |
|
71 | # Test response... | |
72 |
|
72 | |||
73 | def test_edit_permissions_permissions(self): |
|
73 | def test_edit_permissions_permissions(self): | |
74 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
74 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
75 |
|
75 | |||
76 | # Test unauthenticated access - it will redirect to login page |
|
76 | # Test unauthenticated access - it will redirect to login page | |
77 | response = self.app.post( |
|
77 | response = self.app.post( | |
78 | url('edit_repo_perms_update', repo_name=HG_REPO), |
|
78 | base.url('edit_repo_perms_update', repo_name=base.HG_REPO), | |
79 | params=dict( |
|
79 | params=dict( | |
80 | perm_new_member_1='repository.read', |
|
80 | perm_new_member_1='repository.read', | |
81 | perm_new_member_name_1=user.username, |
|
81 | perm_new_member_name_1=user.username, | |
@@ -83,24 +83,24 b' class TestAdminPermissionsController(Tes' | |||||
83 | _session_csrf_secret_token=self.session_csrf_secret_token()), |
|
83 | _session_csrf_secret_token=self.session_csrf_secret_token()), | |
84 | status=302) |
|
84 | status=302) | |
85 |
|
85 | |||
86 | assert not response.location.endswith(url('edit_repo_perms_update', repo_name=HG_REPO)) |
|
86 | assert not response.location.endswith(base.url('edit_repo_perms_update', repo_name=base.HG_REPO)) | |
87 | assert response.location.endswith(url('login_home', came_from=url('edit_repo_perms_update', repo_name=HG_REPO))) |
|
87 | assert response.location.endswith(base.url('login_home', came_from=base.url('edit_repo_perms_update', repo_name=base.HG_REPO))) | |
88 |
|
88 | |||
89 | response = self.app.post( |
|
89 | response = self.app.post( | |
90 | url('edit_repo_perms_revoke', repo_name=HG_REPO), |
|
90 | base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO), | |
91 | params=dict( |
|
91 | params=dict( | |
92 | obj_type='user', |
|
92 | obj_type='user', | |
93 | user_id=user.user_id, |
|
93 | user_id=user.user_id, | |
94 | _session_csrf_secret_token=self.session_csrf_secret_token()), |
|
94 | _session_csrf_secret_token=self.session_csrf_secret_token()), | |
95 | status=302) |
|
95 | status=302) | |
96 |
|
96 | |||
97 | assert response.location.endswith(url('login_home', came_from=url('edit_repo_perms_revoke', repo_name=HG_REPO))) |
|
97 | assert response.location.endswith(base.url('login_home', came_from=base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO))) | |
98 |
|
98 | |||
99 | # Test authenticated access |
|
99 | # Test authenticated access | |
100 | self.log_user() |
|
100 | self.log_user() | |
101 |
|
101 | |||
102 | response = self.app.post( |
|
102 | response = self.app.post( | |
103 | url('edit_repo_perms_update', repo_name=HG_REPO), |
|
103 | base.url('edit_repo_perms_update', repo_name=base.HG_REPO), | |
104 | params=dict( |
|
104 | params=dict( | |
105 | perm_new_member_1='repository.read', |
|
105 | perm_new_member_1='repository.read', | |
106 | perm_new_member_name_1=user.username, |
|
106 | perm_new_member_name_1=user.username, | |
@@ -108,10 +108,10 b' class TestAdminPermissionsController(Tes' | |||||
108 | _session_csrf_secret_token=self.session_csrf_secret_token()), |
|
108 | _session_csrf_secret_token=self.session_csrf_secret_token()), | |
109 | status=302) |
|
109 | status=302) | |
110 |
|
110 | |||
111 | assert response.location.endswith(url('edit_repo_perms_update', repo_name=HG_REPO)) |
|
111 | assert response.location.endswith(base.url('edit_repo_perms_update', repo_name=base.HG_REPO)) | |
112 |
|
112 | |||
113 | response = self.app.post( |
|
113 | response = self.app.post( | |
114 | url('edit_repo_perms_revoke', repo_name=HG_REPO), |
|
114 | base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO), | |
115 | params=dict( |
|
115 | params=dict( | |
116 | obj_type='user', |
|
116 | obj_type='user', | |
117 | user_id=user.user_id, |
|
117 | user_id=user.user_id, |
@@ -13,7 +13,7 b' from kallithea.model.meta import Session' | |||||
13 | from kallithea.model.repo import RepoModel |
|
13 | from kallithea.model.repo import RepoModel | |
14 | from kallithea.model.repo_group import RepoGroupModel |
|
14 | from kallithea.model.repo_group import RepoGroupModel | |
15 | from kallithea.model.user import UserModel |
|
15 | from kallithea.model.user import UserModel | |
16 |
from kallithea.tests |
|
16 | from kallithea.tests import base | |
17 | from kallithea.tests.fixture import Fixture, error_function |
|
17 | from kallithea.tests.fixture import Fixture, error_function | |
18 |
|
18 | |||
19 |
|
19 | |||
@@ -29,7 +29,7 b' def _get_permission_for_user(user, repo)' | |||||
29 | return perm |
|
29 | return perm | |
30 |
|
30 | |||
31 |
|
31 | |||
32 | class _BaseTestCase(TestController): |
|
32 | class _BaseTestCase(base.TestController): | |
33 | """ |
|
33 | """ | |
34 | Write all tests here |
|
34 | Write all tests here | |
35 | """ |
|
35 | """ | |
@@ -41,20 +41,20 b' class _BaseTestCase(TestController):' | |||||
41 |
|
41 | |||
42 | def test_index(self): |
|
42 | def test_index(self): | |
43 | self.log_user() |
|
43 | self.log_user() | |
44 | response = self.app.get(url('repos')) |
|
44 | response = self.app.get(base.url('repos')) | |
45 |
|
45 | |||
46 | def test_create(self): |
|
46 | def test_create(self): | |
47 | self.log_user() |
|
47 | self.log_user() | |
48 | repo_name = self.NEW_REPO |
|
48 | repo_name = self.NEW_REPO | |
49 | description = u'description for newly created repo' |
|
49 | description = u'description for newly created repo' | |
50 | response = self.app.post(url('repos'), |
|
50 | response = self.app.post(base.url('repos'), | |
51 | fixture._get_repo_create_params(repo_private=False, |
|
51 | fixture._get_repo_create_params(repo_private=False, | |
52 | repo_name=repo_name, |
|
52 | repo_name=repo_name, | |
53 | repo_type=self.REPO_TYPE, |
|
53 | repo_type=self.REPO_TYPE, | |
54 | repo_description=description, |
|
54 | repo_description=description, | |
55 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
55 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
56 | ## run the check page that triggers the flash message |
|
56 | ## run the check page that triggers the flash message | |
57 | response = self.app.get(url('repo_check_home', repo_name=repo_name)) |
|
57 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) | |
58 | assert response.json == {u'result': True} |
|
58 | assert response.json == {u'result': True} | |
59 | self.checkSessionFlash(response, |
|
59 | self.checkSessionFlash(response, | |
60 | 'Created repository <a href="/%s">%s</a>' |
|
60 | 'Created repository <a href="/%s">%s</a>' | |
@@ -68,7 +68,7 b' class _BaseTestCase(TestController):' | |||||
68 | assert new_repo.description == description |
|
68 | assert new_repo.description == description | |
69 |
|
69 | |||
70 | # test if the repository is visible in the list ? |
|
70 | # test if the repository is visible in the list ? | |
71 | response = self.app.get(url('summary_home', repo_name=repo_name)) |
|
71 | response = self.app.get(base.url('summary_home', repo_name=repo_name)) | |
72 | response.mustcontain(repo_name) |
|
72 | response.mustcontain(repo_name) | |
73 | response.mustcontain(self.REPO_TYPE) |
|
73 | response.mustcontain(self.REPO_TYPE) | |
74 |
|
74 | |||
@@ -85,7 +85,7 b' class _BaseTestCase(TestController):' | |||||
85 | self.log_user() |
|
85 | self.log_user() | |
86 | repo_name = self.NEW_REPO |
|
86 | repo_name = self.NEW_REPO | |
87 | description = u'description for newly created repo' |
|
87 | description = u'description for newly created repo' | |
88 | response = self.app.post(url('repos'), |
|
88 | response = self.app.post(base.url('repos'), | |
89 | fixture._get_repo_create_params(repo_private=False, |
|
89 | fixture._get_repo_create_params(repo_private=False, | |
90 | repo_name=repo_name, |
|
90 | repo_name=repo_name, | |
91 | repo_type=self.REPO_TYPE, |
|
91 | repo_type=self.REPO_TYPE, | |
@@ -93,7 +93,7 b' class _BaseTestCase(TestController):' | |||||
93 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
93 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
94 | # try to create repo with swapped case |
|
94 | # try to create repo with swapped case | |
95 | swapped_repo_name = repo_name.swapcase() |
|
95 | swapped_repo_name = repo_name.swapcase() | |
96 | response = self.app.post(url('repos'), |
|
96 | response = self.app.post(base.url('repos'), | |
97 | fixture._get_repo_create_params(repo_private=False, |
|
97 | fixture._get_repo_create_params(repo_private=False, | |
98 | repo_name=swapped_repo_name, |
|
98 | repo_name=swapped_repo_name, | |
99 | repo_type=self.REPO_TYPE, |
|
99 | repo_type=self.REPO_TYPE, | |
@@ -111,13 +111,13 b' class _BaseTestCase(TestController):' | |||||
111 | group_name = u'sometest_%s' % self.REPO_TYPE |
|
111 | group_name = u'sometest_%s' % self.REPO_TYPE | |
112 | gr = RepoGroupModel().create(group_name=group_name, |
|
112 | gr = RepoGroupModel().create(group_name=group_name, | |
113 | group_description=u'test', |
|
113 | group_description=u'test', | |
114 | owner=TEST_USER_ADMIN_LOGIN) |
|
114 | owner=base.TEST_USER_ADMIN_LOGIN) | |
115 | Session().commit() |
|
115 | Session().commit() | |
116 |
|
116 | |||
117 | repo_name = u'ingroup' |
|
117 | repo_name = u'ingroup' | |
118 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
118 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
119 | description = u'description for newly created repo' |
|
119 | description = u'description for newly created repo' | |
120 | response = self.app.post(url('repos'), |
|
120 | response = self.app.post(base.url('repos'), | |
121 | fixture._get_repo_create_params(repo_private=False, |
|
121 | fixture._get_repo_create_params(repo_private=False, | |
122 | repo_name=repo_name, |
|
122 | repo_name=repo_name, | |
123 | repo_type=self.REPO_TYPE, |
|
123 | repo_type=self.REPO_TYPE, | |
@@ -125,7 +125,7 b' class _BaseTestCase(TestController):' | |||||
125 | repo_group=gr.group_id, |
|
125 | repo_group=gr.group_id, | |
126 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
126 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
127 | ## run the check page that triggers the flash message |
|
127 | ## run the check page that triggers the flash message | |
128 | response = self.app.get(url('repo_check_home', repo_name=repo_name_full)) |
|
128 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) | |
129 | assert response.json == {u'result': True} |
|
129 | assert response.json == {u'result': True} | |
130 | self.checkSessionFlash(response, |
|
130 | self.checkSessionFlash(response, | |
131 | 'Created repository <a href="/%s">%s</a>' |
|
131 | 'Created repository <a href="/%s">%s</a>' | |
@@ -139,7 +139,7 b' class _BaseTestCase(TestController):' | |||||
139 | assert new_repo.description == description |
|
139 | assert new_repo.description == description | |
140 |
|
140 | |||
141 | # test if the repository is visible in the list ? |
|
141 | # test if the repository is visible in the list ? | |
142 | response = self.app.get(url('summary_home', repo_name=repo_name_full)) |
|
142 | response = self.app.get(base.url('summary_home', repo_name=repo_name_full)) | |
143 | response.mustcontain(repo_name_full) |
|
143 | response.mustcontain(repo_name_full) | |
144 | response.mustcontain(self.REPO_TYPE) |
|
144 | response.mustcontain(self.REPO_TYPE) | |
145 |
|
145 | |||
@@ -160,7 +160,7 b' class _BaseTestCase(TestController):' | |||||
160 | Session().commit() |
|
160 | Session().commit() | |
161 |
|
161 | |||
162 | def test_create_in_group_without_needed_permissions(self): |
|
162 | def test_create_in_group_without_needed_permissions(self): | |
163 | usr = self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
163 | usr = self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
164 | # avoid spurious RepoGroup DetachedInstanceError ... |
|
164 | # avoid spurious RepoGroup DetachedInstanceError ... | |
165 | session_csrf_secret_token = self.session_csrf_secret_token() |
|
165 | session_csrf_secret_token = self.session_csrf_secret_token() | |
166 | # revoke |
|
166 | # revoke | |
@@ -172,29 +172,29 b' class _BaseTestCase(TestController):' | |||||
172 | user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none') |
|
172 | user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none') | |
173 |
|
173 | |||
174 | # disable on regular user |
|
174 | # disable on regular user | |
175 | user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository') |
|
175 | user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.repository') | |
176 | user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none') |
|
176 | user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.none') | |
177 | user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository') |
|
177 | user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.repository') | |
178 | user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none') |
|
178 | user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.none') | |
179 | Session().commit() |
|
179 | Session().commit() | |
180 |
|
180 | |||
181 | ## create GROUP |
|
181 | ## create GROUP | |
182 | group_name = u'reg_sometest_%s' % self.REPO_TYPE |
|
182 | group_name = u'reg_sometest_%s' % self.REPO_TYPE | |
183 | gr = RepoGroupModel().create(group_name=group_name, |
|
183 | gr = RepoGroupModel().create(group_name=group_name, | |
184 | group_description=u'test', |
|
184 | group_description=u'test', | |
185 | owner=TEST_USER_ADMIN_LOGIN) |
|
185 | owner=base.TEST_USER_ADMIN_LOGIN) | |
186 | Session().commit() |
|
186 | Session().commit() | |
187 |
|
187 | |||
188 | group_name_allowed = u'reg_sometest_allowed_%s' % self.REPO_TYPE |
|
188 | group_name_allowed = u'reg_sometest_allowed_%s' % self.REPO_TYPE | |
189 | gr_allowed = RepoGroupModel().create(group_name=group_name_allowed, |
|
189 | gr_allowed = RepoGroupModel().create(group_name=group_name_allowed, | |
190 | group_description=u'test', |
|
190 | group_description=u'test', | |
191 | owner=TEST_USER_REGULAR_LOGIN) |
|
191 | owner=base.TEST_USER_REGULAR_LOGIN) | |
192 | Session().commit() |
|
192 | Session().commit() | |
193 |
|
193 | |||
194 | repo_name = u'ingroup' |
|
194 | repo_name = u'ingroup' | |
195 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
195 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
196 | description = u'description for newly created repo' |
|
196 | description = u'description for newly created repo' | |
197 | response = self.app.post(url('repos'), |
|
197 | response = self.app.post(base.url('repos'), | |
198 | fixture._get_repo_create_params(repo_private=False, |
|
198 | fixture._get_repo_create_params(repo_private=False, | |
199 | repo_name=repo_name, |
|
199 | repo_name=repo_name, | |
200 | repo_type=self.REPO_TYPE, |
|
200 | repo_type=self.REPO_TYPE, | |
@@ -208,7 +208,7 b' class _BaseTestCase(TestController):' | |||||
208 | repo_name = u'ingroup' |
|
208 | repo_name = u'ingroup' | |
209 | repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name]) |
|
209 | repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name]) | |
210 | description = u'description for newly created repo' |
|
210 | description = u'description for newly created repo' | |
211 | response = self.app.post(url('repos'), |
|
211 | response = self.app.post(base.url('repos'), | |
212 | fixture._get_repo_create_params(repo_private=False, |
|
212 | fixture._get_repo_create_params(repo_private=False, | |
213 | repo_name=repo_name, |
|
213 | repo_name=repo_name, | |
214 | repo_type=self.REPO_TYPE, |
|
214 | repo_type=self.REPO_TYPE, | |
@@ -217,7 +217,7 b' class _BaseTestCase(TestController):' | |||||
217 | _session_csrf_secret_token=session_csrf_secret_token)) |
|
217 | _session_csrf_secret_token=session_csrf_secret_token)) | |
218 |
|
218 | |||
219 | ## run the check page that triggers the flash message |
|
219 | ## run the check page that triggers the flash message | |
220 | response = self.app.get(url('repo_check_home', repo_name=repo_name_full)) |
|
220 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) | |
221 | assert response.json == {u'result': True} |
|
221 | assert response.json == {u'result': True} | |
222 | self.checkSessionFlash(response, |
|
222 | self.checkSessionFlash(response, | |
223 | 'Created repository <a href="/%s">%s</a>' |
|
223 | 'Created repository <a href="/%s">%s</a>' | |
@@ -231,7 +231,7 b' class _BaseTestCase(TestController):' | |||||
231 | assert new_repo.description == description |
|
231 | assert new_repo.description == description | |
232 |
|
232 | |||
233 | # test if the repository is visible in the list ? |
|
233 | # test if the repository is visible in the list ? | |
234 | response = self.app.get(url('summary_home', repo_name=repo_name_full)) |
|
234 | response = self.app.get(base.url('summary_home', repo_name=repo_name_full)) | |
235 | response.mustcontain(repo_name_full) |
|
235 | response.mustcontain(repo_name_full) | |
236 | response.mustcontain(self.REPO_TYPE) |
|
236 | response.mustcontain(self.REPO_TYPE) | |
237 |
|
237 | |||
@@ -259,9 +259,9 b' class _BaseTestCase(TestController):' | |||||
259 | group_name = u'sometest_%s' % self.REPO_TYPE |
|
259 | group_name = u'sometest_%s' % self.REPO_TYPE | |
260 | gr = RepoGroupModel().create(group_name=group_name, |
|
260 | gr = RepoGroupModel().create(group_name=group_name, | |
261 | group_description=u'test', |
|
261 | group_description=u'test', | |
262 | owner=TEST_USER_ADMIN_LOGIN) |
|
262 | owner=base.TEST_USER_ADMIN_LOGIN) | |
263 | perm = Permission.get_by_key('repository.write') |
|
263 | perm = Permission.get_by_key('repository.write') | |
264 | RepoGroupModel().grant_user_permission(gr, TEST_USER_REGULAR_LOGIN, perm) |
|
264 | RepoGroupModel().grant_user_permission(gr, base.TEST_USER_REGULAR_LOGIN, perm) | |
265 |
|
265 | |||
266 | ## add repo permissions |
|
266 | ## add repo permissions | |
267 | Session().commit() |
|
267 | Session().commit() | |
@@ -269,7 +269,7 b' class _BaseTestCase(TestController):' | |||||
269 | repo_name = u'ingroup_inherited_%s' % self.REPO_TYPE |
|
269 | repo_name = u'ingroup_inherited_%s' % self.REPO_TYPE | |
270 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
270 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
271 | description = u'description for newly created repo' |
|
271 | description = u'description for newly created repo' | |
272 | response = self.app.post(url('repos'), |
|
272 | response = self.app.post(base.url('repos'), | |
273 | fixture._get_repo_create_params(repo_private=False, |
|
273 | fixture._get_repo_create_params(repo_private=False, | |
274 | repo_name=repo_name, |
|
274 | repo_name=repo_name, | |
275 | repo_type=self.REPO_TYPE, |
|
275 | repo_type=self.REPO_TYPE, | |
@@ -279,7 +279,7 b' class _BaseTestCase(TestController):' | |||||
279 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
279 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
280 |
|
280 | |||
281 | ## run the check page that triggers the flash message |
|
281 | ## run the check page that triggers the flash message | |
282 | response = self.app.get(url('repo_check_home', repo_name=repo_name_full)) |
|
282 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full)) | |
283 | self.checkSessionFlash(response, |
|
283 | self.checkSessionFlash(response, | |
284 | 'Created repository <a href="/%s">%s</a>' |
|
284 | 'Created repository <a href="/%s">%s</a>' | |
285 | % (repo_name_full, repo_name_full)) |
|
285 | % (repo_name_full, repo_name_full)) | |
@@ -292,7 +292,7 b' class _BaseTestCase(TestController):' | |||||
292 | assert new_repo.description == description |
|
292 | assert new_repo.description == description | |
293 |
|
293 | |||
294 | # test if the repository is visible in the list ? |
|
294 | # test if the repository is visible in the list ? | |
295 | response = self.app.get(url('summary_home', repo_name=repo_name_full)) |
|
295 | response = self.app.get(base.url('summary_home', repo_name=repo_name_full)) | |
296 | response.mustcontain(repo_name_full) |
|
296 | response.mustcontain(repo_name_full) | |
297 | response.mustcontain(self.REPO_TYPE) |
|
297 | response.mustcontain(self.REPO_TYPE) | |
298 |
|
298 | |||
@@ -309,7 +309,7 b' class _BaseTestCase(TestController):' | |||||
309 | .filter(UserRepoToPerm.repository_id == new_repo_id).all() |
|
309 | .filter(UserRepoToPerm.repository_id == new_repo_id).all() | |
310 | assert len(inherited_perms) == 2 |
|
310 | assert len(inherited_perms) == 2 | |
311 |
|
311 | |||
312 | assert TEST_USER_REGULAR_LOGIN in [x.user.username |
|
312 | assert base.TEST_USER_REGULAR_LOGIN in [x.user.username | |
313 | for x in inherited_perms] |
|
313 | for x in inherited_perms] | |
314 | assert 'repository.write' in [x.permission.permission_name |
|
314 | assert 'repository.write' in [x.permission.permission_name | |
315 | for x in inherited_perms] |
|
315 | for x in inherited_perms] | |
@@ -322,7 +322,7 b' class _BaseTestCase(TestController):' | |||||
322 | self.log_user() |
|
322 | self.log_user() | |
323 | repo_name = self.NEW_REPO |
|
323 | repo_name = self.NEW_REPO | |
324 | description = u'description for newly created repo' |
|
324 | description = u'description for newly created repo' | |
325 | response = self.app.post(url('repos'), |
|
325 | response = self.app.post(base.url('repos'), | |
326 | fixture._get_repo_create_params(repo_private=False, |
|
326 | fixture._get_repo_create_params(repo_private=False, | |
327 | repo_name=repo_name, |
|
327 | repo_name=repo_name, | |
328 | repo_type=self.REPO_TYPE, |
|
328 | repo_type=self.REPO_TYPE, | |
@@ -335,7 +335,7 b' class _BaseTestCase(TestController):' | |||||
335 | self.log_user() |
|
335 | self.log_user() | |
336 | repo_name = self.NEW_REPO |
|
336 | repo_name = self.NEW_REPO | |
337 | description = u'description for newly created repo' |
|
337 | description = u'description for newly created repo' | |
338 | response = self.app.post(url('repos'), |
|
338 | response = self.app.post(base.url('repos'), | |
339 | fixture._get_repo_create_params(repo_private=False, |
|
339 | fixture._get_repo_create_params(repo_private=False, | |
340 | repo_name=repo_name, |
|
340 | repo_name=repo_name, | |
341 | repo_type=self.REPO_TYPE, |
|
341 | repo_type=self.REPO_TYPE, | |
@@ -348,14 +348,14 b' class _BaseTestCase(TestController):' | |||||
348 | self.log_user() |
|
348 | self.log_user() | |
349 | repo_name = u'vcs_test_new_to_delete_%s' % self.REPO_TYPE |
|
349 | repo_name = u'vcs_test_new_to_delete_%s' % self.REPO_TYPE | |
350 | description = u'description for newly created repo' |
|
350 | description = u'description for newly created repo' | |
351 | response = self.app.post(url('repos'), |
|
351 | response = self.app.post(base.url('repos'), | |
352 | fixture._get_repo_create_params(repo_private=False, |
|
352 | fixture._get_repo_create_params(repo_private=False, | |
353 | repo_type=self.REPO_TYPE, |
|
353 | repo_type=self.REPO_TYPE, | |
354 | repo_name=repo_name, |
|
354 | repo_name=repo_name, | |
355 | repo_description=description, |
|
355 | repo_description=description, | |
356 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
356 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
357 | ## run the check page that triggers the flash message |
|
357 | ## run the check page that triggers the flash message | |
358 | response = self.app.get(url('repo_check_home', repo_name=repo_name)) |
|
358 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) | |
359 | self.checkSessionFlash(response, |
|
359 | self.checkSessionFlash(response, | |
360 | 'Created repository <a href="/%s">%s</a>' |
|
360 | 'Created repository <a href="/%s">%s</a>' | |
361 | % (repo_name, repo_name)) |
|
361 | % (repo_name, repo_name)) | |
@@ -367,7 +367,7 b' class _BaseTestCase(TestController):' | |||||
367 | assert new_repo.description == description |
|
367 | assert new_repo.description == description | |
368 |
|
368 | |||
369 | # test if the repository is visible in the list ? |
|
369 | # test if the repository is visible in the list ? | |
370 | response = self.app.get(url('summary_home', repo_name=repo_name)) |
|
370 | response = self.app.get(base.url('summary_home', repo_name=repo_name)) | |
371 | response.mustcontain(repo_name) |
|
371 | response.mustcontain(repo_name) | |
372 | response.mustcontain(self.REPO_TYPE) |
|
372 | response.mustcontain(self.REPO_TYPE) | |
373 |
|
373 | |||
@@ -377,7 +377,7 b' class _BaseTestCase(TestController):' | |||||
377 | except vcs.exceptions.VCSError: |
|
377 | except vcs.exceptions.VCSError: | |
378 | pytest.fail('no repo %s in filesystem' % repo_name) |
|
378 | pytest.fail('no repo %s in filesystem' % repo_name) | |
379 |
|
379 | |||
380 | response = self.app.post(url('delete_repo', repo_name=repo_name), |
|
380 | response = self.app.post(base.url('delete_repo', repo_name=repo_name), | |
381 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
381 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
382 |
|
382 | |||
383 | self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name)) |
|
383 | self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name)) | |
@@ -399,14 +399,14 b' class _BaseTestCase(TestController):' | |||||
399 | repo_name_unicode = safe_unicode(repo_name) |
|
399 | repo_name_unicode = safe_unicode(repo_name) | |
400 | description = 'description for newly created repo' + non_ascii |
|
400 | description = 'description for newly created repo' + non_ascii | |
401 | description_unicode = safe_unicode(description) |
|
401 | description_unicode = safe_unicode(description) | |
402 | response = self.app.post(url('repos'), |
|
402 | response = self.app.post(base.url('repos'), | |
403 | fixture._get_repo_create_params(repo_private=False, |
|
403 | fixture._get_repo_create_params(repo_private=False, | |
404 | repo_name=repo_name, |
|
404 | repo_name=repo_name, | |
405 | repo_type=self.REPO_TYPE, |
|
405 | repo_type=self.REPO_TYPE, | |
406 | repo_description=description, |
|
406 | repo_description=description, | |
407 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
407 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
408 | ## run the check page that triggers the flash message |
|
408 | ## run the check page that triggers the flash message | |
409 | response = self.app.get(url('repo_check_home', repo_name=repo_name)) |
|
409 | response = self.app.get(base.url('repo_check_home', repo_name=repo_name)) | |
410 | assert response.json == {u'result': True} |
|
410 | assert response.json == {u'result': True} | |
411 | self.checkSessionFlash(response, |
|
411 | self.checkSessionFlash(response, | |
412 | u'Created repository <a href="/%s">%s</a>' |
|
412 | u'Created repository <a href="/%s">%s</a>' | |
@@ -419,7 +419,7 b' class _BaseTestCase(TestController):' | |||||
419 | assert new_repo.description == description_unicode |
|
419 | assert new_repo.description == description_unicode | |
420 |
|
420 | |||
421 | # test if the repository is visible in the list ? |
|
421 | # test if the repository is visible in the list ? | |
422 | response = self.app.get(url('summary_home', repo_name=repo_name)) |
|
422 | response = self.app.get(base.url('summary_home', repo_name=repo_name)) | |
423 | response.mustcontain(repo_name) |
|
423 | response.mustcontain(repo_name) | |
424 | response.mustcontain(self.REPO_TYPE) |
|
424 | response.mustcontain(self.REPO_TYPE) | |
425 |
|
425 | |||
@@ -429,7 +429,7 b' class _BaseTestCase(TestController):' | |||||
429 | except vcs.exceptions.VCSError: |
|
429 | except vcs.exceptions.VCSError: | |
430 | pytest.fail('no repo %s in filesystem' % repo_name) |
|
430 | pytest.fail('no repo %s in filesystem' % repo_name) | |
431 |
|
431 | |||
432 | response = self.app.post(url('delete_repo', repo_name=repo_name), |
|
432 | response = self.app.post(base.url('delete_repo', repo_name=repo_name), | |
433 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
433 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
434 | self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name_unicode)) |
|
434 | self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name_unicode)) | |
435 | response.follow() |
|
435 | response.follow() | |
@@ -447,15 +447,15 b' class _BaseTestCase(TestController):' | |||||
447 | pass |
|
447 | pass | |
448 |
|
448 | |||
449 | def test_delete_browser_fakeout(self): |
|
449 | def test_delete_browser_fakeout(self): | |
450 | response = self.app.post(url('delete_repo', repo_name=self.REPO), |
|
450 | response = self.app.post(base.url('delete_repo', repo_name=self.REPO), | |
451 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
|
451 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) | |
452 |
|
452 | |||
453 | def test_show(self): |
|
453 | def test_show(self): | |
454 | self.log_user() |
|
454 | self.log_user() | |
455 | response = self.app.get(url('summary_home', repo_name=self.REPO)) |
|
455 | response = self.app.get(base.url('summary_home', repo_name=self.REPO)) | |
456 |
|
456 | |||
457 | def test_edit(self): |
|
457 | def test_edit(self): | |
458 | response = self.app.get(url('edit_repo', repo_name=self.REPO)) |
|
458 | response = self.app.get(base.url('edit_repo', repo_name=self.REPO)) | |
459 |
|
459 | |||
460 | def test_set_private_flag_sets_default_to_none(self): |
|
460 | def test_set_private_flag_sets_default_to_none(self): | |
461 | self.log_user() |
|
461 | self.log_user() | |
@@ -465,11 +465,11 b' class _BaseTestCase(TestController):' | |||||
465 | assert perm[0].permission.permission_name == 'repository.read' |
|
465 | assert perm[0].permission.permission_name == 'repository.read' | |
466 | assert Repository.get_by_repo_name(self.REPO).private == False |
|
466 | assert Repository.get_by_repo_name(self.REPO).private == False | |
467 |
|
467 | |||
468 | response = self.app.post(url('update_repo', repo_name=self.REPO), |
|
468 | response = self.app.post(base.url('update_repo', repo_name=self.REPO), | |
469 | fixture._get_repo_create_params(repo_private=1, |
|
469 | fixture._get_repo_create_params(repo_private=1, | |
470 | repo_name=self.REPO, |
|
470 | repo_name=self.REPO, | |
471 | repo_type=self.REPO_TYPE, |
|
471 | repo_type=self.REPO_TYPE, | |
472 | owner=TEST_USER_ADMIN_LOGIN, |
|
472 | owner=base.TEST_USER_ADMIN_LOGIN, | |
473 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
473 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
474 | self.checkSessionFlash(response, |
|
474 | self.checkSessionFlash(response, | |
475 | msg='Repository %s updated successfully' % (self.REPO)) |
|
475 | msg='Repository %s updated successfully' % (self.REPO)) | |
@@ -480,11 +480,11 b' class _BaseTestCase(TestController):' | |||||
480 | assert len(perm), 1 |
|
480 | assert len(perm), 1 | |
481 | assert perm[0].permission.permission_name == 'repository.none' |
|
481 | assert perm[0].permission.permission_name == 'repository.none' | |
482 |
|
482 | |||
483 | response = self.app.post(url('update_repo', repo_name=self.REPO), |
|
483 | response = self.app.post(base.url('update_repo', repo_name=self.REPO), | |
484 | fixture._get_repo_create_params(repo_private=False, |
|
484 | fixture._get_repo_create_params(repo_private=False, | |
485 | repo_name=self.REPO, |
|
485 | repo_name=self.REPO, | |
486 | repo_type=self.REPO_TYPE, |
|
486 | repo_type=self.REPO_TYPE, | |
487 | owner=TEST_USER_ADMIN_LOGIN, |
|
487 | owner=base.TEST_USER_ADMIN_LOGIN, | |
488 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
488 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
489 | self.checkSessionFlash(response, |
|
489 | self.checkSessionFlash(response, | |
490 | msg='Repository %s updated successfully' % (self.REPO)) |
|
490 | msg='Repository %s updated successfully' % (self.REPO)) | |
@@ -502,7 +502,7 b' class _BaseTestCase(TestController):' | |||||
502 | def test_set_repo_fork_has_no_self_id(self): |
|
502 | def test_set_repo_fork_has_no_self_id(self): | |
503 | self.log_user() |
|
503 | self.log_user() | |
504 | repo = Repository.get_by_repo_name(self.REPO) |
|
504 | repo = Repository.get_by_repo_name(self.REPO) | |
505 | response = self.app.get(url('edit_repo_advanced', repo_name=self.REPO)) |
|
505 | response = self.app.get(base.url('edit_repo_advanced', repo_name=self.REPO)) | |
506 | opt = """<option value="%s">%s</option>""" % (repo.repo_id, self.REPO) |
|
506 | opt = """<option value="%s">%s</option>""" % (repo.repo_id, self.REPO) | |
507 | response.mustcontain(no=[opt]) |
|
507 | response.mustcontain(no=[opt]) | |
508 |
|
508 | |||
@@ -512,7 +512,7 b' class _BaseTestCase(TestController):' | |||||
512 | fixture.create_repo(other_repo, repo_type=self.REPO_TYPE) |
|
512 | fixture.create_repo(other_repo, repo_type=self.REPO_TYPE) | |
513 | repo = Repository.get_by_repo_name(self.REPO) |
|
513 | repo = Repository.get_by_repo_name(self.REPO) | |
514 | repo2 = Repository.get_by_repo_name(other_repo) |
|
514 | repo2 = Repository.get_by_repo_name(other_repo) | |
515 | response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO), |
|
515 | response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO), | |
516 | params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
516 | params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
517 | repo = Repository.get_by_repo_name(self.REPO) |
|
517 | repo = Repository.get_by_repo_name(self.REPO) | |
518 | repo2 = Repository.get_by_repo_name(other_repo) |
|
518 | repo2 = Repository.get_by_repo_name(other_repo) | |
@@ -533,7 +533,7 b' class _BaseTestCase(TestController):' | |||||
533 | self.log_user() |
|
533 | self.log_user() | |
534 | repo = Repository.get_by_repo_name(self.REPO) |
|
534 | repo = Repository.get_by_repo_name(self.REPO) | |
535 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) |
|
535 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) | |
536 | response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO), |
|
536 | response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO), | |
537 | params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
537 | params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
538 | repo = Repository.get_by_repo_name(self.REPO) |
|
538 | repo = Repository.get_by_repo_name(self.REPO) | |
539 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) |
|
539 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) | |
@@ -543,7 +543,7 b' class _BaseTestCase(TestController):' | |||||
543 | def test_set_fork_of_none(self): |
|
543 | def test_set_fork_of_none(self): | |
544 | self.log_user() |
|
544 | self.log_user() | |
545 | ## mark it as None |
|
545 | ## mark it as None | |
546 | response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO), |
|
546 | response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO), | |
547 | params=dict(id_fork_of=None, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
547 | params=dict(id_fork_of=None, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
548 | repo = Repository.get_by_repo_name(self.REPO) |
|
548 | repo = Repository.get_by_repo_name(self.REPO) | |
549 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) |
|
549 | repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO) | |
@@ -555,13 +555,13 b' class _BaseTestCase(TestController):' | |||||
555 | def test_set_fork_of_same_repo(self): |
|
555 | def test_set_fork_of_same_repo(self): | |
556 | self.log_user() |
|
556 | self.log_user() | |
557 | repo = Repository.get_by_repo_name(self.REPO) |
|
557 | repo = Repository.get_by_repo_name(self.REPO) | |
558 | response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO), |
|
558 | response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO), | |
559 | params=dict(id_fork_of=repo.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
559 | params=dict(id_fork_of=repo.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
560 | self.checkSessionFlash(response, |
|
560 | self.checkSessionFlash(response, | |
561 | 'An error occurred during this operation') |
|
561 | 'An error occurred during this operation') | |
562 |
|
562 | |||
563 | def test_create_on_top_level_without_permissions(self): |
|
563 | def test_create_on_top_level_without_permissions(self): | |
564 | usr = self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
564 | usr = self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
565 | # revoke |
|
565 | # revoke | |
566 | user_model = UserModel() |
|
566 | user_model = UserModel() | |
567 | # disable fork and create on default user |
|
567 | # disable fork and create on default user | |
@@ -571,10 +571,10 b' class _BaseTestCase(TestController):' | |||||
571 | user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none') |
|
571 | user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none') | |
572 |
|
572 | |||
573 | # disable on regular user |
|
573 | # disable on regular user | |
574 | user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository') |
|
574 | user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.repository') | |
575 | user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none') |
|
575 | user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.none') | |
576 | user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository') |
|
576 | user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.repository') | |
577 | user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none') |
|
577 | user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.none') | |
578 | Session().commit() |
|
578 | Session().commit() | |
579 |
|
579 | |||
580 |
|
580 | |||
@@ -582,7 +582,7 b' class _BaseTestCase(TestController):' | |||||
582 |
|
582 | |||
583 | repo_name = self.NEW_REPO + u'no_perms' |
|
583 | repo_name = self.NEW_REPO + u'no_perms' | |
584 | description = 'description for newly created repo' |
|
584 | description = 'description for newly created repo' | |
585 | response = self.app.post(url('repos'), |
|
585 | response = self.app.post(base.url('repos'), | |
586 | fixture._get_repo_create_params(repo_private=False, |
|
586 | fixture._get_repo_create_params(repo_private=False, | |
587 | repo_name=repo_name, |
|
587 | repo_name=repo_name, | |
588 | repo_type=self.REPO_TYPE, |
|
588 | repo_type=self.REPO_TYPE, | |
@@ -600,7 +600,7 b' class _BaseTestCase(TestController):' | |||||
600 | repo_name = self.NEW_REPO |
|
600 | repo_name = self.NEW_REPO | |
601 | description = 'description for newly created repo' |
|
601 | description = 'description for newly created repo' | |
602 |
|
602 | |||
603 | response = self.app.post(url('repos'), |
|
603 | response = self.app.post(base.url('repos'), | |
604 | fixture._get_repo_create_params(repo_private=False, |
|
604 | fixture._get_repo_create_params(repo_private=False, | |
605 | repo_name=repo_name, |
|
605 | repo_name=repo_name, | |
606 | repo_type=self.REPO_TYPE, |
|
606 | repo_type=self.REPO_TYPE, | |
@@ -618,18 +618,18 b' class _BaseTestCase(TestController):' | |||||
618 |
|
618 | |||
619 |
|
619 | |||
620 | class TestAdminReposControllerGIT(_BaseTestCase): |
|
620 | class TestAdminReposControllerGIT(_BaseTestCase): | |
621 | REPO = GIT_REPO |
|
621 | REPO = base.GIT_REPO | |
622 | REPO_TYPE = 'git' |
|
622 | REPO_TYPE = 'git' | |
623 | NEW_REPO = NEW_GIT_REPO |
|
623 | NEW_REPO = base.NEW_GIT_REPO | |
624 | OTHER_TYPE_REPO = HG_REPO |
|
624 | OTHER_TYPE_REPO = base.HG_REPO | |
625 | OTHER_TYPE = 'hg' |
|
625 | OTHER_TYPE = 'hg' | |
626 |
|
626 | |||
627 |
|
627 | |||
628 | class TestAdminReposControllerHG(_BaseTestCase): |
|
628 | class TestAdminReposControllerHG(_BaseTestCase): | |
629 | REPO = HG_REPO |
|
629 | REPO = base.HG_REPO | |
630 | REPO_TYPE = 'hg' |
|
630 | REPO_TYPE = 'hg' | |
631 | NEW_REPO = NEW_HG_REPO |
|
631 | NEW_REPO = base.NEW_HG_REPO | |
632 | OTHER_TYPE_REPO = GIT_REPO |
|
632 | OTHER_TYPE_REPO = base.GIT_REPO | |
633 | OTHER_TYPE = 'git' |
|
633 | OTHER_TYPE = 'git' | |
634 |
|
634 | |||
635 | def test_permanent_url_protocol_access(self): |
|
635 | def test_permanent_url_protocol_access(self): | |
@@ -637,7 +637,7 b' class TestAdminReposControllerHG(_BaseTe' | |||||
637 | permanent_name = '_%d' % repo.repo_id |
|
637 | permanent_name = '_%d' % repo.repo_id | |
638 |
|
638 | |||
639 | # 400 Bad Request - Unable to detect pull/push action |
|
639 | # 400 Bad Request - Unable to detect pull/push action | |
640 | self.app.get(url('summary_home', repo_name=permanent_name), |
|
640 | self.app.get(base.url('summary_home', repo_name=permanent_name), | |
641 | extra_environ={'HTTP_ACCEPT': 'application/mercurial'}, |
|
641 | extra_environ={'HTTP_ACCEPT': 'application/mercurial'}, | |
642 | status=400, |
|
642 | status=400, | |
643 | ) |
|
643 | ) |
@@ -1,54 +1,54 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | from kallithea.model.db import Setting, Ui |
|
3 | from kallithea.model.db import Setting, Ui | |
4 |
from kallithea.tests |
|
4 | from kallithea.tests import base | |
5 | from kallithea.tests.fixture import Fixture |
|
5 | from kallithea.tests.fixture import Fixture | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | fixture = Fixture() |
|
8 | fixture = Fixture() | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | class TestAdminSettingsController(TestController): |
|
11 | class TestAdminSettingsController(base.TestController): | |
12 |
|
12 | |||
13 | def test_index_main(self): |
|
13 | def test_index_main(self): | |
14 | self.log_user() |
|
14 | self.log_user() | |
15 | response = self.app.get(url('admin_settings')) |
|
15 | response = self.app.get(base.url('admin_settings')) | |
16 |
|
16 | |||
17 | def test_index_mapping(self): |
|
17 | def test_index_mapping(self): | |
18 | self.log_user() |
|
18 | self.log_user() | |
19 | response = self.app.get(url('admin_settings_mapping')) |
|
19 | response = self.app.get(base.url('admin_settings_mapping')) | |
20 |
|
20 | |||
21 | def test_index_global(self): |
|
21 | def test_index_global(self): | |
22 | self.log_user() |
|
22 | self.log_user() | |
23 | response = self.app.get(url('admin_settings_global')) |
|
23 | response = self.app.get(base.url('admin_settings_global')) | |
24 |
|
24 | |||
25 | def test_index_visual(self): |
|
25 | def test_index_visual(self): | |
26 | self.log_user() |
|
26 | self.log_user() | |
27 | response = self.app.get(url('admin_settings_visual')) |
|
27 | response = self.app.get(base.url('admin_settings_visual')) | |
28 |
|
28 | |||
29 | def test_index_email(self): |
|
29 | def test_index_email(self): | |
30 | self.log_user() |
|
30 | self.log_user() | |
31 | response = self.app.get(url('admin_settings_email')) |
|
31 | response = self.app.get(base.url('admin_settings_email')) | |
32 |
|
32 | |||
33 | def test_index_hooks(self): |
|
33 | def test_index_hooks(self): | |
34 | self.log_user() |
|
34 | self.log_user() | |
35 | response = self.app.get(url('admin_settings_hooks')) |
|
35 | response = self.app.get(base.url('admin_settings_hooks')) | |
36 |
|
36 | |||
37 | def test_create_custom_hook(self): |
|
37 | def test_create_custom_hook(self): | |
38 | self.log_user() |
|
38 | self.log_user() | |
39 | response = self.app.post(url('admin_settings_hooks'), |
|
39 | response = self.app.post(base.url('admin_settings_hooks'), | |
40 | params=dict(new_hook_ui_key='test_hooks_1', |
|
40 | params=dict(new_hook_ui_key='test_hooks_1', | |
41 | new_hook_ui_value='cd %s' % TESTS_TMP_PATH, |
|
41 | new_hook_ui_value='cd %s' % base.TESTS_TMP_PATH, | |
42 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
42 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
43 |
|
43 | |||
44 | self.checkSessionFlash(response, 'Added new hook') |
|
44 | self.checkSessionFlash(response, 'Added new hook') | |
45 | response = response.follow() |
|
45 | response = response.follow() | |
46 | response.mustcontain('test_hooks_1') |
|
46 | response.mustcontain('test_hooks_1') | |
47 | response.mustcontain('cd %s' % TESTS_TMP_PATH) |
|
47 | response.mustcontain('cd %s' % base.TESTS_TMP_PATH) | |
48 |
|
48 | |||
49 | def test_edit_custom_hook(self): |
|
49 | def test_edit_custom_hook(self): | |
50 | self.log_user() |
|
50 | self.log_user() | |
51 | response = self.app.post(url('admin_settings_hooks'), |
|
51 | response = self.app.post(base.url('admin_settings_hooks'), | |
52 | params=dict(hook_ui_key='test_hooks_1', |
|
52 | params=dict(hook_ui_key='test_hooks_1', | |
53 | hook_ui_value='old_value_of_hook_1', |
|
53 | hook_ui_value='old_value_of_hook_1', | |
54 | hook_ui_value_new='new_value_of_hook_1', |
|
54 | hook_ui_value_new='new_value_of_hook_1', | |
@@ -60,7 +60,7 b' class TestAdminSettingsController(TestCo' | |||||
60 |
|
60 | |||
61 | def test_add_existing_custom_hook(self): |
|
61 | def test_add_existing_custom_hook(self): | |
62 | self.log_user() |
|
62 | self.log_user() | |
63 | response = self.app.post(url('admin_settings_hooks'), |
|
63 | response = self.app.post(base.url('admin_settings_hooks'), | |
64 | params=dict(new_hook_ui_key='test_hooks_1', |
|
64 | params=dict(new_hook_ui_key='test_hooks_1', | |
65 | new_hook_ui_value='attempted_new_value', |
|
65 | new_hook_ui_value='attempted_new_value', | |
66 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
66 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
@@ -72,27 +72,27 b' class TestAdminSettingsController(TestCo' | |||||
72 |
|
72 | |||
73 | def test_create_custom_hook_delete(self): |
|
73 | def test_create_custom_hook_delete(self): | |
74 | self.log_user() |
|
74 | self.log_user() | |
75 | response = self.app.post(url('admin_settings_hooks'), |
|
75 | response = self.app.post(base.url('admin_settings_hooks'), | |
76 | params=dict(new_hook_ui_key='test_hooks_2', |
|
76 | params=dict(new_hook_ui_key='test_hooks_2', | |
77 | new_hook_ui_value='cd %s2' % TESTS_TMP_PATH, |
|
77 | new_hook_ui_value='cd %s2' % base.TESTS_TMP_PATH, | |
78 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
78 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
79 |
|
79 | |||
80 | self.checkSessionFlash(response, 'Added new hook') |
|
80 | self.checkSessionFlash(response, 'Added new hook') | |
81 | response = response.follow() |
|
81 | response = response.follow() | |
82 | response.mustcontain('test_hooks_2') |
|
82 | response.mustcontain('test_hooks_2') | |
83 | response.mustcontain('cd %s2' % TESTS_TMP_PATH) |
|
83 | response.mustcontain('cd %s2' % base.TESTS_TMP_PATH) | |
84 |
|
84 | |||
85 | hook_id = Ui.get_by_key('hooks', 'test_hooks_2').ui_id |
|
85 | hook_id = Ui.get_by_key('hooks', 'test_hooks_2').ui_id | |
86 | ## delete |
|
86 | ## delete | |
87 | self.app.post(url('admin_settings_hooks'), |
|
87 | self.app.post(base.url('admin_settings_hooks'), | |
88 | params=dict(hook_id=hook_id, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
88 | params=dict(hook_id=hook_id, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
89 | response = self.app.get(url('admin_settings_hooks')) |
|
89 | response = self.app.get(base.url('admin_settings_hooks')) | |
90 | response.mustcontain(no=['test_hooks_2']) |
|
90 | response.mustcontain(no=['test_hooks_2']) | |
91 | response.mustcontain(no=['cd %s2' % TESTS_TMP_PATH]) |
|
91 | response.mustcontain(no=['cd %s2' % base.TESTS_TMP_PATH]) | |
92 |
|
92 | |||
93 | def test_add_existing_builtin_hook(self): |
|
93 | def test_add_existing_builtin_hook(self): | |
94 | self.log_user() |
|
94 | self.log_user() | |
95 | response = self.app.post(url('admin_settings_hooks'), |
|
95 | response = self.app.post(base.url('admin_settings_hooks'), | |
96 | params=dict(new_hook_ui_key='changegroup.update', |
|
96 | params=dict(new_hook_ui_key='changegroup.update', | |
97 | new_hook_ui_value='attempted_new_value', |
|
97 | new_hook_ui_value='attempted_new_value', | |
98 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
98 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
@@ -104,18 +104,18 b' class TestAdminSettingsController(TestCo' | |||||
104 |
|
104 | |||
105 | def test_index_search(self): |
|
105 | def test_index_search(self): | |
106 | self.log_user() |
|
106 | self.log_user() | |
107 | response = self.app.get(url('admin_settings_search')) |
|
107 | response = self.app.get(base.url('admin_settings_search')) | |
108 |
|
108 | |||
109 | def test_index_system(self): |
|
109 | def test_index_system(self): | |
110 | self.log_user() |
|
110 | self.log_user() | |
111 | response = self.app.get(url('admin_settings_system')) |
|
111 | response = self.app.get(base.url('admin_settings_system')) | |
112 |
|
112 | |||
113 | def test_ga_code_active(self): |
|
113 | def test_ga_code_active(self): | |
114 | self.log_user() |
|
114 | self.log_user() | |
115 | old_title = 'Kallithea' |
|
115 | old_title = 'Kallithea' | |
116 | old_realm = 'Kallithea authentication' |
|
116 | old_realm = 'Kallithea authentication' | |
117 | new_ga_code = 'ga-test-123456789' |
|
117 | new_ga_code = 'ga-test-123456789' | |
118 | response = self.app.post(url('admin_settings_global'), |
|
118 | response = self.app.post(base.url('admin_settings_global'), | |
119 | params=dict(title=old_title, |
|
119 | params=dict(title=old_title, | |
120 | realm=old_realm, |
|
120 | realm=old_realm, | |
121 | ga_code=new_ga_code, |
|
121 | ga_code=new_ga_code, | |
@@ -136,7 +136,7 b' class TestAdminSettingsController(TestCo' | |||||
136 | old_title = 'Kallithea' |
|
136 | old_title = 'Kallithea' | |
137 | old_realm = 'Kallithea authentication' |
|
137 | old_realm = 'Kallithea authentication' | |
138 | new_ga_code = '' |
|
138 | new_ga_code = '' | |
139 | response = self.app.post(url('admin_settings_global'), |
|
139 | response = self.app.post(base.url('admin_settings_global'), | |
140 | params=dict(title=old_title, |
|
140 | params=dict(title=old_title, | |
141 | realm=old_realm, |
|
141 | realm=old_realm, | |
142 | ga_code=new_ga_code, |
|
142 | ga_code=new_ga_code, | |
@@ -156,7 +156,7 b' class TestAdminSettingsController(TestCo' | |||||
156 | old_title = 'Kallithea' |
|
156 | old_title = 'Kallithea' | |
157 | old_realm = 'Kallithea authentication' |
|
157 | old_realm = 'Kallithea authentication' | |
158 | new_ga_code = '' |
|
158 | new_ga_code = '' | |
159 | response = self.app.post(url('admin_settings_global'), |
|
159 | response = self.app.post(base.url('admin_settings_global'), | |
160 | params=dict(title=old_title, |
|
160 | params=dict(title=old_title, | |
161 | realm=old_realm, |
|
161 | realm=old_realm, | |
162 | ga_code=new_ga_code, |
|
162 | ga_code=new_ga_code, | |
@@ -168,7 +168,7 b' class TestAdminSettingsController(TestCo' | |||||
168 | self.checkSessionFlash(response, 'Updated application settings') |
|
168 | self.checkSessionFlash(response, 'Updated application settings') | |
169 | assert Setting.get_app_settings()['captcha_private_key'] == '1234567890' |
|
169 | assert Setting.get_app_settings()['captcha_private_key'] == '1234567890' | |
170 |
|
170 | |||
171 | response = self.app.get(url('register')) |
|
171 | response = self.app.get(base.url('register')) | |
172 | response.mustcontain('captcha') |
|
172 | response.mustcontain('captcha') | |
173 |
|
173 | |||
174 | def test_captcha_deactivate(self): |
|
174 | def test_captcha_deactivate(self): | |
@@ -176,7 +176,7 b' class TestAdminSettingsController(TestCo' | |||||
176 | old_title = 'Kallithea' |
|
176 | old_title = 'Kallithea' | |
177 | old_realm = 'Kallithea authentication' |
|
177 | old_realm = 'Kallithea authentication' | |
178 | new_ga_code = '' |
|
178 | new_ga_code = '' | |
179 | response = self.app.post(url('admin_settings_global'), |
|
179 | response = self.app.post(base.url('admin_settings_global'), | |
180 | params=dict(title=old_title, |
|
180 | params=dict(title=old_title, | |
181 | realm=old_realm, |
|
181 | realm=old_realm, | |
182 | ga_code=new_ga_code, |
|
182 | ga_code=new_ga_code, | |
@@ -188,7 +188,7 b' class TestAdminSettingsController(TestCo' | |||||
188 | self.checkSessionFlash(response, 'Updated application settings') |
|
188 | self.checkSessionFlash(response, 'Updated application settings') | |
189 | assert Setting.get_app_settings()['captcha_private_key'] == '' |
|
189 | assert Setting.get_app_settings()['captcha_private_key'] == '' | |
190 |
|
190 | |||
191 | response = self.app.get(url('register')) |
|
191 | response = self.app.get(base.url('register')) | |
192 | response.mustcontain(no=['captcha']) |
|
192 | response.mustcontain(no=['captcha']) | |
193 |
|
193 | |||
194 | def test_title_change(self): |
|
194 | def test_title_change(self): | |
@@ -198,7 +198,7 b' class TestAdminSettingsController(TestCo' | |||||
198 | old_realm = 'Kallithea authentication' |
|
198 | old_realm = 'Kallithea authentication' | |
199 |
|
199 | |||
200 | for new_title in ['Changed', 'Ε»Γ³Εwik', old_title]: |
|
200 | for new_title in ['Changed', 'Ε»Γ³Εwik', old_title]: | |
201 | response = self.app.post(url('admin_settings_global'), |
|
201 | response = self.app.post(base.url('admin_settings_global'), | |
202 | params=dict(title=new_title, |
|
202 | params=dict(title=new_title, | |
203 | realm=old_realm, |
|
203 | realm=old_realm, | |
204 | ga_code='', |
|
204 | ga_code='', |
@@ -1,23 +1,23 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | from kallithea.model.db import Permission, UserGroup, UserGroupToPerm |
|
2 | from kallithea.model.db import Permission, UserGroup, UserGroupToPerm | |
3 | from kallithea.model.meta import Session |
|
3 | from kallithea.model.meta import Session | |
4 |
from kallithea.tests |
|
4 | from kallithea.tests import base | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | TEST_USER_GROUP = u'admins_test' |
|
7 | TEST_USER_GROUP = u'admins_test' | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | class TestAdminUsersGroupsController(TestController): |
|
10 | class TestAdminUsersGroupsController(base.TestController): | |
11 |
|
11 | |||
12 | def test_index(self): |
|
12 | def test_index(self): | |
13 | self.log_user() |
|
13 | self.log_user() | |
14 | response = self.app.get(url('users_groups')) |
|
14 | response = self.app.get(base.url('users_groups')) | |
15 | # Test response... |
|
15 | # Test response... | |
16 |
|
16 | |||
17 | def test_create(self): |
|
17 | def test_create(self): | |
18 | self.log_user() |
|
18 | self.log_user() | |
19 | users_group_name = TEST_USER_GROUP |
|
19 | users_group_name = TEST_USER_GROUP | |
20 | response = self.app.post(url('users_groups'), |
|
20 | response = self.app.post(base.url('users_groups'), | |
21 | {'users_group_name': users_group_name, |
|
21 | {'users_group_name': users_group_name, | |
22 | 'user_group_description': u'DESC', |
|
22 | 'user_group_description': u'DESC', | |
23 | 'active': True, |
|
23 | 'active': True, | |
@@ -30,19 +30,19 b' class TestAdminUsersGroupsController(Tes' | |||||
30 | '/edit">%s</a>' % TEST_USER_GROUP) |
|
30 | '/edit">%s</a>' % TEST_USER_GROUP) | |
31 |
|
31 | |||
32 | def test_new(self): |
|
32 | def test_new(self): | |
33 | response = self.app.get(url('new_users_group')) |
|
33 | response = self.app.get(base.url('new_users_group')) | |
34 |
|
34 | |||
35 | def test_update(self): |
|
35 | def test_update(self): | |
36 | response = self.app.post(url('update_users_group', id=1), status=403) |
|
36 | response = self.app.post(base.url('update_users_group', id=1), status=403) | |
37 |
|
37 | |||
38 | def test_update_browser_fakeout(self): |
|
38 | def test_update_browser_fakeout(self): | |
39 | response = self.app.post(url('update_users_group', id=1), |
|
39 | response = self.app.post(base.url('update_users_group', id=1), | |
40 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
|
40 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) | |
41 |
|
41 | |||
42 | def test_delete(self): |
|
42 | def test_delete(self): | |
43 | self.log_user() |
|
43 | self.log_user() | |
44 | users_group_name = TEST_USER_GROUP + 'another' |
|
44 | users_group_name = TEST_USER_GROUP + 'another' | |
45 | response = self.app.post(url('users_groups'), |
|
45 | response = self.app.post(base.url('users_groups'), | |
46 | {'users_group_name': users_group_name, |
|
46 | {'users_group_name': users_group_name, | |
47 | 'user_group_description': u'DESC', |
|
47 | 'user_group_description': u'DESC', | |
48 | 'active': True, |
|
48 | 'active': True, | |
@@ -55,7 +55,7 b' class TestAdminUsersGroupsController(Tes' | |||||
55 | gr = Session().query(UserGroup) \ |
|
55 | gr = Session().query(UserGroup) \ | |
56 | .filter(UserGroup.users_group_name == users_group_name).one() |
|
56 | .filter(UserGroup.users_group_name == users_group_name).one() | |
57 |
|
57 | |||
58 | response = self.app.post(url('delete_users_group', id=gr.users_group_id), |
|
58 | response = self.app.post(base.url('delete_users_group', id=gr.users_group_id), | |
59 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
59 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
60 |
|
60 | |||
61 | gr = Session().query(UserGroup) \ |
|
61 | gr = Session().query(UserGroup) \ | |
@@ -66,7 +66,7 b' class TestAdminUsersGroupsController(Tes' | |||||
66 | def test_default_perms_enable_repository_read_on_group(self): |
|
66 | def test_default_perms_enable_repository_read_on_group(self): | |
67 | self.log_user() |
|
67 | self.log_user() | |
68 | users_group_name = TEST_USER_GROUP + 'another2' |
|
68 | users_group_name = TEST_USER_GROUP + 'another2' | |
69 | response = self.app.post(url('users_groups'), |
|
69 | response = self.app.post(base.url('users_groups'), | |
70 | {'users_group_name': users_group_name, |
|
70 | {'users_group_name': users_group_name, | |
71 | 'user_group_description': u'DESC', |
|
71 | 'user_group_description': u'DESC', | |
72 | 'active': True, |
|
72 | 'active': True, | |
@@ -77,7 +77,7 b' class TestAdminUsersGroupsController(Tes' | |||||
77 | self.checkSessionFlash(response, |
|
77 | self.checkSessionFlash(response, | |
78 | 'Created user group ') |
|
78 | 'Created user group ') | |
79 | ## ENABLE REPO CREATE ON A GROUP |
|
79 | ## ENABLE REPO CREATE ON A GROUP | |
80 | response = self.app.post(url('edit_user_group_default_perms_update', |
|
80 | response = self.app.post(base.url('edit_user_group_default_perms_update', | |
81 | id=ug.users_group_id), |
|
81 | id=ug.users_group_id), | |
82 | {'create_repo_perm': True, |
|
82 | {'create_repo_perm': True, | |
83 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
83 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -97,7 +97,7 b' class TestAdminUsersGroupsController(Tes' | |||||
97 |
|
97 | |||
98 | ## DISABLE REPO CREATE ON A GROUP |
|
98 | ## DISABLE REPO CREATE ON A GROUP | |
99 | response = self.app.post( |
|
99 | response = self.app.post( | |
100 | url('edit_user_group_default_perms_update', id=ug.users_group_id), |
|
100 | base.url('edit_user_group_default_perms_update', id=ug.users_group_id), | |
101 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
101 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
102 |
|
102 | |||
103 | response.follow() |
|
103 | response.follow() | |
@@ -118,7 +118,7 b' class TestAdminUsersGroupsController(Tes' | |||||
118 | # DELETE ! |
|
118 | # DELETE ! | |
119 | ug = UserGroup.get_by_group_name(users_group_name) |
|
119 | ug = UserGroup.get_by_group_name(users_group_name) | |
120 | ugid = ug.users_group_id |
|
120 | ugid = ug.users_group_id | |
121 | response = self.app.post(url('delete_users_group', id=ug.users_group_id), |
|
121 | response = self.app.post(base.url('delete_users_group', id=ug.users_group_id), | |
122 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
122 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
123 | response = response.follow() |
|
123 | response = response.follow() | |
124 | gr = Session().query(UserGroup) \ |
|
124 | gr = Session().query(UserGroup) \ | |
@@ -135,7 +135,7 b' class TestAdminUsersGroupsController(Tes' | |||||
135 | def test_default_perms_enable_repository_fork_on_group(self): |
|
135 | def test_default_perms_enable_repository_fork_on_group(self): | |
136 | self.log_user() |
|
136 | self.log_user() | |
137 | users_group_name = TEST_USER_GROUP + 'another2' |
|
137 | users_group_name = TEST_USER_GROUP + 'another2' | |
138 | response = self.app.post(url('users_groups'), |
|
138 | response = self.app.post(base.url('users_groups'), | |
139 | {'users_group_name': users_group_name, |
|
139 | {'users_group_name': users_group_name, | |
140 | 'user_group_description': u'DESC', |
|
140 | 'user_group_description': u'DESC', | |
141 | 'active': True, |
|
141 | 'active': True, | |
@@ -146,7 +146,7 b' class TestAdminUsersGroupsController(Tes' | |||||
146 | self.checkSessionFlash(response, |
|
146 | self.checkSessionFlash(response, | |
147 | 'Created user group ') |
|
147 | 'Created user group ') | |
148 | ## ENABLE REPO CREATE ON A GROUP |
|
148 | ## ENABLE REPO CREATE ON A GROUP | |
149 | response = self.app.post(url('edit_user_group_default_perms_update', |
|
149 | response = self.app.post(base.url('edit_user_group_default_perms_update', | |
150 | id=ug.users_group_id), |
|
150 | id=ug.users_group_id), | |
151 | {'fork_repo_perm': True, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
151 | {'fork_repo_perm': True, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
152 |
|
152 | |||
@@ -165,7 +165,7 b' class TestAdminUsersGroupsController(Tes' | |||||
165 | [ug.users_group_id, p3.permission_id]]) |
|
165 | [ug.users_group_id, p3.permission_id]]) | |
166 |
|
166 | |||
167 | ## DISABLE REPO CREATE ON A GROUP |
|
167 | ## DISABLE REPO CREATE ON A GROUP | |
168 | response = self.app.post(url('edit_user_group_default_perms_update', id=ug.users_group_id), |
|
168 | response = self.app.post(base.url('edit_user_group_default_perms_update', id=ug.users_group_id), | |
169 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
169 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
170 |
|
170 | |||
171 | response.follow() |
|
171 | response.follow() | |
@@ -185,7 +185,7 b' class TestAdminUsersGroupsController(Tes' | |||||
185 | # DELETE ! |
|
185 | # DELETE ! | |
186 | ug = UserGroup.get_by_group_name(users_group_name) |
|
186 | ug = UserGroup.get_by_group_name(users_group_name) | |
187 | ugid = ug.users_group_id |
|
187 | ugid = ug.users_group_id | |
188 | response = self.app.post(url('delete_users_group', id=ug.users_group_id), |
|
188 | response = self.app.post(base.url('delete_users_group', id=ug.users_group_id), | |
189 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
189 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
190 | response = response.follow() |
|
190 | response = response.follow() | |
191 | gr = Session().query(UserGroup) \ |
|
191 | gr = Session().query(UserGroup) \ | |
@@ -201,5 +201,5 b' class TestAdminUsersGroupsController(Tes' | |||||
201 | assert perms == [] |
|
201 | assert perms == [] | |
202 |
|
202 | |||
203 | def test_delete_browser_fakeout(self): |
|
203 | def test_delete_browser_fakeout(self): | |
204 | response = self.app.post(url('delete_users_group', id=1), |
|
204 | response = self.app.post(base.url('delete_users_group', id=1), | |
205 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
|
205 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
@@ -24,7 +24,7 b' from kallithea.model import validators' | |||||
24 | from kallithea.model.db import Permission, RepoGroup, User, UserApiKeys, UserSshKeys |
|
24 | from kallithea.model.db import Permission, RepoGroup, User, UserApiKeys, UserSshKeys | |
25 | from kallithea.model.meta import Session |
|
25 | from kallithea.model.meta import Session | |
26 | from kallithea.model.user import UserModel |
|
26 | from kallithea.model.user import UserModel | |
27 |
from kallithea.tests |
|
27 | from kallithea.tests import base | |
28 | from kallithea.tests.fixture import Fixture |
|
28 | from kallithea.tests.fixture import Fixture | |
29 |
|
29 | |||
30 |
|
30 | |||
@@ -43,7 +43,7 b' def user_and_repo_group_fail():' | |||||
43 | fixture.destroy_repo_group(repo_group) |
|
43 | fixture.destroy_repo_group(repo_group) | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | class TestAdminUsersController(TestController): |
|
46 | class TestAdminUsersController(base.TestController): | |
47 | test_user_1 = 'testme' |
|
47 | test_user_1 = 'testme' | |
48 |
|
48 | |||
49 | @classmethod |
|
49 | @classmethod | |
@@ -54,7 +54,7 b' class TestAdminUsersController(TestContr' | |||||
54 |
|
54 | |||
55 | def test_index(self): |
|
55 | def test_index(self): | |
56 | self.log_user() |
|
56 | self.log_user() | |
57 | response = self.app.get(url('users')) |
|
57 | response = self.app.get(base.url('users')) | |
58 | # TODO: Test response... |
|
58 | # TODO: Test response... | |
59 |
|
59 | |||
60 | def test_create(self): |
|
60 | def test_create(self): | |
@@ -66,7 +66,7 b' class TestAdminUsersController(TestContr' | |||||
66 | lastname = u'lastname' |
|
66 | lastname = u'lastname' | |
67 | email = 'mail@example.com' |
|
67 | email = 'mail@example.com' | |
68 |
|
68 | |||
69 | response = self.app.post(url('new_user'), |
|
69 | response = self.app.post(base.url('new_user'), | |
70 | {'username': username, |
|
70 | {'username': username, | |
71 | 'password': password, |
|
71 | 'password': password, | |
72 | 'password_confirmation': password_confirmation, |
|
72 | 'password_confirmation': password_confirmation, | |
@@ -102,7 +102,7 b' class TestAdminUsersController(TestContr' | |||||
102 | lastname = u'lastname' |
|
102 | lastname = u'lastname' | |
103 | email = 'errmail.example.com' |
|
103 | email = 'errmail.example.com' | |
104 |
|
104 | |||
105 | response = self.app.post(url('new_user'), |
|
105 | response = self.app.post(base.url('new_user'), | |
106 | {'username': username, |
|
106 | {'username': username, | |
107 | 'password': password, |
|
107 | 'password': password, | |
108 | 'name': name, |
|
108 | 'name': name, | |
@@ -126,9 +126,9 b' class TestAdminUsersController(TestContr' | |||||
126 |
|
126 | |||
127 | def test_new(self): |
|
127 | def test_new(self): | |
128 | self.log_user() |
|
128 | self.log_user() | |
129 | response = self.app.get(url('new_user')) |
|
129 | response = self.app.get(base.url('new_user')) | |
130 |
|
130 | |||
131 | @parametrize('name,attrs', |
|
131 | @base.parametrize('name,attrs', | |
132 | [('firstname', {'firstname': 'new_username'}), |
|
132 | [('firstname', {'firstname': 'new_username'}), | |
133 | ('lastname', {'lastname': 'new_username'}), |
|
133 | ('lastname', {'lastname': 'new_username'}), | |
134 | ('admin', {'admin': True}), |
|
134 | ('admin', {'admin': True}), | |
@@ -167,7 +167,7 b' class TestAdminUsersController(TestContr' | |||||
167 | # not filled so we use creation data |
|
167 | # not filled so we use creation data | |
168 |
|
168 | |||
169 | params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
169 | params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
170 | response = self.app.post(url('update_user', id=usr.user_id), params) |
|
170 | response = self.app.post(base.url('update_user', id=usr.user_id), params) | |
171 | self.checkSessionFlash(response, 'User updated successfully') |
|
171 | self.checkSessionFlash(response, 'User updated successfully') | |
172 | params.pop('_session_csrf_secret_token') |
|
172 | params.pop('_session_csrf_secret_token') | |
173 |
|
173 | |||
@@ -186,7 +186,7 b' class TestAdminUsersController(TestContr' | |||||
186 |
|
186 | |||
187 | new_user = Session().query(User) \ |
|
187 | new_user = Session().query(User) \ | |
188 | .filter(User.username == username).one() |
|
188 | .filter(User.username == username).one() | |
189 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
189 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
190 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
190 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
191 |
|
191 | |||
192 | self.checkSessionFlash(response, 'Successfully deleted user') |
|
192 | self.checkSessionFlash(response, 'Successfully deleted user') | |
@@ -201,18 +201,18 b' class TestAdminUsersController(TestContr' | |||||
201 |
|
201 | |||
202 | new_user = Session().query(User) \ |
|
202 | new_user = Session().query(User) \ | |
203 | .filter(User.username == username).one() |
|
203 | .filter(User.username == username).one() | |
204 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
204 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
205 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
205 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
206 | self.checkSessionFlash(response, 'User "%s" still ' |
|
206 | self.checkSessionFlash(response, 'User "%s" still ' | |
207 | 'owns 1 repositories and cannot be removed. ' |
|
207 | 'owns 1 repositories and cannot be removed. ' | |
208 | 'Switch owners or remove those repositories: ' |
|
208 | 'Switch owners or remove those repositories: ' | |
209 | '%s' % (username, reponame)) |
|
209 | '%s' % (username, reponame)) | |
210 |
|
210 | |||
211 | response = self.app.post(url('delete_repo', repo_name=reponame), |
|
211 | response = self.app.post(base.url('delete_repo', repo_name=reponame), | |
212 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
212 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
213 | self.checkSessionFlash(response, 'Deleted repository %s' % reponame) |
|
213 | self.checkSessionFlash(response, 'Deleted repository %s' % reponame) | |
214 |
|
214 | |||
215 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
215 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
216 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
216 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
217 | self.checkSessionFlash(response, 'Successfully deleted user') |
|
217 | self.checkSessionFlash(response, 'Successfully deleted user') | |
218 |
|
218 | |||
@@ -223,7 +223,7 b' class TestAdminUsersController(TestContr' | |||||
223 |
|
223 | |||
224 | self.log_user() |
|
224 | self.log_user() | |
225 |
|
225 | |||
226 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
226 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
227 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
227 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
228 | self.checkSessionFlash(response, 'User "%s" still ' |
|
228 | self.checkSessionFlash(response, 'User "%s" still ' | |
229 | 'owns 1 repository groups and cannot be removed. ' |
|
229 | 'owns 1 repository groups and cannot be removed. ' | |
@@ -232,13 +232,13 b' class TestAdminUsersController(TestContr' | |||||
232 |
|
232 | |||
233 | # Relevant _if_ the user deletion succeeded to make sure we can render groups without owner |
|
233 | # Relevant _if_ the user deletion succeeded to make sure we can render groups without owner | |
234 | # rg = RepoGroup.get_by_group_name(group_name=groupname) |
|
234 | # rg = RepoGroup.get_by_group_name(group_name=groupname) | |
235 | # response = self.app.get(url('repos_groups', id=rg.group_id)) |
|
235 | # response = self.app.get(base.url('repos_groups', id=rg.group_id)) | |
236 |
|
236 | |||
237 | response = self.app.post(url('delete_repo_group', group_name=groupname), |
|
237 | response = self.app.post(base.url('delete_repo_group', group_name=groupname), | |
238 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
238 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
239 | self.checkSessionFlash(response, 'Removed repository group %s' % groupname) |
|
239 | self.checkSessionFlash(response, 'Removed repository group %s' % groupname) | |
240 |
|
240 | |||
241 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
241 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
242 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
242 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
243 | self.checkSessionFlash(response, 'Successfully deleted user') |
|
243 | self.checkSessionFlash(response, 'Successfully deleted user') | |
244 |
|
244 | |||
@@ -252,7 +252,7 b' class TestAdminUsersController(TestContr' | |||||
252 |
|
252 | |||
253 | new_user = Session().query(User) \ |
|
253 | new_user = Session().query(User) \ | |
254 | .filter(User.username == username).one() |
|
254 | .filter(User.username == username).one() | |
255 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
255 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
256 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
256 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
257 | self.checkSessionFlash(response, 'User "%s" still ' |
|
257 | self.checkSessionFlash(response, 'User "%s" still ' | |
258 | 'owns 1 user groups and cannot be removed. ' |
|
258 | 'owns 1 user groups and cannot be removed. ' | |
@@ -260,19 +260,19 b' class TestAdminUsersController(TestContr' | |||||
260 | '%s' % (username, groupname)) |
|
260 | '%s' % (username, groupname)) | |
261 |
|
261 | |||
262 | # TODO: why do this fail? |
|
262 | # TODO: why do this fail? | |
263 | #response = self.app.delete(url('delete_users_group', id=groupname)) |
|
263 | #response = self.app.delete(base.url('delete_users_group', id=groupname)) | |
264 | #self.checkSessionFlash(response, 'Removed user group %s' % groupname) |
|
264 | #self.checkSessionFlash(response, 'Removed user group %s' % groupname) | |
265 |
|
265 | |||
266 | fixture.destroy_user_group(ug.users_group_id) |
|
266 | fixture.destroy_user_group(ug.users_group_id) | |
267 |
|
267 | |||
268 | response = self.app.post(url('delete_user', id=new_user.user_id), |
|
268 | response = self.app.post(base.url('delete_user', id=new_user.user_id), | |
269 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
269 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
270 | self.checkSessionFlash(response, 'Successfully deleted user') |
|
270 | self.checkSessionFlash(response, 'Successfully deleted user') | |
271 |
|
271 | |||
272 | def test_edit(self): |
|
272 | def test_edit(self): | |
273 | self.log_user() |
|
273 | self.log_user() | |
274 | user = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
274 | user = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
275 | response = self.app.get(url('edit_user', id=user.user_id)) |
|
275 | response = self.app.get(base.url('edit_user', id=user.user_id)) | |
276 |
|
276 | |||
277 | def test_add_perm_create_repo(self): |
|
277 | def test_add_perm_create_repo(self): | |
278 | self.log_user() |
|
278 | self.log_user() | |
@@ -290,7 +290,7 b' class TestAdminUsersController(TestContr' | |||||
290 | assert UserModel().has_perm(user, perm_none) == False |
|
290 | assert UserModel().has_perm(user, perm_none) == False | |
291 | assert UserModel().has_perm(user, perm_create) == False |
|
291 | assert UserModel().has_perm(user, perm_create) == False | |
292 |
|
292 | |||
293 | response = self.app.post(url('edit_user_perms_update', id=uid), |
|
293 | response = self.app.post(base.url('edit_user_perms_update', id=uid), | |
294 | params=dict(create_repo_perm=True, |
|
294 | params=dict(create_repo_perm=True, | |
295 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
295 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
296 |
|
296 | |||
@@ -320,7 +320,7 b' class TestAdminUsersController(TestContr' | |||||
320 | assert UserModel().has_perm(user, perm_none) == False |
|
320 | assert UserModel().has_perm(user, perm_none) == False | |
321 | assert UserModel().has_perm(user, perm_create) == False |
|
321 | assert UserModel().has_perm(user, perm_create) == False | |
322 |
|
322 | |||
323 | response = self.app.post(url('edit_user_perms_update', id=uid), |
|
323 | response = self.app.post(base.url('edit_user_perms_update', id=uid), | |
324 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
|
324 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) | |
325 |
|
325 | |||
326 | perm_none = Permission.get_by_key('hg.create.none') |
|
326 | perm_none = Permission.get_by_key('hg.create.none') | |
@@ -349,7 +349,7 b' class TestAdminUsersController(TestContr' | |||||
349 | assert UserModel().has_perm(user, perm_none) == False |
|
349 | assert UserModel().has_perm(user, perm_none) == False | |
350 | assert UserModel().has_perm(user, perm_fork) == False |
|
350 | assert UserModel().has_perm(user, perm_fork) == False | |
351 |
|
351 | |||
352 | response = self.app.post(url('edit_user_perms_update', id=uid), |
|
352 | response = self.app.post(base.url('edit_user_perms_update', id=uid), | |
353 | params=dict(create_repo_perm=True, |
|
353 | params=dict(create_repo_perm=True, | |
354 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
354 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
355 |
|
355 | |||
@@ -379,7 +379,7 b' class TestAdminUsersController(TestContr' | |||||
379 | assert UserModel().has_perm(user, perm_none) == False |
|
379 | assert UserModel().has_perm(user, perm_none) == False | |
380 | assert UserModel().has_perm(user, perm_fork) == False |
|
380 | assert UserModel().has_perm(user, perm_fork) == False | |
381 |
|
381 | |||
382 | response = self.app.post(url('edit_user_perms_update', id=uid), |
|
382 | response = self.app.post(base.url('edit_user_perms_update', id=uid), | |
383 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) |
|
383 | params=dict(_session_csrf_secret_token=self.session_csrf_secret_token())) | |
384 |
|
384 | |||
385 | perm_none = Permission.get_by_key('hg.create.none') |
|
385 | perm_none = Permission.get_by_key('hg.create.none') | |
@@ -394,11 +394,11 b' class TestAdminUsersController(TestContr' | |||||
394 |
|
394 | |||
395 | def test_ips(self): |
|
395 | def test_ips(self): | |
396 | self.log_user() |
|
396 | self.log_user() | |
397 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
397 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
398 | response = self.app.get(url('edit_user_ips', id=user.user_id)) |
|
398 | response = self.app.get(base.url('edit_user_ips', id=user.user_id)) | |
399 | response.mustcontain('All IP addresses are allowed') |
|
399 | response.mustcontain('All IP addresses are allowed') | |
400 |
|
400 | |||
401 | @parametrize('test_name,ip,ip_range,failure', [ |
|
401 | @base.parametrize('test_name,ip,ip_range,failure', [ | |
402 | ('127/24', '127.0.0.1/24', '127.0.0.0 - 127.0.0.255', False), |
|
402 | ('127/24', '127.0.0.1/24', '127.0.0.0 - 127.0.0.255', False), | |
403 | ('10/32', '10.0.0.10/32', '10.0.0.10 - 10.0.0.10', False), |
|
403 | ('10/32', '10.0.0.10/32', '10.0.0.10 - 10.0.0.10', False), | |
404 | ('0/16', '0.0.0.0/16', '0.0.0.0 - 0.0.255.255', False), |
|
404 | ('0/16', '0.0.0.0/16', '0.0.0.0 - 0.0.255.255', False), | |
@@ -408,26 +408,26 b' class TestAdminUsersController(TestContr' | |||||
408 | ]) |
|
408 | ]) | |
409 | def test_add_ip(self, test_name, ip, ip_range, failure, auto_clear_ip_permissions): |
|
409 | def test_add_ip(self, test_name, ip, ip_range, failure, auto_clear_ip_permissions): | |
410 | self.log_user() |
|
410 | self.log_user() | |
411 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
411 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
412 | user_id = user.user_id |
|
412 | user_id = user.user_id | |
413 |
|
413 | |||
414 | response = self.app.post(url('edit_user_ips_update', id=user_id), |
|
414 | response = self.app.post(base.url('edit_user_ips_update', id=user_id), | |
415 | params=dict(new_ip=ip, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
415 | params=dict(new_ip=ip, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
416 |
|
416 | |||
417 | if failure: |
|
417 | if failure: | |
418 | self.checkSessionFlash(response, 'Please enter a valid IPv4 or IPv6 address') |
|
418 | self.checkSessionFlash(response, 'Please enter a valid IPv4 or IPv6 address') | |
419 | response = self.app.get(url('edit_user_ips', id=user_id)) |
|
419 | response = self.app.get(base.url('edit_user_ips', id=user_id)) | |
420 | response.mustcontain(no=[ip]) |
|
420 | response.mustcontain(no=[ip]) | |
421 | response.mustcontain(no=[ip_range]) |
|
421 | response.mustcontain(no=[ip_range]) | |
422 |
|
422 | |||
423 | else: |
|
423 | else: | |
424 | response = self.app.get(url('edit_user_ips', id=user_id)) |
|
424 | response = self.app.get(base.url('edit_user_ips', id=user_id)) | |
425 | response.mustcontain(ip) |
|
425 | response.mustcontain(ip) | |
426 | response.mustcontain(ip_range) |
|
426 | response.mustcontain(ip_range) | |
427 |
|
427 | |||
428 | def test_delete_ip(self, auto_clear_ip_permissions): |
|
428 | def test_delete_ip(self, auto_clear_ip_permissions): | |
429 | self.log_user() |
|
429 | self.log_user() | |
430 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
430 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
431 | user_id = user.user_id |
|
431 | user_id = user.user_id | |
432 | ip = '127.0.0.1/32' |
|
432 | ip = '127.0.0.1/32' | |
433 | ip_range = '127.0.0.1 - 127.0.0.1' |
|
433 | ip_range = '127.0.0.1 - 127.0.0.1' | |
@@ -436,14 +436,14 b' class TestAdminUsersController(TestContr' | |||||
436 | Session().commit() |
|
436 | Session().commit() | |
437 | new_ip_id = new_ip.ip_id |
|
437 | new_ip_id = new_ip.ip_id | |
438 |
|
438 | |||
439 | response = self.app.get(url('edit_user_ips', id=user_id)) |
|
439 | response = self.app.get(base.url('edit_user_ips', id=user_id)) | |
440 | response.mustcontain(ip) |
|
440 | response.mustcontain(ip) | |
441 | response.mustcontain(ip_range) |
|
441 | response.mustcontain(ip_range) | |
442 |
|
442 | |||
443 | self.app.post(url('edit_user_ips_delete', id=user_id), |
|
443 | self.app.post(base.url('edit_user_ips_delete', id=user_id), | |
444 | params=dict(del_ip_id=new_ip_id, _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
444 | params=dict(del_ip_id=new_ip_id, _session_csrf_secret_token=self.session_csrf_secret_token())) | |
445 |
|
445 | |||
446 | response = self.app.get(url('edit_user_ips', id=user_id)) |
|
446 | response = self.app.get(base.url('edit_user_ips', id=user_id)) | |
447 | response.mustcontain('All IP addresses are allowed') |
|
447 | response.mustcontain('All IP addresses are allowed') | |
448 | response.mustcontain(no=[ip]) |
|
448 | response.mustcontain(no=[ip]) | |
449 | response.mustcontain(no=[ip_range]) |
|
449 | response.mustcontain(no=[ip_range]) | |
@@ -451,22 +451,22 b' class TestAdminUsersController(TestContr' | |||||
451 | def test_api_keys(self): |
|
451 | def test_api_keys(self): | |
452 | self.log_user() |
|
452 | self.log_user() | |
453 |
|
453 | |||
454 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
454 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
455 | response = self.app.get(url('edit_user_api_keys', id=user.user_id)) |
|
455 | response = self.app.get(base.url('edit_user_api_keys', id=user.user_id)) | |
456 | response.mustcontain(user.api_key) |
|
456 | response.mustcontain(user.api_key) | |
457 | response.mustcontain('Expires: Never') |
|
457 | response.mustcontain('Expires: Never') | |
458 |
|
458 | |||
459 | @parametrize('desc,lifetime', [ |
|
459 | @base.parametrize('desc,lifetime', [ | |
460 | ('forever', -1), |
|
460 | ('forever', -1), | |
461 | ('5mins', 60*5), |
|
461 | ('5mins', 60*5), | |
462 | ('30days', 60*60*24*30), |
|
462 | ('30days', 60*60*24*30), | |
463 | ]) |
|
463 | ]) | |
464 | def test_add_api_keys(self, desc, lifetime): |
|
464 | def test_add_api_keys(self, desc, lifetime): | |
465 | self.log_user() |
|
465 | self.log_user() | |
466 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
466 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
467 | user_id = user.user_id |
|
467 | user_id = user.user_id | |
468 |
|
468 | |||
469 | response = self.app.post(url('edit_user_api_keys_update', id=user_id), |
|
469 | response = self.app.post(base.url('edit_user_api_keys_update', id=user_id), | |
470 | {'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
470 | {'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
471 | self.checkSessionFlash(response, 'API key successfully created') |
|
471 | self.checkSessionFlash(response, 'API key successfully created') | |
472 | try: |
|
472 | try: | |
@@ -481,10 +481,10 b' class TestAdminUsersController(TestContr' | |||||
481 |
|
481 | |||
482 | def test_remove_api_key(self): |
|
482 | def test_remove_api_key(self): | |
483 | self.log_user() |
|
483 | self.log_user() | |
484 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
484 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
485 | user_id = user.user_id |
|
485 | user_id = user.user_id | |
486 |
|
486 | |||
487 | response = self.app.post(url('edit_user_api_keys_update', id=user_id), |
|
487 | response = self.app.post(base.url('edit_user_api_keys_update', id=user_id), | |
488 | {'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
488 | {'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
489 | self.checkSessionFlash(response, 'API key successfully created') |
|
489 | self.checkSessionFlash(response, 'API key successfully created') | |
490 | response = response.follow() |
|
490 | response = response.follow() | |
@@ -493,7 +493,7 b' class TestAdminUsersController(TestContr' | |||||
493 | keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() |
|
493 | keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() | |
494 | assert 1 == len(keys) |
|
494 | assert 1 == len(keys) | |
495 |
|
495 | |||
496 | response = self.app.post(url('edit_user_api_keys_delete', id=user_id), |
|
496 | response = self.app.post(base.url('edit_user_api_keys_delete', id=user_id), | |
497 | {'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
497 | {'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
498 | self.checkSessionFlash(response, 'API key successfully deleted') |
|
498 | self.checkSessionFlash(response, 'API key successfully deleted') | |
499 | keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() |
|
499 | keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all() | |
@@ -501,14 +501,14 b' class TestAdminUsersController(TestContr' | |||||
501 |
|
501 | |||
502 | def test_reset_main_api_key(self): |
|
502 | def test_reset_main_api_key(self): | |
503 | self.log_user() |
|
503 | self.log_user() | |
504 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
504 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
505 | user_id = user.user_id |
|
505 | user_id = user.user_id | |
506 | api_key = user.api_key |
|
506 | api_key = user.api_key | |
507 | response = self.app.get(url('edit_user_api_keys', id=user_id)) |
|
507 | response = self.app.get(base.url('edit_user_api_keys', id=user_id)) | |
508 | response.mustcontain(api_key) |
|
508 | response.mustcontain(api_key) | |
509 | response.mustcontain('Expires: Never') |
|
509 | response.mustcontain('Expires: Never') | |
510 |
|
510 | |||
511 | response = self.app.post(url('edit_user_api_keys_delete', id=user_id), |
|
511 | response = self.app.post(base.url('edit_user_api_keys_delete', id=user_id), | |
512 | {'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
512 | {'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
513 | self.checkSessionFlash(response, 'API key successfully reset') |
|
513 | self.checkSessionFlash(response, 'API key successfully reset') | |
514 | response = response.follow() |
|
514 | response = response.follow() | |
@@ -520,10 +520,10 b' class TestAdminUsersController(TestContr' | |||||
520 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' |
|
520 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
521 |
|
521 | |||
522 | self.log_user() |
|
522 | self.log_user() | |
523 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
523 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
524 | user_id = user.user_id |
|
524 | user_id = user.user_id | |
525 |
|
525 | |||
526 | response = self.app.post(url('edit_user_ssh_keys', id=user_id), |
|
526 | response = self.app.post(base.url('edit_user_ssh_keys', id=user_id), | |
527 | {'description': description, |
|
527 | {'description': description, | |
528 | 'public_key': public_key, |
|
528 | 'public_key': public_key, | |
529 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
529 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -543,10 +543,10 b' class TestAdminUsersController(TestContr' | |||||
543 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' |
|
543 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
544 |
|
544 | |||
545 | self.log_user() |
|
545 | self.log_user() | |
546 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
546 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
547 | user_id = user.user_id |
|
547 | user_id = user.user_id | |
548 |
|
548 | |||
549 | response = self.app.post(url('edit_user_ssh_keys', id=user_id), |
|
549 | response = self.app.post(base.url('edit_user_ssh_keys', id=user_id), | |
550 | {'description': description, |
|
550 | {'description': description, | |
551 | 'public_key': public_key, |
|
551 | 'public_key': public_key, | |
552 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
552 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -555,7 +555,7 b' class TestAdminUsersController(TestContr' | |||||
555 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() |
|
555 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() | |
556 | assert ssh_key.description == u'me@localhost' |
|
556 | assert ssh_key.description == u'me@localhost' | |
557 |
|
557 | |||
558 | response = self.app.post(url('edit_user_ssh_keys_delete', id=user_id), |
|
558 | response = self.app.post(base.url('edit_user_ssh_keys_delete', id=user_id), | |
559 | {'del_public_key': ssh_key.public_key, |
|
559 | {'del_public_key': ssh_key.public_key, | |
560 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
560 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
561 | self.checkSessionFlash(response, 'SSH key successfully deleted') |
|
561 | self.checkSessionFlash(response, 'SSH key successfully deleted') | |
@@ -563,7 +563,7 b' class TestAdminUsersController(TestContr' | |||||
563 | assert 0 == len(keys) |
|
563 | assert 0 == len(keys) | |
564 |
|
564 | |||
565 |
|
565 | |||
566 | class TestAdminUsersController_unittest(TestController): |
|
566 | class TestAdminUsersController_unittest(base.TestController): | |
567 | """ Unit tests for the users controller """ |
|
567 | """ Unit tests for the users controller """ | |
568 |
|
568 | |||
569 | def test_get_user_or_raise_if_default(self, monkeypatch, test_context_fixture): |
|
569 | def test_get_user_or_raise_if_default(self, monkeypatch, test_context_fixture): | |
@@ -574,14 +574,14 b' class TestAdminUsersController_unittest(' | |||||
574 |
|
574 | |||
575 | u = UsersController() |
|
575 | u = UsersController() | |
576 | # a regular user should work correctly |
|
576 | # a regular user should work correctly | |
577 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
577 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
578 | assert u._get_user_or_raise_if_default(user.user_id) == user |
|
578 | assert u._get_user_or_raise_if_default(user.user_id) == user | |
579 | # the default user should raise |
|
579 | # the default user should raise | |
580 | with pytest.raises(HTTPNotFound): |
|
580 | with pytest.raises(HTTPNotFound): | |
581 | u._get_user_or_raise_if_default(User.get_default_user().user_id) |
|
581 | u._get_user_or_raise_if_default(User.get_default_user().user_id) | |
582 |
|
582 | |||
583 |
|
583 | |||
584 | class TestAdminUsersControllerForDefaultUser(TestController): |
|
584 | class TestAdminUsersControllerForDefaultUser(base.TestController): | |
585 | """ |
|
585 | """ | |
586 | Edit actions on the default user are not allowed. |
|
586 | Edit actions on the default user are not allowed. | |
587 | Validate that they throw a 404 exception. |
|
587 | Validate that they throw a 404 exception. | |
@@ -589,59 +589,59 b' class TestAdminUsersControllerForDefault' | |||||
589 | def test_edit_default_user(self): |
|
589 | def test_edit_default_user(self): | |
590 | self.log_user() |
|
590 | self.log_user() | |
591 | user = User.get_default_user() |
|
591 | user = User.get_default_user() | |
592 | response = self.app.get(url('edit_user', id=user.user_id), status=404) |
|
592 | response = self.app.get(base.url('edit_user', id=user.user_id), status=404) | |
593 |
|
593 | |||
594 | def test_edit_advanced_default_user(self): |
|
594 | def test_edit_advanced_default_user(self): | |
595 | self.log_user() |
|
595 | self.log_user() | |
596 | user = User.get_default_user() |
|
596 | user = User.get_default_user() | |
597 | response = self.app.get(url('edit_user_advanced', id=user.user_id), status=404) |
|
597 | response = self.app.get(base.url('edit_user_advanced', id=user.user_id), status=404) | |
598 |
|
598 | |||
599 | # API keys |
|
599 | # API keys | |
600 | def test_edit_api_keys_default_user(self): |
|
600 | def test_edit_api_keys_default_user(self): | |
601 | self.log_user() |
|
601 | self.log_user() | |
602 | user = User.get_default_user() |
|
602 | user = User.get_default_user() | |
603 | response = self.app.get(url('edit_user_api_keys', id=user.user_id), status=404) |
|
603 | response = self.app.get(base.url('edit_user_api_keys', id=user.user_id), status=404) | |
604 |
|
604 | |||
605 | def test_add_api_keys_default_user(self): |
|
605 | def test_add_api_keys_default_user(self): | |
606 | self.log_user() |
|
606 | self.log_user() | |
607 | user = User.get_default_user() |
|
607 | user = User.get_default_user() | |
608 | response = self.app.post(url('edit_user_api_keys_update', id=user.user_id), |
|
608 | response = self.app.post(base.url('edit_user_api_keys_update', id=user.user_id), | |
609 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) |
|
609 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) | |
610 |
|
610 | |||
611 | def test_delete_api_keys_default_user(self): |
|
611 | def test_delete_api_keys_default_user(self): | |
612 | self.log_user() |
|
612 | self.log_user() | |
613 | user = User.get_default_user() |
|
613 | user = User.get_default_user() | |
614 | response = self.app.post(url('edit_user_api_keys_delete', id=user.user_id), |
|
614 | response = self.app.post(base.url('edit_user_api_keys_delete', id=user.user_id), | |
615 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) |
|
615 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) | |
616 |
|
616 | |||
617 | # Permissions |
|
617 | # Permissions | |
618 | def test_edit_perms_default_user(self): |
|
618 | def test_edit_perms_default_user(self): | |
619 | self.log_user() |
|
619 | self.log_user() | |
620 | user = User.get_default_user() |
|
620 | user = User.get_default_user() | |
621 | response = self.app.get(url('edit_user_perms', id=user.user_id), status=404) |
|
621 | response = self.app.get(base.url('edit_user_perms', id=user.user_id), status=404) | |
622 |
|
622 | |||
623 | def test_update_perms_default_user(self): |
|
623 | def test_update_perms_default_user(self): | |
624 | self.log_user() |
|
624 | self.log_user() | |
625 | user = User.get_default_user() |
|
625 | user = User.get_default_user() | |
626 | response = self.app.post(url('edit_user_perms_update', id=user.user_id), |
|
626 | response = self.app.post(base.url('edit_user_perms_update', id=user.user_id), | |
627 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) |
|
627 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) | |
628 |
|
628 | |||
629 | # Emails |
|
629 | # Emails | |
630 | def test_edit_emails_default_user(self): |
|
630 | def test_edit_emails_default_user(self): | |
631 | self.log_user() |
|
631 | self.log_user() | |
632 | user = User.get_default_user() |
|
632 | user = User.get_default_user() | |
633 | response = self.app.get(url('edit_user_emails', id=user.user_id), status=404) |
|
633 | response = self.app.get(base.url('edit_user_emails', id=user.user_id), status=404) | |
634 |
|
634 | |||
635 | def test_add_emails_default_user(self): |
|
635 | def test_add_emails_default_user(self): | |
636 | self.log_user() |
|
636 | self.log_user() | |
637 | user = User.get_default_user() |
|
637 | user = User.get_default_user() | |
638 | response = self.app.post(url('edit_user_emails_update', id=user.user_id), |
|
638 | response = self.app.post(base.url('edit_user_emails_update', id=user.user_id), | |
639 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) |
|
639 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) | |
640 |
|
640 | |||
641 | def test_delete_emails_default_user(self): |
|
641 | def test_delete_emails_default_user(self): | |
642 | self.log_user() |
|
642 | self.log_user() | |
643 | user = User.get_default_user() |
|
643 | user = User.get_default_user() | |
644 | response = self.app.post(url('edit_user_emails_delete', id=user.user_id), |
|
644 | response = self.app.post(base.url('edit_user_emails_delete', id=user.user_id), | |
645 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) |
|
645 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404) | |
646 |
|
646 | |||
647 | # IP addresses |
|
647 | # IP addresses | |
@@ -650,4 +650,4 b' class TestAdminUsersControllerForDefault' | |||||
650 | def test_edit_ip_default_user(self): |
|
650 | def test_edit_ip_default_user(self): | |
651 | self.log_user() |
|
651 | self.log_user() | |
652 | user = User.get_default_user() |
|
652 | user = User.get_default_user() | |
653 | response = self.app.get(url('edit_user_ips', id=user.user_id), status=404) |
|
653 | response = self.app.get(base.url('edit_user_ips', id=user.user_id), status=404) |
@@ -1,12 +1,12 b'' | |||||
1 |
from kallithea.tests |
|
1 | from kallithea.tests import base | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | class TestChangelogController(TestController): |
|
4 | class TestChangelogController(base.TestController): | |
5 |
|
5 | |||
6 | def test_index_hg(self): |
|
6 | def test_index_hg(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
8 | response = self.app.get(url(controller='changelog', action='index', |
|
8 | response = self.app.get(base.url(controller='changelog', action='index', | |
9 | repo_name=HG_REPO)) |
|
9 | repo_name=base.HG_REPO)) | |
10 |
|
10 | |||
11 | response.mustcontain('''id="chg_20" class="mergerow"''') |
|
11 | response.mustcontain('''id="chg_20" class="mergerow"''') | |
12 | response.mustcontain( |
|
12 | response.mustcontain( | |
@@ -17,7 +17,7 b' class TestChangelogController(TestContro' | |||||
17 | ) |
|
17 | ) | |
18 | # rev 640: code garden |
|
18 | # rev 640: code garden | |
19 | response.mustcontain( |
|
19 | response.mustcontain( | |
20 | """<a class="changeset_hash" href="/%s/changeset/0a4e54a4460401d6dbbd6a3604b17cd2b3606b82">r640:0a4e54a44604</a>""" % HG_REPO |
|
20 | """<a class="changeset_hash" href="/%s/changeset/0a4e54a4460401d6dbbd6a3604b17cd2b3606b82">r640:0a4e54a44604</a>""" % base.HG_REPO | |
21 | ) |
|
21 | ) | |
22 | response.mustcontain("""code garden""") |
|
22 | response.mustcontain("""code garden""") | |
23 |
|
23 | |||
@@ -26,18 +26,18 b' class TestChangelogController(TestContro' | |||||
26 | def test_index_pagination_hg(self): |
|
26 | def test_index_pagination_hg(self): | |
27 | self.log_user() |
|
27 | self.log_user() | |
28 | # pagination |
|
28 | # pagination | |
29 | self.app.get(url(controller='changelog', action='index', |
|
29 | self.app.get(base.url(controller='changelog', action='index', | |
30 | repo_name=HG_REPO), {'page': 1}) |
|
30 | repo_name=base.HG_REPO), {'page': 1}) | |
31 | self.app.get(url(controller='changelog', action='index', |
|
31 | self.app.get(base.url(controller='changelog', action='index', | |
32 | repo_name=HG_REPO), {'page': 2}) |
|
32 | repo_name=base.HG_REPO), {'page': 2}) | |
33 | self.app.get(url(controller='changelog', action='index', |
|
33 | self.app.get(base.url(controller='changelog', action='index', | |
34 | repo_name=HG_REPO), {'page': 3}) |
|
34 | repo_name=base.HG_REPO), {'page': 3}) | |
35 | self.app.get(url(controller='changelog', action='index', |
|
35 | self.app.get(base.url(controller='changelog', action='index', | |
36 | repo_name=HG_REPO), {'page': 4}) |
|
36 | repo_name=base.HG_REPO), {'page': 4}) | |
37 | self.app.get(url(controller='changelog', action='index', |
|
37 | self.app.get(base.url(controller='changelog', action='index', | |
38 | repo_name=HG_REPO), {'page': 5}) |
|
38 | repo_name=base.HG_REPO), {'page': 5}) | |
39 | response = self.app.get(url(controller='changelog', action='index', |
|
39 | response = self.app.get(base.url(controller='changelog', action='index', | |
40 | repo_name=HG_REPO), {'page': 6, 'size': 20}) |
|
40 | repo_name=base.HG_REPO), {'page': 6, 'size': 20}) | |
41 |
|
41 | |||
42 | # Test response after pagination... |
|
42 | # Test response after pagination... | |
43 | response.mustcontain( |
|
43 | response.mustcontain( | |
@@ -53,8 +53,8 b' class TestChangelogController(TestContro' | |||||
53 |
|
53 | |||
54 | def test_index_git(self): |
|
54 | def test_index_git(self): | |
55 | self.log_user() |
|
55 | self.log_user() | |
56 | response = self.app.get(url(controller='changelog', action='index', |
|
56 | response = self.app.get(base.url(controller='changelog', action='index', | |
57 | repo_name=GIT_REPO)) |
|
57 | repo_name=base.GIT_REPO)) | |
58 |
|
58 | |||
59 | response.mustcontain('''id="chg_20" class=""''') # why no mergerow for git? |
|
59 | response.mustcontain('''id="chg_20" class=""''') # why no mergerow for git? | |
60 | response.mustcontain( |
|
60 | response.mustcontain( | |
@@ -82,18 +82,18 b' class TestChangelogController(TestContro' | |||||
82 | def test_index_pagination_git(self): |
|
82 | def test_index_pagination_git(self): | |
83 | self.log_user() |
|
83 | self.log_user() | |
84 | # pagination |
|
84 | # pagination | |
85 | self.app.get(url(controller='changelog', action='index', |
|
85 | self.app.get(base.url(controller='changelog', action='index', | |
86 | repo_name=GIT_REPO), {'page': 1}) |
|
86 | repo_name=base.GIT_REPO), {'page': 1}) | |
87 | self.app.get(url(controller='changelog', action='index', |
|
87 | self.app.get(base.url(controller='changelog', action='index', | |
88 | repo_name=GIT_REPO), {'page': 2}) |
|
88 | repo_name=base.GIT_REPO), {'page': 2}) | |
89 | self.app.get(url(controller='changelog', action='index', |
|
89 | self.app.get(base.url(controller='changelog', action='index', | |
90 | repo_name=GIT_REPO), {'page': 3}) |
|
90 | repo_name=base.GIT_REPO), {'page': 3}) | |
91 | self.app.get(url(controller='changelog', action='index', |
|
91 | self.app.get(base.url(controller='changelog', action='index', | |
92 | repo_name=GIT_REPO), {'page': 4}) |
|
92 | repo_name=base.GIT_REPO), {'page': 4}) | |
93 | self.app.get(url(controller='changelog', action='index', |
|
93 | self.app.get(base.url(controller='changelog', action='index', | |
94 | repo_name=GIT_REPO), {'page': 5}) |
|
94 | repo_name=base.GIT_REPO), {'page': 5}) | |
95 | response = self.app.get(url(controller='changelog', action='index', |
|
95 | response = self.app.get(base.url(controller='changelog', action='index', | |
96 | repo_name=GIT_REPO), {'page': 6, 'size': 20}) |
|
96 | repo_name=base.GIT_REPO), {'page': 6, 'size': 20}) | |
97 |
|
97 | |||
98 | # Test response after pagination... |
|
98 | # Test response after pagination... | |
99 | response.mustcontain( |
|
99 | response.mustcontain( | |
@@ -109,9 +109,9 b' class TestChangelogController(TestContro' | |||||
109 |
|
109 | |||
110 | def test_index_hg_with_filenode(self): |
|
110 | def test_index_hg_with_filenode(self): | |
111 | self.log_user() |
|
111 | self.log_user() | |
112 | response = self.app.get(url(controller='changelog', action='index', |
|
112 | response = self.app.get(base.url(controller='changelog', action='index', | |
113 | revision='tip', f_path='/vcs/exceptions.py', |
|
113 | revision='tip', f_path='/vcs/exceptions.py', | |
114 | repo_name=HG_REPO)) |
|
114 | repo_name=base.HG_REPO)) | |
115 | # history commits messages |
|
115 | # history commits messages | |
116 | response.mustcontain('Added exceptions module, this time for real') |
|
116 | response.mustcontain('Added exceptions module, this time for real') | |
117 | response.mustcontain('Added not implemented hg backend test case') |
|
117 | response.mustcontain('Added not implemented hg backend test case') | |
@@ -120,9 +120,9 b' class TestChangelogController(TestContro' | |||||
120 |
|
120 | |||
121 | def test_index_git_with_filenode(self): |
|
121 | def test_index_git_with_filenode(self): | |
122 | self.log_user() |
|
122 | self.log_user() | |
123 | response = self.app.get(url(controller='changelog', action='index', |
|
123 | response = self.app.get(base.url(controller='changelog', action='index', | |
124 | revision='tip', f_path='/vcs/exceptions.py', |
|
124 | revision='tip', f_path='/vcs/exceptions.py', | |
125 | repo_name=GIT_REPO)) |
|
125 | repo_name=base.GIT_REPO)) | |
126 | # history commits messages |
|
126 | # history commits messages | |
127 | response.mustcontain('Added exceptions module, this time for real') |
|
127 | response.mustcontain('Added exceptions module, this time for real') | |
128 | response.mustcontain('Added not implemented hg backend test case') |
|
128 | response.mustcontain('Added not implemented hg backend test case') | |
@@ -130,28 +130,28 b' class TestChangelogController(TestContro' | |||||
130 |
|
130 | |||
131 | def test_index_hg_with_filenode_that_is_dirnode(self): |
|
131 | def test_index_hg_with_filenode_that_is_dirnode(self): | |
132 | self.log_user() |
|
132 | self.log_user() | |
133 | response = self.app.get(url(controller='changelog', action='index', |
|
133 | response = self.app.get(base.url(controller='changelog', action='index', | |
134 | revision='tip', f_path='/tests', |
|
134 | revision='tip', f_path='/tests', | |
135 | repo_name=HG_REPO)) |
|
135 | repo_name=base.HG_REPO)) | |
136 | assert response.status == '302 Found' |
|
136 | assert response.status == '302 Found' | |
137 |
|
137 | |||
138 | def test_index_git_with_filenode_that_is_dirnode(self): |
|
138 | def test_index_git_with_filenode_that_is_dirnode(self): | |
139 | self.log_user() |
|
139 | self.log_user() | |
140 | response = self.app.get(url(controller='changelog', action='index', |
|
140 | response = self.app.get(base.url(controller='changelog', action='index', | |
141 | revision='tip', f_path='/tests', |
|
141 | revision='tip', f_path='/tests', | |
142 | repo_name=GIT_REPO)) |
|
142 | repo_name=base.GIT_REPO)) | |
143 | assert response.status == '302 Found' |
|
143 | assert response.status == '302 Found' | |
144 |
|
144 | |||
145 | def test_index_hg_with_filenode_not_existing(self): |
|
145 | def test_index_hg_with_filenode_not_existing(self): | |
146 | self.log_user() |
|
146 | self.log_user() | |
147 | response = self.app.get(url(controller='changelog', action='index', |
|
147 | response = self.app.get(base.url(controller='changelog', action='index', | |
148 | revision='tip', f_path='/wrong_path', |
|
148 | revision='tip', f_path='/wrong_path', | |
149 | repo_name=HG_REPO)) |
|
149 | repo_name=base.HG_REPO)) | |
150 | assert response.status == '302 Found' |
|
150 | assert response.status == '302 Found' | |
151 |
|
151 | |||
152 | def test_index_git_with_filenode_not_existing(self): |
|
152 | def test_index_git_with_filenode_not_existing(self): | |
153 | self.log_user() |
|
153 | self.log_user() | |
154 | response = self.app.get(url(controller='changelog', action='index', |
|
154 | response = self.app.get(base.url(controller='changelog', action='index', | |
155 | revision='tip', f_path='/wrong_path', |
|
155 | revision='tip', f_path='/wrong_path', | |
156 | repo_name=GIT_REPO)) |
|
156 | repo_name=base.GIT_REPO)) | |
157 | assert response.status == '302 Found' |
|
157 | assert response.status == '302 Found' |
@@ -1,24 +1,24 b'' | |||||
1 |
from kallithea.tests |
|
1 | from kallithea.tests import base | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | class TestChangesetController(TestController): |
|
4 | class TestChangesetController(base.TestController): | |
5 |
|
5 | |||
6 | def test_index(self): |
|
6 | def test_index(self): | |
7 | response = self.app.get(url(controller='changeset', action='index', |
|
7 | response = self.app.get(base.url(controller='changeset', action='index', | |
8 | repo_name=HG_REPO, revision='tip')) |
|
8 | repo_name=base.HG_REPO, revision='tip')) | |
9 | # Test response... |
|
9 | # Test response... | |
10 |
|
10 | |||
11 | def test_changeset_range(self): |
|
11 | def test_changeset_range(self): | |
12 | #print self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO)) |
|
12 | #print self.app.get(base.url(controller='changelog', action='index', repo_name=base.HG_REPO)) | |
13 |
|
13 | |||
14 | response = self.app.get(url(controller='changeset', action='index', |
|
14 | response = self.app.get(base.url(controller='changeset', action='index', | |
15 | repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52...96507bd11ecc815ebc6270fdf6db110928c09c1e')) |
|
15 | repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52...96507bd11ecc815ebc6270fdf6db110928c09c1e')) | |
16 |
|
16 | |||
17 | response = self.app.get(url(controller='changeset', action='changeset_raw', |
|
17 | response = self.app.get(base.url(controller='changeset', action='changeset_raw', | |
18 | repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) |
|
18 | repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) | |
19 |
|
19 | |||
20 | response = self.app.get(url(controller='changeset', action='changeset_patch', |
|
20 | response = self.app.get(base.url(controller='changeset', action='changeset_patch', | |
21 | repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) |
|
21 | repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) | |
22 |
|
22 | |||
23 | response = self.app.get(url(controller='changeset', action='changeset_download', |
|
23 | response = self.app.get(base.url(controller='changeset', action='changeset_download', | |
24 | repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) |
|
24 | repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52')) |
@@ -3,10 +3,10 b' import re' | |||||
3 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
3 | from kallithea.model.changeset_status import ChangesetStatusModel | |
4 | from kallithea.model.db import ChangesetComment, PullRequest |
|
4 | from kallithea.model.db import ChangesetComment, PullRequest | |
5 | from kallithea.model.meta import Session |
|
5 | from kallithea.model.meta import Session | |
6 |
from kallithea.tests |
|
6 | from kallithea.tests import base | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | class TestChangeSetCommentsController(TestController): |
|
9 | class TestChangeSetCommentsController(base.TestController): | |
10 |
|
10 | |||
11 | def setup_method(self, method): |
|
11 | def setup_method(self, method): | |
12 | for x in ChangesetComment.query().all(): |
|
12 | for x in ChangesetComment.query().all(): | |
@@ -19,14 +19,14 b' class TestChangeSetCommentsController(Te' | |||||
19 | text = u'general comment on changeset' |
|
19 | text = u'general comment on changeset' | |
20 |
|
20 | |||
21 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
21 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
22 | response = self.app.post(url(controller='changeset', action='comment', |
|
22 | response = self.app.post(base.url(controller='changeset', action='comment', | |
23 | repo_name=HG_REPO, revision=rev), |
|
23 | repo_name=base.HG_REPO, revision=rev), | |
24 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
24 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
25 | # Test response... |
|
25 | # Test response... | |
26 | assert response.status == '200 OK' |
|
26 | assert response.status == '200 OK' | |
27 |
|
27 | |||
28 | response = self.app.get(url(controller='changeset', action='index', |
|
28 | response = self.app.get(base.url(controller='changeset', action='index', | |
29 | repo_name=HG_REPO, revision=rev)) |
|
29 | repo_name=base.HG_REPO, revision=rev)) | |
30 | response.mustcontain( |
|
30 | response.mustcontain( | |
31 | '''<div class="comments-number">''' |
|
31 | '''<div class="comments-number">''' | |
32 | ''' 1 comment (0 inline, 1 general)''' |
|
32 | ''' 1 comment (0 inline, 1 general)''' | |
@@ -44,14 +44,14 b' class TestChangeSetCommentsController(Te' | |||||
44 | line = 'n1' |
|
44 | line = 'n1' | |
45 |
|
45 | |||
46 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
46 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
47 | response = self.app.post(url(controller='changeset', action='comment', |
|
47 | response = self.app.post(base.url(controller='changeset', action='comment', | |
48 | repo_name=HG_REPO, revision=rev), |
|
48 | repo_name=base.HG_REPO, revision=rev), | |
49 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
49 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
50 | # Test response... |
|
50 | # Test response... | |
51 | assert response.status == '200 OK' |
|
51 | assert response.status == '200 OK' | |
52 |
|
52 | |||
53 | response = self.app.get(url(controller='changeset', action='index', |
|
53 | response = self.app.get(base.url(controller='changeset', action='index', | |
54 | repo_name=HG_REPO, revision=rev)) |
|
54 | repo_name=base.HG_REPO, revision=rev)) | |
55 | response.mustcontain( |
|
55 | response.mustcontain( | |
56 | '''<div class="comments-number">''' |
|
56 | '''<div class="comments-number">''' | |
57 | ''' 1 comment (1 inline, 0 general)''' |
|
57 | ''' 1 comment (1 inline, 0 general)''' | |
@@ -70,22 +70,22 b' class TestChangeSetCommentsController(Te' | |||||
70 | self.log_user() |
|
70 | self.log_user() | |
71 |
|
71 | |||
72 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
72 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
73 | text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN |
|
73 | text = u'@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN | |
74 |
|
74 | |||
75 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
75 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
76 | response = self.app.post(url(controller='changeset', action='comment', |
|
76 | response = self.app.post(base.url(controller='changeset', action='comment', | |
77 | repo_name=HG_REPO, revision=rev), |
|
77 | repo_name=base.HG_REPO, revision=rev), | |
78 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
78 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
79 | # Test response... |
|
79 | # Test response... | |
80 | assert response.status == '200 OK' |
|
80 | assert response.status == '200 OK' | |
81 |
|
81 | |||
82 | response = self.app.get(url(controller='changeset', action='index', |
|
82 | response = self.app.get(base.url(controller='changeset', action='index', | |
83 | repo_name=HG_REPO, revision=rev)) |
|
83 | repo_name=base.HG_REPO, revision=rev)) | |
84 | response.mustcontain( |
|
84 | response.mustcontain( | |
85 | '''<div class="comments-number">''' |
|
85 | '''<div class="comments-number">''' | |
86 | ''' 1 comment (0 inline, 1 general)''' |
|
86 | ''' 1 comment (0 inline, 1 general)''' | |
87 | ) |
|
87 | ) | |
88 | response.mustcontain('<b>@%s</b> check CommentOnRevision' % TEST_USER_REGULAR_LOGIN) |
|
88 | response.mustcontain('<b>@%s</b> check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN) | |
89 |
|
89 | |||
90 | # test DB |
|
90 | # test DB | |
91 | assert ChangesetComment.query().count() == 1 |
|
91 | assert ChangesetComment.query().count() == 1 | |
@@ -97,14 +97,14 b' class TestChangeSetCommentsController(Te' | |||||
97 |
|
97 | |||
98 | params = {'text': text, 'changeset_status': 'rejected', |
|
98 | params = {'text': text, 'changeset_status': 'rejected', | |
99 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
99 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
100 | response = self.app.post(url(controller='changeset', action='comment', |
|
100 | response = self.app.post(base.url(controller='changeset', action='comment', | |
101 | repo_name=HG_REPO, revision=rev), |
|
101 | repo_name=base.HG_REPO, revision=rev), | |
102 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
102 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
103 | # Test response... |
|
103 | # Test response... | |
104 | assert response.status == '200 OK' |
|
104 | assert response.status == '200 OK' | |
105 |
|
105 | |||
106 | response = self.app.get(url(controller='changeset', action='index', |
|
106 | response = self.app.get(base.url(controller='changeset', action='index', | |
107 | repo_name=HG_REPO, revision=rev)) |
|
107 | repo_name=base.HG_REPO, revision=rev)) | |
108 | response.mustcontain( |
|
108 | response.mustcontain( | |
109 | '''<div class="comments-number">''' |
|
109 | '''<div class="comments-number">''' | |
110 | ''' 1 comment (0 inline, 1 general)''' |
|
110 | ''' 1 comment (0 inline, 1 general)''' | |
@@ -115,7 +115,7 b' class TestChangeSetCommentsController(Te' | |||||
115 | assert ChangesetComment.query().count() == 1 |
|
115 | assert ChangesetComment.query().count() == 1 | |
116 |
|
116 | |||
117 | # check status |
|
117 | # check status | |
118 | status = ChangesetStatusModel().get_status(repo=HG_REPO, revision=rev) |
|
118 | status = ChangesetStatusModel().get_status(repo=base.HG_REPO, revision=rev) | |
119 | assert status == 'rejected' |
|
119 | assert status == 'rejected' | |
120 |
|
120 | |||
121 | def test_delete(self): |
|
121 | def test_delete(self): | |
@@ -124,24 +124,24 b' class TestChangeSetCommentsController(Te' | |||||
124 | text = u'general comment on changeset to be deleted' |
|
124 | text = u'general comment on changeset to be deleted' | |
125 |
|
125 | |||
126 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
126 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
127 | response = self.app.post(url(controller='changeset', action='comment', |
|
127 | response = self.app.post(base.url(controller='changeset', action='comment', | |
128 | repo_name=HG_REPO, revision=rev), |
|
128 | repo_name=base.HG_REPO, revision=rev), | |
129 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
129 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
130 |
|
130 | |||
131 | comments = ChangesetComment.query().all() |
|
131 | comments = ChangesetComment.query().all() | |
132 | assert len(comments) == 1 |
|
132 | assert len(comments) == 1 | |
133 | comment_id = comments[0].comment_id |
|
133 | comment_id = comments[0].comment_id | |
134 |
|
134 | |||
135 | self.app.post(url("changeset_comment_delete", |
|
135 | self.app.post(base.url("changeset_comment_delete", | |
136 | repo_name=HG_REPO, |
|
136 | repo_name=base.HG_REPO, | |
137 | comment_id=comment_id), |
|
137 | comment_id=comment_id), | |
138 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
138 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
139 |
|
139 | |||
140 | comments = ChangesetComment.query().all() |
|
140 | comments = ChangesetComment.query().all() | |
141 | assert len(comments) == 0 |
|
141 | assert len(comments) == 0 | |
142 |
|
142 | |||
143 | response = self.app.get(url(controller='changeset', action='index', |
|
143 | response = self.app.get(base.url(controller='changeset', action='index', | |
144 | repo_name=HG_REPO, revision=rev)) |
|
144 | repo_name=base.HG_REPO, revision=rev)) | |
145 | response.mustcontain( |
|
145 | response.mustcontain( | |
146 | '''<div class="comments-number">''' |
|
146 | '''<div class="comments-number">''' | |
147 | ''' 0 comments (0 inline, 0 general)''' |
|
147 | ''' 0 comments (0 inline, 0 general)''' | |
@@ -149,7 +149,7 b' class TestChangeSetCommentsController(Te' | |||||
149 | response.mustcontain(no=text) |
|
149 | response.mustcontain(no=text) | |
150 |
|
150 | |||
151 |
|
151 | |||
152 | class TestPullrequestsCommentsController(TestController): |
|
152 | class TestPullrequestsCommentsController(base.TestController): | |
153 |
|
153 | |||
154 | def setup_method(self, method): |
|
154 | def setup_method(self, method): | |
155 | for x in ChangesetComment.query().all(): |
|
155 | for x in ChangesetComment.query().all(): | |
@@ -157,11 +157,11 b' class TestPullrequestsCommentsController' | |||||
157 | Session().commit() |
|
157 | Session().commit() | |
158 |
|
158 | |||
159 | def _create_pr(self): |
|
159 | def _create_pr(self): | |
160 | response = self.app.post(url(controller='pullrequests', action='create', |
|
160 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
161 | repo_name=HG_REPO), |
|
161 | repo_name=base.HG_REPO), | |
162 | {'org_repo': HG_REPO, |
|
162 | {'org_repo': base.HG_REPO, | |
163 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
163 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
164 | 'other_repo': HG_REPO, |
|
164 | 'other_repo': base.HG_REPO, | |
165 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
165 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
166 | 'pullrequest_title': 'title', |
|
166 | 'pullrequest_title': 'title', | |
167 | 'pullrequest_desc': 'description', |
|
167 | 'pullrequest_desc': 'description', | |
@@ -177,14 +177,14 b' class TestPullrequestsCommentsController' | |||||
177 |
|
177 | |||
178 | text = u'general comment on pullrequest' |
|
178 | text = u'general comment on pullrequest' | |
179 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
179 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
180 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
180 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
181 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
181 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
182 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
182 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
183 | # Test response... |
|
183 | # Test response... | |
184 | assert response.status == '200 OK' |
|
184 | assert response.status == '200 OK' | |
185 |
|
185 | |||
186 | response = self.app.get(url(controller='pullrequests', action='show', |
|
186 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
187 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
187 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
188 | # PRs currently always have an initial 'Under Review' status change |
|
188 | # PRs currently always have an initial 'Under Review' status change | |
189 | # that counts as a general comment, hence '2' in the test below. That |
|
189 | # that counts as a general comment, hence '2' in the test below. That | |
190 | # could be counted as a misfeature, to be reworked later. |
|
190 | # could be counted as a misfeature, to be reworked later. | |
@@ -205,14 +205,14 b' class TestPullrequestsCommentsController' | |||||
205 | f_path = 'vcs/web/simplevcs/views/repository.py' |
|
205 | f_path = 'vcs/web/simplevcs/views/repository.py' | |
206 | line = 'n1' |
|
206 | line = 'n1' | |
207 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
207 | params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
208 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
208 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
209 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
209 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
210 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
210 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
211 | # Test response... |
|
211 | # Test response... | |
212 | assert response.status == '200 OK' |
|
212 | assert response.status == '200 OK' | |
213 |
|
213 | |||
214 | response = self.app.get(url(controller='pullrequests', action='show', |
|
214 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
215 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
215 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
216 | response.mustcontain( |
|
216 | response.mustcontain( | |
217 | '''<div class="comments-number">''' |
|
217 | '''<div class="comments-number">''' | |
218 | ''' 2 comments (1 inline, 1 general)''' |
|
218 | ''' 2 comments (1 inline, 1 general)''' | |
@@ -231,21 +231,21 b' class TestPullrequestsCommentsController' | |||||
231 | self.log_user() |
|
231 | self.log_user() | |
232 | pr_id = self._create_pr() |
|
232 | pr_id = self._create_pr() | |
233 |
|
233 | |||
234 | text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN |
|
234 | text = u'@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN | |
235 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
235 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
236 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
236 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
237 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
237 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
238 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
238 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
239 | # Test response... |
|
239 | # Test response... | |
240 | assert response.status == '200 OK' |
|
240 | assert response.status == '200 OK' | |
241 |
|
241 | |||
242 | response = self.app.get(url(controller='pullrequests', action='show', |
|
242 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
243 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
243 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
244 | response.mustcontain( |
|
244 | response.mustcontain( | |
245 | '''<div class="comments-number">''' |
|
245 | '''<div class="comments-number">''' | |
246 | ''' 2 comments (0 inline, 2 general)''' |
|
246 | ''' 2 comments (0 inline, 2 general)''' | |
247 | ) |
|
247 | ) | |
248 | response.mustcontain('<b>@%s</b> check CommentOnRevision' % TEST_USER_REGULAR_LOGIN) |
|
248 | response.mustcontain('<b>@%s</b> check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN) | |
249 |
|
249 | |||
250 | # test DB |
|
250 | # test DB | |
251 | assert ChangesetComment.query().count() == 2 |
|
251 | assert ChangesetComment.query().count() == 2 | |
@@ -257,14 +257,14 b' class TestPullrequestsCommentsController' | |||||
257 | text = u'general comment on pullrequest' |
|
257 | text = u'general comment on pullrequest' | |
258 | params = {'text': text, 'changeset_status': 'rejected', |
|
258 | params = {'text': text, 'changeset_status': 'rejected', | |
259 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
259 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
260 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
260 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
261 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
261 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
262 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
262 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
263 | # Test response... |
|
263 | # Test response... | |
264 | assert response.status == '200 OK' |
|
264 | assert response.status == '200 OK' | |
265 |
|
265 | |||
266 | response = self.app.get(url(controller='pullrequests', action='show', |
|
266 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
267 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
267 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
268 | # PRs currently always have an initial 'Under Review' status change |
|
268 | # PRs currently always have an initial 'Under Review' status change | |
269 | # that counts as a general comment, hence '2' in the test below. That |
|
269 | # that counts as a general comment, hence '2' in the test below. That | |
270 | # could be counted as a misfeature, to be reworked later. |
|
270 | # could be counted as a misfeature, to be reworked later. | |
@@ -278,7 +278,7 b' class TestPullrequestsCommentsController' | |||||
278 | assert ChangesetComment.query().count() == 2 |
|
278 | assert ChangesetComment.query().count() == 2 | |
279 |
|
279 | |||
280 | # check status |
|
280 | # check status | |
281 | status = ChangesetStatusModel().get_status(repo=HG_REPO, pull_request=pr_id) |
|
281 | status = ChangesetStatusModel().get_status(repo=base.HG_REPO, pull_request=pr_id) | |
282 | assert status == 'rejected' |
|
282 | assert status == 'rejected' | |
283 |
|
283 | |||
284 | def test_delete(self): |
|
284 | def test_delete(self): | |
@@ -287,24 +287,24 b' class TestPullrequestsCommentsController' | |||||
287 |
|
287 | |||
288 | text = u'general comment on changeset to be deleted' |
|
288 | text = u'general comment on changeset to be deleted' | |
289 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
289 | params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
290 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
290 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
291 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
291 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
292 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
292 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
293 |
|
293 | |||
294 | comments = ChangesetComment.query().all() |
|
294 | comments = ChangesetComment.query().all() | |
295 | assert len(comments) == 2 |
|
295 | assert len(comments) == 2 | |
296 | comment_id = comments[-1].comment_id |
|
296 | comment_id = comments[-1].comment_id | |
297 |
|
297 | |||
298 | self.app.post(url("pullrequest_comment_delete", |
|
298 | self.app.post(base.url("pullrequest_comment_delete", | |
299 | repo_name=HG_REPO, |
|
299 | repo_name=base.HG_REPO, | |
300 | comment_id=comment_id), |
|
300 | comment_id=comment_id), | |
301 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
301 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
302 |
|
302 | |||
303 | comments = ChangesetComment.query().all() |
|
303 | comments = ChangesetComment.query().all() | |
304 | assert len(comments) == 1 |
|
304 | assert len(comments) == 1 | |
305 |
|
305 | |||
306 | response = self.app.get(url(controller='pullrequests', action='show', |
|
306 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
307 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
307 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
308 | response.mustcontain( |
|
308 | response.mustcontain( | |
309 | '''<div class="comments-number">''' |
|
309 | '''<div class="comments-number">''' | |
310 | ''' 1 comment (0 inline, 1 general)''' |
|
310 | ''' 1 comment (0 inline, 1 general)''' | |
@@ -318,14 +318,14 b' class TestPullrequestsCommentsController' | |||||
318 | text = u'general comment on pullrequest' |
|
318 | text = u'general comment on pullrequest' | |
319 | params = {'text': text, 'save_close': 'close', |
|
319 | params = {'text': text, 'save_close': 'close', | |
320 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
320 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
321 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
321 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
322 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
322 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
323 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
323 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
324 | # Test response... |
|
324 | # Test response... | |
325 | assert response.status == '200 OK' |
|
325 | assert response.status == '200 OK' | |
326 |
|
326 | |||
327 | response = self.app.get(url(controller='pullrequests', action='show', |
|
327 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
328 | repo_name=HG_REPO, pull_request_id=pr_id, extra='')) |
|
328 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra='')) | |
329 | response.mustcontain( |
|
329 | response.mustcontain( | |
330 | '''title (Closed)''' |
|
330 | '''title (Closed)''' | |
331 | ) |
|
331 | ) | |
@@ -341,14 +341,14 b' class TestPullrequestsCommentsController' | |||||
341 | text = u'general comment on pullrequest' |
|
341 | text = u'general comment on pullrequest' | |
342 | params = {'text': text, 'save_delete': 'delete', |
|
342 | params = {'text': text, 'save_delete': 'delete', | |
343 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
343 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
344 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
344 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
345 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
345 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
346 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
346 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
347 | # Test response... |
|
347 | # Test response... | |
348 | assert response.status == '200 OK' |
|
348 | assert response.status == '200 OK' | |
349 |
|
349 | |||
350 | response = self.app.get(url(controller='pullrequests', action='show', |
|
350 | response = self.app.get(base.url(controller='pullrequests', action='show', | |
351 | repo_name=HG_REPO, pull_request_id=pr_id, extra=''), status=404) |
|
351 | repo_name=base.HG_REPO, pull_request_id=pr_id, extra=''), status=404) | |
352 |
|
352 | |||
353 | # test DB |
|
353 | # test DB | |
354 | assert PullRequest.get(pr_id) is None |
|
354 | assert PullRequest.get(pr_id) is None | |
@@ -361,16 +361,16 b' class TestPullrequestsCommentsController' | |||||
361 | text = u'general comment on pullrequest' |
|
361 | text = u'general comment on pullrequest' | |
362 | params = {'text': text, 'save_close': 'close', |
|
362 | params = {'text': text, 'save_close': 'close', | |
363 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
363 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
364 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
364 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
365 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
365 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
366 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) |
|
366 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}) | |
367 | assert response.status == '200 OK' |
|
367 | assert response.status == '200 OK' | |
368 |
|
368 | |||
369 | # attempt delete, should fail |
|
369 | # attempt delete, should fail | |
370 | params = {'text': text, 'save_delete': 'delete', |
|
370 | params = {'text': text, 'save_delete': 'delete', | |
371 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
371 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
372 | response = self.app.post(url(controller='pullrequests', action='comment', |
|
372 | response = self.app.post(base.url(controller='pullrequests', action='comment', | |
373 | repo_name=HG_REPO, pull_request_id=pr_id), |
|
373 | repo_name=base.HG_REPO, pull_request_id=pr_id), | |
374 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, status=403) |
|
374 | params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, status=403) | |
375 |
|
375 | |||
376 | # verify that PR still exists, in closed state |
|
376 | # verify that PR still exists, in closed state |
@@ -1,7 +1,7 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | from kallithea.model.meta import Session |
|
2 | from kallithea.model.meta import Session | |
3 | from kallithea.model.repo import RepoModel |
|
3 | from kallithea.model.repo import RepoModel | |
4 |
from kallithea.tests |
|
4 | from kallithea.tests import base | |
5 | from kallithea.tests.fixture import Fixture |
|
5 | from kallithea.tests.fixture import Fixture | |
6 |
|
6 | |||
7 |
|
7 | |||
@@ -12,7 +12,7 b' def _commit_ref(repo_name, sha, msg):' | |||||
12 | return '''<div class="message-firstline"><a class="message-link" href="/%s/changeset/%s">%s</a></div>''' % (repo_name, sha, msg) |
|
12 | return '''<div class="message-firstline"><a class="message-link" href="/%s/changeset/%s">%s</a></div>''' % (repo_name, sha, msg) | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | class TestCompareController(TestController): |
|
15 | class TestCompareController(base.TestController): | |
16 |
|
16 | |||
17 | def setup_method(self, method): |
|
17 | def setup_method(self, method): | |
18 | self.r1_id = None |
|
18 | self.r1_id = None | |
@@ -30,7 +30,7 b' class TestCompareController(TestControll' | |||||
30 | self.log_user() |
|
30 | self.log_user() | |
31 | repo1 = fixture.create_repo(u'one', repo_type='hg', |
|
31 | repo1 = fixture.create_repo(u'one', repo_type='hg', | |
32 | repo_description='diff-test', |
|
32 | repo_description='diff-test', | |
33 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
33 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
34 | self.r1_id = repo1.repo_id |
|
34 | self.r1_id = repo1.repo_id | |
35 | # commit something ! |
|
35 | # commit something ! | |
36 | cs0 = fixture.commit_change(repo1.repo_name, filename='file1', |
|
36 | cs0 = fixture.commit_change(repo1.repo_name, filename='file1', | |
@@ -53,7 +53,7 b' class TestCompareController(TestControll' | |||||
53 | rev1 = 'default' |
|
53 | rev1 = 'default' | |
54 | rev2 = 'default' |
|
54 | rev2 = 'default' | |
55 |
|
55 | |||
56 | response = self.app.get(url('compare_url', |
|
56 | response = self.app.get(base.url('compare_url', | |
57 | repo_name=repo1.repo_name, |
|
57 | repo_name=repo1.repo_name, | |
58 | org_ref_type="branch", |
|
58 | org_ref_type="branch", | |
59 | org_ref_name=rev2, |
|
59 | org_ref_name=rev2, | |
@@ -81,7 +81,7 b' class TestCompareController(TestControll' | |||||
81 | self.log_user() |
|
81 | self.log_user() | |
82 | repo1 = fixture.create_repo(u'one-git', repo_type='git', |
|
82 | repo1 = fixture.create_repo(u'one-git', repo_type='git', | |
83 | repo_description='diff-test', |
|
83 | repo_description='diff-test', | |
84 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
84 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
85 | self.r1_id = repo1.repo_id |
|
85 | self.r1_id = repo1.repo_id | |
86 | # commit something ! |
|
86 | # commit something ! | |
87 | cs0 = fixture.commit_change(repo1.repo_name, filename='file1', |
|
87 | cs0 = fixture.commit_change(repo1.repo_name, filename='file1', | |
@@ -104,7 +104,7 b' class TestCompareController(TestControll' | |||||
104 | rev1 = 'master' |
|
104 | rev1 = 'master' | |
105 | rev2 = 'master' |
|
105 | rev2 = 'master' | |
106 |
|
106 | |||
107 | response = self.app.get(url('compare_url', |
|
107 | response = self.app.get(base.url('compare_url', | |
108 | repo_name=repo1.repo_name, |
|
108 | repo_name=repo1.repo_name, | |
109 | org_ref_type="branch", |
|
109 | org_ref_type="branch", | |
110 | org_ref_name=rev2, |
|
110 | org_ref_name=rev2, | |
@@ -133,7 +133,7 b' class TestCompareController(TestControll' | |||||
133 |
|
133 | |||
134 | repo1 = fixture.create_repo(u'one', repo_type='hg', |
|
134 | repo1 = fixture.create_repo(u'one', repo_type='hg', | |
135 | repo_description='diff-test', |
|
135 | repo_description='diff-test', | |
136 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
136 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
137 |
|
137 | |||
138 | self.r1_id = repo1.repo_id |
|
138 | self.r1_id = repo1.repo_id | |
139 |
|
139 | |||
@@ -163,7 +163,7 b' class TestCompareController(TestControll' | |||||
163 | rev1 = 'default' |
|
163 | rev1 = 'default' | |
164 | rev2 = 'default' |
|
164 | rev2 = 'default' | |
165 |
|
165 | |||
166 | response = self.app.get(url('compare_url', |
|
166 | response = self.app.get(base.url('compare_url', | |
167 | repo_name=repo1.repo_name, |
|
167 | repo_name=repo1.repo_name, | |
168 | org_ref_type="branch", |
|
168 | org_ref_type="branch", | |
169 | org_ref_name=rev2, |
|
169 | org_ref_name=rev2, | |
@@ -192,7 +192,7 b' class TestCompareController(TestControll' | |||||
192 |
|
192 | |||
193 | repo1 = fixture.create_repo(u'one-git', repo_type='git', |
|
193 | repo1 = fixture.create_repo(u'one-git', repo_type='git', | |
194 | repo_description='diff-test', |
|
194 | repo_description='diff-test', | |
195 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
195 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
196 |
|
196 | |||
197 | self.r1_id = repo1.repo_id |
|
197 | self.r1_id = repo1.repo_id | |
198 |
|
198 | |||
@@ -222,7 +222,7 b' class TestCompareController(TestControll' | |||||
222 | rev1 = 'master' |
|
222 | rev1 = 'master' | |
223 | rev2 = 'master' |
|
223 | rev2 = 'master' | |
224 |
|
224 | |||
225 | response = self.app.get(url('compare_url', |
|
225 | response = self.app.get(base.url('compare_url', | |
226 | repo_name=repo1.repo_name, |
|
226 | repo_name=repo1.repo_name, | |
227 | org_ref_type="branch", |
|
227 | org_ref_type="branch", | |
228 | org_ref_name=rev2, |
|
228 | org_ref_name=rev2, | |
@@ -263,7 +263,7 b' class TestCompareController(TestControll' | |||||
263 |
|
263 | |||
264 | repo1 = fixture.create_repo(u'repo1', repo_type='hg', |
|
264 | repo1 = fixture.create_repo(u'repo1', repo_type='hg', | |
265 | repo_description='diff-test', |
|
265 | repo_description='diff-test', | |
266 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
266 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
267 | self.r1_id = repo1.repo_id |
|
267 | self.r1_id = repo1.repo_id | |
268 |
|
268 | |||
269 | # commit something ! |
|
269 | # commit something ! | |
@@ -290,7 +290,7 b' class TestCompareController(TestControll' | |||||
290 | content='line1\nline2\nline3\nline4\nline5\nline6\n', |
|
290 | content='line1\nline2\nline3\nline4\nline5\nline6\n', | |
291 | message='commit6', vcs_type='hg', parent=cs4) |
|
291 | message='commit6', vcs_type='hg', parent=cs4) | |
292 |
|
292 | |||
293 | response = self.app.get(url('compare_url', |
|
293 | response = self.app.get(base.url('compare_url', | |
294 | repo_name=repo2.repo_name, |
|
294 | repo_name=repo2.repo_name, | |
295 | org_ref_type="rev", |
|
295 | org_ref_type="rev", | |
296 | org_ref_name=cs1.short_id, # parent of cs2, in repo2 |
|
296 | org_ref_name=cs1.short_id, # parent of cs2, in repo2 | |
@@ -331,7 +331,7 b' class TestCompareController(TestControll' | |||||
331 | self.log_user() |
|
331 | self.log_user() | |
332 | repo1 = fixture.create_repo(u'repo1', repo_type='hg', |
|
332 | repo1 = fixture.create_repo(u'repo1', repo_type='hg', | |
333 | repo_description='diff-test', |
|
333 | repo_description='diff-test', | |
334 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
334 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
335 | self.r1_id = repo1.repo_id |
|
335 | self.r1_id = repo1.repo_id | |
336 |
|
336 | |||
337 | # commit something ! |
|
337 | # commit something ! | |
@@ -358,7 +358,7 b' class TestCompareController(TestControll' | |||||
358 | content='line1\nline2\nline3\nline4\nline5\nline6\n', |
|
358 | content='line1\nline2\nline3\nline4\nline5\nline6\n', | |
359 | message='commit6', vcs_type='hg', parent=cs4) |
|
359 | message='commit6', vcs_type='hg', parent=cs4) | |
360 |
|
360 | |||
361 | response = self.app.get(url('compare_url', |
|
361 | response = self.app.get(base.url('compare_url', | |
362 | repo_name=repo1.repo_name, |
|
362 | repo_name=repo1.repo_name, | |
363 | org_ref_type="rev", |
|
363 | org_ref_type="rev", | |
364 | org_ref_name=cs2.short_id, # parent of cs3, not in repo2 |
|
364 | org_ref_name=cs2.short_id, # parent of cs3, not in repo2 | |
@@ -388,27 +388,27 b' class TestCompareController(TestControll' | |||||
388 | def test_compare_remote_branches_hg(self): |
|
388 | def test_compare_remote_branches_hg(self): | |
389 | self.log_user() |
|
389 | self.log_user() | |
390 |
|
390 | |||
391 | repo2 = fixture.create_fork(HG_REPO, HG_FORK) |
|
391 | repo2 = fixture.create_fork(base.HG_REPO, base.HG_FORK) | |
392 | self.r2_id = repo2.repo_id |
|
392 | self.r2_id = repo2.repo_id | |
393 | rev1 = '56349e29c2af' |
|
393 | rev1 = '56349e29c2af' | |
394 | rev2 = '7d4bc8ec6be5' |
|
394 | rev2 = '7d4bc8ec6be5' | |
395 |
|
395 | |||
396 | response = self.app.get(url('compare_url', |
|
396 | response = self.app.get(base.url('compare_url', | |
397 | repo_name=HG_REPO, |
|
397 | repo_name=base.HG_REPO, | |
398 | org_ref_type="rev", |
|
398 | org_ref_type="rev", | |
399 | org_ref_name=rev1, |
|
399 | org_ref_name=rev1, | |
400 | other_ref_type="rev", |
|
400 | other_ref_type="rev", | |
401 | other_ref_name=rev2, |
|
401 | other_ref_name=rev2, | |
402 | other_repo=HG_FORK, |
|
402 | other_repo=base.HG_FORK, | |
403 | merge='1',)) |
|
403 | merge='1',)) | |
404 |
|
404 | |||
405 | response.mustcontain('%s@%s' % (HG_REPO, rev1)) |
|
405 | response.mustcontain('%s@%s' % (base.HG_REPO, rev1)) | |
406 | response.mustcontain('%s@%s' % (HG_FORK, rev2)) |
|
406 | response.mustcontain('%s@%s' % (base.HG_FORK, rev2)) | |
407 | ## outgoing changesets between those revisions |
|
407 | ## outgoing changesets between those revisions | |
408 |
|
408 | |||
409 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_FORK)) |
|
409 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (base.HG_FORK)) | |
410 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_FORK)) |
|
410 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (base.HG_FORK)) | |
411 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_FORK, rev2)) |
|
411 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (base.HG_FORK, rev2)) | |
412 |
|
412 | |||
413 | ## files |
|
413 | ## files | |
414 | response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""") |
|
414 | response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""") | |
@@ -418,27 +418,27 b' class TestCompareController(TestControll' | |||||
418 | def test_compare_remote_branches_git(self): |
|
418 | def test_compare_remote_branches_git(self): | |
419 | self.log_user() |
|
419 | self.log_user() | |
420 |
|
420 | |||
421 | repo2 = fixture.create_fork(GIT_REPO, GIT_FORK) |
|
421 | repo2 = fixture.create_fork(base.GIT_REPO, base.GIT_FORK) | |
422 | self.r2_id = repo2.repo_id |
|
422 | self.r2_id = repo2.repo_id | |
423 | rev1 = '102607b09cdd60e2793929c4f90478be29f85a17' |
|
423 | rev1 = '102607b09cdd60e2793929c4f90478be29f85a17' | |
424 | rev2 = 'd7e0d30fbcae12c90680eb095a4f5f02505ce501' |
|
424 | rev2 = 'd7e0d30fbcae12c90680eb095a4f5f02505ce501' | |
425 |
|
425 | |||
426 | response = self.app.get(url('compare_url', |
|
426 | response = self.app.get(base.url('compare_url', | |
427 | repo_name=GIT_REPO, |
|
427 | repo_name=base.GIT_REPO, | |
428 | org_ref_type="rev", |
|
428 | org_ref_type="rev", | |
429 | org_ref_name=rev1, |
|
429 | org_ref_name=rev1, | |
430 | other_ref_type="rev", |
|
430 | other_ref_type="rev", | |
431 | other_ref_name=rev2, |
|
431 | other_ref_name=rev2, | |
432 | other_repo=GIT_FORK, |
|
432 | other_repo=base.GIT_FORK, | |
433 | merge='1',)) |
|
433 | merge='1',)) | |
434 |
|
434 | |||
435 | response.mustcontain('%s@%s' % (GIT_REPO, rev1)) |
|
435 | response.mustcontain('%s@%s' % (base.GIT_REPO, rev1)) | |
436 | response.mustcontain('%s@%s' % (GIT_FORK, rev2)) |
|
436 | response.mustcontain('%s@%s' % (base.GIT_FORK, rev2)) | |
437 | ## outgoing changesets between those revisions |
|
437 | ## outgoing changesets between those revisions | |
438 |
|
438 | |||
439 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/49d3fd156b6f7db46313fac355dca1a0b94a0017">r4:49d3fd156b6f</a>""" % (GIT_FORK)) |
|
439 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/49d3fd156b6f7db46313fac355dca1a0b94a0017">r4:49d3fd156b6f</a>""" % (base.GIT_FORK)) | |
440 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2d1028c054665b962fa3d307adfc923ddd528038">r5:2d1028c05466</a>""" % (GIT_FORK)) |
|
440 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2d1028c054665b962fa3d307adfc923ddd528038">r5:2d1028c05466</a>""" % (base.GIT_FORK)) | |
441 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/d7e0d30fbcae12c90680eb095a4f5f02505ce501">r6:%s</a>""" % (GIT_FORK, rev2[:12])) |
|
441 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/d7e0d30fbcae12c90680eb095a4f5f02505ce501">r6:%s</a>""" % (base.GIT_FORK, rev2[:12])) | |
442 |
|
442 | |||
443 | ## files |
|
443 | ## files | |
444 | response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""") |
|
444 | response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""") | |
@@ -450,7 +450,7 b' class TestCompareController(TestControll' | |||||
450 |
|
450 | |||
451 | repo1 = fixture.create_repo(u'one', repo_type='hg', |
|
451 | repo1 = fixture.create_repo(u'one', repo_type='hg', | |
452 | repo_description='diff-test', |
|
452 | repo_description='diff-test', | |
453 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
453 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
454 |
|
454 | |||
455 | self.r1_id = repo1.repo_id |
|
455 | self.r1_id = repo1.repo_id | |
456 | r1_name = repo1.repo_name |
|
456 | r1_name = repo1.repo_name | |
@@ -461,7 +461,7 b' class TestCompareController(TestControll' | |||||
461 | assert repo1.scm_instance.revisions == [cs0.raw_id] |
|
461 | assert repo1.scm_instance.revisions == [cs0.raw_id] | |
462 | # fork the repo1 |
|
462 | # fork the repo1 | |
463 | repo2 = fixture.create_fork(r1_name, u'one-fork', |
|
463 | repo2 = fixture.create_fork(r1_name, u'one-fork', | |
464 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
464 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
465 | Session().commit() |
|
465 | Session().commit() | |
466 | assert repo2.scm_instance.revisions == [cs0.raw_id] |
|
466 | assert repo2.scm_instance.revisions == [cs0.raw_id] | |
467 | self.r2_id = repo2.repo_id |
|
467 | self.r2_id = repo2.repo_id | |
@@ -482,7 +482,7 b' class TestCompareController(TestControll' | |||||
482 | rev1 = 'default' |
|
482 | rev1 = 'default' | |
483 | rev2 = 'default' |
|
483 | rev2 = 'default' | |
484 |
|
484 | |||
485 | response = self.app.get(url('compare_url', |
|
485 | response = self.app.get(base.url('compare_url', | |
486 | repo_name=r2_name, |
|
486 | repo_name=r2_name, | |
487 | org_ref_type="branch", |
|
487 | org_ref_type="branch", | |
488 | org_ref_name=rev2, |
|
488 | org_ref_name=rev2, | |
@@ -500,7 +500,7 b' class TestCompareController(TestControll' | |||||
500 | # compare ! |
|
500 | # compare ! | |
501 | rev1 = 'default' |
|
501 | rev1 = 'default' | |
502 | rev2 = 'default' |
|
502 | rev2 = 'default' | |
503 | response = self.app.get(url('compare_url', |
|
503 | response = self.app.get(base.url('compare_url', | |
504 | repo_name=r2_name, |
|
504 | repo_name=r2_name, | |
505 | org_ref_type="branch", |
|
505 | org_ref_type="branch", | |
506 | org_ref_name=rev2, |
|
506 | org_ref_name=rev2, | |
@@ -522,7 +522,7 b' class TestCompareController(TestControll' | |||||
522 |
|
522 | |||
523 | repo1 = fixture.create_repo(u'one-git', repo_type='git', |
|
523 | repo1 = fixture.create_repo(u'one-git', repo_type='git', | |
524 | repo_description='diff-test', |
|
524 | repo_description='diff-test', | |
525 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
525 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
526 |
|
526 | |||
527 | self.r1_id = repo1.repo_id |
|
527 | self.r1_id = repo1.repo_id | |
528 | r1_name = repo1.repo_name |
|
528 | r1_name = repo1.repo_name | |
@@ -534,7 +534,7 b' class TestCompareController(TestControll' | |||||
534 | assert repo1.scm_instance.revisions == [cs0.raw_id] |
|
534 | assert repo1.scm_instance.revisions == [cs0.raw_id] | |
535 | # fork the repo1 |
|
535 | # fork the repo1 | |
536 | repo2 = fixture.create_fork(r1_name, u'one-git-fork', |
|
536 | repo2 = fixture.create_fork(r1_name, u'one-git-fork', | |
537 | cur_user=TEST_USER_ADMIN_LOGIN) |
|
537 | cur_user=base.TEST_USER_ADMIN_LOGIN) | |
538 | Session().commit() |
|
538 | Session().commit() | |
539 | assert repo2.scm_instance.revisions == [cs0.raw_id] |
|
539 | assert repo2.scm_instance.revisions == [cs0.raw_id] | |
540 | self.r2_id = repo2.repo_id |
|
540 | self.r2_id = repo2.repo_id | |
@@ -556,7 +556,7 b' class TestCompareController(TestControll' | |||||
556 | rev1 = 'master' |
|
556 | rev1 = 'master' | |
557 | rev2 = 'master' |
|
557 | rev2 = 'master' | |
558 |
|
558 | |||
559 | response = self.app.get(url('compare_url', |
|
559 | response = self.app.get(base.url('compare_url', | |
560 | repo_name=r2_name, |
|
560 | repo_name=r2_name, | |
561 | org_ref_type="branch", |
|
561 | org_ref_type="branch", | |
562 | org_ref_name=rev1, |
|
562 | org_ref_name=rev1, | |
@@ -574,7 +574,7 b' class TestCompareController(TestControll' | |||||
574 | # compare ! |
|
574 | # compare ! | |
575 | rev1 = 'master' |
|
575 | rev1 = 'master' | |
576 | rev2 = 'master' |
|
576 | rev2 = 'master' | |
577 | response = self.app.get(url('compare_url', |
|
577 | response = self.app.get(base.url('compare_url', | |
578 | repo_name=r2_name, |
|
578 | repo_name=r2_name, | |
579 | org_ref_type="branch", |
|
579 | org_ref_type="branch", | |
580 | org_ref_name=rev1, |
|
580 | org_ref_name=rev1, |
@@ -1,31 +1,31 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
from kallithea.tests |
|
2 | from kallithea.tests import base | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | class TestCompareController(TestController): |
|
5 | class TestCompareController(base.TestController): | |
6 |
|
6 | |||
7 | def test_compare_tag_hg(self): |
|
7 | def test_compare_tag_hg(self): | |
8 | self.log_user() |
|
8 | self.log_user() | |
9 | tag1 = 'v0.1.2' |
|
9 | tag1 = 'v0.1.2' | |
10 | tag2 = 'v0.1.3' |
|
10 | tag2 = 'v0.1.3' | |
11 | response = self.app.get(url('compare_url', |
|
11 | response = self.app.get(base.url('compare_url', | |
12 | repo_name=HG_REPO, |
|
12 | repo_name=base.HG_REPO, | |
13 | org_ref_type="tag", |
|
13 | org_ref_type="tag", | |
14 | org_ref_name=tag1, |
|
14 | org_ref_name=tag1, | |
15 | other_ref_type="tag", |
|
15 | other_ref_type="tag", | |
16 | other_ref_name=tag2, |
|
16 | other_ref_name=tag2, | |
17 | ), status=200) |
|
17 | ), status=200) | |
18 | response.mustcontain('%s@%s' % (HG_REPO, tag1)) |
|
18 | response.mustcontain('%s@%s' % (base.HG_REPO, tag1)) | |
19 | response.mustcontain('%s@%s' % (HG_REPO, tag2)) |
|
19 | response.mustcontain('%s@%s' % (base.HG_REPO, tag2)) | |
20 |
|
20 | |||
21 | ## outgoing changesets between tags |
|
21 | ## outgoing changesets between tags | |
22 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % HG_REPO) |
|
22 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % base.HG_REPO) | |
23 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % HG_REPO) |
|
23 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % base.HG_REPO) | |
24 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/9749bfbfc0d2eba208d7947de266303b67c87cda">r116:9749bfbfc0d2</a>''' % HG_REPO) |
|
24 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/9749bfbfc0d2eba208d7947de266303b67c87cda">r116:9749bfbfc0d2</a>''' % base.HG_REPO) | |
25 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/41fda979f02fda216374bf8edac4e83f69e7581c">r117:41fda979f02f</a>''' % HG_REPO) |
|
25 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/41fda979f02fda216374bf8edac4e83f69e7581c">r117:41fda979f02f</a>''' % base.HG_REPO) | |
26 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</a>''' % HG_REPO) |
|
26 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</a>''' % base.HG_REPO) | |
27 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % HG_REPO) |
|
27 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % base.HG_REPO) | |
28 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % HG_REPO) |
|
28 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % base.HG_REPO) | |
29 |
|
29 | |||
30 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') |
|
30 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') | |
31 |
|
31 | |||
@@ -80,24 +80,24 b' class TestCompareController(TestControll' | |||||
80 | self.log_user() |
|
80 | self.log_user() | |
81 | tag1 = 'v0.1.2' |
|
81 | tag1 = 'v0.1.2' | |
82 | tag2 = 'v0.1.3' |
|
82 | tag2 = 'v0.1.3' | |
83 | response = self.app.get(url('compare_url', |
|
83 | response = self.app.get(base.url('compare_url', | |
84 | repo_name=GIT_REPO, |
|
84 | repo_name=base.GIT_REPO, | |
85 | org_ref_type="tag", |
|
85 | org_ref_type="tag", | |
86 | org_ref_name=tag1, |
|
86 | org_ref_name=tag1, | |
87 | other_ref_type="tag", |
|
87 | other_ref_type="tag", | |
88 | other_ref_name=tag2, |
|
88 | other_ref_name=tag2, | |
89 | ), status=200) |
|
89 | ), status=200) | |
90 | response.mustcontain('%s@%s' % (GIT_REPO, tag1)) |
|
90 | response.mustcontain('%s@%s' % (base.GIT_REPO, tag1)) | |
91 | response.mustcontain('%s@%s' % (GIT_REPO, tag2)) |
|
91 | response.mustcontain('%s@%s' % (base.GIT_REPO, tag2)) | |
92 |
|
92 | |||
93 | ## outgoing changesets between tags |
|
93 | ## outgoing changesets between tags | |
94 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/794bbdd31545c199f74912709ea350dedcd189a2">r113:794bbdd31545</a>''' % GIT_REPO) |
|
94 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/794bbdd31545c199f74912709ea350dedcd189a2">r113:794bbdd31545</a>''' % base.GIT_REPO) | |
95 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/e36d8c5025329bdd4212bd53d4ed8a70ff44985f">r115:e36d8c502532</a>''' % GIT_REPO) |
|
95 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/e36d8c5025329bdd4212bd53d4ed8a70ff44985f">r115:e36d8c502532</a>''' % base.GIT_REPO) | |
96 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5c9ff4f6d7508db0e72b1d2991c357d0d8e07af2">r116:5c9ff4f6d750</a>''' % GIT_REPO) |
|
96 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5c9ff4f6d7508db0e72b1d2991c357d0d8e07af2">r116:5c9ff4f6d750</a>''' % base.GIT_REPO) | |
97 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/b7187fa2b8c1d773ec35e9dee12f01f74808c879">r117:b7187fa2b8c1</a>''' % GIT_REPO) |
|
97 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/b7187fa2b8c1d773ec35e9dee12f01f74808c879">r117:b7187fa2b8c1</a>''' % base.GIT_REPO) | |
98 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5f3b74262014a8de2dc7dade1152de9fd0c8efef">r118:5f3b74262014</a>''' % GIT_REPO) |
|
98 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5f3b74262014a8de2dc7dade1152de9fd0c8efef">r118:5f3b74262014</a>''' % base.GIT_REPO) | |
99 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/17438a11f72b93f56d0e08e7d1fa79a378578a82">r119:17438a11f72b</a>''' % GIT_REPO) |
|
99 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/17438a11f72b93f56d0e08e7d1fa79a378578a82">r119:17438a11f72b</a>''' % base.GIT_REPO) | |
100 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5a3a8fb005554692b16e21dee62bf02667d8dc3e">r120:5a3a8fb00555</a>''' % GIT_REPO) |
|
100 | response.mustcontain('''<a class="changeset_hash" href="/%s/changeset/5a3a8fb005554692b16e21dee62bf02667d8dc3e">r120:5a3a8fb00555</a>''' % base.GIT_REPO) | |
101 |
|
101 | |||
102 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') |
|
102 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') | |
103 |
|
103 | |||
@@ -116,32 +116,32 b' class TestCompareController(TestControll' | |||||
116 |
|
116 | |||
117 | def test_index_branch_hg(self): |
|
117 | def test_index_branch_hg(self): | |
118 | self.log_user() |
|
118 | self.log_user() | |
119 | response = self.app.get(url('compare_url', |
|
119 | response = self.app.get(base.url('compare_url', | |
120 | repo_name=HG_REPO, |
|
120 | repo_name=base.HG_REPO, | |
121 | org_ref_type="branch", |
|
121 | org_ref_type="branch", | |
122 | org_ref_name='default', |
|
122 | org_ref_name='default', | |
123 | other_ref_type="branch", |
|
123 | other_ref_type="branch", | |
124 | other_ref_name='default', |
|
124 | other_ref_name='default', | |
125 | )) |
|
125 | )) | |
126 |
|
126 | |||
127 | response.mustcontain('%s@default' % (HG_REPO)) |
|
127 | response.mustcontain('%s@default' % (base.HG_REPO)) | |
128 | response.mustcontain('%s@default' % (HG_REPO)) |
|
128 | response.mustcontain('%s@default' % (base.HG_REPO)) | |
129 | # branch are equal |
|
129 | # branch are equal | |
130 | response.mustcontain('<span class="text-muted">No files</span>') |
|
130 | response.mustcontain('<span class="text-muted">No files</span>') | |
131 | response.mustcontain('<span class="text-muted">No changesets</span>') |
|
131 | response.mustcontain('<span class="text-muted">No changesets</span>') | |
132 |
|
132 | |||
133 | def test_index_branch_git(self): |
|
133 | def test_index_branch_git(self): | |
134 | self.log_user() |
|
134 | self.log_user() | |
135 | response = self.app.get(url('compare_url', |
|
135 | response = self.app.get(base.url('compare_url', | |
136 | repo_name=GIT_REPO, |
|
136 | repo_name=base.GIT_REPO, | |
137 | org_ref_type="branch", |
|
137 | org_ref_type="branch", | |
138 | org_ref_name='master', |
|
138 | org_ref_name='master', | |
139 | other_ref_type="branch", |
|
139 | other_ref_type="branch", | |
140 | other_ref_name='master', |
|
140 | other_ref_name='master', | |
141 | )) |
|
141 | )) | |
142 |
|
142 | |||
143 | response.mustcontain('%s@master' % (GIT_REPO)) |
|
143 | response.mustcontain('%s@master' % (base.GIT_REPO)) | |
144 | response.mustcontain('%s@master' % (GIT_REPO)) |
|
144 | response.mustcontain('%s@master' % (base.GIT_REPO)) | |
145 | # branch are equal |
|
145 | # branch are equal | |
146 | response.mustcontain('<span class="text-muted">No files</span>') |
|
146 | response.mustcontain('<span class="text-muted">No files</span>') | |
147 | response.mustcontain('<span class="text-muted">No changesets</span>') |
|
147 | response.mustcontain('<span class="text-muted">No changesets</span>') | |
@@ -151,18 +151,18 b' class TestCompareController(TestControll' | |||||
151 | rev1 = 'b986218ba1c9' |
|
151 | rev1 = 'b986218ba1c9' | |
152 | rev2 = '3d8f361e72ab' |
|
152 | rev2 = '3d8f361e72ab' | |
153 |
|
153 | |||
154 | response = self.app.get(url('compare_url', |
|
154 | response = self.app.get(base.url('compare_url', | |
155 | repo_name=HG_REPO, |
|
155 | repo_name=base.HG_REPO, | |
156 | org_ref_type="rev", |
|
156 | org_ref_type="rev", | |
157 | org_ref_name=rev1, |
|
157 | org_ref_name=rev1, | |
158 | other_ref_type="rev", |
|
158 | other_ref_type="rev", | |
159 | other_ref_name=rev2, |
|
159 | other_ref_name=rev2, | |
160 | )) |
|
160 | )) | |
161 | response.mustcontain('%s@%s' % (HG_REPO, rev1)) |
|
161 | response.mustcontain('%s@%s' % (base.HG_REPO, rev1)) | |
162 | response.mustcontain('%s@%s' % (HG_REPO, rev2)) |
|
162 | response.mustcontain('%s@%s' % (base.HG_REPO, rev2)) | |
163 |
|
163 | |||
164 | ## outgoing changesets between those revisions |
|
164 | ## outgoing changesets between those revisions | |
165 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev2)) |
|
165 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (base.HG_REPO, rev2)) | |
166 |
|
166 | |||
167 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') |
|
167 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') | |
168 | ## files |
|
168 | ## files | |
@@ -173,18 +173,18 b' class TestCompareController(TestControll' | |||||
173 | rev1 = 'c1214f7e79e02fc37156ff215cd71275450cffc3' |
|
173 | rev1 = 'c1214f7e79e02fc37156ff215cd71275450cffc3' | |
174 | rev2 = '38b5fe81f109cb111f549bfe9bb6b267e10bc557' |
|
174 | rev2 = '38b5fe81f109cb111f549bfe9bb6b267e10bc557' | |
175 |
|
175 | |||
176 | response = self.app.get(url('compare_url', |
|
176 | response = self.app.get(base.url('compare_url', | |
177 | repo_name=GIT_REPO, |
|
177 | repo_name=base.GIT_REPO, | |
178 | org_ref_type="rev", |
|
178 | org_ref_type="rev", | |
179 | org_ref_name=rev1, |
|
179 | org_ref_name=rev1, | |
180 | other_ref_type="rev", |
|
180 | other_ref_type="rev", | |
181 | other_ref_name=rev2, |
|
181 | other_ref_name=rev2, | |
182 | )) |
|
182 | )) | |
183 | response.mustcontain('%s@%s' % (GIT_REPO, rev1)) |
|
183 | response.mustcontain('%s@%s' % (base.GIT_REPO, rev1)) | |
184 | response.mustcontain('%s@%s' % (GIT_REPO, rev2)) |
|
184 | response.mustcontain('%s@%s' % (base.GIT_REPO, rev2)) | |
185 |
|
185 | |||
186 | ## outgoing changesets between those revisions |
|
186 | ## outgoing changesets between those revisions | |
187 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/38b5fe81f109cb111f549bfe9bb6b267e10bc557">r1:%s</a>""" % (GIT_REPO, rev2[:12])) |
|
187 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/38b5fe81f109cb111f549bfe9bb6b267e10bc557">r1:%s</a>""" % (base.GIT_REPO, rev2[:12])) | |
188 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') |
|
188 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') | |
189 |
|
189 | |||
190 | ## files |
|
190 | ## files | |
@@ -195,8 +195,8 b' class TestCompareController(TestControll' | |||||
195 | rev1 = 'b986218ba1c9' |
|
195 | rev1 = 'b986218ba1c9' | |
196 | rev2 = '3d8f361e72ab' |
|
196 | rev2 = '3d8f361e72ab' | |
197 |
|
197 | |||
198 | response = self.app.get(url('compare_url', |
|
198 | response = self.app.get(base.url('compare_url', | |
199 | repo_name=HG_REPO, |
|
199 | repo_name=base.HG_REPO, | |
200 | org_ref_type="rev", |
|
200 | org_ref_type="rev", | |
201 | org_ref_name=rev1, |
|
201 | org_ref_name=rev1, | |
202 | other_ref_type="rev", |
|
202 | other_ref_type="rev", | |
@@ -206,18 +206,18 b' class TestCompareController(TestControll' | |||||
206 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) |
|
206 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | |
207 |
|
207 | |||
208 | ## outgoing changesets between those revisions |
|
208 | ## outgoing changesets between those revisions | |
209 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev2)) |
|
209 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (base.HG_REPO, rev2)) | |
210 |
|
210 | |||
211 | response.mustcontain('Merge Ancestor') |
|
211 | response.mustcontain('Merge Ancestor') | |
212 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/b986218ba1c9b0d6a259fac9b050b1724ed8e545">%s</a>""" % (HG_REPO, rev1)) |
|
212 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/b986218ba1c9b0d6a259fac9b050b1724ed8e545">%s</a>""" % (base.HG_REPO, rev1)) | |
213 |
|
213 | |||
214 | def test_compare_revisions_git_is_ajax_preview(self): |
|
214 | def test_compare_revisions_git_is_ajax_preview(self): | |
215 | self.log_user() |
|
215 | self.log_user() | |
216 | rev1 = 'c1214f7e79e02fc37156ff215cd71275450cffc3' |
|
216 | rev1 = 'c1214f7e79e02fc37156ff215cd71275450cffc3' | |
217 | rev2 = '38b5fe81f109cb111f549bfe9bb6b267e10bc557' |
|
217 | rev2 = '38b5fe81f109cb111f549bfe9bb6b267e10bc557' | |
218 |
|
218 | |||
219 | response = self.app.get(url('compare_url', |
|
219 | response = self.app.get(base.url('compare_url', | |
220 | repo_name=GIT_REPO, |
|
220 | repo_name=base.GIT_REPO, | |
221 | org_ref_type="rev", |
|
221 | org_ref_type="rev", | |
222 | org_ref_name=rev1, |
|
222 | org_ref_name=rev1, | |
223 | other_ref_type="rev", |
|
223 | other_ref_type="rev", | |
@@ -226,7 +226,7 b' class TestCompareController(TestControll' | |||||
226 | ), |
|
226 | ), | |
227 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) |
|
227 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | |
228 | ## outgoing changesets between those revisions |
|
228 | ## outgoing changesets between those revisions | |
229 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/38b5fe81f109cb111f549bfe9bb6b267e10bc557">r1:%s</a>""" % (GIT_REPO, rev2[:12])) |
|
229 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/38b5fe81f109cb111f549bfe9bb6b267e10bc557">r1:%s</a>""" % (base.GIT_REPO, rev2[:12])) | |
230 |
|
230 | |||
231 | response.mustcontain('Merge Ancestor') |
|
231 | response.mustcontain('Merge Ancestor') | |
232 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/c1214f7e79e02fc37156ff215cd71275450cffc3">%s</a>""" % (GIT_REPO, rev1[:12])) |
|
232 | response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/c1214f7e79e02fc37156ff215cd71275450cffc3">%s</a>""" % (base.GIT_REPO, rev1[:12])) |
@@ -1,20 +1,20 b'' | |||||
1 |
from kallithea.tests |
|
1 | from kallithea.tests import base | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | class TestFeedController(TestController): |
|
4 | class TestFeedController(base.TestController): | |
5 |
|
5 | |||
6 | def test_rss(self): |
|
6 | def test_rss(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
8 | response = self.app.get(url(controller='feed', action='rss', |
|
8 | response = self.app.get(base.url(controller='feed', action='rss', | |
9 | repo_name=HG_REPO)) |
|
9 | repo_name=base.HG_REPO)) | |
10 |
|
10 | |||
11 | assert response.content_type == "application/rss+xml" |
|
11 | assert response.content_type == "application/rss+xml" | |
12 | assert """<rss version="2.0">""" in response |
|
12 | assert """<rss version="2.0">""" in response | |
13 |
|
13 | |||
14 | def test_atom(self): |
|
14 | def test_atom(self): | |
15 | self.log_user() |
|
15 | self.log_user() | |
16 | response = self.app.get(url(controller='feed', action='atom', |
|
16 | response = self.app.get(base.url(controller='feed', action='atom', | |
17 | repo_name=HG_REPO)) |
|
17 | repo_name=base.HG_REPO)) | |
18 |
|
18 | |||
19 | assert response.content_type == """application/atom+xml""" |
|
19 | assert response.content_type == """application/atom+xml""" | |
20 | assert """<?xml version="1.0" encoding="utf-8"?>""" in response |
|
20 | assert """<?xml version="1.0" encoding="utf-8"?>""" in response |
@@ -5,7 +5,7 b' import posixpath' | |||||
5 |
|
5 | |||
6 | from kallithea.model.db import Repository |
|
6 | from kallithea.model.db import Repository | |
7 | from kallithea.model.meta import Session |
|
7 | from kallithea.model.meta import Session | |
8 |
from kallithea.tests |
|
8 | from kallithea.tests import base | |
9 | from kallithea.tests.fixture import Fixture |
|
9 | from kallithea.tests.fixture import Fixture | |
10 |
|
10 | |||
11 |
|
11 | |||
@@ -27,51 +27,51 b' def _set_downloads(repo_name, set_to):' | |||||
27 | Session().commit() |
|
27 | Session().commit() | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | class TestFilesController(TestController): |
|
30 | class TestFilesController(base.TestController): | |
31 |
|
31 | |||
32 | def test_index(self): |
|
32 | def test_index(self): | |
33 | self.log_user() |
|
33 | self.log_user() | |
34 | response = self.app.get(url(controller='files', action='index', |
|
34 | response = self.app.get(base.url(controller='files', action='index', | |
35 | repo_name=HG_REPO, |
|
35 | repo_name=base.HG_REPO, | |
36 | revision='tip', |
|
36 | revision='tip', | |
37 | f_path='/')) |
|
37 | f_path='/')) | |
38 | # Test response... |
|
38 | # Test response... | |
39 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/docs"><i class="icon-folder-open"></i><span>docs</span></a>' % HG_REPO) |
|
39 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/docs"><i class="icon-folder-open"></i><span>docs</span></a>' % base.HG_REPO) | |
40 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/vcs"><i class="icon-folder-open"></i><span>vcs</span></a>' % HG_REPO) |
|
40 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/vcs"><i class="icon-folder-open"></i><span>vcs</span></a>' % base.HG_REPO) | |
41 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.gitignore"><i class="icon-doc"></i><span>.gitignore</span></a>' % HG_REPO) |
|
41 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.gitignore"><i class="icon-doc"></i><span>.gitignore</span></a>' % base.HG_REPO) | |
42 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgignore"><i class="icon-doc"></i><span>.hgignore</span></a>' % HG_REPO) |
|
42 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgignore"><i class="icon-doc"></i><span>.hgignore</span></a>' % base.HG_REPO) | |
43 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgtags"><i class="icon-doc"></i><span>.hgtags</span></a>' % HG_REPO) |
|
43 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.hgtags"><i class="icon-doc"></i><span>.hgtags</span></a>' % base.HG_REPO) | |
44 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.travis.yml"><i class="icon-doc"></i><span>.travis.yml</span></a>' % HG_REPO) |
|
44 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/.travis.yml"><i class="icon-doc"></i><span>.travis.yml</span></a>' % base.HG_REPO) | |
45 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/MANIFEST.in"><i class="icon-doc"></i><span>MANIFEST.in</span></a>' % HG_REPO) |
|
45 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/MANIFEST.in"><i class="icon-doc"></i><span>MANIFEST.in</span></a>' % base.HG_REPO) | |
46 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/README.rst"><i class="icon-doc"></i><span>README.rst</span></a>' % HG_REPO) |
|
46 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/README.rst"><i class="icon-doc"></i><span>README.rst</span></a>' % base.HG_REPO) | |
47 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/run_test_and_report.sh"><i class="icon-doc"></i><span>run_test_and_report.sh</span></a>' % HG_REPO) |
|
47 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/run_test_and_report.sh"><i class="icon-doc"></i><span>run_test_and_report.sh</span></a>' % base.HG_REPO) | |
48 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.cfg"><i class="icon-doc"></i><span>setup.cfg</span></a>' % HG_REPO) |
|
48 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.cfg"><i class="icon-doc"></i><span>setup.cfg</span></a>' % base.HG_REPO) | |
49 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.py"><i class="icon-doc"></i><span>setup.py</span></a>' % HG_REPO) |
|
49 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/setup.py"><i class="icon-doc"></i><span>setup.py</span></a>' % base.HG_REPO) | |
50 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/test_and_report.sh"><i class="icon-doc"></i><span>test_and_report.sh</span></a>' % HG_REPO) |
|
50 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/test_and_report.sh"><i class="icon-doc"></i><span>test_and_report.sh</span></a>' % base.HG_REPO) | |
51 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/tox.ini"><i class="icon-doc"></i><span>tox.ini</span></a>' % HG_REPO) |
|
51 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/96507bd11ecc815ebc6270fdf6db110928c09c1e/tox.ini"><i class="icon-doc"></i><span>tox.ini</span></a>' % base.HG_REPO) | |
52 |
|
52 | |||
53 | def test_index_revision(self): |
|
53 | def test_index_revision(self): | |
54 | self.log_user() |
|
54 | self.log_user() | |
55 |
|
55 | |||
56 | response = self.app.get( |
|
56 | response = self.app.get( | |
57 | url(controller='files', action='index', |
|
57 | base.url(controller='files', action='index', | |
58 | repo_name=HG_REPO, |
|
58 | repo_name=base.HG_REPO, | |
59 | revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', |
|
59 | revision='7ba66bec8d6dbba14a2155be32408c435c5f4492', | |
60 | f_path='/') |
|
60 | f_path='/') | |
61 | ) |
|
61 | ) | |
62 |
|
62 | |||
63 | # Test response... |
|
63 | # Test response... | |
64 |
|
64 | |||
65 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs"><i class="icon-folder-open"></i><span>docs</span></a>' % HG_REPO) |
|
65 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/docs"><i class="icon-folder-open"></i><span>docs</span></a>' % base.HG_REPO) | |
66 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests"><i class="icon-folder-open"></i><span>tests</span></a>' % HG_REPO) |
|
66 | response.mustcontain('<a class="browser-dir ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/tests"><i class="icon-folder-open"></i><span>tests</span></a>' % base.HG_REPO) | |
67 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst"><i class="icon-doc"></i><span>README.rst</span></a>' % HG_REPO) |
|
67 | response.mustcontain('<a class="browser-file ypjax-link" href="/%s/files/7ba66bec8d6dbba14a2155be32408c435c5f4492/README.rst"><i class="icon-doc"></i><span>README.rst</span></a>' % base.HG_REPO) | |
68 | response.mustcontain('1.1 KiB') |
|
68 | response.mustcontain('1.1 KiB') | |
69 |
|
69 | |||
70 | def test_index_different_branch(self): |
|
70 | def test_index_different_branch(self): | |
71 | self.log_user() |
|
71 | self.log_user() | |
72 |
|
72 | |||
73 | response = self.app.get(url(controller='files', action='index', |
|
73 | response = self.app.get(base.url(controller='files', action='index', | |
74 | repo_name=HG_REPO, |
|
74 | repo_name=base.HG_REPO, | |
75 | revision='97e8b885c04894463c51898e14387d80c30ed1ee', |
|
75 | revision='97e8b885c04894463c51898e14387d80c30ed1ee', | |
76 | f_path='/')) |
|
76 | f_path='/')) | |
77 |
|
77 | |||
@@ -86,8 +86,8 b' class TestFilesController(TestController' | |||||
86 | (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'), |
|
86 | (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'), | |
87 | (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]: |
|
87 | (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]: | |
88 |
|
88 | |||
89 | response = self.app.get(url(controller='files', action='index', |
|
89 | response = self.app.get(base.url(controller='files', action='index', | |
90 | repo_name=HG_REPO, |
|
90 | repo_name=base.HG_REPO, | |
91 | revision=r[1], |
|
91 | revision=r[1], | |
92 | f_path='/')) |
|
92 | f_path='/')) | |
93 |
|
93 | |||
@@ -99,8 +99,8 b' class TestFilesController(TestController' | |||||
99 | import kallithea.lib.helpers |
|
99 | import kallithea.lib.helpers | |
100 | kallithea.lib.helpers._urlify_issues_f = None |
|
100 | kallithea.lib.helpers._urlify_issues_f = None | |
101 | self.log_user() |
|
101 | self.log_user() | |
102 | response = self.app.get(url(controller='files', action='index', |
|
102 | response = self.app.get(base.url(controller='files', action='index', | |
103 | repo_name=HG_REPO, |
|
103 | repo_name=base.HG_REPO, | |
104 | revision='8911406ad776fdd3d0b9932a2e89677e57405a48', |
|
104 | revision='8911406ad776fdd3d0b9932a2e89677e57405a48', | |
105 | f_path='vcs/nodes.py')) |
|
105 | f_path='vcs/nodes.py')) | |
106 |
|
106 | |||
@@ -115,8 +115,8 b' class TestFilesController(TestController' | |||||
115 |
|
115 | |||
116 | def test_file_source_history(self): |
|
116 | def test_file_source_history(self): | |
117 | self.log_user() |
|
117 | self.log_user() | |
118 | response = self.app.get(url(controller='files', action='history', |
|
118 | response = self.app.get(base.url(controller='files', action='history', | |
119 | repo_name=HG_REPO, |
|
119 | repo_name=base.HG_REPO, | |
120 | revision='tip', |
|
120 | revision='tip', | |
121 | f_path='vcs/nodes.py'), |
|
121 | f_path='vcs/nodes.py'), | |
122 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) |
|
122 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | |
@@ -124,8 +124,8 b' class TestFilesController(TestController' | |||||
124 |
|
124 | |||
125 | def test_file_source_history_git(self): |
|
125 | def test_file_source_history_git(self): | |
126 | self.log_user() |
|
126 | self.log_user() | |
127 | response = self.app.get(url(controller='files', action='history', |
|
127 | response = self.app.get(base.url(controller='files', action='history', | |
128 | repo_name=GIT_REPO, |
|
128 | repo_name=base.GIT_REPO, | |
129 | revision='master', |
|
129 | revision='master', | |
130 | f_path='vcs/nodes.py'), |
|
130 | f_path='vcs/nodes.py'), | |
131 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) |
|
131 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'},) | |
@@ -133,8 +133,8 b' class TestFilesController(TestController' | |||||
133 |
|
133 | |||
134 | def test_file_annotation(self): |
|
134 | def test_file_annotation(self): | |
135 | self.log_user() |
|
135 | self.log_user() | |
136 | response = self.app.get(url(controller='files', action='index', |
|
136 | response = self.app.get(base.url(controller='files', action='index', | |
137 | repo_name=HG_REPO, |
|
137 | repo_name=base.HG_REPO, | |
138 | revision='tip', |
|
138 | revision='tip', | |
139 | f_path='vcs/nodes.py', |
|
139 | f_path='vcs/nodes.py', | |
140 | annotate='1')) |
|
140 | annotate='1')) | |
@@ -143,8 +143,8 b' class TestFilesController(TestController' | |||||
143 |
|
143 | |||
144 | def test_file_annotation_git(self): |
|
144 | def test_file_annotation_git(self): | |
145 | self.log_user() |
|
145 | self.log_user() | |
146 | response = self.app.get(url(controller='files', action='index', |
|
146 | response = self.app.get(base.url(controller='files', action='index', | |
147 | repo_name=GIT_REPO, |
|
147 | repo_name=base.GIT_REPO, | |
148 | revision='master', |
|
148 | revision='master', | |
149 | f_path='vcs/nodes.py', |
|
149 | f_path='vcs/nodes.py', | |
150 | annotate='1')) |
|
150 | annotate='1')) | |
@@ -152,8 +152,8 b' class TestFilesController(TestController' | |||||
152 |
|
152 | |||
153 | def test_file_annotation_history(self): |
|
153 | def test_file_annotation_history(self): | |
154 | self.log_user() |
|
154 | self.log_user() | |
155 | response = self.app.get(url(controller='files', action='history', |
|
155 | response = self.app.get(base.url(controller='files', action='history', | |
156 | repo_name=HG_REPO, |
|
156 | repo_name=base.HG_REPO, | |
157 | revision='tip', |
|
157 | revision='tip', | |
158 | f_path='vcs/nodes.py', |
|
158 | f_path='vcs/nodes.py', | |
159 | annotate='1'), |
|
159 | annotate='1'), | |
@@ -163,8 +163,8 b' class TestFilesController(TestController' | |||||
163 |
|
163 | |||
164 | def test_file_annotation_history_git(self): |
|
164 | def test_file_annotation_history_git(self): | |
165 | self.log_user() |
|
165 | self.log_user() | |
166 | response = self.app.get(url(controller='files', action='history', |
|
166 | response = self.app.get(base.url(controller='files', action='history', | |
167 | repo_name=GIT_REPO, |
|
167 | repo_name=base.GIT_REPO, | |
168 | revision='master', |
|
168 | revision='master', | |
169 | f_path='vcs/nodes.py', |
|
169 | f_path='vcs/nodes.py', | |
170 | annotate=True), |
|
170 | annotate=True), | |
@@ -174,8 +174,8 b' class TestFilesController(TestController' | |||||
174 |
|
174 | |||
175 | def test_file_authors(self): |
|
175 | def test_file_authors(self): | |
176 | self.log_user() |
|
176 | self.log_user() | |
177 | response = self.app.get(url(controller='files', action='authors', |
|
177 | response = self.app.get(base.url(controller='files', action='authors', | |
178 | repo_name=HG_REPO, |
|
178 | repo_name=base.HG_REPO, | |
179 | revision='tip', |
|
179 | revision='tip', | |
180 | f_path='vcs/nodes.py', |
|
180 | f_path='vcs/nodes.py', | |
181 | annotate='1')) |
|
181 | annotate='1')) | |
@@ -184,8 +184,8 b' class TestFilesController(TestController' | |||||
184 |
|
184 | |||
185 | def test_file_authors_git(self): |
|
185 | def test_file_authors_git(self): | |
186 | self.log_user() |
|
186 | self.log_user() | |
187 | response = self.app.get(url(controller='files', action='authors', |
|
187 | response = self.app.get(base.url(controller='files', action='authors', | |
188 | repo_name=GIT_REPO, |
|
188 | repo_name=base.GIT_REPO, | |
189 | revision='master', |
|
189 | revision='master', | |
190 | f_path='vcs/nodes.py', |
|
190 | f_path='vcs/nodes.py', | |
191 | annotate='1')) |
|
191 | annotate='1')) | |
@@ -194,14 +194,14 b' class TestFilesController(TestController' | |||||
194 |
|
194 | |||
195 | def test_archival(self): |
|
195 | def test_archival(self): | |
196 | self.log_user() |
|
196 | self.log_user() | |
197 | _set_downloads(HG_REPO, set_to=True) |
|
197 | _set_downloads(base.HG_REPO, set_to=True) | |
198 | for arch_ext, info in ARCHIVE_SPECS.items(): |
|
198 | for arch_ext, info in ARCHIVE_SPECS.items(): | |
199 | short = '27cd5cce30c9%s' % arch_ext |
|
199 | short = '27cd5cce30c9%s' % arch_ext | |
200 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext |
|
200 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | |
201 | filename = '%s-%s' % (HG_REPO, short) |
|
201 | filename = '%s-%s' % (base.HG_REPO, short) | |
202 | response = self.app.get(url(controller='files', |
|
202 | response = self.app.get(base.url(controller='files', | |
203 | action='archivefile', |
|
203 | action='archivefile', | |
204 | repo_name=HG_REPO, |
|
204 | repo_name=base.HG_REPO, | |
205 | fname=fname)) |
|
205 | fname=fname)) | |
206 |
|
206 | |||
207 | assert response.status == '200 OK' |
|
207 | assert response.status == '200 OK' | |
@@ -215,25 +215,25 b' class TestFilesController(TestController' | |||||
215 |
|
215 | |||
216 | def test_archival_wrong_ext(self): |
|
216 | def test_archival_wrong_ext(self): | |
217 | self.log_user() |
|
217 | self.log_user() | |
218 | _set_downloads(HG_REPO, set_to=True) |
|
218 | _set_downloads(base.HG_REPO, set_to=True) | |
219 | for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: |
|
219 | for arch_ext in ['tar', 'rar', 'x', '..ax', '.zipz']: | |
220 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext |
|
220 | fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext | |
221 |
|
221 | |||
222 | response = self.app.get(url(controller='files', |
|
222 | response = self.app.get(base.url(controller='files', | |
223 | action='archivefile', |
|
223 | action='archivefile', | |
224 | repo_name=HG_REPO, |
|
224 | repo_name=base.HG_REPO, | |
225 | fname=fname)) |
|
225 | fname=fname)) | |
226 | response.mustcontain('Unknown archive type') |
|
226 | response.mustcontain('Unknown archive type') | |
227 |
|
227 | |||
228 | def test_archival_wrong_revision(self): |
|
228 | def test_archival_wrong_revision(self): | |
229 | self.log_user() |
|
229 | self.log_user() | |
230 | _set_downloads(HG_REPO, set_to=True) |
|
230 | _set_downloads(base.HG_REPO, set_to=True) | |
231 | for rev in ['00x000000', 'tar', 'wrong', '@##$@$42413232', '232dffcd']: |
|
231 | for rev in ['00x000000', 'tar', 'wrong', '@##$@$42413232', '232dffcd']: | |
232 | fname = '%s.zip' % rev |
|
232 | fname = '%s.zip' % rev | |
233 |
|
233 | |||
234 | response = self.app.get(url(controller='files', |
|
234 | response = self.app.get(base.url(controller='files', | |
235 | action='archivefile', |
|
235 | action='archivefile', | |
236 | repo_name=HG_REPO, |
|
236 | repo_name=base.HG_REPO, | |
237 | fname=fname)) |
|
237 | fname=fname)) | |
238 | response.mustcontain('Unknown revision') |
|
238 | response.mustcontain('Unknown revision') | |
239 |
|
239 | |||
@@ -242,8 +242,8 b' class TestFilesController(TestController' | |||||
242 | #========================================================================== |
|
242 | #========================================================================== | |
243 | def test_raw_file_ok(self): |
|
243 | def test_raw_file_ok(self): | |
244 | self.log_user() |
|
244 | self.log_user() | |
245 | response = self.app.get(url(controller='files', action='rawfile', |
|
245 | response = self.app.get(base.url(controller='files', action='rawfile', | |
246 | repo_name=HG_REPO, |
|
246 | repo_name=base.HG_REPO, | |
247 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
247 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
248 | f_path='vcs/nodes.py')) |
|
248 | f_path='vcs/nodes.py')) | |
249 |
|
249 | |||
@@ -255,8 +255,8 b' class TestFilesController(TestController' | |||||
255 | rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc' |
|
255 | rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc' | |
256 | f_path = 'vcs/nodes.py' |
|
256 | f_path = 'vcs/nodes.py' | |
257 |
|
257 | |||
258 | response = self.app.get(url(controller='files', action='rawfile', |
|
258 | response = self.app.get(base.url(controller='files', action='rawfile', | |
259 | repo_name=HG_REPO, |
|
259 | repo_name=base.HG_REPO, | |
260 | revision=rev, |
|
260 | revision=rev, | |
261 | f_path=f_path), status=404) |
|
261 | f_path=f_path), status=404) | |
262 |
|
262 | |||
@@ -267,8 +267,8 b' class TestFilesController(TestController' | |||||
267 | self.log_user() |
|
267 | self.log_user() | |
268 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
268 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
269 | f_path = 'vcs/ERRORnodes.py' |
|
269 | f_path = 'vcs/ERRORnodes.py' | |
270 | response = self.app.get(url(controller='files', action='rawfile', |
|
270 | response = self.app.get(base.url(controller='files', action='rawfile', | |
271 | repo_name=HG_REPO, |
|
271 | repo_name=base.HG_REPO, | |
272 | revision=rev, |
|
272 | revision=rev, | |
273 | f_path=f_path), status=404) |
|
273 | f_path=f_path), status=404) | |
274 |
|
274 | |||
@@ -280,8 +280,8 b' class TestFilesController(TestController' | |||||
280 | #========================================================================== |
|
280 | #========================================================================== | |
281 | def test_raw_ok(self): |
|
281 | def test_raw_ok(self): | |
282 | self.log_user() |
|
282 | self.log_user() | |
283 | response = self.app.get(url(controller='files', action='raw', |
|
283 | response = self.app.get(base.url(controller='files', action='raw', | |
284 | repo_name=HG_REPO, |
|
284 | repo_name=base.HG_REPO, | |
285 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', |
|
285 | revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc', | |
286 | f_path='vcs/nodes.py')) |
|
286 | f_path='vcs/nodes.py')) | |
287 |
|
287 | |||
@@ -292,8 +292,8 b' class TestFilesController(TestController' | |||||
292 | rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc' |
|
292 | rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc' | |
293 | f_path = 'vcs/nodes.py' |
|
293 | f_path = 'vcs/nodes.py' | |
294 |
|
294 | |||
295 | response = self.app.get(url(controller='files', action='raw', |
|
295 | response = self.app.get(base.url(controller='files', action='raw', | |
296 | repo_name=HG_REPO, |
|
296 | repo_name=base.HG_REPO, | |
297 | revision=rev, |
|
297 | revision=rev, | |
298 | f_path=f_path), status=404) |
|
298 | f_path=f_path), status=404) | |
299 |
|
299 | |||
@@ -304,8 +304,8 b' class TestFilesController(TestController' | |||||
304 | self.log_user() |
|
304 | self.log_user() | |
305 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
305 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
306 | f_path = 'vcs/ERRORnodes.py' |
|
306 | f_path = 'vcs/ERRORnodes.py' | |
307 | response = self.app.get(url(controller='files', action='raw', |
|
307 | response = self.app.get(base.url(controller='files', action='raw', | |
308 | repo_name=HG_REPO, |
|
308 | repo_name=base.HG_REPO, | |
309 | revision=rev, |
|
309 | revision=rev, | |
310 | f_path=f_path), status=404) |
|
310 | f_path=f_path), status=404) | |
311 | msg = "There is no file nor directory at the given path: '%s' at revision %s" % (f_path, rev[:12]) |
|
311 | msg = "There is no file nor directory at the given path: '%s' at revision %s" % (f_path, rev[:12]) | |
@@ -315,7 +315,7 b' class TestFilesController(TestController' | |||||
315 | self.log_user() |
|
315 | self.log_user() | |
316 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' |
|
316 | rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc' | |
317 | response = self.app.get( |
|
317 | response = self.app.get( | |
318 | url('files_nodelist_home', repo_name=HG_REPO, f_path='/', |
|
318 | base.url('files_nodelist_home', repo_name=base.HG_REPO, f_path='/', | |
319 | revision=rev), |
|
319 | revision=rev), | |
320 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, |
|
320 | extra_environ={'HTTP_X_PARTIAL_XHR': '1'}, | |
321 | ) |
|
321 | ) | |
@@ -324,14 +324,14 b' class TestFilesController(TestController' | |||||
324 | # Hg - ADD FILE |
|
324 | # Hg - ADD FILE | |
325 | def test_add_file_view_hg(self): |
|
325 | def test_add_file_view_hg(self): | |
326 | self.log_user() |
|
326 | self.log_user() | |
327 | response = self.app.get(url('files_add_home', |
|
327 | response = self.app.get(base.url('files_add_home', | |
328 | repo_name=HG_REPO, |
|
328 | repo_name=base.HG_REPO, | |
329 | revision='tip', f_path='/')) |
|
329 | revision='tip', f_path='/')) | |
330 |
|
330 | |||
331 | def test_add_file_into_hg_missing_content(self): |
|
331 | def test_add_file_into_hg_missing_content(self): | |
332 | self.log_user() |
|
332 | self.log_user() | |
333 | response = self.app.post(url('files_add_home', |
|
333 | response = self.app.post(base.url('files_add_home', | |
334 | repo_name=HG_REPO, |
|
334 | repo_name=base.HG_REPO, | |
335 | revision='tip', f_path='/'), |
|
335 | revision='tip', f_path='/'), | |
336 | params={ |
|
336 | params={ | |
337 | 'content': '', |
|
337 | 'content': '', | |
@@ -343,8 +343,8 b' class TestFilesController(TestController' | |||||
343 |
|
343 | |||
344 | def test_add_file_into_hg_missing_filename(self): |
|
344 | def test_add_file_into_hg_missing_filename(self): | |
345 | self.log_user() |
|
345 | self.log_user() | |
346 | response = self.app.post(url('files_add_home', |
|
346 | response = self.app.post(base.url('files_add_home', | |
347 | repo_name=HG_REPO, |
|
347 | repo_name=base.HG_REPO, | |
348 | revision='tip', f_path='/'), |
|
348 | revision='tip', f_path='/'), | |
349 | params={ |
|
349 | params={ | |
350 | 'content': "foo", |
|
350 | 'content': "foo", | |
@@ -354,15 +354,15 b' class TestFilesController(TestController' | |||||
354 |
|
354 | |||
355 | self.checkSessionFlash(response, 'No filename') |
|
355 | self.checkSessionFlash(response, 'No filename') | |
356 |
|
356 | |||
357 | @parametrize('location,filename', [ |
|
357 | @base.parametrize('location,filename', [ | |
358 | ('/abs', 'foo'), |
|
358 | ('/abs', 'foo'), | |
359 | ('../rel', 'foo'), |
|
359 | ('../rel', 'foo'), | |
360 | ('file/../foo', 'foo'), |
|
360 | ('file/../foo', 'foo'), | |
361 | ]) |
|
361 | ]) | |
362 | def test_add_file_into_hg_bad_filenames(self, location, filename): |
|
362 | def test_add_file_into_hg_bad_filenames(self, location, filename): | |
363 | self.log_user() |
|
363 | self.log_user() | |
364 | response = self.app.post(url('files_add_home', |
|
364 | response = self.app.post(base.url('files_add_home', | |
365 | repo_name=HG_REPO, |
|
365 | repo_name=base.HG_REPO, | |
366 | revision='tip', f_path='/'), |
|
366 | revision='tip', f_path='/'), | |
367 | params={ |
|
367 | params={ | |
368 | 'content': "foo", |
|
368 | 'content': "foo", | |
@@ -374,7 +374,7 b' class TestFilesController(TestController' | |||||
374 |
|
374 | |||
375 | self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') |
|
375 | self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') | |
376 |
|
376 | |||
377 | @parametrize('cnt,location,filename', [ |
|
377 | @base.parametrize('cnt,location,filename', [ | |
378 | (1, '', 'foo.txt'), |
|
378 | (1, '', 'foo.txt'), | |
379 | (2, 'dir', 'foo.rst'), |
|
379 | (2, 'dir', 'foo.rst'), | |
380 | (3, 'rel/dir', 'foo.bar'), |
|
380 | (3, 'rel/dir', 'foo.bar'), | |
@@ -382,7 +382,7 b' class TestFilesController(TestController' | |||||
382 | def test_add_file_into_hg(self, cnt, location, filename): |
|
382 | def test_add_file_into_hg(self, cnt, location, filename): | |
383 | self.log_user() |
|
383 | self.log_user() | |
384 | repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='hg') |
|
384 | repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='hg') | |
385 | response = self.app.post(url('files_add_home', |
|
385 | response = self.app.post(base.url('files_add_home', | |
386 | repo_name=repo.repo_name, |
|
386 | repo_name=repo.repo_name, | |
387 | revision='tip', f_path='/'), |
|
387 | revision='tip', f_path='/'), | |
388 | params={ |
|
388 | params={ | |
@@ -401,14 +401,14 b' class TestFilesController(TestController' | |||||
401 | # Git - add file |
|
401 | # Git - add file | |
402 | def test_add_file_view_git(self): |
|
402 | def test_add_file_view_git(self): | |
403 | self.log_user() |
|
403 | self.log_user() | |
404 | response = self.app.get(url('files_add_home', |
|
404 | response = self.app.get(base.url('files_add_home', | |
405 | repo_name=GIT_REPO, |
|
405 | repo_name=base.GIT_REPO, | |
406 | revision='tip', f_path='/')) |
|
406 | revision='tip', f_path='/')) | |
407 |
|
407 | |||
408 | def test_add_file_into_git_missing_content(self): |
|
408 | def test_add_file_into_git_missing_content(self): | |
409 | self.log_user() |
|
409 | self.log_user() | |
410 | response = self.app.post(url('files_add_home', |
|
410 | response = self.app.post(base.url('files_add_home', | |
411 | repo_name=GIT_REPO, |
|
411 | repo_name=base.GIT_REPO, | |
412 | revision='tip', f_path='/'), |
|
412 | revision='tip', f_path='/'), | |
413 | params={ |
|
413 | params={ | |
414 | 'content': '', |
|
414 | 'content': '', | |
@@ -419,8 +419,8 b' class TestFilesController(TestController' | |||||
419 |
|
419 | |||
420 | def test_add_file_into_git_missing_filename(self): |
|
420 | def test_add_file_into_git_missing_filename(self): | |
421 | self.log_user() |
|
421 | self.log_user() | |
422 | response = self.app.post(url('files_add_home', |
|
422 | response = self.app.post(base.url('files_add_home', | |
423 | repo_name=GIT_REPO, |
|
423 | repo_name=base.GIT_REPO, | |
424 | revision='tip', f_path='/'), |
|
424 | revision='tip', f_path='/'), | |
425 | params={ |
|
425 | params={ | |
426 | 'content': "foo", |
|
426 | 'content': "foo", | |
@@ -430,15 +430,15 b' class TestFilesController(TestController' | |||||
430 |
|
430 | |||
431 | self.checkSessionFlash(response, 'No filename') |
|
431 | self.checkSessionFlash(response, 'No filename') | |
432 |
|
432 | |||
433 | @parametrize('location,filename', [ |
|
433 | @base.parametrize('location,filename', [ | |
434 | ('/abs', 'foo'), |
|
434 | ('/abs', 'foo'), | |
435 | ('../rel', 'foo'), |
|
435 | ('../rel', 'foo'), | |
436 | ('file/../foo', 'foo'), |
|
436 | ('file/../foo', 'foo'), | |
437 | ]) |
|
437 | ]) | |
438 | def test_add_file_into_git_bad_filenames(self, location, filename): |
|
438 | def test_add_file_into_git_bad_filenames(self, location, filename): | |
439 | self.log_user() |
|
439 | self.log_user() | |
440 | response = self.app.post(url('files_add_home', |
|
440 | response = self.app.post(base.url('files_add_home', | |
441 | repo_name=GIT_REPO, |
|
441 | repo_name=base.GIT_REPO, | |
442 | revision='tip', f_path='/'), |
|
442 | revision='tip', f_path='/'), | |
443 | params={ |
|
443 | params={ | |
444 | 'content': "foo", |
|
444 | 'content': "foo", | |
@@ -450,7 +450,7 b' class TestFilesController(TestController' | |||||
450 |
|
450 | |||
451 | self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') |
|
451 | self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path') | |
452 |
|
452 | |||
453 | @parametrize('cnt,location,filename', [ |
|
453 | @base.parametrize('cnt,location,filename', [ | |
454 | (1, '', 'foo.txt'), |
|
454 | (1, '', 'foo.txt'), | |
455 | (2, 'dir', 'foo.rst'), |
|
455 | (2, 'dir', 'foo.rst'), | |
456 | (3, 'rel/dir', 'foo.bar'), |
|
456 | (3, 'rel/dir', 'foo.bar'), | |
@@ -458,7 +458,7 b' class TestFilesController(TestController' | |||||
458 | def test_add_file_into_git(self, cnt, location, filename): |
|
458 | def test_add_file_into_git(self, cnt, location, filename): | |
459 | self.log_user() |
|
459 | self.log_user() | |
460 | repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='git') |
|
460 | repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='git') | |
461 | response = self.app.post(url('files_add_home', |
|
461 | response = self.app.post(base.url('files_add_home', | |
462 | repo_name=repo.repo_name, |
|
462 | repo_name=repo.repo_name, | |
463 | revision='tip', f_path='/'), |
|
463 | revision='tip', f_path='/'), | |
464 | params={ |
|
464 | params={ | |
@@ -477,16 +477,16 b' class TestFilesController(TestController' | |||||
477 | # Hg - EDIT |
|
477 | # Hg - EDIT | |
478 | def test_edit_file_view_hg(self): |
|
478 | def test_edit_file_view_hg(self): | |
479 | self.log_user() |
|
479 | self.log_user() | |
480 | response = self.app.get(url('files_edit_home', |
|
480 | response = self.app.get(base.url('files_edit_home', | |
481 | repo_name=HG_REPO, |
|
481 | repo_name=base.HG_REPO, | |
482 | revision='tip', f_path='vcs/nodes.py')) |
|
482 | revision='tip', f_path='vcs/nodes.py')) | |
483 | # Odd error when on tip ... |
|
483 | # Odd error when on tip ... | |
484 | self.checkSessionFlash(response, "You can only edit files with revision being a valid branch") |
|
484 | self.checkSessionFlash(response, "You can only edit files with revision being a valid branch") | |
485 | assert "Commit Message" not in response.body |
|
485 | assert "Commit Message" not in response.body | |
486 |
|
486 | |||
487 | # Specify branch head revision to avoid "valid branch" error and get coverage of edit form |
|
487 | # Specify branch head revision to avoid "valid branch" error and get coverage of edit form | |
488 | response = self.app.get(url('files_edit_home', |
|
488 | response = self.app.get(base.url('files_edit_home', | |
489 | repo_name=HG_REPO, |
|
489 | repo_name=base.HG_REPO, | |
490 | revision='96507bd11ecc815ebc6270fdf6db110928c09c1e', f_path='vcs/nodes.py')) |
|
490 | revision='96507bd11ecc815ebc6270fdf6db110928c09c1e', f_path='vcs/nodes.py')) | |
491 | assert "Commit Message" in response.body |
|
491 | assert "Commit Message" in response.body | |
492 |
|
492 | |||
@@ -497,7 +497,7 b' class TestFilesController(TestController' | |||||
497 | ## add file |
|
497 | ## add file | |
498 | location = 'vcs' |
|
498 | location = 'vcs' | |
499 | filename = 'nodes.py' |
|
499 | filename = 'nodes.py' | |
500 | response = self.app.post(url('files_add_home', |
|
500 | response = self.app.post(base.url('files_add_home', | |
501 | repo_name=repo.repo_name, |
|
501 | repo_name=repo.repo_name, | |
502 | revision='tip', f_path='/'), |
|
502 | revision='tip', f_path='/'), | |
503 | params={ |
|
503 | params={ | |
@@ -511,7 +511,7 b' class TestFilesController(TestController' | |||||
511 | try: |
|
511 | try: | |
512 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
512 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
513 | % posixpath.join(location, filename)) |
|
513 | % posixpath.join(location, filename)) | |
514 | response = self.app.get(url('files_edit_home', |
|
514 | response = self.app.get(base.url('files_edit_home', | |
515 | repo_name=repo.repo_name, |
|
515 | repo_name=repo.repo_name, | |
516 | revision='tip', f_path=posixpath.join(location, filename)), |
|
516 | revision='tip', f_path=posixpath.join(location, filename)), | |
517 | status=302) |
|
517 | status=302) | |
@@ -527,7 +527,7 b' class TestFilesController(TestController' | |||||
527 | ## add file |
|
527 | ## add file | |
528 | location = 'vcs' |
|
528 | location = 'vcs' | |
529 | filename = 'nodes.py' |
|
529 | filename = 'nodes.py' | |
530 | response = self.app.post(url('files_add_home', |
|
530 | response = self.app.post(base.url('files_add_home', | |
531 | repo_name=repo.repo_name, |
|
531 | repo_name=repo.repo_name, | |
532 | revision='tip', |
|
532 | revision='tip', | |
533 | f_path='/'), |
|
533 | f_path='/'), | |
@@ -542,7 +542,7 b' class TestFilesController(TestController' | |||||
542 | try: |
|
542 | try: | |
543 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
543 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
544 | % posixpath.join(location, filename)) |
|
544 | % posixpath.join(location, filename)) | |
545 | response = self.app.post(url('files_edit_home', |
|
545 | response = self.app.post(base.url('files_edit_home', | |
546 | repo_name=repo.repo_name, |
|
546 | repo_name=repo.repo_name, | |
547 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, |
|
547 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | |
548 | f_path=posixpath.join(location, filename)), |
|
548 | f_path=posixpath.join(location, filename)), | |
@@ -560,8 +560,8 b' class TestFilesController(TestController' | |||||
560 | # Git - edit |
|
560 | # Git - edit | |
561 | def test_edit_file_view_git(self): |
|
561 | def test_edit_file_view_git(self): | |
562 | self.log_user() |
|
562 | self.log_user() | |
563 | response = self.app.get(url('files_edit_home', |
|
563 | response = self.app.get(base.url('files_edit_home', | |
564 | repo_name=GIT_REPO, |
|
564 | repo_name=base.GIT_REPO, | |
565 | revision='tip', f_path='vcs/nodes.py')) |
|
565 | revision='tip', f_path='vcs/nodes.py')) | |
566 |
|
566 | |||
567 | def test_edit_file_view_not_on_branch_git(self): |
|
567 | def test_edit_file_view_not_on_branch_git(self): | |
@@ -571,7 +571,7 b' class TestFilesController(TestController' | |||||
571 | ## add file |
|
571 | ## add file | |
572 | location = 'vcs' |
|
572 | location = 'vcs' | |
573 | filename = 'nodes.py' |
|
573 | filename = 'nodes.py' | |
574 | response = self.app.post(url('files_add_home', |
|
574 | response = self.app.post(base.url('files_add_home', | |
575 | repo_name=repo.repo_name, |
|
575 | repo_name=repo.repo_name, | |
576 | revision='tip', f_path='/'), |
|
576 | revision='tip', f_path='/'), | |
577 | params={ |
|
577 | params={ | |
@@ -585,7 +585,7 b' class TestFilesController(TestController' | |||||
585 | try: |
|
585 | try: | |
586 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
586 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
587 | % posixpath.join(location, filename)) |
|
587 | % posixpath.join(location, filename)) | |
588 | response = self.app.get(url('files_edit_home', |
|
588 | response = self.app.get(base.url('files_edit_home', | |
589 | repo_name=repo.repo_name, |
|
589 | repo_name=repo.repo_name, | |
590 | revision='tip', f_path=posixpath.join(location, filename)), |
|
590 | revision='tip', f_path=posixpath.join(location, filename)), | |
591 | status=302) |
|
591 | status=302) | |
@@ -601,7 +601,7 b' class TestFilesController(TestController' | |||||
601 | ## add file |
|
601 | ## add file | |
602 | location = 'vcs' |
|
602 | location = 'vcs' | |
603 | filename = 'nodes.py' |
|
603 | filename = 'nodes.py' | |
604 | response = self.app.post(url('files_add_home', |
|
604 | response = self.app.post(base.url('files_add_home', | |
605 | repo_name=repo.repo_name, |
|
605 | repo_name=repo.repo_name, | |
606 | revision='tip', |
|
606 | revision='tip', | |
607 | f_path='/'), |
|
607 | f_path='/'), | |
@@ -616,7 +616,7 b' class TestFilesController(TestController' | |||||
616 | try: |
|
616 | try: | |
617 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
617 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
618 | % posixpath.join(location, filename)) |
|
618 | % posixpath.join(location, filename)) | |
619 | response = self.app.post(url('files_edit_home', |
|
619 | response = self.app.post(base.url('files_edit_home', | |
620 | repo_name=repo.repo_name, |
|
620 | repo_name=repo.repo_name, | |
621 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, |
|
621 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | |
622 | f_path=posixpath.join(location, filename)), |
|
622 | f_path=posixpath.join(location, filename)), | |
@@ -634,8 +634,8 b' class TestFilesController(TestController' | |||||
634 | # Hg - delete |
|
634 | # Hg - delete | |
635 | def test_delete_file_view_hg(self): |
|
635 | def test_delete_file_view_hg(self): | |
636 | self.log_user() |
|
636 | self.log_user() | |
637 | response = self.app.get(url('files_delete_home', |
|
637 | response = self.app.get(base.url('files_delete_home', | |
638 | repo_name=HG_REPO, |
|
638 | repo_name=base.HG_REPO, | |
639 | revision='tip', f_path='vcs/nodes.py')) |
|
639 | revision='tip', f_path='vcs/nodes.py')) | |
640 |
|
640 | |||
641 | def test_delete_file_view_not_on_branch_hg(self): |
|
641 | def test_delete_file_view_not_on_branch_hg(self): | |
@@ -645,7 +645,7 b' class TestFilesController(TestController' | |||||
645 | ## add file |
|
645 | ## add file | |
646 | location = 'vcs' |
|
646 | location = 'vcs' | |
647 | filename = 'nodes.py' |
|
647 | filename = 'nodes.py' | |
648 | response = self.app.post(url('files_add_home', |
|
648 | response = self.app.post(base.url('files_add_home', | |
649 | repo_name=repo.repo_name, |
|
649 | repo_name=repo.repo_name, | |
650 | revision='tip', f_path='/'), |
|
650 | revision='tip', f_path='/'), | |
651 | params={ |
|
651 | params={ | |
@@ -659,7 +659,7 b' class TestFilesController(TestController' | |||||
659 | try: |
|
659 | try: | |
660 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
660 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
661 | % posixpath.join(location, filename)) |
|
661 | % posixpath.join(location, filename)) | |
662 | response = self.app.get(url('files_delete_home', |
|
662 | response = self.app.get(base.url('files_delete_home', | |
663 | repo_name=repo.repo_name, |
|
663 | repo_name=repo.repo_name, | |
664 | revision='tip', f_path=posixpath.join(location, filename)), |
|
664 | revision='tip', f_path=posixpath.join(location, filename)), | |
665 | status=302) |
|
665 | status=302) | |
@@ -675,7 +675,7 b' class TestFilesController(TestController' | |||||
675 | ## add file |
|
675 | ## add file | |
676 | location = 'vcs' |
|
676 | location = 'vcs' | |
677 | filename = 'nodes.py' |
|
677 | filename = 'nodes.py' | |
678 | response = self.app.post(url('files_add_home', |
|
678 | response = self.app.post(base.url('files_add_home', | |
679 | repo_name=repo.repo_name, |
|
679 | repo_name=repo.repo_name, | |
680 | revision='tip', |
|
680 | revision='tip', | |
681 | f_path='/'), |
|
681 | f_path='/'), | |
@@ -690,7 +690,7 b' class TestFilesController(TestController' | |||||
690 | try: |
|
690 | try: | |
691 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
691 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
692 | % posixpath.join(location, filename)) |
|
692 | % posixpath.join(location, filename)) | |
693 | response = self.app.post(url('files_delete_home', |
|
693 | response = self.app.post(base.url('files_delete_home', | |
694 | repo_name=repo.repo_name, |
|
694 | repo_name=repo.repo_name, | |
695 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, |
|
695 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | |
696 | f_path=posixpath.join(location, filename)), |
|
696 | f_path=posixpath.join(location, filename)), | |
@@ -707,8 +707,8 b' class TestFilesController(TestController' | |||||
707 | # Git - delete |
|
707 | # Git - delete | |
708 | def test_delete_file_view_git(self): |
|
708 | def test_delete_file_view_git(self): | |
709 | self.log_user() |
|
709 | self.log_user() | |
710 | response = self.app.get(url('files_delete_home', |
|
710 | response = self.app.get(base.url('files_delete_home', | |
711 | repo_name=HG_REPO, |
|
711 | repo_name=base.HG_REPO, | |
712 | revision='tip', f_path='vcs/nodes.py')) |
|
712 | revision='tip', f_path='vcs/nodes.py')) | |
713 |
|
713 | |||
714 | def test_delete_file_view_not_on_branch_git(self): |
|
714 | def test_delete_file_view_not_on_branch_git(self): | |
@@ -718,7 +718,7 b' class TestFilesController(TestController' | |||||
718 | ## add file |
|
718 | ## add file | |
719 | location = 'vcs' |
|
719 | location = 'vcs' | |
720 | filename = 'nodes.py' |
|
720 | filename = 'nodes.py' | |
721 | response = self.app.post(url('files_add_home', |
|
721 | response = self.app.post(base.url('files_add_home', | |
722 | repo_name=repo.repo_name, |
|
722 | repo_name=repo.repo_name, | |
723 | revision='tip', f_path='/'), |
|
723 | revision='tip', f_path='/'), | |
724 | params={ |
|
724 | params={ | |
@@ -732,7 +732,7 b' class TestFilesController(TestController' | |||||
732 | try: |
|
732 | try: | |
733 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
733 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
734 | % posixpath.join(location, filename)) |
|
734 | % posixpath.join(location, filename)) | |
735 | response = self.app.get(url('files_delete_home', |
|
735 | response = self.app.get(base.url('files_delete_home', | |
736 | repo_name=repo.repo_name, |
|
736 | repo_name=repo.repo_name, | |
737 | revision='tip', f_path=posixpath.join(location, filename)), |
|
737 | revision='tip', f_path=posixpath.join(location, filename)), | |
738 | status=302) |
|
738 | status=302) | |
@@ -748,7 +748,7 b' class TestFilesController(TestController' | |||||
748 | ## add file |
|
748 | ## add file | |
749 | location = 'vcs' |
|
749 | location = 'vcs' | |
750 | filename = 'nodes.py' |
|
750 | filename = 'nodes.py' | |
751 | response = self.app.post(url('files_add_home', |
|
751 | response = self.app.post(base.url('files_add_home', | |
752 | repo_name=repo.repo_name, |
|
752 | repo_name=repo.repo_name, | |
753 | revision='tip', |
|
753 | revision='tip', | |
754 | f_path='/'), |
|
754 | f_path='/'), | |
@@ -763,7 +763,7 b' class TestFilesController(TestController' | |||||
763 | try: |
|
763 | try: | |
764 | self.checkSessionFlash(response, 'Successfully committed to %s' |
|
764 | self.checkSessionFlash(response, 'Successfully committed to %s' | |
765 | % posixpath.join(location, filename)) |
|
765 | % posixpath.join(location, filename)) | |
766 | response = self.app.post(url('files_delete_home', |
|
766 | response = self.app.post(base.url('files_delete_home', | |
767 | repo_name=repo.repo_name, |
|
767 | repo_name=repo.repo_name, | |
768 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, |
|
768 | revision=repo.scm_instance.DEFAULT_BRANCH_NAME, | |
769 | f_path=posixpath.join(location, filename)), |
|
769 | f_path=posixpath.join(location, filename)), | |
@@ -779,16 +779,16 b' class TestFilesController(TestController' | |||||
779 |
|
779 | |||
780 | def test_png_diff_no_crash_hg(self): |
|
780 | def test_png_diff_no_crash_hg(self): | |
781 | self.log_user() |
|
781 | self.log_user() | |
782 | response = self.app.get(url('files_diff_home', |
|
782 | response = self.app.get(base.url('files_diff_home', | |
783 | repo_name=HG_REPO, |
|
783 | repo_name=base.HG_REPO, | |
784 | f_path='docs/theme/ADC/static/documentation.png', |
|
784 | f_path='docs/theme/ADC/static/documentation.png', | |
785 | diff1='tip', diff2='tip')) |
|
785 | diff1='tip', diff2='tip')) | |
786 | response.mustcontain("""<pre>Binary file</pre>""") |
|
786 | response.mustcontain("""<pre>Binary file</pre>""") | |
787 |
|
787 | |||
788 | def test_png_diff_no_crash_git(self): |
|
788 | def test_png_diff_no_crash_git(self): | |
789 | self.log_user() |
|
789 | self.log_user() | |
790 | response = self.app.get(url('files_diff_home', |
|
790 | response = self.app.get(base.url('files_diff_home', | |
791 | repo_name=GIT_REPO, |
|
791 | repo_name=base.GIT_REPO, | |
792 | f_path='docs/theme/ADC/static/documentation.png', |
|
792 | f_path='docs/theme/ADC/static/documentation.png', | |
793 | diff1='master', diff2='master')) |
|
793 | diff1='master', diff2='master')) | |
794 | response.mustcontain("""<pre>Binary file</pre>""") |
|
794 | response.mustcontain("""<pre>Binary file</pre>""") |
@@ -1,24 +1,24 b'' | |||||
1 |
from kallithea.tests |
|
1 | from kallithea.tests import base | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | class TestFollowersController(TestController): |
|
4 | class TestFollowersController(base.TestController): | |
5 |
|
5 | |||
6 | def test_index_hg(self): |
|
6 | def test_index_hg(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
8 | repo_name = HG_REPO |
|
8 | repo_name = base.HG_REPO | |
9 | response = self.app.get(url(controller='followers', |
|
9 | response = self.app.get(base.url(controller='followers', | |
10 | action='followers', |
|
10 | action='followers', | |
11 | repo_name=repo_name)) |
|
11 | repo_name=repo_name)) | |
12 |
|
12 | |||
13 | response.mustcontain(TEST_USER_ADMIN_LOGIN) |
|
13 | response.mustcontain(base.TEST_USER_ADMIN_LOGIN) | |
14 | response.mustcontain("""Started following""") |
|
14 | response.mustcontain("""Started following""") | |
15 |
|
15 | |||
16 | def test_index_git(self): |
|
16 | def test_index_git(self): | |
17 | self.log_user() |
|
17 | self.log_user() | |
18 | repo_name = GIT_REPO |
|
18 | repo_name = base.GIT_REPO | |
19 | response = self.app.get(url(controller='followers', |
|
19 | response = self.app.get(base.url(controller='followers', | |
20 | action='followers', |
|
20 | action='followers', | |
21 | repo_name=repo_name)) |
|
21 | repo_name=repo_name)) | |
22 |
|
22 | |||
23 | response.mustcontain(TEST_USER_ADMIN_LOGIN) |
|
23 | response.mustcontain(base.TEST_USER_ADMIN_LOGIN) | |
24 | response.mustcontain("""Started following""") |
|
24 | response.mustcontain("""Started following""") |
@@ -7,14 +7,14 b' from kallithea.model.db import Repositor' | |||||
7 | from kallithea.model.meta import Session |
|
7 | from kallithea.model.meta import Session | |
8 | from kallithea.model.repo import RepoModel |
|
8 | from kallithea.model.repo import RepoModel | |
9 | from kallithea.model.user import UserModel |
|
9 | from kallithea.model.user import UserModel | |
10 |
from kallithea.tests |
|
10 | from kallithea.tests import base | |
11 | from kallithea.tests.fixture import Fixture |
|
11 | from kallithea.tests.fixture import Fixture | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | fixture = Fixture() |
|
14 | fixture = Fixture() | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | class _BaseTestCase(TestController): |
|
17 | class _BaseTestCase(base.TestController): | |
18 | """ |
|
18 | """ | |
19 | Write all tests here |
|
19 | Write all tests here | |
20 | """ |
|
20 | """ | |
@@ -37,13 +37,13 b' class _BaseTestCase(TestController):' | |||||
37 | def test_index(self): |
|
37 | def test_index(self): | |
38 | self.log_user() |
|
38 | self.log_user() | |
39 | repo_name = self.REPO |
|
39 | repo_name = self.REPO | |
40 | response = self.app.get(url(controller='forks', action='forks', |
|
40 | response = self.app.get(base.url(controller='forks', action='forks', | |
41 | repo_name=repo_name)) |
|
41 | repo_name=repo_name)) | |
42 |
|
42 | |||
43 | response.mustcontain("""There are no forks yet""") |
|
43 | response.mustcontain("""There are no forks yet""") | |
44 |
|
44 | |||
45 | def test_no_permissions_to_fork(self): |
|
45 | def test_no_permissions_to_fork(self): | |
46 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)['user_id'] |
|
46 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)['user_id'] | |
47 | try: |
|
47 | try: | |
48 | user_model = UserModel() |
|
48 | user_model = UserModel() | |
49 | usr = User.get_default_user() |
|
49 | usr = User.get_default_user() | |
@@ -52,7 +52,7 b' class _BaseTestCase(TestController):' | |||||
52 | Session().commit() |
|
52 | Session().commit() | |
53 | # try create a fork |
|
53 | # try create a fork | |
54 | repo_name = self.REPO |
|
54 | repo_name = self.REPO | |
55 | self.app.post(url(controller='forks', action='fork_create', |
|
55 | self.app.post(base.url(controller='forks', action='fork_create', | |
56 | repo_name=repo_name), {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=403) |
|
56 | repo_name=repo_name), {'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=403) | |
57 | finally: |
|
57 | finally: | |
58 | usr = User.get_default_user() |
|
58 | usr = User.get_default_user() | |
@@ -78,10 +78,10 b' class _BaseTestCase(TestController):' | |||||
78 | 'landing_rev': 'rev:tip', |
|
78 | 'landing_rev': 'rev:tip', | |
79 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
79 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
80 |
|
80 | |||
81 | self.app.post(url(controller='forks', action='fork_create', |
|
81 | self.app.post(base.url(controller='forks', action='fork_create', | |
82 | repo_name=repo_name), creation_args) |
|
82 | repo_name=repo_name), creation_args) | |
83 |
|
83 | |||
84 | response = self.app.get(url(controller='forks', action='forks', |
|
84 | response = self.app.get(base.url(controller='forks', action='forks', | |
85 | repo_name=repo_name)) |
|
85 | repo_name=repo_name)) | |
86 |
|
86 | |||
87 | response.mustcontain( |
|
87 | response.mustcontain( | |
@@ -89,7 +89,7 b' class _BaseTestCase(TestController):' | |||||
89 | ) |
|
89 | ) | |
90 |
|
90 | |||
91 | # remove this fork |
|
91 | # remove this fork | |
92 | response = self.app.post(url('delete_repo', repo_name=fork_name), |
|
92 | response = self.app.post(base.url('delete_repo', repo_name=fork_name), | |
93 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
93 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
94 |
|
94 | |||
95 | def test_fork_create_into_group(self): |
|
95 | def test_fork_create_into_group(self): | |
@@ -110,13 +110,13 b' class _BaseTestCase(TestController):' | |||||
110 | 'private': 'False', |
|
110 | 'private': 'False', | |
111 | 'landing_rev': 'rev:tip', |
|
111 | 'landing_rev': 'rev:tip', | |
112 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
112 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
113 | self.app.post(url(controller='forks', action='fork_create', |
|
113 | self.app.post(base.url(controller='forks', action='fork_create', | |
114 | repo_name=repo_name), creation_args) |
|
114 | repo_name=repo_name), creation_args) | |
115 | repo = Repository.get_by_repo_name(fork_name_full) |
|
115 | repo = Repository.get_by_repo_name(fork_name_full) | |
116 | assert repo.fork.repo_name == self.REPO |
|
116 | assert repo.fork.repo_name == self.REPO | |
117 |
|
117 | |||
118 | ## run the check page that triggers the flash message |
|
118 | ## run the check page that triggers the flash message | |
119 | response = self.app.get(url('repo_check_home', repo_name=fork_name_full)) |
|
119 | response = self.app.get(base.url('repo_check_home', repo_name=fork_name_full)) | |
120 | # test if we have a message that fork is ok |
|
120 | # test if we have a message that fork is ok | |
121 | self.checkSessionFlash(response, |
|
121 | self.checkSessionFlash(response, | |
122 | 'Forked repository %s as <a href="/%s">%s</a>' |
|
122 | 'Forked repository %s as <a href="/%s">%s</a>' | |
@@ -130,7 +130,7 b' class _BaseTestCase(TestController):' | |||||
130 | assert fork_repo.fork.repo_name == repo_name |
|
130 | assert fork_repo.fork.repo_name == repo_name | |
131 |
|
131 | |||
132 | # test if the repository is visible in the list ? |
|
132 | # test if the repository is visible in the list ? | |
133 | response = self.app.get(url('summary_home', repo_name=fork_name_full)) |
|
133 | response = self.app.get(base.url('summary_home', repo_name=fork_name_full)) | |
134 | response.mustcontain(fork_name_full) |
|
134 | response.mustcontain(fork_name_full) | |
135 | response.mustcontain(self.REPO_TYPE) |
|
135 | response.mustcontain(self.REPO_TYPE) | |
136 | response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name)) |
|
136 | response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name)) | |
@@ -154,9 +154,9 b' class _BaseTestCase(TestController):' | |||||
154 | 'private': 'False', |
|
154 | 'private': 'False', | |
155 | 'landing_rev': 'rev:tip', |
|
155 | 'landing_rev': 'rev:tip', | |
156 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
156 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
157 | self.app.post(url(controller='forks', action='fork_create', |
|
157 | self.app.post(base.url(controller='forks', action='fork_create', | |
158 | repo_name=repo_name), creation_args) |
|
158 | repo_name=repo_name), creation_args) | |
159 | response = self.app.get(url(controller='forks', action='forks', |
|
159 | response = self.app.get(base.url(controller='forks', action='forks', | |
160 | repo_name=repo_name)) |
|
160 | repo_name=repo_name)) | |
161 | response.mustcontain( |
|
161 | response.mustcontain( | |
162 | """<a href="/%s">%s</a>""" % (urllib.quote(fork_name), fork_name) |
|
162 | """<a href="/%s">%s</a>""" % (urllib.quote(fork_name), fork_name) | |
@@ -175,18 +175,18 b' class _BaseTestCase(TestController):' | |||||
175 | 'private': 'False', |
|
175 | 'private': 'False', | |
176 | 'landing_rev': 'rev:tip', |
|
176 | 'landing_rev': 'rev:tip', | |
177 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
177 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
178 | self.app.post(url(controller='forks', action='fork_create', |
|
178 | self.app.post(base.url(controller='forks', action='fork_create', | |
179 | repo_name=fork_name), creation_args) |
|
179 | repo_name=fork_name), creation_args) | |
180 | response = self.app.get(url(controller='forks', action='forks', |
|
180 | response = self.app.get(base.url(controller='forks', action='forks', | |
181 | repo_name=fork_name)) |
|
181 | repo_name=fork_name)) | |
182 | response.mustcontain( |
|
182 | response.mustcontain( | |
183 | """<a href="/%s">%s</a>""" % (urllib.quote(fork_name_2), fork_name_2) |
|
183 | """<a href="/%s">%s</a>""" % (urllib.quote(fork_name_2), fork_name_2) | |
184 | ) |
|
184 | ) | |
185 |
|
185 | |||
186 | # remove these forks |
|
186 | # remove these forks | |
187 | response = self.app.post(url('delete_repo', repo_name=fork_name_2), |
|
187 | response = self.app.post(base.url('delete_repo', repo_name=fork_name_2), | |
188 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
188 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
189 | response = self.app.post(url('delete_repo', repo_name=fork_name), |
|
189 | response = self.app.post(base.url('delete_repo', repo_name=fork_name), | |
190 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
190 | params={'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
191 |
|
191 | |||
192 | def test_fork_create_and_permissions(self): |
|
192 | def test_fork_create_and_permissions(self): | |
@@ -204,13 +204,13 b' class _BaseTestCase(TestController):' | |||||
204 | 'private': 'False', |
|
204 | 'private': 'False', | |
205 | 'landing_rev': 'rev:tip', |
|
205 | 'landing_rev': 'rev:tip', | |
206 | '_session_csrf_secret_token': self.session_csrf_secret_token()} |
|
206 | '_session_csrf_secret_token': self.session_csrf_secret_token()} | |
207 | self.app.post(url(controller='forks', action='fork_create', |
|
207 | self.app.post(base.url(controller='forks', action='fork_create', | |
208 | repo_name=repo_name), creation_args) |
|
208 | repo_name=repo_name), creation_args) | |
209 | repo = Repository.get_by_repo_name(self.REPO_FORK) |
|
209 | repo = Repository.get_by_repo_name(self.REPO_FORK) | |
210 | assert repo.fork.repo_name == self.REPO |
|
210 | assert repo.fork.repo_name == self.REPO | |
211 |
|
211 | |||
212 | ## run the check page that triggers the flash message |
|
212 | ## run the check page that triggers the flash message | |
213 | response = self.app.get(url('repo_check_home', repo_name=fork_name)) |
|
213 | response = self.app.get(base.url('repo_check_home', repo_name=fork_name)) | |
214 | # test if we have a message that fork is ok |
|
214 | # test if we have a message that fork is ok | |
215 | self.checkSessionFlash(response, |
|
215 | self.checkSessionFlash(response, | |
216 | 'Forked repository %s as <a href="/%s">%s</a>' |
|
216 | 'Forked repository %s as <a href="/%s">%s</a>' | |
@@ -224,7 +224,7 b' class _BaseTestCase(TestController):' | |||||
224 | assert fork_repo.fork.repo_name == repo_name |
|
224 | assert fork_repo.fork.repo_name == repo_name | |
225 |
|
225 | |||
226 | # test if the repository is visible in the list ? |
|
226 | # test if the repository is visible in the list ? | |
227 | response = self.app.get(url('summary_home', repo_name=fork_name)) |
|
227 | response = self.app.get(base.url('summary_home', repo_name=fork_name)) | |
228 | response.mustcontain(fork_name) |
|
228 | response.mustcontain(fork_name) | |
229 | response.mustcontain(self.REPO_TYPE) |
|
229 | response.mustcontain(self.REPO_TYPE) | |
230 | response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name)) |
|
230 | response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name)) | |
@@ -242,7 +242,7 b' class _BaseTestCase(TestController):' | |||||
242 | perm='repository.read') |
|
242 | perm='repository.read') | |
243 | Session().commit() |
|
243 | Session().commit() | |
244 |
|
244 | |||
245 | response = self.app.get(url(controller='forks', action='forks', |
|
245 | response = self.app.get(base.url(controller='forks', action='forks', | |
246 | repo_name=repo_name)) |
|
246 | repo_name=repo_name)) | |
247 |
|
247 | |||
248 | response.mustcontain('<div>fork of vcs test</div>') |
|
248 | response.mustcontain('<div>fork of vcs test</div>') | |
@@ -257,7 +257,7 b' class _BaseTestCase(TestController):' | |||||
257 | Session().commit() |
|
257 | Session().commit() | |
258 |
|
258 | |||
259 | # fork shouldn't be visible |
|
259 | # fork shouldn't be visible | |
260 | response = self.app.get(url(controller='forks', action='forks', |
|
260 | response = self.app.get(base.url(controller='forks', action='forks', | |
261 | repo_name=repo_name)) |
|
261 | repo_name=repo_name)) | |
262 | response.mustcontain('There are no forks yet') |
|
262 | response.mustcontain('There are no forks yet') | |
263 |
|
263 | |||
@@ -270,14 +270,14 b' class _BaseTestCase(TestController):' | |||||
270 |
|
270 | |||
271 |
|
271 | |||
272 | class TestGIT(_BaseTestCase): |
|
272 | class TestGIT(_BaseTestCase): | |
273 | REPO = GIT_REPO |
|
273 | REPO = base.GIT_REPO | |
274 | NEW_REPO = NEW_GIT_REPO |
|
274 | NEW_REPO = base.NEW_GIT_REPO | |
275 | REPO_TYPE = 'git' |
|
275 | REPO_TYPE = 'git' | |
276 | REPO_FORK = GIT_FORK |
|
276 | REPO_FORK = base.GIT_FORK | |
277 |
|
277 | |||
278 |
|
278 | |||
279 | class TestHG(_BaseTestCase): |
|
279 | class TestHG(_BaseTestCase): | |
280 | REPO = HG_REPO |
|
280 | REPO = base.HG_REPO | |
281 | NEW_REPO = NEW_HG_REPO |
|
281 | NEW_REPO = base.NEW_HG_REPO | |
282 | REPO_TYPE = 'hg' |
|
282 | REPO_TYPE = 'hg' | |
283 | REPO_FORK = HG_FORK |
|
283 | REPO_FORK = base.HG_FORK |
@@ -4,18 +4,18 b' import json' | |||||
4 | from kallithea.model.meta import Session |
|
4 | from kallithea.model.meta import Session | |
5 | from kallithea.model.repo import RepoModel |
|
5 | from kallithea.model.repo import RepoModel | |
6 | from kallithea.model.repo_group import RepoGroupModel |
|
6 | from kallithea.model.repo_group import RepoGroupModel | |
7 |
from kallithea.tests |
|
7 | from kallithea.tests import base | |
8 | from kallithea.tests.fixture import Fixture |
|
8 | from kallithea.tests.fixture import Fixture | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | fixture = Fixture() |
|
11 | fixture = Fixture() | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | class TestHomeController(TestController): |
|
14 | class TestHomeController(base.TestController): | |
15 |
|
15 | |||
16 | def test_index(self): |
|
16 | def test_index(self): | |
17 | self.log_user() |
|
17 | self.log_user() | |
18 | response = self.app.get(url(controller='home', action='index')) |
|
18 | response = self.app.get(base.url(controller='home', action='index')) | |
19 | # if global permission is set |
|
19 | # if global permission is set | |
20 | response.mustcontain('Add Repository') |
|
20 | response.mustcontain('Add Repository') | |
21 |
|
21 | |||
@@ -28,26 +28,26 b' class TestHomeController(TestController)' | |||||
28 | ) |
|
28 | ) | |
29 |
|
29 | |||
30 | # html in javascript variable: |
|
30 | # html in javascript variable: | |
31 | response.mustcontain(r'href=\"/%s\"' % HG_REPO) |
|
31 | response.mustcontain(r'href=\"/%s\"' % base.HG_REPO) | |
32 |
|
32 | |||
33 | response.mustcontain(r'\x3ci class=\"icon-globe\"') |
|
33 | response.mustcontain(r'\x3ci class=\"icon-globe\"') | |
34 |
|
34 | |||
35 | response.mustcontain(r'\"fixes issue with having custom format for git-log\n\"') |
|
35 | response.mustcontain(r'\"fixes issue with having custom format for git-log\n\"') | |
36 | response.mustcontain(r'\"/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3\"' % GIT_REPO) |
|
36 | response.mustcontain(r'\"/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3\"' % base.GIT_REPO) | |
37 |
|
37 | |||
38 | response.mustcontain(r'\"disable security checks on hg clone for travis\"') |
|
38 | response.mustcontain(r'\"disable security checks on hg clone for travis\"') | |
39 | response.mustcontain(r'\"/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e\"' % HG_REPO) |
|
39 | response.mustcontain(r'\"/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e\"' % base.HG_REPO) | |
40 |
|
40 | |||
41 | def test_repo_summary_with_anonymous_access_disabled(self): |
|
41 | def test_repo_summary_with_anonymous_access_disabled(self): | |
42 | with fixture.anon_access(False): |
|
42 | with fixture.anon_access(False): | |
43 | response = self.app.get(url(controller='summary', |
|
43 | response = self.app.get(base.url(controller='summary', | |
44 | action='index', repo_name=HG_REPO), |
|
44 | action='index', repo_name=base.HG_REPO), | |
45 | status=302) |
|
45 | status=302) | |
46 | assert 'login' in response.location |
|
46 | assert 'login' in response.location | |
47 |
|
47 | |||
48 | def test_index_with_anonymous_access_disabled(self): |
|
48 | def test_index_with_anonymous_access_disabled(self): | |
49 | with fixture.anon_access(False): |
|
49 | with fixture.anon_access(False): | |
50 | response = self.app.get(url(controller='home', action='index'), |
|
50 | response = self.app.get(base.url(controller='home', action='index'), | |
51 | status=302) |
|
51 | status=302) | |
52 | assert 'login' in response.location |
|
52 | assert 'login' in response.location | |
53 |
|
53 | |||
@@ -55,7 +55,7 b' class TestHomeController(TestController)' | |||||
55 | self.log_user() |
|
55 | self.log_user() | |
56 | gr = fixture.create_repo_group(u'gr1') |
|
56 | gr = fixture.create_repo_group(u'gr1') | |
57 | fixture.create_repo(name=u'gr1/repo_in_group', repo_group=gr) |
|
57 | fixture.create_repo(name=u'gr1/repo_in_group', repo_group=gr) | |
58 | response = self.app.get(url('repos_group_home', group_name=u'gr1')) |
|
58 | response = self.app.get(base.url('repos_group_home', group_name=u'gr1')) | |
59 |
|
59 | |||
60 | try: |
|
60 | try: | |
61 | response.mustcontain(u"gr1/repo_in_group") |
|
61 | response.mustcontain(u"gr1/repo_in_group") | |
@@ -67,21 +67,21 b' class TestHomeController(TestController)' | |||||
67 | def test_users_and_groups_data(self): |
|
67 | def test_users_and_groups_data(self): | |
68 | fixture.create_user('evil', firstname=u'D\'o\'ct"o"r', lastname=u'ΓvΓl') |
|
68 | fixture.create_user('evil', firstname=u'D\'o\'ct"o"r', lastname=u'ΓvΓl') | |
69 | fixture.create_user_group(u'grrrr', user_group_description=u"GroΓΌp") |
|
69 | fixture.create_user_group(u'grrrr', user_group_description=u"GroΓΌp") | |
70 | response = self.app.get(url('users_and_groups_data', query=u'evi')) |
|
70 | response = self.app.get(base.url('users_and_groups_data', query=u'evi')) | |
71 | assert response.status_code == 302 |
|
71 | assert response.status_code == 302 | |
72 | assert url('login_home') in response.location |
|
72 | assert base.url('login_home') in response.location | |
73 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
73 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
74 | response = self.app.get(url('users_and_groups_data', query=u'evi')) |
|
74 | response = self.app.get(base.url('users_and_groups_data', query=u'evi')) | |
75 | result = json.loads(response.body)['results'] |
|
75 | result = json.loads(response.body)['results'] | |
76 | assert result[0].get('fname') == u'D\'o\'ct"o"r' |
|
76 | assert result[0].get('fname') == u'D\'o\'ct"o"r' | |
77 | assert result[0].get('lname') == u'ΓvΓl' |
|
77 | assert result[0].get('lname') == u'ΓvΓl' | |
78 | response = self.app.get(url('users_and_groups_data', key=u'evil')) |
|
78 | response = self.app.get(base.url('users_and_groups_data', key=u'evil')) | |
79 | result = json.loads(response.body)['results'] |
|
79 | result = json.loads(response.body)['results'] | |
80 | assert result[0].get('fname') == u'D\'o\'ct"o"r' |
|
80 | assert result[0].get('fname') == u'D\'o\'ct"o"r' | |
81 | assert result[0].get('lname') == u'ΓvΓl' |
|
81 | assert result[0].get('lname') == u'ΓvΓl' | |
82 | response = self.app.get(url('users_and_groups_data', query=u'rrrr')) |
|
82 | response = self.app.get(base.url('users_and_groups_data', query=u'rrrr')) | |
83 | result = json.loads(response.body)['results'] |
|
83 | result = json.loads(response.body)['results'] | |
84 | assert not result |
|
84 | assert not result | |
85 | response = self.app.get(url('users_and_groups_data', types='users,groups', query=u'rrrr')) |
|
85 | response = self.app.get(base.url('users_and_groups_data', types='users,groups', query=u'rrrr')) | |
86 | result = json.loads(response.body)['results'] |
|
86 | result = json.loads(response.body)['results'] | |
87 | assert result[0].get('grname') == u'grrrr' |
|
87 | assert result[0].get('grname') == u'grrrr' |
@@ -1,13 +1,13 b'' | |||||
1 | import datetime |
|
1 | import datetime | |
2 |
|
2 | |||
3 |
from kallithea.tests |
|
3 | from kallithea.tests import base | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | class TestJournalController(TestController): |
|
6 | class TestJournalController(base.TestController): | |
7 |
|
7 | |||
8 | def test_index(self): |
|
8 | def test_index(self): | |
9 | self.log_user() |
|
9 | self.log_user() | |
10 | response = self.app.get(url(controller='journal', action='index')) |
|
10 | response = self.app.get(base.url(controller='journal', action='index')) | |
11 |
|
11 | |||
12 | response.mustcontain("""<h4>%s</h4>""" % datetime.date.today()) |
|
12 | response.mustcontain("""<h4>%s</h4>""" % datetime.date.today()) | |
13 |
|
13 | |||
@@ -22,18 +22,18 b' class TestJournalController(TestControll' | |||||
22 | # |
|
22 | # | |
23 | # assert len(followings) == 1, 'Not following any repository' |
|
23 | # assert len(followings) == 1, 'Not following any repository' | |
24 | # |
|
24 | # | |
25 | # response = self.app.post(url(controller='journal', |
|
25 | # response = self.app.post(base.url(controller='journal', | |
26 | # action='toggle_following'), |
|
26 | # action='toggle_following'), | |
27 | # {'follows_repository_id':repo.repo_id}) |
|
27 | # {'follows_repository_id':repo.repo_id}) | |
28 |
|
28 | |||
29 | def test_start_following_repository(self): |
|
29 | def test_start_following_repository(self): | |
30 | self.log_user() |
|
30 | self.log_user() | |
31 | response = self.app.get(url(controller='journal', action='index'),) |
|
31 | response = self.app.get(base.url(controller='journal', action='index'),) | |
32 |
|
32 | |||
33 | def test_public_journal_atom(self): |
|
33 | def test_public_journal_atom(self): | |
34 | self.log_user() |
|
34 | self.log_user() | |
35 | response = self.app.get(url(controller='journal', action='public_journal_atom'),) |
|
35 | response = self.app.get(base.url(controller='journal', action='public_journal_atom'),) | |
36 |
|
36 | |||
37 | def test_public_journal_rss(self): |
|
37 | def test_public_journal_rss(self): | |
38 | self.log_user() |
|
38 | self.log_user() | |
39 | response = self.app.get(url(controller='journal', action='public_journal_rss'),) |
|
39 | response = self.app.get(base.url(controller='journal', action='public_journal_rss'),) |
@@ -13,61 +13,61 b' from kallithea.model.api_key import ApiK' | |||||
13 | from kallithea.model.db import User |
|
13 | from kallithea.model.db import User | |
14 | from kallithea.model.meta import Session |
|
14 | from kallithea.model.meta import Session | |
15 | from kallithea.model.user import UserModel |
|
15 | from kallithea.model.user import UserModel | |
16 |
from kallithea.tests |
|
16 | from kallithea.tests import base | |
17 | from kallithea.tests.fixture import Fixture |
|
17 | from kallithea.tests.fixture import Fixture | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | fixture = Fixture() |
|
20 | fixture = Fixture() | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | class TestLoginController(TestController): |
|
23 | class TestLoginController(base.TestController): | |
24 |
|
24 | |||
25 | def test_index(self): |
|
25 | def test_index(self): | |
26 | response = self.app.get(url(controller='login', action='index')) |
|
26 | response = self.app.get(base.url(controller='login', action='index')) | |
27 | assert response.status == '200 OK' |
|
27 | assert response.status == '200 OK' | |
28 | # Test response... |
|
28 | # Test response... | |
29 |
|
29 | |||
30 | def test_login_admin_ok(self): |
|
30 | def test_login_admin_ok(self): | |
31 | response = self.app.post(url(controller='login', action='index'), |
|
31 | response = self.app.post(base.url(controller='login', action='index'), | |
32 | {'username': TEST_USER_ADMIN_LOGIN, |
|
32 | {'username': base.TEST_USER_ADMIN_LOGIN, | |
33 | 'password': TEST_USER_ADMIN_PASS, |
|
33 | 'password': base.TEST_USER_ADMIN_PASS, | |
34 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
34 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
35 | assert response.status == '302 Found' |
|
35 | assert response.status == '302 Found' | |
36 | self.assert_authenticated_user(response, TEST_USER_ADMIN_LOGIN) |
|
36 | self.assert_authenticated_user(response, base.TEST_USER_ADMIN_LOGIN) | |
37 |
|
37 | |||
38 | response = response.follow() |
|
38 | response = response.follow() | |
39 | response.mustcontain('/%s' % HG_REPO) |
|
39 | response.mustcontain('/%s' % base.HG_REPO) | |
40 |
|
40 | |||
41 | def test_login_regular_ok(self): |
|
41 | def test_login_regular_ok(self): | |
42 | response = self.app.post(url(controller='login', action='index'), |
|
42 | response = self.app.post(base.url(controller='login', action='index'), | |
43 | {'username': TEST_USER_REGULAR_LOGIN, |
|
43 | {'username': base.TEST_USER_REGULAR_LOGIN, | |
44 | 'password': TEST_USER_REGULAR_PASS, |
|
44 | 'password': base.TEST_USER_REGULAR_PASS, | |
45 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
45 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
46 |
|
46 | |||
47 | assert response.status == '302 Found' |
|
47 | assert response.status == '302 Found' | |
48 | self.assert_authenticated_user(response, TEST_USER_REGULAR_LOGIN) |
|
48 | self.assert_authenticated_user(response, base.TEST_USER_REGULAR_LOGIN) | |
49 |
|
49 | |||
50 | response = response.follow() |
|
50 | response = response.follow() | |
51 | response.mustcontain('/%s' % HG_REPO) |
|
51 | response.mustcontain('/%s' % base.HG_REPO) | |
52 |
|
52 | |||
53 | def test_login_regular_email_ok(self): |
|
53 | def test_login_regular_email_ok(self): | |
54 | response = self.app.post(url(controller='login', action='index'), |
|
54 | response = self.app.post(base.url(controller='login', action='index'), | |
55 | {'username': TEST_USER_REGULAR_EMAIL, |
|
55 | {'username': base.TEST_USER_REGULAR_EMAIL, | |
56 | 'password': TEST_USER_REGULAR_PASS, |
|
56 | 'password': base.TEST_USER_REGULAR_PASS, | |
57 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
57 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
58 |
|
58 | |||
59 | assert response.status == '302 Found' |
|
59 | assert response.status == '302 Found' | |
60 | self.assert_authenticated_user(response, TEST_USER_REGULAR_LOGIN) |
|
60 | self.assert_authenticated_user(response, base.TEST_USER_REGULAR_LOGIN) | |
61 |
|
61 | |||
62 | response = response.follow() |
|
62 | response = response.follow() | |
63 | response.mustcontain('/%s' % HG_REPO) |
|
63 | response.mustcontain('/%s' % base.HG_REPO) | |
64 |
|
64 | |||
65 | def test_login_ok_came_from(self): |
|
65 | def test_login_ok_came_from(self): | |
66 | test_came_from = '/_admin/users' |
|
66 | test_came_from = '/_admin/users' | |
67 | response = self.app.post(url(controller='login', action='index', |
|
67 | response = self.app.post(base.url(controller='login', action='index', | |
68 | came_from=test_came_from), |
|
68 | came_from=test_came_from), | |
69 | {'username': TEST_USER_ADMIN_LOGIN, |
|
69 | {'username': base.TEST_USER_ADMIN_LOGIN, | |
70 | 'password': TEST_USER_ADMIN_PASS, |
|
70 | 'password': base.TEST_USER_ADMIN_PASS, | |
71 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
71 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
72 | assert response.status == '302 Found' |
|
72 | assert response.status == '302 Found' | |
73 | response = response.follow() |
|
73 | response = response.follow() | |
@@ -76,9 +76,9 b' class TestLoginController(TestController' | |||||
76 | response.mustcontain('Users Administration') |
|
76 | response.mustcontain('Users Administration') | |
77 |
|
77 | |||
78 | def test_login_do_not_remember(self): |
|
78 | def test_login_do_not_remember(self): | |
79 | response = self.app.post(url(controller='login', action='index'), |
|
79 | response = self.app.post(base.url(controller='login', action='index'), | |
80 | {'username': TEST_USER_REGULAR_LOGIN, |
|
80 | {'username': base.TEST_USER_REGULAR_LOGIN, | |
81 | 'password': TEST_USER_REGULAR_PASS, |
|
81 | 'password': base.TEST_USER_REGULAR_PASS, | |
82 | 'remember': False, |
|
82 | 'remember': False, | |
83 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
83 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
84 |
|
84 | |||
@@ -87,9 +87,9 b' class TestLoginController(TestController' | |||||
87 | assert not re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r has expiration date, but should be a session cookie' % cookie |
|
87 | assert not re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r has expiration date, but should be a session cookie' % cookie | |
88 |
|
88 | |||
89 | def test_login_remember(self): |
|
89 | def test_login_remember(self): | |
90 | response = self.app.post(url(controller='login', action='index'), |
|
90 | response = self.app.post(base.url(controller='login', action='index'), | |
91 | {'username': TEST_USER_REGULAR_LOGIN, |
|
91 | {'username': base.TEST_USER_REGULAR_LOGIN, | |
92 | 'password': TEST_USER_REGULAR_PASS, |
|
92 | 'password': base.TEST_USER_REGULAR_PASS, | |
93 | 'remember': True, |
|
93 | 'remember': True, | |
94 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
94 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
95 |
|
95 | |||
@@ -98,23 +98,23 b' class TestLoginController(TestController' | |||||
98 | assert re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r should have expiration date, but is a session cookie' % cookie |
|
98 | assert re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r should have expiration date, but is a session cookie' % cookie | |
99 |
|
99 | |||
100 | def test_logout(self): |
|
100 | def test_logout(self): | |
101 | response = self.app.post(url(controller='login', action='index'), |
|
101 | response = self.app.post(base.url(controller='login', action='index'), | |
102 | {'username': TEST_USER_REGULAR_LOGIN, |
|
102 | {'username': base.TEST_USER_REGULAR_LOGIN, | |
103 | 'password': TEST_USER_REGULAR_PASS, |
|
103 | 'password': base.TEST_USER_REGULAR_PASS, | |
104 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
104 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
105 |
|
105 | |||
106 | # Verify that a login session has been established. |
|
106 | # Verify that a login session has been established. | |
107 | response = self.app.get(url(controller='login', action='index')) |
|
107 | response = self.app.get(base.url(controller='login', action='index')) | |
108 | response = response.follow() |
|
108 | response = response.follow() | |
109 | assert 'authuser' in response.session |
|
109 | assert 'authuser' in response.session | |
110 |
|
110 | |||
111 | response.click('Log Out') |
|
111 | response.click('Log Out') | |
112 |
|
112 | |||
113 | # Verify that the login session has been terminated. |
|
113 | # Verify that the login session has been terminated. | |
114 | response = self.app.get(url(controller='login', action='index')) |
|
114 | response = self.app.get(base.url(controller='login', action='index')) | |
115 | assert 'authuser' not in response.session |
|
115 | assert 'authuser' not in response.session | |
116 |
|
116 | |||
117 | @parametrize('url_came_from', [ |
|
117 | @base.parametrize('url_came_from', [ | |
118 | ('data:text/html,<script>window.alert("xss")</script>',), |
|
118 | ('data:text/html,<script>window.alert("xss")</script>',), | |
119 | ('mailto:test@example.com',), |
|
119 | ('mailto:test@example.com',), | |
120 | ('file:///etc/passwd',), |
|
120 | ('file:///etc/passwd',), | |
@@ -126,16 +126,16 b' class TestLoginController(TestController' | |||||
126 | ('non-absolute-path',), |
|
126 | ('non-absolute-path',), | |
127 | ]) |
|
127 | ]) | |
128 | def test_login_bad_came_froms(self, url_came_from): |
|
128 | def test_login_bad_came_froms(self, url_came_from): | |
129 | response = self.app.post(url(controller='login', action='index', |
|
129 | response = self.app.post(base.url(controller='login', action='index', | |
130 | came_from=url_came_from), |
|
130 | came_from=url_came_from), | |
131 | {'username': TEST_USER_ADMIN_LOGIN, |
|
131 | {'username': base.TEST_USER_ADMIN_LOGIN, | |
132 | 'password': TEST_USER_ADMIN_PASS, |
|
132 | 'password': base.TEST_USER_ADMIN_PASS, | |
133 | '_session_csrf_secret_token': self.session_csrf_secret_token()}, |
|
133 | '_session_csrf_secret_token': self.session_csrf_secret_token()}, | |
134 | status=400) |
|
134 | status=400) | |
135 |
|
135 | |||
136 | def test_login_short_password(self): |
|
136 | def test_login_short_password(self): | |
137 | response = self.app.post(url(controller='login', action='index'), |
|
137 | response = self.app.post(base.url(controller='login', action='index'), | |
138 | {'username': TEST_USER_ADMIN_LOGIN, |
|
138 | {'username': base.TEST_USER_ADMIN_LOGIN, | |
139 | 'password': 'as', |
|
139 | 'password': 'as', | |
140 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
140 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
141 | assert response.status == '200 OK' |
|
141 | assert response.status == '200 OK' | |
@@ -143,7 +143,7 b' class TestLoginController(TestController' | |||||
143 | response.mustcontain('Enter 3 characters or more') |
|
143 | response.mustcontain('Enter 3 characters or more') | |
144 |
|
144 | |||
145 | def test_login_wrong_username_password(self): |
|
145 | def test_login_wrong_username_password(self): | |
146 | response = self.app.post(url(controller='login', action='index'), |
|
146 | response = self.app.post(base.url(controller='login', action='index'), | |
147 | {'username': 'error', |
|
147 | {'username': 'error', | |
148 | 'password': 'test12', |
|
148 | 'password': 'test12', | |
149 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
149 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -151,8 +151,8 b' class TestLoginController(TestController' | |||||
151 | response.mustcontain('Invalid username or password') |
|
151 | response.mustcontain('Invalid username or password') | |
152 |
|
152 | |||
153 | def test_login_non_ascii(self): |
|
153 | def test_login_non_ascii(self): | |
154 | response = self.app.post(url(controller='login', action='index'), |
|
154 | response = self.app.post(base.url(controller='login', action='index'), | |
155 | {'username': TEST_USER_REGULAR_LOGIN, |
|
155 | {'username': base.TEST_USER_REGULAR_LOGIN, | |
156 | 'password': 'blΓ₯bΓ¦rgrΓΈd', |
|
156 | 'password': 'blΓ₯bΓ¦rgrΓΈd', | |
157 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
157 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
158 |
|
158 | |||
@@ -160,55 +160,55 b' class TestLoginController(TestController' | |||||
160 |
|
160 | |||
161 | # verify that get arguments are correctly passed along login redirection |
|
161 | # verify that get arguments are correctly passed along login redirection | |
162 |
|
162 | |||
163 | @parametrize('args', [ |
|
163 | @base.parametrize('args', [ | |
164 | {'foo':'one', 'bar':'two'}, |
|
164 | {'foo':'one', 'bar':'two'}, | |
165 | {'blue': u'blΓ₯', 'green': u'grΓΈn'}, |
|
165 | {'blue': u'blΓ₯', 'green': u'grΓΈn'}, | |
166 | ]) |
|
166 | ]) | |
167 | def test_redirection_to_login_form_preserves_get_args(self, args): |
|
167 | def test_redirection_to_login_form_preserves_get_args(self, args): | |
168 | with fixture.anon_access(False): |
|
168 | with fixture.anon_access(False): | |
169 | response = self.app.get(url(controller='summary', action='index', |
|
169 | response = self.app.get(base.url(controller='summary', action='index', | |
170 | repo_name=HG_REPO, |
|
170 | repo_name=base.HG_REPO, | |
171 | **args)) |
|
171 | **args)) | |
172 | assert response.status == '302 Found' |
|
172 | assert response.status == '302 Found' | |
173 | came_from = urlparse.parse_qs(urlparse.urlparse(response.location).query)['came_from'][0] |
|
173 | came_from = urlparse.parse_qs(urlparse.urlparse(response.location).query)['came_from'][0] | |
174 | came_from_qs = urlparse.parse_qsl(urlparse.urlparse(came_from).query) |
|
174 | came_from_qs = urlparse.parse_qsl(urlparse.urlparse(came_from).query) | |
175 | assert sorted(came_from_qs) == sorted((k, v.encode('utf-8')) for k, v in args.items()) |
|
175 | assert sorted(came_from_qs) == sorted((k, v.encode('utf-8')) for k, v in args.items()) | |
176 |
|
176 | |||
177 | @parametrize('args,args_encoded', [ |
|
177 | @base.parametrize('args,args_encoded', [ | |
178 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
178 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
179 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, |
|
179 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, | |
180 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
180 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
181 | ]) |
|
181 | ]) | |
182 | def test_login_form_preserves_get_args(self, args, args_encoded): |
|
182 | def test_login_form_preserves_get_args(self, args, args_encoded): | |
183 | response = self.app.get(url(controller='login', action='index', |
|
183 | response = self.app.get(base.url(controller='login', action='index', | |
184 | came_from=url('/_admin/users', **args))) |
|
184 | came_from=base.url('/_admin/users', **args))) | |
185 | came_from = urlparse.parse_qs(urlparse.urlparse(response.form.action).query)['came_from'][0] |
|
185 | came_from = urlparse.parse_qs(urlparse.urlparse(response.form.action).query)['came_from'][0] | |
186 | for encoded in args_encoded: |
|
186 | for encoded in args_encoded: | |
187 | assert encoded in came_from |
|
187 | assert encoded in came_from | |
188 |
|
188 | |||
189 | @parametrize('args,args_encoded', [ |
|
189 | @base.parametrize('args,args_encoded', [ | |
190 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
190 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
191 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, |
|
191 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, | |
192 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
192 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
193 | ]) |
|
193 | ]) | |
194 | def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded): |
|
194 | def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded): | |
195 | response = self.app.post(url(controller='login', action='index', |
|
195 | response = self.app.post(base.url(controller='login', action='index', | |
196 | came_from=url('/_admin/users', **args)), |
|
196 | came_from=base.url('/_admin/users', **args)), | |
197 | {'username': TEST_USER_ADMIN_LOGIN, |
|
197 | {'username': base.TEST_USER_ADMIN_LOGIN, | |
198 | 'password': TEST_USER_ADMIN_PASS, |
|
198 | 'password': base.TEST_USER_ADMIN_PASS, | |
199 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
199 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
200 | assert response.status == '302 Found' |
|
200 | assert response.status == '302 Found' | |
201 | for encoded in args_encoded: |
|
201 | for encoded in args_encoded: | |
202 | assert encoded in response.location |
|
202 | assert encoded in response.location | |
203 |
|
203 | |||
204 | @parametrize('args,args_encoded', [ |
|
204 | @base.parametrize('args,args_encoded', [ | |
205 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), |
|
205 | ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')), | |
206 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, |
|
206 | ({'blue': u'blΓ₯', 'green':u'grΓΈn'}, | |
207 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), |
|
207 | ('blue=bl%C3%A5', 'green=gr%C3%B8n')), | |
208 | ]) |
|
208 | ]) | |
209 | def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded): |
|
209 | def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded): | |
210 | response = self.app.post(url(controller='login', action='index', |
|
210 | response = self.app.post(base.url(controller='login', action='index', | |
211 | came_from=url('/_admin/users', **args)), |
|
211 | came_from=base.url('/_admin/users', **args)), | |
212 | {'username': 'error', |
|
212 | {'username': 'error', | |
213 | 'password': 'test12', |
|
213 | 'password': 'test12', | |
214 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
214 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -222,12 +222,12 b' class TestLoginController(TestController' | |||||
222 | # REGISTRATIONS |
|
222 | # REGISTRATIONS | |
223 | #========================================================================== |
|
223 | #========================================================================== | |
224 | def test_register(self): |
|
224 | def test_register(self): | |
225 | response = self.app.get(url(controller='login', action='register')) |
|
225 | response = self.app.get(base.url(controller='login', action='register')) | |
226 | response.mustcontain('Sign Up') |
|
226 | response.mustcontain('Sign Up') | |
227 |
|
227 | |||
228 | def test_register_err_same_username(self): |
|
228 | def test_register_err_same_username(self): | |
229 | uname = TEST_USER_ADMIN_LOGIN |
|
229 | uname = base.TEST_USER_ADMIN_LOGIN | |
230 | response = self.app.post(url(controller='login', action='register'), |
|
230 | response = self.app.post(base.url(controller='login', action='register'), | |
231 | {'username': uname, |
|
231 | {'username': uname, | |
232 | 'password': 'test12', |
|
232 | 'password': 'test12', | |
233 | 'password_confirmation': 'test12', |
|
233 | 'password_confirmation': 'test12', | |
@@ -242,11 +242,11 b' class TestLoginController(TestController' | |||||
242 | response.mustcontain(msg) |
|
242 | response.mustcontain(msg) | |
243 |
|
243 | |||
244 | def test_register_err_same_email(self): |
|
244 | def test_register_err_same_email(self): | |
245 | response = self.app.post(url(controller='login', action='register'), |
|
245 | response = self.app.post(base.url(controller='login', action='register'), | |
246 | {'username': 'test_admin_0', |
|
246 | {'username': 'test_admin_0', | |
247 | 'password': 'test12', |
|
247 | 'password': 'test12', | |
248 | 'password_confirmation': 'test12', |
|
248 | 'password_confirmation': 'test12', | |
249 | 'email': TEST_USER_ADMIN_EMAIL, |
|
249 | 'email': base.TEST_USER_ADMIN_EMAIL, | |
250 | 'firstname': 'test', |
|
250 | 'firstname': 'test', | |
251 | 'lastname': 'test', |
|
251 | 'lastname': 'test', | |
252 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
252 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -256,11 +256,11 b' class TestLoginController(TestController' | |||||
256 | response.mustcontain(msg) |
|
256 | response.mustcontain(msg) | |
257 |
|
257 | |||
258 | def test_register_err_same_email_case_sensitive(self): |
|
258 | def test_register_err_same_email_case_sensitive(self): | |
259 | response = self.app.post(url(controller='login', action='register'), |
|
259 | response = self.app.post(base.url(controller='login', action='register'), | |
260 | {'username': 'test_admin_1', |
|
260 | {'username': 'test_admin_1', | |
261 | 'password': 'test12', |
|
261 | 'password': 'test12', | |
262 | 'password_confirmation': 'test12', |
|
262 | 'password_confirmation': 'test12', | |
263 | 'email': TEST_USER_ADMIN_EMAIL.title(), |
|
263 | 'email': base.TEST_USER_ADMIN_EMAIL.title(), | |
264 | 'firstname': 'test', |
|
264 | 'firstname': 'test', | |
265 | 'lastname': 'test', |
|
265 | 'lastname': 'test', | |
266 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
266 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -269,7 +269,7 b' class TestLoginController(TestController' | |||||
269 | response.mustcontain(msg) |
|
269 | response.mustcontain(msg) | |
270 |
|
270 | |||
271 | def test_register_err_wrong_data(self): |
|
271 | def test_register_err_wrong_data(self): | |
272 | response = self.app.post(url(controller='login', action='register'), |
|
272 | response = self.app.post(base.url(controller='login', action='register'), | |
273 | {'username': 'xs', |
|
273 | {'username': 'xs', | |
274 | 'password': 'test', |
|
274 | 'password': 'test', | |
275 | 'password_confirmation': 'test', |
|
275 | 'password_confirmation': 'test', | |
@@ -282,7 +282,7 b' class TestLoginController(TestController' | |||||
282 | response.mustcontain('Enter a value 6 characters long or more') |
|
282 | response.mustcontain('Enter a value 6 characters long or more') | |
283 |
|
283 | |||
284 | def test_register_err_username(self): |
|
284 | def test_register_err_username(self): | |
285 | response = self.app.post(url(controller='login', action='register'), |
|
285 | response = self.app.post(base.url(controller='login', action='register'), | |
286 | {'username': 'error user', |
|
286 | {'username': 'error user', | |
287 | 'password': 'test12', |
|
287 | 'password': 'test12', | |
288 | 'password_confirmation': 'test12', |
|
288 | 'password_confirmation': 'test12', | |
@@ -298,8 +298,8 b' class TestLoginController(TestController' | |||||
298 | 'alphanumeric character') |
|
298 | 'alphanumeric character') | |
299 |
|
299 | |||
300 | def test_register_err_case_sensitive(self): |
|
300 | def test_register_err_case_sensitive(self): | |
301 | usr = TEST_USER_ADMIN_LOGIN.title() |
|
301 | usr = base.TEST_USER_ADMIN_LOGIN.title() | |
302 | response = self.app.post(url(controller='login', action='register'), |
|
302 | response = self.app.post(base.url(controller='login', action='register'), | |
303 | {'username': usr, |
|
303 | {'username': usr, | |
304 | 'password': 'test12', |
|
304 | 'password': 'test12', | |
305 | 'password_confirmation': 'test12', |
|
305 | 'password_confirmation': 'test12', | |
@@ -315,7 +315,7 b' class TestLoginController(TestController' | |||||
315 | response.mustcontain(msg) |
|
315 | response.mustcontain(msg) | |
316 |
|
316 | |||
317 | def test_register_special_chars(self): |
|
317 | def test_register_special_chars(self): | |
318 | response = self.app.post(url(controller='login', action='register'), |
|
318 | response = self.app.post(base.url(controller='login', action='register'), | |
319 | {'username': 'xxxaxn', |
|
319 | {'username': 'xxxaxn', | |
320 | 'password': 'Δ ΔΕΊΕΌΔ ΕΕΕΕ', |
|
320 | 'password': 'Δ ΔΕΊΕΌΔ ΕΕΕΕ', | |
321 | 'password_confirmation': 'Δ ΔΕΊΕΌΔ ΕΕΕΕ', |
|
321 | 'password_confirmation': 'Δ ΔΕΊΕΌΔ ΕΕΕΕ', | |
@@ -329,7 +329,7 b' class TestLoginController(TestController' | |||||
329 | response.mustcontain(msg) |
|
329 | response.mustcontain(msg) | |
330 |
|
330 | |||
331 | def test_register_password_mismatch(self): |
|
331 | def test_register_password_mismatch(self): | |
332 | response = self.app.post(url(controller='login', action='register'), |
|
332 | response = self.app.post(base.url(controller='login', action='register'), | |
333 | {'username': 'xs', |
|
333 | {'username': 'xs', | |
334 | 'password': '123qwe', |
|
334 | 'password': '123qwe', | |
335 | 'password_confirmation': 'qwe123', |
|
335 | 'password_confirmation': 'qwe123', | |
@@ -348,7 +348,7 b' class TestLoginController(TestController' | |||||
348 | name = 'testname' |
|
348 | name = 'testname' | |
349 | lastname = 'testlastname' |
|
349 | lastname = 'testlastname' | |
350 |
|
350 | |||
351 | response = self.app.post(url(controller='login', action='register'), |
|
351 | response = self.app.post(base.url(controller='login', action='register'), | |
352 | {'username': username, |
|
352 | {'username': username, | |
353 | 'password': password, |
|
353 | 'password': password, | |
354 | 'password_confirmation': password, |
|
354 | 'password_confirmation': password, | |
@@ -376,14 +376,14 b' class TestLoginController(TestController' | |||||
376 | def test_forgot_password_wrong_mail(self): |
|
376 | def test_forgot_password_wrong_mail(self): | |
377 | bad_email = 'username%wrongmail.org' |
|
377 | bad_email = 'username%wrongmail.org' | |
378 | response = self.app.post( |
|
378 | response = self.app.post( | |
379 | url(controller='login', action='password_reset'), |
|
379 | base.url(controller='login', action='password_reset'), | |
380 | {'email': bad_email, |
|
380 | {'email': bad_email, | |
381 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
381 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
382 |
|
382 | |||
383 | response.mustcontain('An email address must contain a single @') |
|
383 | response.mustcontain('An email address must contain a single @') | |
384 |
|
384 | |||
385 | def test_forgot_password(self): |
|
385 | def test_forgot_password(self): | |
386 | response = self.app.get(url(controller='login', |
|
386 | response = self.app.get(base.url(controller='login', | |
387 | action='password_reset')) |
|
387 | action='password_reset')) | |
388 | assert response.status == '200 OK' |
|
388 | assert response.status == '200 OK' | |
389 |
|
389 | |||
@@ -404,7 +404,7 b' class TestLoginController(TestController' | |||||
404 | Session().add(new) |
|
404 | Session().add(new) | |
405 | Session().commit() |
|
405 | Session().commit() | |
406 |
|
406 | |||
407 | response = self.app.post(url(controller='login', |
|
407 | response = self.app.post(base.url(controller='login', | |
408 | action='password_reset'), |
|
408 | action='password_reset'), | |
409 | {'email': email, |
|
409 | {'email': email, | |
410 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
410 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -417,7 +417,7 b' class TestLoginController(TestController' | |||||
417 |
|
417 | |||
418 | token = "bad" |
|
418 | token = "bad" | |
419 |
|
419 | |||
420 | response = self.app.post(url(controller='login', |
|
420 | response = self.app.post(base.url(controller='login', | |
421 | action='password_reset_confirmation'), |
|
421 | action='password_reset_confirmation'), | |
422 | {'email': email, |
|
422 | {'email': email, | |
423 | 'timestamp': timestamp, |
|
423 | 'timestamp': timestamp, | |
@@ -437,7 +437,7 b' class TestLoginController(TestController' | |||||
437 | token = UserModel().get_reset_password_token( |
|
437 | token = UserModel().get_reset_password_token( | |
438 | User.get_by_username(username), timestamp, self.session_csrf_secret_token()) |
|
438 | User.get_by_username(username), timestamp, self.session_csrf_secret_token()) | |
439 |
|
439 | |||
440 | response = self.app.get(url(controller='login', |
|
440 | response = self.app.get(base.url(controller='login', | |
441 | action='password_reset_confirmation', |
|
441 | action='password_reset_confirmation', | |
442 | email=email, |
|
442 | email=email, | |
443 | timestamp=timestamp, |
|
443 | timestamp=timestamp, | |
@@ -445,7 +445,7 b' class TestLoginController(TestController' | |||||
445 | assert response.status == '200 OK' |
|
445 | assert response.status == '200 OK' | |
446 | response.mustcontain("You are about to set a new password for the email address %s" % email) |
|
446 | response.mustcontain("You are about to set a new password for the email address %s" % email) | |
447 |
|
447 | |||
448 | response = self.app.post(url(controller='login', |
|
448 | response = self.app.post(base.url(controller='login', | |
449 | action='password_reset_confirmation'), |
|
449 | action='password_reset_confirmation'), | |
450 | {'email': email, |
|
450 | {'email': email, | |
451 | 'timestamp': timestamp, |
|
451 | 'timestamp': timestamp, | |
@@ -481,16 +481,16 b' class TestLoginController(TestController' | |||||
481 | params = {'api_key': api_key} |
|
481 | params = {'api_key': api_key} | |
482 | headers = {'Authorization': 'Bearer ' + str(api_key)} |
|
482 | headers = {'Authorization': 'Bearer ' + str(api_key)} | |
483 |
|
483 | |||
484 | self.app.get(url(controller='changeset', action='changeset_raw', |
|
484 | self.app.get(base.url(controller='changeset', action='changeset_raw', | |
485 | repo_name=HG_REPO, revision='tip', **params), |
|
485 | repo_name=base.HG_REPO, revision='tip', **params), | |
486 | status=status) |
|
486 | status=status) | |
487 |
|
487 | |||
488 | self.app.get(url(controller='changeset', action='changeset_raw', |
|
488 | self.app.get(base.url(controller='changeset', action='changeset_raw', | |
489 | repo_name=HG_REPO, revision='tip'), |
|
489 | repo_name=base.HG_REPO, revision='tip'), | |
490 | headers=headers, |
|
490 | headers=headers, | |
491 | status=status) |
|
491 | status=status) | |
492 |
|
492 | |||
493 | @parametrize('test_name,api_key,code', [ |
|
493 | @base.parametrize('test_name,api_key,code', [ | |
494 | ('none', None, 302), |
|
494 | ('none', None, 302), | |
495 | ('empty_string', '', 403), |
|
495 | ('empty_string', '', 403), | |
496 | ('fake_number', '123456', 403), |
|
496 | ('fake_number', '123456', 403), | |
@@ -502,12 +502,12 b' class TestLoginController(TestController' | |||||
502 | self._api_key_test(api_key, code) |
|
502 | self._api_key_test(api_key, code) | |
503 |
|
503 | |||
504 | def test_access_page_via_extra_api_key(self): |
|
504 | def test_access_page_via_extra_api_key(self): | |
505 | new_api_key = ApiKeyModel().create(TEST_USER_ADMIN_LOGIN, u'test') |
|
505 | new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test') | |
506 | Session().commit() |
|
506 | Session().commit() | |
507 | self._api_key_test(new_api_key.api_key, status=200) |
|
507 | self._api_key_test(new_api_key.api_key, status=200) | |
508 |
|
508 | |||
509 | def test_access_page_via_expired_api_key(self): |
|
509 | def test_access_page_via_expired_api_key(self): | |
510 | new_api_key = ApiKeyModel().create(TEST_USER_ADMIN_LOGIN, u'test') |
|
510 | new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test') | |
511 | Session().commit() |
|
511 | Session().commit() | |
512 | # patch the API key and make it expired |
|
512 | # patch the API key and make it expired | |
513 | new_api_key.expires = 0 |
|
513 | new_api_key.expires = 0 |
@@ -6,14 +6,14 b' from kallithea.lib import helpers as h' | |||||
6 | from kallithea.model.db import Repository, User, UserApiKeys, UserFollowing, UserSshKeys |
|
6 | from kallithea.model.db import Repository, User, UserApiKeys, UserFollowing, UserSshKeys | |
7 | from kallithea.model.meta import Session |
|
7 | from kallithea.model.meta import Session | |
8 | from kallithea.model.user import UserModel |
|
8 | from kallithea.model.user import UserModel | |
9 |
from kallithea.tests |
|
9 | from kallithea.tests import base | |
10 | from kallithea.tests.fixture import Fixture |
|
10 | from kallithea.tests.fixture import Fixture | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | fixture = Fixture() |
|
13 | fixture = Fixture() | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | class TestMyAccountController(TestController): |
|
16 | class TestMyAccountController(base.TestController): | |
17 | test_user_1 = 'testme' |
|
17 | test_user_1 = 'testme' | |
18 |
|
18 | |||
19 | @classmethod |
|
19 | @classmethod | |
@@ -24,74 +24,74 b' class TestMyAccountController(TestContro' | |||||
24 |
|
24 | |||
25 | def test_my_account(self): |
|
25 | def test_my_account(self): | |
26 | self.log_user() |
|
26 | self.log_user() | |
27 | response = self.app.get(url('my_account')) |
|
27 | response = self.app.get(base.url('my_account')) | |
28 |
|
28 | |||
29 | response.mustcontain('value="%s' % TEST_USER_ADMIN_LOGIN) |
|
29 | response.mustcontain('value="%s' % base.TEST_USER_ADMIN_LOGIN) | |
30 |
|
30 | |||
31 | def test_my_account_my_repos(self): |
|
31 | def test_my_account_my_repos(self): | |
32 | self.log_user() |
|
32 | self.log_user() | |
33 | response = self.app.get(url('my_account_repos')) |
|
33 | response = self.app.get(base.url('my_account_repos')) | |
34 | cnt = Repository.query().filter(Repository.owner == |
|
34 | cnt = Repository.query().filter(Repository.owner == | |
35 | User.get_by_username(TEST_USER_ADMIN_LOGIN)).count() |
|
35 | User.get_by_username(base.TEST_USER_ADMIN_LOGIN)).count() | |
36 | response.mustcontain('"raw_name": "%s"' % HG_REPO) |
|
36 | response.mustcontain('"raw_name": "%s"' % base.HG_REPO) | |
37 | response.mustcontain('"just_name": "%s"' % GIT_REPO) |
|
37 | response.mustcontain('"just_name": "%s"' % base.GIT_REPO) | |
38 |
|
38 | |||
39 | def test_my_account_my_watched(self): |
|
39 | def test_my_account_my_watched(self): | |
40 | self.log_user() |
|
40 | self.log_user() | |
41 | response = self.app.get(url('my_account_watched')) |
|
41 | response = self.app.get(base.url('my_account_watched')) | |
42 |
|
42 | |||
43 | cnt = UserFollowing.query().filter(UserFollowing.user == |
|
43 | cnt = UserFollowing.query().filter(UserFollowing.user == | |
44 | User.get_by_username(TEST_USER_ADMIN_LOGIN)).count() |
|
44 | User.get_by_username(base.TEST_USER_ADMIN_LOGIN)).count() | |
45 | response.mustcontain('"raw_name": "%s"' % HG_REPO) |
|
45 | response.mustcontain('"raw_name": "%s"' % base.HG_REPO) | |
46 | response.mustcontain('"just_name": "%s"' % GIT_REPO) |
|
46 | response.mustcontain('"just_name": "%s"' % base.GIT_REPO) | |
47 |
|
47 | |||
48 | def test_my_account_my_emails(self): |
|
48 | def test_my_account_my_emails(self): | |
49 | self.log_user() |
|
49 | self.log_user() | |
50 | response = self.app.get(url('my_account_emails')) |
|
50 | response = self.app.get(base.url('my_account_emails')) | |
51 | response.mustcontain('No additional emails specified') |
|
51 | response.mustcontain('No additional emails specified') | |
52 |
|
52 | |||
53 | def test_my_account_my_emails_add_existing_email(self): |
|
53 | def test_my_account_my_emails_add_existing_email(self): | |
54 | self.log_user() |
|
54 | self.log_user() | |
55 | response = self.app.get(url('my_account_emails')) |
|
55 | response = self.app.get(base.url('my_account_emails')) | |
56 | response.mustcontain('No additional emails specified') |
|
56 | response.mustcontain('No additional emails specified') | |
57 | response = self.app.post(url('my_account_emails'), |
|
57 | response = self.app.post(base.url('my_account_emails'), | |
58 | {'new_email': TEST_USER_REGULAR_EMAIL, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
58 | {'new_email': base.TEST_USER_REGULAR_EMAIL, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
59 | self.checkSessionFlash(response, 'This email address is already in use') |
|
59 | self.checkSessionFlash(response, 'This email address is already in use') | |
60 |
|
60 | |||
61 | def test_my_account_my_emails_add_missing_email_in_form(self): |
|
61 | def test_my_account_my_emails_add_missing_email_in_form(self): | |
62 | self.log_user() |
|
62 | self.log_user() | |
63 | response = self.app.get(url('my_account_emails')) |
|
63 | response = self.app.get(base.url('my_account_emails')) | |
64 | response.mustcontain('No additional emails specified') |
|
64 | response.mustcontain('No additional emails specified') | |
65 | response = self.app.post(url('my_account_emails'), |
|
65 | response = self.app.post(base.url('my_account_emails'), | |
66 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
66 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
67 | self.checkSessionFlash(response, 'Please enter an email address') |
|
67 | self.checkSessionFlash(response, 'Please enter an email address') | |
68 |
|
68 | |||
69 | def test_my_account_my_emails_add_remove(self): |
|
69 | def test_my_account_my_emails_add_remove(self): | |
70 | self.log_user() |
|
70 | self.log_user() | |
71 | response = self.app.get(url('my_account_emails')) |
|
71 | response = self.app.get(base.url('my_account_emails')) | |
72 | response.mustcontain('No additional emails specified') |
|
72 | response.mustcontain('No additional emails specified') | |
73 |
|
73 | |||
74 | response = self.app.post(url('my_account_emails'), |
|
74 | response = self.app.post(base.url('my_account_emails'), | |
75 | {'new_email': 'barz@example.com', '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
75 | {'new_email': 'barz@example.com', '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
76 |
|
76 | |||
77 | response = self.app.get(url('my_account_emails')) |
|
77 | response = self.app.get(base.url('my_account_emails')) | |
78 |
|
78 | |||
79 | from kallithea.model.db import UserEmailMap |
|
79 | from kallithea.model.db import UserEmailMap | |
80 | email_id = UserEmailMap.query() \ |
|
80 | email_id = UserEmailMap.query() \ | |
81 | .filter(UserEmailMap.user == User.get_by_username(TEST_USER_ADMIN_LOGIN)) \ |
|
81 | .filter(UserEmailMap.user == User.get_by_username(base.TEST_USER_ADMIN_LOGIN)) \ | |
82 | .filter(UserEmailMap.email == 'barz@example.com').one().email_id |
|
82 | .filter(UserEmailMap.email == 'barz@example.com').one().email_id | |
83 |
|
83 | |||
84 | response.mustcontain('barz@example.com') |
|
84 | response.mustcontain('barz@example.com') | |
85 | response.mustcontain('<input id="del_email_id" name="del_email_id" type="hidden" value="%s" />' % email_id) |
|
85 | response.mustcontain('<input id="del_email_id" name="del_email_id" type="hidden" value="%s" />' % email_id) | |
86 |
|
86 | |||
87 | response = self.app.post(url('my_account_emails_delete'), |
|
87 | response = self.app.post(base.url('my_account_emails_delete'), | |
88 | {'del_email_id': email_id, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
88 | {'del_email_id': email_id, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
89 | self.checkSessionFlash(response, 'Removed email from user') |
|
89 | self.checkSessionFlash(response, 'Removed email from user') | |
90 | response = self.app.get(url('my_account_emails')) |
|
90 | response = self.app.get(base.url('my_account_emails')) | |
91 | response.mustcontain('No additional emails specified') |
|
91 | response.mustcontain('No additional emails specified') | |
92 |
|
92 | |||
93 |
|
93 | |||
94 | @parametrize('name,attrs', |
|
94 | @base.parametrize('name,attrs', | |
95 | [('firstname', {'firstname': 'new_username'}), |
|
95 | [('firstname', {'firstname': 'new_username'}), | |
96 | ('lastname', {'lastname': 'new_username'}), |
|
96 | ('lastname', {'lastname': 'new_username'}), | |
97 | ('admin', {'admin': True}), |
|
97 | ('admin', {'admin': True}), | |
@@ -123,7 +123,7 b' class TestMyAccountController(TestContro' | |||||
123 | params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
123 | params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
124 |
|
124 | |||
125 | params.update(attrs) |
|
125 | params.update(attrs) | |
126 | response = self.app.post(url('my_account'), params) |
|
126 | response = self.app.post(base.url('my_account'), params) | |
127 |
|
127 | |||
128 | self.checkSessionFlash(response, |
|
128 | self.checkSessionFlash(response, | |
129 | 'Your account was updated successfully') |
|
129 | 'Your account was updated successfully') | |
@@ -155,11 +155,11 b' class TestMyAccountController(TestContro' | |||||
155 | def test_my_account_update_err_email_exists(self): |
|
155 | def test_my_account_update_err_email_exists(self): | |
156 | self.log_user() |
|
156 | self.log_user() | |
157 |
|
157 | |||
158 | new_email = TEST_USER_REGULAR_EMAIL # already existing email |
|
158 | new_email = base.TEST_USER_REGULAR_EMAIL # already existing email | |
159 | response = self.app.post(url('my_account'), |
|
159 | response = self.app.post(base.url('my_account'), | |
160 | params=dict( |
|
160 | params=dict( | |
161 | username=TEST_USER_ADMIN_LOGIN, |
|
161 | username=base.TEST_USER_ADMIN_LOGIN, | |
162 | new_password=TEST_USER_ADMIN_PASS, |
|
162 | new_password=base.TEST_USER_ADMIN_PASS, | |
163 | password_confirmation='test122', |
|
163 | password_confirmation='test122', | |
164 | firstname=u'NewName', |
|
164 | firstname=u'NewName', | |
165 | lastname=u'NewLastname', |
|
165 | lastname=u'NewLastname', | |
@@ -170,13 +170,13 b' class TestMyAccountController(TestContro' | |||||
170 | response.mustcontain('This email address is already in use') |
|
170 | response.mustcontain('This email address is already in use') | |
171 |
|
171 | |||
172 | def test_my_account_update_err(self): |
|
172 | def test_my_account_update_err(self): | |
173 | self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
173 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
174 |
|
174 | |||
175 | new_email = 'newmail.pl' |
|
175 | new_email = 'newmail.pl' | |
176 | response = self.app.post(url('my_account'), |
|
176 | response = self.app.post(base.url('my_account'), | |
177 | params=dict( |
|
177 | params=dict( | |
178 | username=TEST_USER_ADMIN_LOGIN, |
|
178 | username=base.TEST_USER_ADMIN_LOGIN, | |
179 | new_password=TEST_USER_ADMIN_PASS, |
|
179 | new_password=base.TEST_USER_ADMIN_PASS, | |
180 | password_confirmation='test122', |
|
180 | password_confirmation='test122', | |
181 | firstname=u'NewName', |
|
181 | firstname=u'NewName', | |
182 | lastname=u'NewLastname', |
|
182 | lastname=u'NewLastname', | |
@@ -188,25 +188,25 b' class TestMyAccountController(TestContro' | |||||
188 | with test_context(self.app): |
|
188 | with test_context(self.app): | |
189 | msg = validators.ValidUsername(edit=False, old_data={}) \ |
|
189 | msg = validators.ValidUsername(edit=False, old_data={}) \ | |
190 | ._messages['username_exists'] |
|
190 | ._messages['username_exists'] | |
191 | msg = h.html_escape(msg % {'username': TEST_USER_ADMIN_LOGIN}) |
|
191 | msg = h.html_escape(msg % {'username': base.TEST_USER_ADMIN_LOGIN}) | |
192 | response.mustcontain(msg) |
|
192 | response.mustcontain(msg) | |
193 |
|
193 | |||
194 | def test_my_account_api_keys(self): |
|
194 | def test_my_account_api_keys(self): | |
195 | usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
195 | usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
196 | user = User.get(usr['user_id']) |
|
196 | user = User.get(usr['user_id']) | |
197 | response = self.app.get(url('my_account_api_keys')) |
|
197 | response = self.app.get(base.url('my_account_api_keys')) | |
198 | response.mustcontain(user.api_key) |
|
198 | response.mustcontain(user.api_key) | |
199 | response.mustcontain('Expires: Never') |
|
199 | response.mustcontain('Expires: Never') | |
200 |
|
200 | |||
201 | @parametrize('desc,lifetime', [ |
|
201 | @base.parametrize('desc,lifetime', [ | |
202 | ('forever', -1), |
|
202 | ('forever', -1), | |
203 | ('5mins', 60*5), |
|
203 | ('5mins', 60*5), | |
204 | ('30days', 60*60*24*30), |
|
204 | ('30days', 60*60*24*30), | |
205 | ]) |
|
205 | ]) | |
206 | def test_my_account_add_api_keys(self, desc, lifetime): |
|
206 | def test_my_account_add_api_keys(self, desc, lifetime): | |
207 | usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
207 | usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
208 | user = User.get(usr['user_id']) |
|
208 | user = User.get(usr['user_id']) | |
209 | response = self.app.post(url('my_account_api_keys'), |
|
209 | response = self.app.post(base.url('my_account_api_keys'), | |
210 | {'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
210 | {'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
211 | self.checkSessionFlash(response, 'API key successfully created') |
|
211 | self.checkSessionFlash(response, 'API key successfully created') | |
212 | try: |
|
212 | try: | |
@@ -220,9 +220,9 b' class TestMyAccountController(TestContro' | |||||
220 | Session().commit() |
|
220 | Session().commit() | |
221 |
|
221 | |||
222 | def test_my_account_remove_api_key(self): |
|
222 | def test_my_account_remove_api_key(self): | |
223 | usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
223 | usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
224 | user = User.get(usr['user_id']) |
|
224 | user = User.get(usr['user_id']) | |
225 | response = self.app.post(url('my_account_api_keys'), |
|
225 | response = self.app.post(base.url('my_account_api_keys'), | |
226 | {'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
226 | {'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
227 | self.checkSessionFlash(response, 'API key successfully created') |
|
227 | self.checkSessionFlash(response, 'API key successfully created') | |
228 | response = response.follow() |
|
228 | response = response.follow() | |
@@ -231,21 +231,21 b' class TestMyAccountController(TestContro' | |||||
231 | keys = UserApiKeys.query().all() |
|
231 | keys = UserApiKeys.query().all() | |
232 | assert 1 == len(keys) |
|
232 | assert 1 == len(keys) | |
233 |
|
233 | |||
234 | response = self.app.post(url('my_account_api_keys_delete'), |
|
234 | response = self.app.post(base.url('my_account_api_keys_delete'), | |
235 | {'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
235 | {'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
236 | self.checkSessionFlash(response, 'API key successfully deleted') |
|
236 | self.checkSessionFlash(response, 'API key successfully deleted') | |
237 | keys = UserApiKeys.query().all() |
|
237 | keys = UserApiKeys.query().all() | |
238 | assert 0 == len(keys) |
|
238 | assert 0 == len(keys) | |
239 |
|
239 | |||
240 | def test_my_account_reset_main_api_key(self): |
|
240 | def test_my_account_reset_main_api_key(self): | |
241 | usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
241 | usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
242 | user = User.get(usr['user_id']) |
|
242 | user = User.get(usr['user_id']) | |
243 | api_key = user.api_key |
|
243 | api_key = user.api_key | |
244 | response = self.app.get(url('my_account_api_keys')) |
|
244 | response = self.app.get(base.url('my_account_api_keys')) | |
245 | response.mustcontain(api_key) |
|
245 | response.mustcontain(api_key) | |
246 | response.mustcontain('Expires: Never') |
|
246 | response.mustcontain('Expires: Never') | |
247 |
|
247 | |||
248 | response = self.app.post(url('my_account_api_keys_delete'), |
|
248 | response = self.app.post(base.url('my_account_api_keys_delete'), | |
249 | {'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
249 | {'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
250 | self.checkSessionFlash(response, 'API key successfully reset') |
|
250 | self.checkSessionFlash(response, 'API key successfully reset') | |
251 | response = response.follow() |
|
251 | response = response.follow() | |
@@ -256,8 +256,8 b' class TestMyAccountController(TestContro' | |||||
256 | public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' |
|
256 | public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
257 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' |
|
257 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
258 |
|
258 | |||
259 | self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
259 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
260 | response = self.app.post(url('my_account_ssh_keys'), |
|
260 | response = self.app.post(base.url('my_account_ssh_keys'), | |
261 | {'description': description, |
|
261 | {'description': description, | |
262 | 'public_key': public_key, |
|
262 | 'public_key': public_key, | |
263 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
263 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -277,8 +277,8 b' class TestMyAccountController(TestContro' | |||||
277 | public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' |
|
277 | public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' | |
278 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' |
|
278 | fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' | |
279 |
|
279 | |||
280 | self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) |
|
280 | self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) | |
281 | response = self.app.post(url('my_account_ssh_keys'), |
|
281 | response = self.app.post(base.url('my_account_ssh_keys'), | |
282 | {'description': description, |
|
282 | {'description': description, | |
283 | 'public_key': public_key, |
|
283 | 'public_key': public_key, | |
284 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
284 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -288,7 +288,7 b' class TestMyAccountController(TestContro' | |||||
288 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() |
|
288 | ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() | |
289 | assert ssh_key.description == u'me@localhost' |
|
289 | assert ssh_key.description == u'me@localhost' | |
290 |
|
290 | |||
291 | response = self.app.post(url('my_account_ssh_keys_delete'), |
|
291 | response = self.app.post(base.url('my_account_ssh_keys_delete'), | |
292 | {'del_public_key': ssh_key.public_key, |
|
292 | {'del_public_key': ssh_key.public_key, | |
293 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
293 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
294 | self.checkSessionFlash(response, 'SSH key successfully deleted') |
|
294 | self.checkSessionFlash(response, 'SSH key successfully deleted') |
@@ -5,27 +5,27 b' import pytest' | |||||
5 | from kallithea.controllers.pullrequests import PullrequestsController |
|
5 | from kallithea.controllers.pullrequests import PullrequestsController | |
6 | from kallithea.model.db import PullRequest, User |
|
6 | from kallithea.model.db import PullRequest, User | |
7 | from kallithea.model.meta import Session |
|
7 | from kallithea.model.meta import Session | |
8 |
from kallithea.tests |
|
8 | from kallithea.tests import base | |
9 | from kallithea.tests.fixture import Fixture |
|
9 | from kallithea.tests.fixture import Fixture | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | fixture = Fixture() |
|
12 | fixture = Fixture() | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | class TestPullrequestsController(TestController): |
|
15 | class TestPullrequestsController(base.TestController): | |
16 |
|
16 | |||
17 | def test_index(self): |
|
17 | def test_index(self): | |
18 | self.log_user() |
|
18 | self.log_user() | |
19 | response = self.app.get(url(controller='pullrequests', action='index', |
|
19 | response = self.app.get(base.url(controller='pullrequests', action='index', | |
20 | repo_name=HG_REPO)) |
|
20 | repo_name=base.HG_REPO)) | |
21 |
|
21 | |||
22 | def test_create_trivial(self): |
|
22 | def test_create_trivial(self): | |
23 | self.log_user() |
|
23 | self.log_user() | |
24 | response = self.app.post(url(controller='pullrequests', action='create', |
|
24 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
25 | repo_name=HG_REPO), |
|
25 | repo_name=base.HG_REPO), | |
26 | {'org_repo': HG_REPO, |
|
26 | {'org_repo': base.HG_REPO, | |
27 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
27 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
28 | 'other_repo': HG_REPO, |
|
28 | 'other_repo': base.HG_REPO, | |
29 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
29 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
30 | 'pullrequest_title': 'title', |
|
30 | 'pullrequest_title': 'title', | |
31 | 'pullrequest_desc': 'description', |
|
31 | 'pullrequest_desc': 'description', | |
@@ -40,11 +40,11 b' class TestPullrequestsController(TestCon' | |||||
40 |
|
40 | |||
41 | def test_available(self): |
|
41 | def test_available(self): | |
42 | self.log_user() |
|
42 | self.log_user() | |
43 | response = self.app.post(url(controller='pullrequests', action='create', |
|
43 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
44 | repo_name=HG_REPO), |
|
44 | repo_name=base.HG_REPO), | |
45 | {'org_repo': HG_REPO, |
|
45 | {'org_repo': base.HG_REPO, | |
46 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', |
|
46 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', | |
47 | 'other_repo': HG_REPO, |
|
47 | 'other_repo': base.HG_REPO, | |
48 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
48 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
49 | 'pullrequest_title': 'title', |
|
49 | 'pullrequest_title': 'title', | |
50 | 'pullrequest_desc': 'description', |
|
50 | 'pullrequest_desc': 'description', | |
@@ -60,11 +60,11 b' class TestPullrequestsController(TestCon' | |||||
60 |
|
60 | |||
61 | def test_range(self): |
|
61 | def test_range(self): | |
62 | self.log_user() |
|
62 | self.log_user() | |
63 | response = self.app.post(url(controller='pullrequests', action='create', |
|
63 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
64 | repo_name=HG_REPO), |
|
64 | repo_name=base.HG_REPO), | |
65 | {'org_repo': HG_REPO, |
|
65 | {'org_repo': base.HG_REPO, | |
66 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
66 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
67 | 'other_repo': HG_REPO, |
|
67 | 'other_repo': base.HG_REPO, | |
68 | 'other_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', |
|
68 | 'other_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', | |
69 | 'pullrequest_title': 'title', |
|
69 | 'pullrequest_title': 'title', | |
70 | 'pullrequest_desc': 'description', |
|
70 | 'pullrequest_desc': 'description', | |
@@ -78,16 +78,16 b' class TestPullrequestsController(TestCon' | |||||
78 |
|
78 | |||
79 | def test_update_reviewers(self): |
|
79 | def test_update_reviewers(self): | |
80 | self.log_user() |
|
80 | self.log_user() | |
81 | regular_user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
81 | regular_user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
82 | regular_user2 = User.get_by_username(TEST_USER_REGULAR2_LOGIN) |
|
82 | regular_user2 = User.get_by_username(base.TEST_USER_REGULAR2_LOGIN) | |
83 | admin_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
83 | admin_user = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
84 |
|
84 | |||
85 | # create initial PR |
|
85 | # create initial PR | |
86 | response = self.app.post(url(controller='pullrequests', action='create', |
|
86 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
87 | repo_name=HG_REPO), |
|
87 | repo_name=base.HG_REPO), | |
88 | {'org_repo': HG_REPO, |
|
88 | {'org_repo': base.HG_REPO, | |
89 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', |
|
89 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', | |
90 | 'other_repo': HG_REPO, |
|
90 | 'other_repo': base.HG_REPO, | |
91 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
91 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
92 | 'pullrequest_title': 'title', |
|
92 | 'pullrequest_title': 'title', | |
93 | 'pullrequest_desc': 'description', |
|
93 | 'pullrequest_desc': 'description', | |
@@ -95,40 +95,40 b' class TestPullrequestsController(TestCon' | |||||
95 | }, |
|
95 | }, | |
96 | status=302) |
|
96 | status=302) | |
97 | pull_request1_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) |
|
97 | pull_request1_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) | |
98 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request1_id) |
|
98 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request1_id) | |
99 |
|
99 | |||
100 | # create new iteration |
|
100 | # create new iteration | |
101 | response = self.app.post(url(controller='pullrequests', action='post', |
|
101 | response = self.app.post(base.url(controller='pullrequests', action='post', | |
102 | repo_name=HG_REPO, pull_request_id=pull_request1_id), |
|
102 | repo_name=base.HG_REPO, pull_request_id=pull_request1_id), | |
103 | { |
|
103 | { | |
104 | 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
104 | 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
105 | 'pullrequest_title': 'title', |
|
105 | 'pullrequest_title': 'title', | |
106 | 'pullrequest_desc': 'description', |
|
106 | 'pullrequest_desc': 'description', | |
107 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
107 | 'owner': base.TEST_USER_ADMIN_LOGIN, | |
108 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
108 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
109 | 'review_members': [regular_user.user_id], |
|
109 | 'review_members': [regular_user.user_id], | |
110 | }, |
|
110 | }, | |
111 | status=302) |
|
111 | status=302) | |
112 | pull_request2_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) |
|
112 | pull_request2_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) | |
113 | assert pull_request2_id != pull_request1_id |
|
113 | assert pull_request2_id != pull_request1_id | |
114 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request2_id) |
|
114 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request2_id) | |
115 | response = response.follow() |
|
115 | response = response.follow() | |
116 | # verify reviewer was added |
|
116 | # verify reviewer was added | |
117 | response.mustcontain('<input type="hidden" value="%s" name="review_members" />' % regular_user.user_id) |
|
117 | response.mustcontain('<input type="hidden" value="%s" name="review_members" />' % regular_user.user_id) | |
118 |
|
118 | |||
119 | # update without creating new iteration |
|
119 | # update without creating new iteration | |
120 | response = self.app.post(url(controller='pullrequests', action='post', |
|
120 | response = self.app.post(base.url(controller='pullrequests', action='post', | |
121 | repo_name=HG_REPO, pull_request_id=pull_request2_id), |
|
121 | repo_name=base.HG_REPO, pull_request_id=pull_request2_id), | |
122 | { |
|
122 | { | |
123 | 'pullrequest_title': 'Title', |
|
123 | 'pullrequest_title': 'Title', | |
124 | 'pullrequest_desc': 'description', |
|
124 | 'pullrequest_desc': 'description', | |
125 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
125 | 'owner': base.TEST_USER_ADMIN_LOGIN, | |
126 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
126 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
127 | 'org_review_members': [admin_user.user_id], # fake - just to get some 'meanwhile' warning ... but it is also added ... |
|
127 | 'org_review_members': [admin_user.user_id], # fake - just to get some 'meanwhile' warning ... but it is also added ... | |
128 | 'review_members': [regular_user2.user_id, admin_user.user_id], |
|
128 | 'review_members': [regular_user2.user_id, admin_user.user_id], | |
129 | }, |
|
129 | }, | |
130 | status=302) |
|
130 | status=302) | |
131 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request2_id) |
|
131 | assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request2_id) | |
132 | response = response.follow() |
|
132 | response = response.follow() | |
133 | # verify reviewers were added / removed |
|
133 | # verify reviewers were added / removed | |
134 | response.mustcontain('Meanwhile, the following reviewers have been added: test_regular') |
|
134 | response.mustcontain('Meanwhile, the following reviewers have been added: test_regular') | |
@@ -141,12 +141,12 b' class TestPullrequestsController(TestCon' | |||||
141 | invalid_user_id = 99999 |
|
141 | invalid_user_id = 99999 | |
142 | self.log_user() |
|
142 | self.log_user() | |
143 | # create a valid pull request |
|
143 | # create a valid pull request | |
144 | response = self.app.post(url(controller='pullrequests', action='create', |
|
144 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
145 | repo_name=HG_REPO), |
|
145 | repo_name=base.HG_REPO), | |
146 | { |
|
146 | { | |
147 | 'org_repo': HG_REPO, |
|
147 | 'org_repo': base.HG_REPO, | |
148 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', |
|
148 | 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', | |
149 | 'other_repo': HG_REPO, |
|
149 | 'other_repo': base.HG_REPO, | |
150 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
150 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
151 | 'pullrequest_title': 'title', |
|
151 | 'pullrequest_title': 'title', | |
152 | 'pullrequest_desc': 'description', |
|
152 | 'pullrequest_desc': 'description', | |
@@ -160,13 +160,13 b' class TestPullrequestsController(TestCon' | |||||
160 | pull_request_id = m.group(1) |
|
160 | pull_request_id = m.group(1) | |
161 |
|
161 | |||
162 | # update it |
|
162 | # update it | |
163 | response = self.app.post(url(controller='pullrequests', action='post', |
|
163 | response = self.app.post(base.url(controller='pullrequests', action='post', | |
164 | repo_name=HG_REPO, pull_request_id=pull_request_id), |
|
164 | repo_name=base.HG_REPO, pull_request_id=pull_request_id), | |
165 | { |
|
165 | { | |
166 | 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
166 | 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
167 | 'pullrequest_title': 'title', |
|
167 | 'pullrequest_title': 'title', | |
168 | 'pullrequest_desc': 'description', |
|
168 | 'pullrequest_desc': 'description', | |
169 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
169 | 'owner': base.TEST_USER_ADMIN_LOGIN, | |
170 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
170 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
171 | 'review_members': [str(invalid_user_id)], |
|
171 | 'review_members': [str(invalid_user_id)], | |
172 | }, |
|
172 | }, | |
@@ -177,12 +177,12 b' class TestPullrequestsController(TestCon' | |||||
177 | invalid_user_id = 99999 |
|
177 | invalid_user_id = 99999 | |
178 | self.log_user() |
|
178 | self.log_user() | |
179 | # create a valid pull request |
|
179 | # create a valid pull request | |
180 | response = self.app.post(url(controller='pullrequests', action='create', |
|
180 | response = self.app.post(base.url(controller='pullrequests', action='create', | |
181 | repo_name=HG_REPO), |
|
181 | repo_name=base.HG_REPO), | |
182 | { |
|
182 | { | |
183 | 'org_repo': HG_REPO, |
|
183 | 'org_repo': base.HG_REPO, | |
184 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', |
|
184 | 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', | |
185 | 'other_repo': HG_REPO, |
|
185 | 'other_repo': base.HG_REPO, | |
186 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', |
|
186 | 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', | |
187 | 'pullrequest_title': 'title', |
|
187 | 'pullrequest_title': 'title', | |
188 | 'pullrequest_desc': 'description', |
|
188 | 'pullrequest_desc': 'description', | |
@@ -196,12 +196,12 b' class TestPullrequestsController(TestCon' | |||||
196 | pull_request_id = m.group(1) |
|
196 | pull_request_id = m.group(1) | |
197 |
|
197 | |||
198 | # edit it |
|
198 | # edit it | |
199 | response = self.app.post(url(controller='pullrequests', action='post', |
|
199 | response = self.app.post(base.url(controller='pullrequests', action='post', | |
200 | repo_name=HG_REPO, pull_request_id=pull_request_id), |
|
200 | repo_name=base.HG_REPO, pull_request_id=pull_request_id), | |
201 | { |
|
201 | { | |
202 | 'pullrequest_title': 'title', |
|
202 | 'pullrequest_title': 'title', | |
203 | 'pullrequest_desc': 'description', |
|
203 | 'pullrequest_desc': 'description', | |
204 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
204 | 'owner': base.TEST_USER_ADMIN_LOGIN, | |
205 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
205 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
206 | 'review_members': [str(invalid_user_id)], |
|
206 | 'review_members': [str(invalid_user_id)], | |
207 | }, |
|
207 | }, | |
@@ -226,11 +226,11 b' class TestPullrequestsController(TestCon' | |||||
226 |
|
226 | |||
227 | # create initial PR |
|
227 | # create initial PR | |
228 | response = self.app.post( |
|
228 | response = self.app.post( | |
229 | url(controller='pullrequests', action='create', repo_name=HG_REPO), |
|
229 | base.url(controller='pullrequests', action='create', repo_name=base.HG_REPO), | |
230 | { |
|
230 | { | |
231 | 'org_repo': HG_REPO, |
|
231 | 'org_repo': base.HG_REPO, | |
232 | 'org_ref': 'rev:9e6119747791:9e6119747791ff886a5abe1193a730b6bf874e1c', |
|
232 | 'org_ref': 'rev:9e6119747791:9e6119747791ff886a5abe1193a730b6bf874e1c', | |
233 | 'other_repo': HG_REPO, |
|
233 | 'other_repo': base.HG_REPO, | |
234 | 'other_ref': 'branch:default:3d1091ee5a533b1f4577ec7d8a226bb315fb1336', |
|
234 | 'other_ref': 'branch:default:3d1091ee5a533b1f4577ec7d8a226bb315fb1336', | |
235 | 'pullrequest_title': 'title', |
|
235 | 'pullrequest_title': 'title', | |
236 | 'pullrequest_desc': 'description', |
|
236 | 'pullrequest_desc': 'description', | |
@@ -247,12 +247,12 b' class TestPullrequestsController(TestCon' | |||||
247 |
|
247 | |||
248 | # create PR 2 (new iteration with same ancestor) |
|
248 | # create PR 2 (new iteration with same ancestor) | |
249 | response = self.app.post( |
|
249 | response = self.app.post( | |
250 | url(controller='pullrequests', action='post', repo_name=HG_REPO, pull_request_id=pr1_id), |
|
250 | base.url(controller='pullrequests', action='post', repo_name=base.HG_REPO, pull_request_id=pr1_id), | |
251 | { |
|
251 | { | |
252 | 'updaterev': '5ec21f21aafe95220f1fc4843a4a57c378498b71', |
|
252 | 'updaterev': '5ec21f21aafe95220f1fc4843a4a57c378498b71', | |
253 | 'pullrequest_title': 'title', |
|
253 | 'pullrequest_title': 'title', | |
254 | 'pullrequest_desc': 'description', |
|
254 | 'pullrequest_desc': 'description', | |
255 | 'owner': TEST_USER_REGULAR_LOGIN, |
|
255 | 'owner': base.TEST_USER_REGULAR_LOGIN, | |
256 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
256 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
257 | }, |
|
257 | }, | |
258 | status=302) |
|
258 | status=302) | |
@@ -269,12 +269,12 b' class TestPullrequestsController(TestCon' | |||||
269 |
|
269 | |||
270 | # create PR 3 (new iteration with new ancestor) |
|
270 | # create PR 3 (new iteration with new ancestor) | |
271 | response = self.app.post( |
|
271 | response = self.app.post( | |
272 | url(controller='pullrequests', action='post', repo_name=HG_REPO, pull_request_id=pr2_id), |
|
272 | base.url(controller='pullrequests', action='post', repo_name=base.HG_REPO, pull_request_id=pr2_id), | |
273 | { |
|
273 | { | |
274 | 'updaterev': 'fb95b340e0d03fa51f33c56c991c08077c99303e', |
|
274 | 'updaterev': 'fb95b340e0d03fa51f33c56c991c08077c99303e', | |
275 | 'pullrequest_title': 'title', |
|
275 | 'pullrequest_title': 'title', | |
276 | 'pullrequest_desc': 'description', |
|
276 | 'pullrequest_desc': 'description', | |
277 | 'owner': TEST_USER_REGULAR_LOGIN, |
|
277 | 'owner': base.TEST_USER_REGULAR_LOGIN, | |
278 | '_session_csrf_secret_token': self.session_csrf_secret_token(), |
|
278 | '_session_csrf_secret_token': self.session_csrf_secret_token(), | |
279 | }, |
|
279 | }, | |
280 | status=302) |
|
280 | status=302) | |
@@ -289,7 +289,7 b' class TestPullrequestsController(TestCon' | |||||
289 |
|
289 | |||
290 |
|
290 | |||
291 | @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods |
|
291 | @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods | |
292 | class TestPullrequestsGetRepoRefs(TestController): |
|
292 | class TestPullrequestsGetRepoRefs(base.TestController): | |
293 |
|
293 | |||
294 | def setup_method(self, method): |
|
294 | def setup_method(self, method): | |
295 | self.repo_name = u'main' |
|
295 | self.repo_name = u'main' |
@@ -1,16 +1,16 b'' | |||||
1 |
from kallithea.tests |
|
1 | from kallithea.tests import base | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | class TestRepoGroupsController(TestController): |
|
4 | class TestRepoGroupsController(base.TestController): | |
5 |
|
5 | |||
6 | def test_index(self): |
|
6 | def test_index(self): | |
7 | self.log_user() |
|
7 | self.log_user() | |
8 | response = self.app.get(url('repos_groups')) |
|
8 | response = self.app.get(base.url('repos_groups')) | |
9 | response.mustcontain('"records": []') |
|
9 | response.mustcontain('"records": []') | |
10 |
|
10 | |||
11 | def test_new(self): |
|
11 | def test_new(self): | |
12 | self.log_user() |
|
12 | self.log_user() | |
13 | response = self.app.get(url('new_repos_group')) |
|
13 | response = self.app.get(base.url('new_repos_group')) | |
14 |
|
14 | |||
15 | def test_create(self): |
|
15 | def test_create(self): | |
16 | self.log_user() |
|
16 | self.log_user() | |
@@ -18,14 +18,14 b' class TestRepoGroupsController(TestContr' | |||||
18 | group_name = 'foo' |
|
18 | group_name = 'foo' | |
19 |
|
19 | |||
20 | # creation with form error |
|
20 | # creation with form error | |
21 | response = self.app.post(url('repos_groups'), |
|
21 | response = self.app.post(base.url('repos_groups'), | |
22 | {'group_name': group_name, |
|
22 | {'group_name': group_name, | |
23 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
23 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
24 | response.mustcontain('name="group_name" type="text" value="%s"' % group_name) |
|
24 | response.mustcontain('name="group_name" type="text" value="%s"' % group_name) | |
25 | response.mustcontain('<!-- for: group_description -->') |
|
25 | response.mustcontain('<!-- for: group_description -->') | |
26 |
|
26 | |||
27 | # creation |
|
27 | # creation | |
28 | response = self.app.post(url('repos_groups'), |
|
28 | response = self.app.post(base.url('repos_groups'), | |
29 | {'group_name': group_name, |
|
29 | {'group_name': group_name, | |
30 | 'group_description': 'lala', |
|
30 | 'group_description': 'lala', | |
31 | 'parent_group_id': '-1', |
|
31 | 'parent_group_id': '-1', | |
@@ -34,18 +34,18 b' class TestRepoGroupsController(TestContr' | |||||
34 | self.checkSessionFlash(response, 'Created repository group %s' % group_name) |
|
34 | self.checkSessionFlash(response, 'Created repository group %s' % group_name) | |
35 |
|
35 | |||
36 | # edit form |
|
36 | # edit form | |
37 | response = self.app.get(url('edit_repo_group', group_name=group_name)) |
|
37 | response = self.app.get(base.url('edit_repo_group', group_name=group_name)) | |
38 | response.mustcontain('>lala<') |
|
38 | response.mustcontain('>lala<') | |
39 |
|
39 | |||
40 | # edit with form error |
|
40 | # edit with form error | |
41 | response = self.app.post(url('update_repos_group', group_name=group_name), |
|
41 | response = self.app.post(base.url('update_repos_group', group_name=group_name), | |
42 | {'group_name': group_name, |
|
42 | {'group_name': group_name, | |
43 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
43 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
44 | response.mustcontain('name="group_name" type="text" value="%s"' % group_name) |
|
44 | response.mustcontain('name="group_name" type="text" value="%s"' % group_name) | |
45 | response.mustcontain('<!-- for: group_description -->') |
|
45 | response.mustcontain('<!-- for: group_description -->') | |
46 |
|
46 | |||
47 | # edit |
|
47 | # edit | |
48 | response = self.app.post(url('update_repos_group', group_name=group_name), |
|
48 | response = self.app.post(base.url('update_repos_group', group_name=group_name), | |
49 | {'group_name': group_name, |
|
49 | {'group_name': group_name, | |
50 | 'group_description': 'lolo', |
|
50 | 'group_description': 'lolo', | |
51 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
51 | '_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
@@ -56,22 +56,22 b' class TestRepoGroupsController(TestContr' | |||||
56 | response.mustcontain('>lolo<') |
|
56 | response.mustcontain('>lolo<') | |
57 |
|
57 | |||
58 | # listing |
|
58 | # listing | |
59 | response = self.app.get(url('repos_groups')) |
|
59 | response = self.app.get(base.url('repos_groups')) | |
60 | response.mustcontain('raw_name": "%s"' % group_name) |
|
60 | response.mustcontain('raw_name": "%s"' % group_name) | |
61 |
|
61 | |||
62 | # show |
|
62 | # show | |
63 | response = self.app.get(url('repos_group', group_name=group_name)) |
|
63 | response = self.app.get(base.url('repos_group', group_name=group_name)) | |
64 | response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) |
|
64 | response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) | |
65 |
|
65 | |||
66 | # show ignores extra trailing slashes in the URL |
|
66 | # show ignores extra trailing slashes in the URL | |
67 | response = self.app.get(url('repos_group', group_name='%s//' % group_name)) |
|
67 | response = self.app.get(base.url('repos_group', group_name='%s//' % group_name)) | |
68 | response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) |
|
68 | response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) | |
69 |
|
69 | |||
70 | # delete |
|
70 | # delete | |
71 | response = self.app.post(url('delete_repo_group', group_name=group_name), |
|
71 | response = self.app.post(base.url('delete_repo_group', group_name=group_name), | |
72 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}) |
|
72 | {'_session_csrf_secret_token': self.session_csrf_secret_token()}) | |
73 | self.checkSessionFlash(response, 'Removed repository group %s' % group_name) |
|
73 | self.checkSessionFlash(response, 'Removed repository group %s' % group_name) | |
74 |
|
74 | |||
75 | def test_new_by_regular_user(self): |
|
75 | def test_new_by_regular_user(self): | |
76 | self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
76 | self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) | |
77 | response = self.app.get(url('new_repos_group'), status=403) |
|
77 | response = self.app.get(base.url('new_repos_group'), status=403) |
@@ -1,13 +1,13 b'' | |||||
1 | import mock |
|
1 | import mock | |
2 |
|
2 | |||
3 |
from kallithea.tests |
|
3 | from kallithea.tests import base | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | class TestSearchController(TestController): |
|
6 | class TestSearchController(base.TestController): | |
7 |
|
7 | |||
8 | def test_index(self): |
|
8 | def test_index(self): | |
9 | self.log_user() |
|
9 | self.log_user() | |
10 | response = self.app.get(url(controller='search', action='index')) |
|
10 | response = self.app.get(base.url(controller='search', action='index')) | |
11 |
|
11 | |||
12 | response.mustcontain('class="form-control" id="q" name="q" type="text"') |
|
12 | response.mustcontain('class="form-control" id="q" name="q" type="text"') | |
13 | # Test response... |
|
13 | # Test response... | |
@@ -20,33 +20,33 b' class TestSearchController(TestControlle' | |||||
20 | 'index_dir': str(tmpdir), |
|
20 | 'index_dir': str(tmpdir), | |
21 | } |
|
21 | } | |
22 | with mock.patch('kallithea.controllers.search.config', config_mock): |
|
22 | with mock.patch('kallithea.controllers.search.config', config_mock): | |
23 | response = self.app.get(url(controller='search', action='index'), |
|
23 | response = self.app.get(base.url(controller='search', action='index'), | |
24 | {'q': HG_REPO}) |
|
24 | {'q': base.HG_REPO}) | |
25 | response.mustcontain('The server has no search index.') |
|
25 | response.mustcontain('The server has no search index.') | |
26 |
|
26 | |||
27 | def test_normal_search(self): |
|
27 | def test_normal_search(self): | |
28 | self.log_user() |
|
28 | self.log_user() | |
29 | response = self.app.get(url(controller='search', action='index'), |
|
29 | response = self.app.get(base.url(controller='search', action='index'), | |
30 | {'q': 'def repo'}) |
|
30 | {'q': 'def repo'}) | |
31 | response.mustcontain('58 results') |
|
31 | response.mustcontain('58 results') | |
32 |
|
32 | |||
33 | def test_repo_search(self): |
|
33 | def test_repo_search(self): | |
34 | self.log_user() |
|
34 | self.log_user() | |
35 | response = self.app.get(url(controller='search', action='index'), |
|
35 | response = self.app.get(base.url(controller='search', action='index'), | |
36 | {'q': 'repository:%s def test' % HG_REPO}) |
|
36 | {'q': 'repository:%s def test' % base.HG_REPO}) | |
37 |
|
37 | |||
38 | response.mustcontain('18 results') |
|
38 | response.mustcontain('18 results') | |
39 |
|
39 | |||
40 | def test_search_last(self): |
|
40 | def test_search_last(self): | |
41 | self.log_user() |
|
41 | self.log_user() | |
42 | response = self.app.get(url(controller='search', action='index'), |
|
42 | response = self.app.get(base.url(controller='search', action='index'), | |
43 | {'q': 'last:t', 'type': 'commit'}) |
|
43 | {'q': 'last:t', 'type': 'commit'}) | |
44 |
|
44 | |||
45 | response.mustcontain('2 results') |
|
45 | response.mustcontain('2 results') | |
46 |
|
46 | |||
47 | def test_search_commit_message(self): |
|
47 | def test_search_commit_message(self): | |
48 | self.log_user() |
|
48 | self.log_user() | |
49 | response = self.app.get(url(controller='search', action='index'), |
|
49 | response = self.app.get(base.url(controller='search', action='index'), | |
50 | {'q': 'bother to ask where to fetch repo during tests', |
|
50 | {'q': 'bother to ask where to fetch repo during tests', | |
51 | 'type': 'commit'}) |
|
51 | 'type': 'commit'}) | |
52 |
|
52 | |||
@@ -56,8 +56,8 b' class TestSearchController(TestControlle' | |||||
56 |
|
56 | |||
57 | def test_search_commit_message_hg_repo(self): |
|
57 | def test_search_commit_message_hg_repo(self): | |
58 | self.log_user() |
|
58 | self.log_user() | |
59 | response = self.app.get(url(controller='search', action='index', |
|
59 | response = self.app.get(base.url(controller='search', action='index', | |
60 | repo_name=HG_REPO), |
|
60 | repo_name=base.HG_REPO), | |
61 | {'q': 'bother to ask where to fetch repo during tests', |
|
61 | {'q': 'bother to ask where to fetch repo during tests', | |
62 | 'type': 'commit'}) |
|
62 | 'type': 'commit'}) | |
63 |
|
63 | |||
@@ -66,7 +66,7 b' class TestSearchController(TestControlle' | |||||
66 |
|
66 | |||
67 | def test_search_commit_changed_file(self): |
|
67 | def test_search_commit_changed_file(self): | |
68 | self.log_user() |
|
68 | self.log_user() | |
69 | response = self.app.get(url(controller='search', action='index'), |
|
69 | response = self.app.get(base.url(controller='search', action='index'), | |
70 | {'q': 'changed:tests/utils.py', |
|
70 | {'q': 'changed:tests/utils.py', | |
71 | 'type': 'commit'}) |
|
71 | 'type': 'commit'}) | |
72 |
|
72 | |||
@@ -74,7 +74,7 b' class TestSearchController(TestControlle' | |||||
74 |
|
74 | |||
75 | def test_search_commit_changed_files_get_commit(self): |
|
75 | def test_search_commit_changed_files_get_commit(self): | |
76 | self.log_user() |
|
76 | self.log_user() | |
77 | response = self.app.get(url(controller='search', action='index'), |
|
77 | response = self.app.get(base.url(controller='search', action='index'), | |
78 | {'q': 'changed:vcs/utils/archivers.py', |
|
78 | {'q': 'changed:vcs/utils/archivers.py', | |
79 | 'type': 'commit'}) |
|
79 | 'type': 'commit'}) | |
80 |
|
80 | |||
@@ -90,7 +90,7 b' class TestSearchController(TestControlle' | |||||
90 |
|
90 | |||
91 | def test_search_commit_added_file(self): |
|
91 | def test_search_commit_added_file(self): | |
92 | self.log_user() |
|
92 | self.log_user() | |
93 | response = self.app.get(url(controller='search', action='index'), |
|
93 | response = self.app.get(base.url(controller='search', action='index'), | |
94 | {'q': 'added:README.rst', |
|
94 | {'q': 'added:README.rst', | |
95 | 'type': 'commit'}) |
|
95 | 'type': 'commit'}) | |
96 |
|
96 | |||
@@ -102,7 +102,7 b' class TestSearchController(TestControlle' | |||||
102 |
|
102 | |||
103 | def test_search_author(self): |
|
103 | def test_search_author(self): | |
104 | self.log_user() |
|
104 | self.log_user() | |
105 | response = self.app.get(url(controller='search', action='index'), |
|
105 | response = self.app.get(base.url(controller='search', action='index'), | |
106 | {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545', |
|
106 | {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545', | |
107 | 'type': 'commit'}) |
|
107 | 'type': 'commit'}) | |
108 |
|
108 | |||
@@ -110,7 +110,7 b' class TestSearchController(TestControlle' | |||||
110 |
|
110 | |||
111 | def test_search_file_name(self): |
|
111 | def test_search_file_name(self): | |
112 | self.log_user() |
|
112 | self.log_user() | |
113 | response = self.app.get(url(controller='search', action='index'), |
|
113 | response = self.app.get(base.url(controller='search', action='index'), | |
114 | {'q': 'README.rst', 'type': 'path'}) |
|
114 | {'q': 'README.rst', 'type': 'path'}) | |
115 |
|
115 | |||
116 | response.mustcontain('2 results') |
|
116 | response.mustcontain('2 results') |
@@ -5,7 +5,7 b' from kallithea.config.conf import INDEX_' | |||||
5 | from kallithea.model.meta import Session |
|
5 | from kallithea.model.meta import Session | |
6 | from kallithea.model.repo import RepoModel |
|
6 | from kallithea.model.repo import RepoModel | |
7 | from kallithea.model.repo_group import RepoGroupModel |
|
7 | from kallithea.model.repo_group import RepoGroupModel | |
8 |
from kallithea.tests |
|
8 | from kallithea.tests import base | |
9 | from kallithea.tests.fixture import Fixture, create_test_index |
|
9 | from kallithea.tests.fixture import Fixture, create_test_index | |
10 |
|
10 | |||
11 |
|
11 | |||
@@ -66,10 +66,10 b' def rebuild_index(full_index):' | |||||
66 | # (FYI, ENOMEM occurs at forking "git" with python 2.7.3, |
|
66 | # (FYI, ENOMEM occurs at forking "git" with python 2.7.3, | |
67 | # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit |
|
67 | # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit | |
68 | # configuration for memory) |
|
68 | # configuration for memory) | |
69 | create_test_index(TESTS_TMP_PATH, CONFIG, full_index=full_index) |
|
69 | create_test_index(base.TESTS_TMP_PATH, CONFIG, full_index=full_index) | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | class TestSearchControllerIndexing(TestController): |
|
72 | class TestSearchControllerIndexing(base.TestController): | |
73 | @classmethod |
|
73 | @classmethod | |
74 | def setup_class(cls): |
|
74 | def setup_class(cls): | |
75 | for reponame, init_or_fork, groupname in repos: |
|
75 | for reponame, init_or_fork, groupname in repos: | |
@@ -108,7 +108,7 b' class TestSearchControllerIndexing(TestC' | |||||
108 |
|
108 | |||
109 | rebuild_index(full_index=True) # rebuild fully for subsequent tests |
|
109 | rebuild_index(full_index=True) # rebuild fully for subsequent tests | |
110 |
|
110 | |||
111 | @parametrize('reponame', [ |
|
111 | @base.parametrize('reponame', [ | |
112 | (u'indexing_test'), |
|
112 | (u'indexing_test'), | |
113 | (u'indexing_test-fork'), |
|
113 | (u'indexing_test-fork'), | |
114 | (u'group/indexing_test'), |
|
114 | (u'group/indexing_test'), | |
@@ -116,7 +116,7 b' class TestSearchControllerIndexing(TestC' | |||||
116 | (u'*-fork'), |
|
116 | (u'*-fork'), | |
117 | (u'group/*'), |
|
117 | (u'group/*'), | |
118 | ]) |
|
118 | ]) | |
119 | @parametrize('searchtype,query,hit', [ |
|
119 | @base.parametrize('searchtype,query,hit', [ | |
120 | ('content', 'this_should_be_unique_content', 1), |
|
120 | ('content', 'this_should_be_unique_content', 1), | |
121 | ('commit', 'this_should_be_unique_commit_log', 1), |
|
121 | ('commit', 'this_should_be_unique_commit_log', 1), | |
122 | ('path', 'this_should_be_unique_filename.txt', 1), |
|
122 | ('path', 'this_should_be_unique_filename.txt', 1), | |
@@ -125,17 +125,17 b' class TestSearchControllerIndexing(TestC' | |||||
125 | self.log_user() |
|
125 | self.log_user() | |
126 |
|
126 | |||
127 | q = 'repository:%s %s' % (reponame, query) |
|
127 | q = 'repository:%s %s' % (reponame, query) | |
128 | response = self.app.get(url(controller='search', action='index'), |
|
128 | response = self.app.get(base.url(controller='search', action='index'), | |
129 | {'q': q, 'type': searchtype}) |
|
129 | {'q': q, 'type': searchtype}) | |
130 | response.mustcontain('>%d results' % hit) |
|
130 | response.mustcontain('>%d results' % hit) | |
131 |
|
131 | |||
132 | @parametrize('reponame', [ |
|
132 | @base.parametrize('reponame', [ | |
133 | (u'indexing_test'), |
|
133 | (u'indexing_test'), | |
134 | (u'indexing_test-fork'), |
|
134 | (u'indexing_test-fork'), | |
135 | (u'group/indexing_test'), |
|
135 | (u'group/indexing_test'), | |
136 | (u'this-is-it'), |
|
136 | (u'this-is-it'), | |
137 | ]) |
|
137 | ]) | |
138 | @parametrize('searchtype,query,hit', [ |
|
138 | @base.parametrize('searchtype,query,hit', [ | |
139 | ('content', 'this_should_be_unique_content', 1), |
|
139 | ('content', 'this_should_be_unique_content', 1), | |
140 | ('commit', 'this_should_be_unique_commit_log', 1), |
|
140 | ('commit', 'this_should_be_unique_commit_log', 1), | |
141 | ('path', 'this_should_be_unique_filename.txt', 1), |
|
141 | ('path', 'this_should_be_unique_filename.txt', 1), | |
@@ -143,12 +143,12 b' class TestSearchControllerIndexing(TestC' | |||||
143 | def test_searching_under_repository(self, reponame, searchtype, query, hit): |
|
143 | def test_searching_under_repository(self, reponame, searchtype, query, hit): | |
144 | self.log_user() |
|
144 | self.log_user() | |
145 |
|
145 | |||
146 | response = self.app.get(url(controller='search', action='index', |
|
146 | response = self.app.get(base.url(controller='search', action='index', | |
147 | repo_name=reponame), |
|
147 | repo_name=reponame), | |
148 | {'q': query, 'type': searchtype}) |
|
148 | {'q': query, 'type': searchtype}) | |
149 | response.mustcontain('>%d results' % hit) |
|
149 | response.mustcontain('>%d results' % hit) | |
150 |
|
150 | |||
151 | @parametrize('searchtype,query,hit', [ |
|
151 | @base.parametrize('searchtype,query,hit', [ | |
152 | ('content', 'path:this/is/it def test', 1), |
|
152 | ('content', 'path:this/is/it def test', 1), | |
153 | ('commit', 'added:this/is/it bother to ask where', 1), |
|
153 | ('commit', 'added:this/is/it bother to ask where', 1), | |
154 | # this condition matches against files below, because |
|
154 | # this condition matches against files below, because | |
@@ -161,12 +161,12 b' class TestSearchControllerIndexing(TestC' | |||||
161 | ('path', 'extension:us', 1), |
|
161 | ('path', 'extension:us', 1), | |
162 | ]) |
|
162 | ]) | |
163 | def test_filename_stopword(self, searchtype, query, hit): |
|
163 | def test_filename_stopword(self, searchtype, query, hit): | |
164 | response = self.app.get(url(controller='search', action='index'), |
|
164 | response = self.app.get(base.url(controller='search', action='index'), | |
165 | {'q': query, 'type': searchtype}) |
|
165 | {'q': query, 'type': searchtype}) | |
166 |
|
166 | |||
167 | response.mustcontain('>%d results' % hit) |
|
167 | response.mustcontain('>%d results' % hit) | |
168 |
|
168 | |||
169 | @parametrize('searchtype,query,hit', [ |
|
169 | @base.parametrize('searchtype,query,hit', [ | |
170 | # matching against both 2 files |
|
170 | # matching against both 2 files | |
171 | ('content', 'owner:"this is it"', 0), |
|
171 | ('content', 'owner:"this is it"', 0), | |
172 | ('content', 'owner:this-is-it', 0), |
|
172 | ('content', 'owner:this-is-it', 0), | |
@@ -182,7 +182,7 b' class TestSearchControllerIndexing(TestC' | |||||
182 | ('commit', 'author:"this-is-it"', 1), |
|
182 | ('commit', 'author:"this-is-it"', 1), | |
183 | ]) |
|
183 | ]) | |
184 | def test_mailaddr_stopword(self, searchtype, query, hit): |
|
184 | def test_mailaddr_stopword(self, searchtype, query, hit): | |
185 | response = self.app.get(url(controller='search', action='index'), |
|
185 | response = self.app.get(base.url(controller='search', action='index'), | |
186 | {'q': query, 'type': searchtype}) |
|
186 | {'q': query, 'type': searchtype}) | |
187 |
|
187 | |||
188 | response.mustcontain('>%d results' % hit) |
|
188 | response.mustcontain('>%d results' % hit) |
@@ -18,7 +18,7 b' from kallithea.model.db import Repositor' | |||||
18 | from kallithea.model.meta import Session |
|
18 | from kallithea.model.meta import Session | |
19 | from kallithea.model.repo import RepoModel |
|
19 | from kallithea.model.repo import RepoModel | |
20 | from kallithea.model.scm import ScmModel |
|
20 | from kallithea.model.scm import ScmModel | |
21 |
from kallithea.tests |
|
21 | from kallithea.tests import base | |
22 | from kallithea.tests.fixture import Fixture |
|
22 | from kallithea.tests.fixture import Fixture | |
23 |
|
23 | |||
24 |
|
24 | |||
@@ -32,14 +32,14 b' def custom_settings(set_test_settings):' | |||||
32 | ) |
|
32 | ) | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | class TestSummaryController(TestController): |
|
35 | class TestSummaryController(base.TestController): | |
36 |
|
36 | |||
37 | def test_index_hg(self, custom_settings): |
|
37 | def test_index_hg(self, custom_settings): | |
38 | self.log_user() |
|
38 | self.log_user() | |
39 | ID = Repository.get_by_repo_name(HG_REPO).repo_id |
|
39 | ID = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
40 | response = self.app.get(url(controller='summary', |
|
40 | response = self.app.get(base.url(controller='summary', | |
41 | action='index', |
|
41 | action='index', | |
42 | repo_name=HG_REPO)) |
|
42 | repo_name=base.HG_REPO)) | |
43 |
|
43 | |||
44 | # repo type |
|
44 | # repo type | |
45 | response.mustcontain( |
|
45 | response.mustcontain( | |
@@ -52,24 +52,24 b' class TestSummaryController(TestControll' | |||||
52 | # clone URLs |
|
52 | # clone URLs | |
53 | response.mustcontain( |
|
53 | response.mustcontain( | |
54 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' % |
|
54 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' % | |
55 | (TEST_USER_ADMIN_LOGIN, HG_REPO) |
|
55 | (base.TEST_USER_ADMIN_LOGIN, base.HG_REPO) | |
56 | ) |
|
56 | ) | |
57 | response.mustcontain( |
|
57 | response.mustcontain( | |
58 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' % |
|
58 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' % | |
59 | (TEST_USER_ADMIN_LOGIN, ID) |
|
59 | (base.TEST_USER_ADMIN_LOGIN, ID) | |
60 | ) |
|
60 | ) | |
61 | response.mustcontain( |
|
61 | response.mustcontain( | |
62 | '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' % |
|
62 | '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' % | |
63 | (HG_REPO) |
|
63 | (base.HG_REPO) | |
64 | ) |
|
64 | ) | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | def test_index_git(self, custom_settings): |
|
67 | def test_index_git(self, custom_settings): | |
68 | self.log_user() |
|
68 | self.log_user() | |
69 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id |
|
69 | ID = Repository.get_by_repo_name(base.GIT_REPO).repo_id | |
70 | response = self.app.get(url(controller='summary', |
|
70 | response = self.app.get(base.url(controller='summary', | |
71 | action='index', |
|
71 | action='index', | |
72 | repo_name=GIT_REPO)) |
|
72 | repo_name=base.GIT_REPO)) | |
73 |
|
73 | |||
74 | # repo type |
|
74 | # repo type | |
75 | response.mustcontain( |
|
75 | response.mustcontain( | |
@@ -82,21 +82,21 b' class TestSummaryController(TestControll' | |||||
82 | # clone URLs |
|
82 | # clone URLs | |
83 | response.mustcontain( |
|
83 | response.mustcontain( | |
84 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' % |
|
84 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/%s"/>''' % | |
85 | (TEST_USER_ADMIN_LOGIN, GIT_REPO) |
|
85 | (base.TEST_USER_ADMIN_LOGIN, base.GIT_REPO) | |
86 | ) |
|
86 | ) | |
87 | response.mustcontain( |
|
87 | response.mustcontain( | |
88 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' % |
|
88 | '''<input class="form-control" size="80" readonly="readonly" value="http://%s@localhost:80/_%s"/>''' % | |
89 | (TEST_USER_ADMIN_LOGIN, ID) |
|
89 | (base.TEST_USER_ADMIN_LOGIN, ID) | |
90 | ) |
|
90 | ) | |
91 | response.mustcontain( |
|
91 | response.mustcontain( | |
92 | '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' % |
|
92 | '''<input id="ssh_url" class="form-control" size="80" readonly="readonly" value="ssh://ssh_user@ssh_hostname/%s"/>''' % | |
93 | (GIT_REPO) |
|
93 | (base.GIT_REPO) | |
94 | ) |
|
94 | ) | |
95 |
|
95 | |||
96 | def test_index_by_id_hg(self): |
|
96 | def test_index_by_id_hg(self): | |
97 | self.log_user() |
|
97 | self.log_user() | |
98 | ID = Repository.get_by_repo_name(HG_REPO).repo_id |
|
98 | ID = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
99 | response = self.app.get(url(controller='summary', |
|
99 | response = self.app.get(base.url(controller='summary', | |
100 | action='index', |
|
100 | action='index', | |
101 | repo_name='_%s' % ID)) |
|
101 | repo_name='_%s' % ID)) | |
102 |
|
102 | |||
@@ -112,7 +112,7 b' class TestSummaryController(TestControll' | |||||
112 | def test_index_by_repo_having_id_path_in_name_hg(self): |
|
112 | def test_index_by_repo_having_id_path_in_name_hg(self): | |
113 | self.log_user() |
|
113 | self.log_user() | |
114 | fixture.create_repo(name=u'repo_1') |
|
114 | fixture.create_repo(name=u'repo_1') | |
115 | response = self.app.get(url(controller='summary', |
|
115 | response = self.app.get(base.url(controller='summary', | |
116 | action='index', |
|
116 | action='index', | |
117 | repo_name='repo_1')) |
|
117 | repo_name='repo_1')) | |
118 |
|
118 | |||
@@ -124,8 +124,8 b' class TestSummaryController(TestControll' | |||||
124 |
|
124 | |||
125 | def test_index_by_id_git(self): |
|
125 | def test_index_by_id_git(self): | |
126 | self.log_user() |
|
126 | self.log_user() | |
127 | ID = Repository.get_by_repo_name(GIT_REPO).repo_id |
|
127 | ID = Repository.get_by_repo_name(base.GIT_REPO).repo_id | |
128 | response = self.app.get(url(controller='summary', |
|
128 | response = self.app.get(base.url(controller='summary', | |
129 | action='index', |
|
129 | action='index', | |
130 | repo_name='_%s' % ID)) |
|
130 | repo_name='_%s' % ID)) | |
131 |
|
131 | |||
@@ -146,14 +146,14 b' class TestSummaryController(TestControll' | |||||
146 | def test_index_trending(self): |
|
146 | def test_index_trending(self): | |
147 | self.log_user() |
|
147 | self.log_user() | |
148 | # codes stats |
|
148 | # codes stats | |
149 | self._enable_stats(HG_REPO) |
|
149 | self._enable_stats(base.HG_REPO) | |
150 |
|
150 | |||
151 | ScmModel().mark_for_invalidation(HG_REPO) |
|
151 | ScmModel().mark_for_invalidation(base.HG_REPO) | |
152 | # generate statistics first |
|
152 | # generate statistics first | |
153 | response = self.app.get(url(controller='summary', action='statistics', |
|
153 | response = self.app.get(base.url(controller='summary', action='statistics', | |
154 | repo_name=HG_REPO)) |
|
154 | repo_name=base.HG_REPO)) | |
155 | response = self.app.get(url(controller='summary', action='index', |
|
155 | response = self.app.get(base.url(controller='summary', action='index', | |
156 | repo_name=HG_REPO)) |
|
156 | repo_name=base.HG_REPO)) | |
157 | response.mustcontain( |
|
157 | response.mustcontain( | |
158 | '[["py", {"count": 68, "desc": ["Python"]}], ' |
|
158 | '[["py", {"count": 68, "desc": ["Python"]}], ' | |
159 | '["rst", {"count": 16, "desc": ["Rst"]}], ' |
|
159 | '["rst", {"count": 16, "desc": ["Rst"]}], ' | |
@@ -170,23 +170,23 b' class TestSummaryController(TestControll' | |||||
170 | def test_index_statistics(self): |
|
170 | def test_index_statistics(self): | |
171 | self.log_user() |
|
171 | self.log_user() | |
172 | # codes stats |
|
172 | # codes stats | |
173 | self._enable_stats(HG_REPO) |
|
173 | self._enable_stats(base.HG_REPO) | |
174 |
|
174 | |||
175 | ScmModel().mark_for_invalidation(HG_REPO) |
|
175 | ScmModel().mark_for_invalidation(base.HG_REPO) | |
176 | response = self.app.get(url(controller='summary', action='statistics', |
|
176 | response = self.app.get(base.url(controller='summary', action='statistics', | |
177 | repo_name=HG_REPO)) |
|
177 | repo_name=base.HG_REPO)) | |
178 |
|
178 | |||
179 | def test_index_trending_git(self): |
|
179 | def test_index_trending_git(self): | |
180 | self.log_user() |
|
180 | self.log_user() | |
181 | # codes stats |
|
181 | # codes stats | |
182 | self._enable_stats(GIT_REPO) |
|
182 | self._enable_stats(base.GIT_REPO) | |
183 |
|
183 | |||
184 | ScmModel().mark_for_invalidation(GIT_REPO) |
|
184 | ScmModel().mark_for_invalidation(base.GIT_REPO) | |
185 | # generate statistics first |
|
185 | # generate statistics first | |
186 | response = self.app.get(url(controller='summary', action='statistics', |
|
186 | response = self.app.get(base.url(controller='summary', action='statistics', | |
187 | repo_name=GIT_REPO)) |
|
187 | repo_name=base.GIT_REPO)) | |
188 | response = self.app.get(url(controller='summary', action='index', |
|
188 | response = self.app.get(base.url(controller='summary', action='index', | |
189 | repo_name=GIT_REPO)) |
|
189 | repo_name=base.GIT_REPO)) | |
190 | response.mustcontain( |
|
190 | response.mustcontain( | |
191 | '[["py", {"count": 68, "desc": ["Python"]}], ' |
|
191 | '[["py", {"count": 68, "desc": ["Python"]}], ' | |
192 | '["rst", {"count": 16, "desc": ["Rst"]}], ' |
|
192 | '["rst", {"count": 16, "desc": ["Rst"]}], ' | |
@@ -203,8 +203,8 b' class TestSummaryController(TestControll' | |||||
203 | def test_index_statistics_git(self): |
|
203 | def test_index_statistics_git(self): | |
204 | self.log_user() |
|
204 | self.log_user() | |
205 | # codes stats |
|
205 | # codes stats | |
206 | self._enable_stats(GIT_REPO) |
|
206 | self._enable_stats(base.GIT_REPO) | |
207 |
|
207 | |||
208 | ScmModel().mark_for_invalidation(GIT_REPO) |
|
208 | ScmModel().mark_for_invalidation(base.GIT_REPO) | |
209 | response = self.app.get(url(controller='summary', action='statistics', |
|
209 | response = self.app.get(base.url(controller='summary', action='statistics', | |
210 | repo_name=GIT_REPO)) |
|
210 | repo_name=base.GIT_REPO)) |
@@ -1,6 +1,6 b'' | |||||
1 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
1 | from kallithea.model.changeset_status import ChangesetStatusModel | |
2 | from kallithea.model.db import ChangesetStatus as CS |
|
2 | from kallithea.model.db import ChangesetStatus as CS | |
3 |
from kallithea.tests |
|
3 | from kallithea.tests import base | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | class CSM(object): # ChangesetStatusMock |
|
6 | class CSM(object): # ChangesetStatusMock | |
@@ -9,12 +9,12 b' class CSM(object): # ChangesetStatusMock' | |||||
9 | self.status = status |
|
9 | self.status = status | |
10 |
|
10 | |||
11 |
|
11 | |||
12 | class TestChangesetStatusCalculation(TestController): |
|
12 | class TestChangesetStatusCalculation(base.TestController): | |
13 |
|
13 | |||
14 | def setup_method(self, method): |
|
14 | def setup_method(self, method): | |
15 | self.m = ChangesetStatusModel() |
|
15 | self.m = ChangesetStatusModel() | |
16 |
|
16 | |||
17 | @parametrize('name,expected_result,statuses', [ |
|
17 | @base.parametrize('name,expected_result,statuses', [ | |
18 | ('empty list', CS.STATUS_UNDER_REVIEW, []), |
|
18 | ('empty list', CS.STATUS_UNDER_REVIEW, []), | |
19 | ('approve', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED)]), |
|
19 | ('approve', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED)]), | |
20 | ('approve2', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_APPROVED)]), |
|
20 | ('approve2', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_APPROVED)]), |
@@ -3,10 +3,10 b' from tg.util.webtest import test_context' | |||||
3 |
|
3 | |||
4 | from kallithea.model.comment import ChangesetCommentsModel |
|
4 | from kallithea.model.comment import ChangesetCommentsModel | |
5 | from kallithea.model.db import Repository |
|
5 | from kallithea.model.db import Repository | |
6 |
from kallithea.tests |
|
6 | from kallithea.tests import base | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | class TestComments(TestController): |
|
9 | class TestComments(base.TestController): | |
10 |
|
10 | |||
11 | def _check_comment_count(self, repo_id, revision, |
|
11 | def _check_comment_count(self, repo_id, revision, | |
12 | expected_len_comments, expected_len_inline_comments, |
|
12 | expected_len_comments, expected_len_inline_comments, | |
@@ -23,7 +23,7 b' class TestComments(TestController):' | |||||
23 |
|
23 | |||
24 | def test_create_delete_general_comment(self): |
|
24 | def test_create_delete_general_comment(self): | |
25 | with test_context(self.app): |
|
25 | with test_context(self.app): | |
26 | repo_id = Repository.get_by_repo_name(HG_REPO).repo_id |
|
26 | repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
27 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' |
|
27 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' | |
28 |
|
28 | |||
29 | self._check_comment_count(repo_id, revision, |
|
29 | self._check_comment_count(repo_id, revision, | |
@@ -32,8 +32,8 b' class TestComments(TestController):' | |||||
32 | text = u'a comment' |
|
32 | text = u'a comment' | |
33 | new_comment = ChangesetCommentsModel().create( |
|
33 | new_comment = ChangesetCommentsModel().create( | |
34 | text=text, |
|
34 | text=text, | |
35 | repo=HG_REPO, |
|
35 | repo=base.HG_REPO, | |
36 | author=TEST_USER_REGULAR_LOGIN, |
|
36 | author=base.TEST_USER_REGULAR_LOGIN, | |
37 | revision=revision, |
|
37 | revision=revision, | |
38 | send_email=False) |
|
38 | send_email=False) | |
39 |
|
39 | |||
@@ -47,7 +47,7 b' class TestComments(TestController):' | |||||
47 |
|
47 | |||
48 | def test_create_delete_inline_comment(self): |
|
48 | def test_create_delete_inline_comment(self): | |
49 | with test_context(self.app): |
|
49 | with test_context(self.app): | |
50 | repo_id = Repository.get_by_repo_name(HG_REPO).repo_id |
|
50 | repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
51 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' |
|
51 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' | |
52 |
|
52 | |||
53 | self._check_comment_count(repo_id, revision, |
|
53 | self._check_comment_count(repo_id, revision, | |
@@ -58,8 +58,8 b' class TestComments(TestController):' | |||||
58 | line_no = u'n50' |
|
58 | line_no = u'n50' | |
59 | new_comment = ChangesetCommentsModel().create( |
|
59 | new_comment = ChangesetCommentsModel().create( | |
60 | text=text, |
|
60 | text=text, | |
61 | repo=HG_REPO, |
|
61 | repo=base.HG_REPO, | |
62 | author=TEST_USER_REGULAR_LOGIN, |
|
62 | author=base.TEST_USER_REGULAR_LOGIN, | |
63 | revision=revision, |
|
63 | revision=revision, | |
64 | f_path=f_path, |
|
64 | f_path=f_path, | |
65 | line_no=line_no, |
|
65 | line_no=line_no, | |
@@ -81,7 +81,7 b' class TestComments(TestController):' | |||||
81 |
|
81 | |||
82 | def test_create_delete_multiple_inline_comments(self): |
|
82 | def test_create_delete_multiple_inline_comments(self): | |
83 | with test_context(self.app): |
|
83 | with test_context(self.app): | |
84 | repo_id = Repository.get_by_repo_name(HG_REPO).repo_id |
|
84 | repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
85 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' |
|
85 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' | |
86 |
|
86 | |||
87 | self._check_comment_count(repo_id, revision, |
|
87 | self._check_comment_count(repo_id, revision, | |
@@ -92,8 +92,8 b' class TestComments(TestController):' | |||||
92 | line_no = u'n50' |
|
92 | line_no = u'n50' | |
93 | new_comment = ChangesetCommentsModel().create( |
|
93 | new_comment = ChangesetCommentsModel().create( | |
94 | text=text, |
|
94 | text=text, | |
95 | repo=HG_REPO, |
|
95 | repo=base.HG_REPO, | |
96 | author=TEST_USER_REGULAR_LOGIN, |
|
96 | author=base.TEST_USER_REGULAR_LOGIN, | |
97 | revision=revision, |
|
97 | revision=revision, | |
98 | f_path=f_path, |
|
98 | f_path=f_path, | |
99 | line_no=line_no, |
|
99 | line_no=line_no, | |
@@ -103,8 +103,8 b' class TestComments(TestController):' | |||||
103 | line_no2 = u'o41' |
|
103 | line_no2 = u'o41' | |
104 | new_comment2 = ChangesetCommentsModel().create( |
|
104 | new_comment2 = ChangesetCommentsModel().create( | |
105 | text=text2, |
|
105 | text=text2, | |
106 | repo=HG_REPO, |
|
106 | repo=base.HG_REPO, | |
107 | author=TEST_USER_REGULAR_LOGIN, |
|
107 | author=base.TEST_USER_REGULAR_LOGIN, | |
108 | revision=revision, |
|
108 | revision=revision, | |
109 | f_path=f_path, |
|
109 | f_path=f_path, | |
110 | line_no=line_no2, |
|
110 | line_no=line_no2, | |
@@ -115,8 +115,8 b' class TestComments(TestController):' | |||||
115 | line_no3 = u'n159' |
|
115 | line_no3 = u'n159' | |
116 | new_comment3 = ChangesetCommentsModel().create( |
|
116 | new_comment3 = ChangesetCommentsModel().create( | |
117 | text=text3, |
|
117 | text=text3, | |
118 | repo=HG_REPO, |
|
118 | repo=base.HG_REPO, | |
119 | author=TEST_USER_REGULAR_LOGIN, |
|
119 | author=base.TEST_USER_REGULAR_LOGIN, | |
120 | revision=revision, |
|
120 | revision=revision, | |
121 | f_path=f_path3, |
|
121 | f_path=f_path3, | |
122 | line_no=line_no3, |
|
122 | line_no=line_no3, | |
@@ -161,7 +161,7 b' class TestComments(TestController):' | |||||
161 |
|
161 | |||
162 | def test_selective_retrieval_of_inline_comments(self): |
|
162 | def test_selective_retrieval_of_inline_comments(self): | |
163 | with test_context(self.app): |
|
163 | with test_context(self.app): | |
164 | repo_id = Repository.get_by_repo_name(HG_REPO).repo_id |
|
164 | repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id | |
165 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' |
|
165 | revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' | |
166 |
|
166 | |||
167 | self._check_comment_count(repo_id, revision, |
|
167 | self._check_comment_count(repo_id, revision, | |
@@ -172,8 +172,8 b' class TestComments(TestController):' | |||||
172 | line_no = u'n50' |
|
172 | line_no = u'n50' | |
173 | new_comment = ChangesetCommentsModel().create( |
|
173 | new_comment = ChangesetCommentsModel().create( | |
174 | text=text, |
|
174 | text=text, | |
175 | repo=HG_REPO, |
|
175 | repo=base.HG_REPO, | |
176 | author=TEST_USER_REGULAR_LOGIN, |
|
176 | author=base.TEST_USER_REGULAR_LOGIN, | |
177 | revision=revision, |
|
177 | revision=revision, | |
178 | f_path=f_path, |
|
178 | f_path=f_path, | |
179 | line_no=line_no, |
|
179 | line_no=line_no, | |
@@ -183,8 +183,8 b' class TestComments(TestController):' | |||||
183 | line_no2 = u'o41' |
|
183 | line_no2 = u'o41' | |
184 | new_comment2 = ChangesetCommentsModel().create( |
|
184 | new_comment2 = ChangesetCommentsModel().create( | |
185 | text=text2, |
|
185 | text=text2, | |
186 | repo=HG_REPO, |
|
186 | repo=base.HG_REPO, | |
187 | author=TEST_USER_REGULAR_LOGIN, |
|
187 | author=base.TEST_USER_REGULAR_LOGIN, | |
188 | revision=revision, |
|
188 | revision=revision, | |
189 | f_path=f_path, |
|
189 | f_path=f_path, | |
190 | line_no=line_no2, |
|
190 | line_no=line_no2, | |
@@ -195,8 +195,8 b' class TestComments(TestController):' | |||||
195 | line_no3 = u'n159' |
|
195 | line_no3 = u'n159' | |
196 | new_comment3 = ChangesetCommentsModel().create( |
|
196 | new_comment3 = ChangesetCommentsModel().create( | |
197 | text=text3, |
|
197 | text=text3, | |
198 | repo=HG_REPO, |
|
198 | repo=base.HG_REPO, | |
199 | author=TEST_USER_REGULAR_LOGIN, |
|
199 | author=base.TEST_USER_REGULAR_LOGIN, | |
200 | revision=revision, |
|
200 | revision=revision, | |
201 | f_path=f_path3, |
|
201 | f_path=f_path3, | |
202 | line_no=line_no3, |
|
202 | line_no=line_no3, |
@@ -1,5 +1,5 b'' | |||||
1 | from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, COPIED_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE, DiffProcessor |
|
1 | from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, COPIED_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE, DiffProcessor | |
2 |
from kallithea.tests |
|
2 | from kallithea.tests import base | |
3 | from kallithea.tests.fixture import Fixture |
|
3 | from kallithea.tests.fixture import Fixture | |
4 |
|
4 | |||
5 |
|
5 | |||
@@ -271,9 +271,9 b' DIFF_FIXTURES = {' | |||||
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 |
|
273 | |||
274 | class TestDiffLib(TestController): |
|
274 | class TestDiffLib(base.TestController): | |
275 |
|
275 | |||
276 | @parametrize('diff_fixture', DIFF_FIXTURES) |
|
276 | @base.parametrize('diff_fixture', DIFF_FIXTURES) | |
277 | def test_diff(self, diff_fixture): |
|
277 | def test_diff(self, diff_fixture): | |
278 | raw_diff = fixture.load_resource(diff_fixture, strip=False) |
|
278 | raw_diff = fixture.load_resource(diff_fixture, strip=False) | |
279 | vcs = 'hg' |
|
279 | vcs = 'hg' |
@@ -11,10 +11,10 b' from kallithea.model.db import User' | |||||
11 | from kallithea.model.meta import Session |
|
11 | from kallithea.model.meta import Session | |
12 | from kallithea.model.notification import EmailNotificationModel, NotificationModel |
|
12 | from kallithea.model.notification import EmailNotificationModel, NotificationModel | |
13 | from kallithea.model.user import UserModel |
|
13 | from kallithea.model.user import UserModel | |
14 |
from kallithea.tests |
|
14 | from kallithea.tests import base | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | class TestNotifications(TestController): |
|
17 | class TestNotifications(base.TestController): | |
18 |
|
18 | |||
19 | def setup_method(self, method): |
|
19 | def setup_method(self, method): | |
20 | Session.remove() |
|
20 | Session.remove() |
@@ -6,14 +6,14 b' from kallithea.model.repo import RepoMod' | |||||
6 | from kallithea.model.repo_group import RepoGroupModel |
|
6 | from kallithea.model.repo_group import RepoGroupModel | |
7 | from kallithea.model.user import UserModel |
|
7 | from kallithea.model.user import UserModel | |
8 | from kallithea.model.user_group import UserGroupModel |
|
8 | from kallithea.model.user_group import UserGroupModel | |
9 |
from kallithea.tests |
|
9 | from kallithea.tests import base | |
10 | from kallithea.tests.fixture import Fixture |
|
10 | from kallithea.tests.fixture import Fixture | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | fixture = Fixture() |
|
13 | fixture = Fixture() | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | class TestPermissions(TestController): |
|
16 | class TestPermissions(base.TestController): | |
17 |
|
17 | |||
18 | @classmethod |
|
18 | @classmethod | |
19 | def setup_class(cls): |
|
19 | def setup_class(cls): | |
@@ -71,33 +71,33 b' class TestPermissions(TestController):' | |||||
71 | 'repositories_groups': {}, |
|
71 | 'repositories_groups': {}, | |
72 | 'global': set(['hg.create.repository', 'repository.read', |
|
72 | 'global': set(['hg.create.repository', 'repository.read', | |
73 | 'hg.register.manual_activate']), |
|
73 | 'hg.register.manual_activate']), | |
74 | 'repositories': {HG_REPO: 'repository.read'} |
|
74 | 'repositories': {base.HG_REPO: 'repository.read'} | |
75 | } |
|
75 | } | |
76 | assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] |
|
76 | assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
77 | new_perm = 'repository.write' |
|
77 | new_perm = 'repository.write' | |
78 | RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, |
|
78 | RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, | |
79 | perm=new_perm) |
|
79 | perm=new_perm) | |
80 | Session().commit() |
|
80 | Session().commit() | |
81 |
|
81 | |||
82 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
82 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
83 | assert u1_auth.permissions['repositories'][HG_REPO] == new_perm |
|
83 | assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm | |
84 |
|
84 | |||
85 | def test_default_admin_perms_set(self): |
|
85 | def test_default_admin_perms_set(self): | |
86 | a1_auth = AuthUser(user_id=self.a1.user_id) |
|
86 | a1_auth = AuthUser(user_id=self.a1.user_id) | |
87 | perms = { |
|
87 | perms = { | |
88 | 'repositories_groups': {}, |
|
88 | 'repositories_groups': {}, | |
89 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), |
|
89 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), | |
90 | 'repositories': {HG_REPO: 'repository.admin'} |
|
90 | 'repositories': {base.HG_REPO: 'repository.admin'} | |
91 | } |
|
91 | } | |
92 | assert a1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] |
|
92 | assert a1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
93 | new_perm = 'repository.write' |
|
93 | new_perm = 'repository.write' | |
94 | RepoModel().grant_user_permission(repo=HG_REPO, user=self.a1, |
|
94 | RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.a1, | |
95 | perm=new_perm) |
|
95 | perm=new_perm) | |
96 | Session().commit() |
|
96 | Session().commit() | |
97 | # cannot really downgrade admins permissions !? they still gets set as |
|
97 | # cannot really downgrade admins permissions !? they still gets set as | |
98 | # admin ! |
|
98 | # admin ! | |
99 | u1_auth = AuthUser(user_id=self.a1.user_id) |
|
99 | u1_auth = AuthUser(user_id=self.a1.user_id) | |
100 | assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] |
|
100 | assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
101 |
|
101 | |||
102 | def test_default_group_perms(self): |
|
102 | def test_default_group_perms(self): | |
103 | self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) |
|
103 | self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) | |
@@ -106,9 +106,9 b' class TestPermissions(TestController):' | |||||
106 | perms = { |
|
106 | perms = { | |
107 | 'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'}, |
|
107 | 'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'}, | |
108 | 'global': set(Permission.DEFAULT_USER_PERMISSIONS), |
|
108 | 'global': set(Permission.DEFAULT_USER_PERMISSIONS), | |
109 | 'repositories': {HG_REPO: 'repository.read'} |
|
109 | 'repositories': {base.HG_REPO: 'repository.read'} | |
110 | } |
|
110 | } | |
111 | assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] |
|
111 | assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
112 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] |
|
112 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] | |
113 | assert u1_auth.permissions['global'] == perms['global'] |
|
113 | assert u1_auth.permissions['global'] == perms['global'] | |
114 |
|
114 | |||
@@ -119,10 +119,10 b' class TestPermissions(TestController):' | |||||
119 | perms = { |
|
119 | perms = { | |
120 | 'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'}, |
|
120 | 'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'}, | |
121 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), |
|
121 | 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), | |
122 | 'repositories': {HG_REPO: 'repository.admin'} |
|
122 | 'repositories': {base.HG_REPO: 'repository.admin'} | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | assert a1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] |
|
125 | assert a1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] | |
126 | assert a1_auth.permissions['repositories_groups'] == perms['repositories_groups'] |
|
126 | assert a1_auth.permissions['repositories_groups'] == perms['repositories_groups'] | |
127 |
|
127 | |||
128 | def test_propagated_permission_from_users_group_by_explicit_perms_exist(self): |
|
128 | def test_propagated_permission_from_users_group_by_explicit_perms_exist(self): | |
@@ -131,19 +131,19 b' class TestPermissions(TestController):' | |||||
131 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
131 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
132 |
|
132 | |||
133 | # set user permission none |
|
133 | # set user permission none | |
134 | RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, perm='repository.none') |
|
134 | RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, perm='repository.none') | |
135 | Session().commit() |
|
135 | Session().commit() | |
136 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
136 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
137 | assert u1_auth.permissions['repositories'][HG_REPO] == 'repository.read' # inherit from default user |
|
137 | assert u1_auth.permissions['repositories'][base.HG_REPO] == 'repository.read' # inherit from default user | |
138 |
|
138 | |||
139 | # grant perm for group this should override permission from user |
|
139 | # grant perm for group this should override permission from user | |
140 | RepoModel().grant_user_group_permission(repo=HG_REPO, |
|
140 | RepoModel().grant_user_group_permission(repo=base.HG_REPO, | |
141 | group_name=self.ug1, |
|
141 | group_name=self.ug1, | |
142 | perm='repository.write') |
|
142 | perm='repository.write') | |
143 |
|
143 | |||
144 | # verify that user group permissions win |
|
144 | # verify that user group permissions win | |
145 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
145 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
146 | assert u1_auth.permissions['repositories'][HG_REPO] == 'repository.write' |
|
146 | assert u1_auth.permissions['repositories'][base.HG_REPO] == 'repository.write' | |
147 |
|
147 | |||
148 | def test_propagated_permission_from_users_group(self): |
|
148 | def test_propagated_permission_from_users_group(self): | |
149 | # make group |
|
149 | # make group | |
@@ -152,7 +152,7 b' class TestPermissions(TestController):' | |||||
152 |
|
152 | |||
153 | # grant perm for group this should override default permission from user |
|
153 | # grant perm for group this should override default permission from user | |
154 | new_perm_gr = 'repository.write' |
|
154 | new_perm_gr = 'repository.write' | |
155 | RepoModel().grant_user_group_permission(repo=HG_REPO, |
|
155 | RepoModel().grant_user_group_permission(repo=base.HG_REPO, | |
156 | group_name=self.ug1, |
|
156 | group_name=self.ug1, | |
157 | perm=new_perm_gr) |
|
157 | perm=new_perm_gr) | |
158 | # check perms |
|
158 | # check perms | |
@@ -161,9 +161,9 b' class TestPermissions(TestController):' | |||||
161 | 'repositories_groups': {}, |
|
161 | 'repositories_groups': {}, | |
162 | 'global': set(['hg.create.repository', 'repository.read', |
|
162 | 'global': set(['hg.create.repository', 'repository.read', | |
163 | 'hg.register.manual_activate']), |
|
163 | 'hg.register.manual_activate']), | |
164 | 'repositories': {HG_REPO: 'repository.read'} |
|
164 | 'repositories': {base.HG_REPO: 'repository.read'} | |
165 | } |
|
165 | } | |
166 | assert u3_auth.permissions['repositories'][HG_REPO] == new_perm_gr |
|
166 | assert u3_auth.permissions['repositories'][base.HG_REPO] == new_perm_gr | |
167 | assert u3_auth.permissions['repositories_groups'] == perms['repositories_groups'] |
|
167 | assert u3_auth.permissions['repositories_groups'] == perms['repositories_groups'] | |
168 |
|
168 | |||
169 | def test_propagated_permission_from_users_group_lower_weight(self): |
|
169 | def test_propagated_permission_from_users_group_lower_weight(self): | |
@@ -174,16 +174,16 b' class TestPermissions(TestController):' | |||||
174 |
|
174 | |||
175 | # set permission to lower |
|
175 | # set permission to lower | |
176 | new_perm_h = 'repository.write' |
|
176 | new_perm_h = 'repository.write' | |
177 | RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, |
|
177 | RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, | |
178 | perm=new_perm_h) |
|
178 | perm=new_perm_h) | |
179 | Session().commit() |
|
179 | Session().commit() | |
180 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
180 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
181 | assert u1_auth.permissions['repositories'][HG_REPO] == new_perm_h |
|
181 | assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm_h | |
182 |
|
182 | |||
183 | # grant perm for group this should NOT override permission from user |
|
183 | # grant perm for group this should NOT override permission from user | |
184 | # since it's lower than granted |
|
184 | # since it's lower than granted | |
185 | new_perm_l = 'repository.read' |
|
185 | new_perm_l = 'repository.read' | |
186 | RepoModel().grant_user_group_permission(repo=HG_REPO, |
|
186 | RepoModel().grant_user_group_permission(repo=base.HG_REPO, | |
187 | group_name=self.ug1, |
|
187 | group_name=self.ug1, | |
188 | perm=new_perm_l) |
|
188 | perm=new_perm_l) | |
189 | # check perms |
|
189 | # check perms | |
@@ -192,9 +192,9 b' class TestPermissions(TestController):' | |||||
192 | 'repositories_groups': {}, |
|
192 | 'repositories_groups': {}, | |
193 | 'global': set(['hg.create.repository', 'repository.read', |
|
193 | 'global': set(['hg.create.repository', 'repository.read', | |
194 | 'hg.register.manual_activate']), |
|
194 | 'hg.register.manual_activate']), | |
195 | 'repositories': {HG_REPO: 'repository.write'} |
|
195 | 'repositories': {base.HG_REPO: 'repository.write'} | |
196 | } |
|
196 | } | |
197 | assert u1_auth.permissions['repositories'][HG_REPO] == new_perm_h |
|
197 | assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm_h | |
198 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] |
|
198 | assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] | |
199 |
|
199 | |||
200 | def test_repo_in_group_permissions(self): |
|
200 | def test_repo_in_group_permissions(self): | |
@@ -641,7 +641,7 b' class TestPermissions(TestController):' | |||||
641 | PermissionModel().create_default_permissions(user=self.u1) |
|
641 | PermissionModel().create_default_permissions(user=self.u1) | |
642 | self._test_def_perm_equal(user=self.u1) |
|
642 | self._test_def_perm_equal(user=self.u1) | |
643 |
|
643 | |||
644 | @parametrize('perm,modify_to', [ |
|
644 | @base.parametrize('perm,modify_to', [ | |
645 | ('repository.read', 'repository.none'), |
|
645 | ('repository.read', 'repository.none'), | |
646 | ('group.read', 'group.none'), |
|
646 | ('group.read', 'group.none'), | |
647 | ('usergroup.read', 'usergroup.none'), |
|
647 | ('usergroup.read', 'usergroup.none'), |
@@ -7,7 +7,7 b' from kallithea.model.db import RepoGroup' | |||||
7 | from kallithea.model.meta import Session |
|
7 | from kallithea.model.meta import Session | |
8 | from kallithea.model.repo import RepoModel |
|
8 | from kallithea.model.repo import RepoModel | |
9 | from kallithea.model.repo_group import RepoGroupModel |
|
9 | from kallithea.model.repo_group import RepoGroupModel | |
10 |
from kallithea.tests |
|
10 | from kallithea.tests import base | |
11 | from kallithea.tests.fixture import Fixture |
|
11 | from kallithea.tests.fixture import Fixture | |
12 |
|
12 | |||
13 |
|
13 | |||
@@ -34,7 +34,7 b' def _update_repo(name, **kwargs):' | |||||
34 | return r |
|
34 | return r | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class TestRepoGroups(TestController): |
|
37 | class TestRepoGroups(base.TestController): | |
38 |
|
38 | |||
39 | def setup_method(self, method): |
|
39 | def setup_method(self, method): | |
40 | self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) |
|
40 | self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) | |
@@ -48,7 +48,7 b' class TestRepoGroups(TestController):' | |||||
48 | """ |
|
48 | """ | |
49 | Checks the path for existence ! |
|
49 | Checks the path for existence ! | |
50 | """ |
|
50 | """ | |
51 | path = [TESTS_TMP_PATH] + list(path) |
|
51 | path = [base.TESTS_TMP_PATH] + list(path) | |
52 | path = os.path.join(*path) |
|
52 | path = os.path.join(*path) | |
53 | return os.path.isdir(path) |
|
53 | return os.path.isdir(path) | |
54 |
|
54 |
@@ -4,14 +4,14 b' from kallithea.lib.exceptions import Att' | |||||
4 | from kallithea.model.db import Repository |
|
4 | from kallithea.model.db import Repository | |
5 | from kallithea.model.meta import Session |
|
5 | from kallithea.model.meta import Session | |
6 | from kallithea.model.repo import RepoModel |
|
6 | from kallithea.model.repo import RepoModel | |
7 |
from kallithea.tests |
|
7 | from kallithea.tests import base | |
8 | from kallithea.tests.fixture import Fixture |
|
8 | from kallithea.tests.fixture import Fixture | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | fixture = Fixture() |
|
11 | fixture = Fixture() | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | class TestRepos(TestController): |
|
14 | class TestRepos(base.TestController): | |
15 |
|
15 | |||
16 | def teardown_method(self, method): |
|
16 | def teardown_method(self, method): | |
17 | Session.remove() |
|
17 | Session.remove() |
@@ -1,14 +1,14 b'' | |||||
1 | from kallithea.model.db import User, UserGroup |
|
1 | from kallithea.model.db import User, UserGroup | |
2 | from kallithea.model.meta import Session |
|
2 | from kallithea.model.meta import Session | |
3 | from kallithea.model.user_group import UserGroupModel |
|
3 | from kallithea.model.user_group import UserGroupModel | |
4 |
from kallithea.tests |
|
4 | from kallithea.tests import base | |
5 | from kallithea.tests.fixture import Fixture |
|
5 | from kallithea.tests.fixture import Fixture | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | fixture = Fixture() |
|
8 | fixture = Fixture() | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | class TestUserGroups(TestController): |
|
11 | class TestUserGroups(base.TestController): | |
12 |
|
12 | |||
13 | def teardown_method(self, method): |
|
13 | def teardown_method(self, method): | |
14 | # delete all groups |
|
14 | # delete all groups | |
@@ -16,7 +16,7 b' class TestUserGroups(TestController):' | |||||
16 | fixture.destroy_user_group(gr) |
|
16 | fixture.destroy_user_group(gr) | |
17 | Session().commit() |
|
17 | Session().commit() | |
18 |
|
18 | |||
19 | @parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ |
|
19 | @base.parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ | |
20 | ([], [], [], [], []), |
|
20 | ([], [], [], [], []), | |
21 | ([], [u'regular'], [], [], [u'regular']), # no changes of regular |
|
21 | ([], [u'regular'], [], [], [u'regular']), # no changes of regular | |
22 | ([u'some_other'], [], [], [u'some_other'], []), # not added to regular group |
|
22 | ([u'some_other'], [], [], [u'some_other'], []), # not added to regular group | |
@@ -32,7 +32,7 b' class TestUserGroups(TestController):' | |||||
32 | fixture.destroy_user_group(gr) |
|
32 | fixture.destroy_user_group(gr) | |
33 | Session().commit() |
|
33 | Session().commit() | |
34 |
|
34 | |||
35 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
35 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
36 | for gr in pre_existing: |
|
36 | for gr in pre_existing: | |
37 | gr = fixture.create_user_group(gr) |
|
37 | gr = fixture.create_user_group(gr) | |
38 | Session().commit() |
|
38 | Session().commit() | |
@@ -54,6 +54,6 b' class TestUserGroups(TestController):' | |||||
54 | UserGroupModel().enforce_groups(user, groups, 'container') |
|
54 | UserGroupModel().enforce_groups(user, groups, 'container') | |
55 | Session().commit() |
|
55 | Session().commit() | |
56 |
|
56 | |||
57 | user = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
57 | user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
58 | in_groups = user.group_member |
|
58 | in_groups = user.group_member | |
59 | assert sorted(expected) == sorted(x.users_group.users_group_name for x in in_groups) |
|
59 | assert sorted(expected) == sorted(x.users_group.users_group_name for x in in_groups) |
@@ -4,14 +4,14 b' from kallithea.model.db import Permissio' | |||||
4 | from kallithea.model.meta import Session |
|
4 | from kallithea.model.meta import Session | |
5 | from kallithea.model.user import UserModel |
|
5 | from kallithea.model.user import UserModel | |
6 | from kallithea.model.user_group import UserGroupModel |
|
6 | from kallithea.model.user_group import UserGroupModel | |
7 |
from kallithea.tests |
|
7 | from kallithea.tests import base | |
8 | from kallithea.tests.fixture import Fixture |
|
8 | from kallithea.tests.fixture import Fixture | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | fixture = Fixture() |
|
11 | fixture = Fixture() | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | class TestUser(TestController): |
|
14 | class TestUser(base.TestController): | |
15 |
|
15 | |||
16 | @classmethod |
|
16 | @classmethod | |
17 | def setup_class(cls): |
|
17 | def setup_class(cls): | |
@@ -101,7 +101,7 b' class TestUser(TestController):' | |||||
101 | Session().commit() |
|
101 | Session().commit() | |
102 |
|
102 | |||
103 |
|
103 | |||
104 | class TestUsers(TestController): |
|
104 | class TestUsers(base.TestController): | |
105 |
|
105 | |||
106 | def setup_method(self, method): |
|
106 | def setup_method(self, method): | |
107 | self.u1 = UserModel().create_or_update(username=u'u1', |
|
107 | self.u1 = UserModel().create_or_update(username=u'u1', |
@@ -33,7 +33,7 b' from tg.util.webtest import test_context' | |||||
33 |
|
33 | |||
34 | from kallithea.lib.utils2 import AttributeDict |
|
34 | from kallithea.lib.utils2 import AttributeDict | |
35 | from kallithea.model.db import Repository |
|
35 | from kallithea.model.db import Repository | |
36 |
from kallithea.tests |
|
36 | from kallithea.tests import base | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | proto = 'http' |
|
39 | proto = 'http' | |
@@ -91,19 +91,19 b' class FakeUrlGenerator(object):' | |||||
91 | return self.current_url % kwargs |
|
91 | return self.current_url % kwargs | |
92 |
|
92 | |||
93 |
|
93 | |||
94 | class TestLibs(TestController): |
|
94 | class TestLibs(base.TestController): | |
95 |
|
95 | |||
96 | @parametrize('test_url,expected,expected_creds', TEST_URLS) |
|
96 | @base.parametrize('test_url,expected,expected_creds', TEST_URLS) | |
97 | def test_uri_filter(self, test_url, expected, expected_creds): |
|
97 | def test_uri_filter(self, test_url, expected, expected_creds): | |
98 | from kallithea.lib.utils2 import uri_filter |
|
98 | from kallithea.lib.utils2 import uri_filter | |
99 | assert uri_filter(test_url) == expected |
|
99 | assert uri_filter(test_url) == expected | |
100 |
|
100 | |||
101 | @parametrize('test_url,expected,expected_creds', TEST_URLS) |
|
101 | @base.parametrize('test_url,expected,expected_creds', TEST_URLS) | |
102 | def test_credentials_filter(self, test_url, expected, expected_creds): |
|
102 | def test_credentials_filter(self, test_url, expected, expected_creds): | |
103 | from kallithea.lib.utils2 import credentials_filter |
|
103 | from kallithea.lib.utils2 import credentials_filter | |
104 | assert credentials_filter(test_url) == expected_creds |
|
104 | assert credentials_filter(test_url) == expected_creds | |
105 |
|
105 | |||
106 | @parametrize('str_bool,expected', [ |
|
106 | @base.parametrize('str_bool,expected', [ | |
107 | ('t', True), |
|
107 | ('t', True), | |
108 | ('true', True), |
|
108 | ('true', True), | |
109 | ('y', True), |
|
109 | ('y', True), | |
@@ -141,7 +141,7 b' class TestLibs(TestController):' | |||||
141 | 'marian.user', 'marco-polo', 'marco_polo', 'world']) |
|
141 | 'marian.user', 'marco-polo', 'marco_polo', 'world']) | |
142 | assert expected == set(extract_mentioned_usernames(sample)) |
|
142 | assert expected == set(extract_mentioned_usernames(sample)) | |
143 |
|
143 | |||
144 | @parametrize('age_args,expected', [ |
|
144 | @base.parametrize('age_args,expected', [ | |
145 | (dict(), u'just now'), |
|
145 | (dict(), u'just now'), | |
146 | (dict(seconds= -1), u'1 second ago'), |
|
146 | (dict(seconds= -1), u'1 second ago'), | |
147 | (dict(seconds= -60 * 2), u'2 minutes ago'), |
|
147 | (dict(seconds= -60 * 2), u'2 minutes ago'), | |
@@ -165,7 +165,7 b' class TestLibs(TestController):' | |||||
165 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) |
|
165 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) | |
166 | assert age(n + delt(**age_args), now=n) == expected |
|
166 | assert age(n + delt(**age_args), now=n) == expected | |
167 |
|
167 | |||
168 | @parametrize('age_args,expected', [ |
|
168 | @base.parametrize('age_args,expected', [ | |
169 | (dict(), u'just now'), |
|
169 | (dict(), u'just now'), | |
170 | (dict(seconds= -1), u'1 second ago'), |
|
170 | (dict(seconds= -1), u'1 second ago'), | |
171 | (dict(seconds= -60 * 2), u'2 minutes ago'), |
|
171 | (dict(seconds= -60 * 2), u'2 minutes ago'), | |
@@ -190,7 +190,7 b' class TestLibs(TestController):' | |||||
190 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) |
|
190 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) | |
191 | assert age(n + delt(**age_args), show_short_version=True, now=n) == expected |
|
191 | assert age(n + delt(**age_args), show_short_version=True, now=n) == expected | |
192 |
|
192 | |||
193 | @parametrize('age_args,expected', [ |
|
193 | @base.parametrize('age_args,expected', [ | |
194 | (dict(), u'just now'), |
|
194 | (dict(), u'just now'), | |
195 | (dict(seconds=1), u'in 1 second'), |
|
195 | (dict(seconds=1), u'in 1 second'), | |
196 | (dict(seconds=60 * 2), u'in 2 minutes'), |
|
196 | (dict(seconds=60 * 2), u'in 2 minutes'), | |
@@ -270,7 +270,7 b' class TestLibs(TestController):' | |||||
270 | grav = gravatar_url(email_address=em, size=24) |
|
270 | grav = gravatar_url(email_address=em, size=24) | |
271 | assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) |
|
271 | assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) | |
272 |
|
272 | |||
273 | @parametrize('clone_uri_tmpl,repo_name,username,prefix,expected', [ |
|
273 | @base.parametrize('clone_uri_tmpl,repo_name,username,prefix,expected', [ | |
274 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '', 'http://vps1:8000/group/repo1'), |
|
274 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '', 'http://vps1:8000/group/repo1'), | |
275 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', 'username', '', 'http://username@vps1:8000/group/repo1'), |
|
275 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', 'username', '', 'http://username@vps1:8000/group/repo1'), | |
276 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '/prefix', 'http://vps1:8000/prefix/group/repo1'), |
|
276 | (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '/prefix', 'http://vps1:8000/prefix/group/repo1'), | |
@@ -307,7 +307,7 b' class TestLibs(TestController):' | |||||
307 | return tmpl % (url_ or '/repo_name/changeset/%s' % _url, _url) |
|
307 | return tmpl % (url_ or '/repo_name/changeset/%s' % _url, _url) | |
308 | return url_pattern.sub(url_func, text) |
|
308 | return url_pattern.sub(url_func, text) | |
309 |
|
309 | |||
310 | @parametrize('sample,expected', [ |
|
310 | @base.parametrize('sample,expected', [ | |
311 | ("", |
|
311 | ("", | |
312 | ""), |
|
312 | ""), | |
313 | ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68", |
|
313 | ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68", | |
@@ -341,7 +341,7 b' class TestLibs(TestController):' | |||||
341 | from kallithea.lib.helpers import urlify_text |
|
341 | from kallithea.lib.helpers import urlify_text | |
342 | assert urlify_text(sample, 'repo_name') == expected |
|
342 | assert urlify_text(sample, 'repo_name') == expected | |
343 |
|
343 | |||
344 | @parametrize('sample,expected,url_', [ |
|
344 | @base.parametrize('sample,expected,url_', [ | |
345 | ("", |
|
345 | ("", | |
346 | "", |
|
346 | "", | |
347 | ""), |
|
347 | ""), | |
@@ -396,7 +396,7 b' class TestLibs(TestController):' | |||||
396 | from kallithea.lib.helpers import urlify_text |
|
396 | from kallithea.lib.helpers import urlify_text | |
397 | assert urlify_text(sample, 'repo_name', stylize=True) == expected |
|
397 | assert urlify_text(sample, 'repo_name', stylize=True) == expected | |
398 |
|
398 | |||
399 | @parametrize('sample,expected', [ |
|
399 | @base.parametrize('sample,expected', [ | |
400 | ("deadbeefcafe @mention, and http://foo.bar/ yo", |
|
400 | ("deadbeefcafe @mention, and http://foo.bar/ yo", | |
401 | """<a class="changeset_hash" href="/repo_name/changeset/deadbeefcafe">deadbeefcafe</a>""" |
|
401 | """<a class="changeset_hash" href="/repo_name/changeset/deadbeefcafe">deadbeefcafe</a>""" | |
402 | """<a class="message-link" href="#the-link"> <b>@mention</b>, and </a>""" |
|
402 | """<a class="message-link" href="#the-link"> <b>@mention</b>, and </a>""" | |
@@ -409,7 +409,7 b' class TestLibs(TestController):' | |||||
409 | from kallithea.lib.helpers import urlify_text |
|
409 | from kallithea.lib.helpers import urlify_text | |
410 | assert urlify_text(sample, 'repo_name', link_='#the-link') == expected |
|
410 | assert urlify_text(sample, 'repo_name', link_='#the-link') == expected | |
411 |
|
411 | |||
412 | @parametrize('issue_pat,issue_server,issue_sub,sample,expected', [ |
|
412 | @base.parametrize('issue_pat,issue_server,issue_sub,sample,expected', [ | |
413 | (r'#(\d+)', 'http://foo/{repo}/issue/\\1', '#\\1', |
|
413 | (r'#(\d+)', 'http://foo/{repo}/issue/\\1', '#\\1', | |
414 | 'issue #123 and issue#456', |
|
414 | 'issue #123 and issue#456', | |
415 | """issue <a class="issue-tracker-link" href="http://foo/repo_name/issue/123">#123</a> and """ |
|
415 | """issue <a class="issue-tracker-link" href="http://foo/repo_name/issue/123">#123</a> and """ | |
@@ -500,7 +500,7 b' class TestLibs(TestController):' | |||||
500 | with mock.patch('kallithea.CONFIG', config_stub): |
|
500 | with mock.patch('kallithea.CONFIG', config_stub): | |
501 | assert urlify_text(sample, 'repo_name') == expected |
|
501 | assert urlify_text(sample, 'repo_name') == expected | |
502 |
|
502 | |||
503 | @parametrize('sample,expected', [ |
|
503 | @base.parametrize('sample,expected', [ | |
504 | ('abc X5', 'abc <a class="issue-tracker-link" href="http://main/repo_name/main/5/">#5</a>'), |
|
504 | ('abc X5', 'abc <a class="issue-tracker-link" href="http://main/repo_name/main/5/">#5</a>'), | |
505 | ('abc pullrequest #6 xyz', 'abc <a class="issue-tracker-link" href="http://pr/repo_name/pr/6">PR#6</a> xyz'), |
|
505 | ('abc pullrequest #6 xyz', 'abc <a class="issue-tracker-link" href="http://pr/repo_name/pr/6">PR#6</a> xyz'), | |
506 | ('pull request7 #', '<a class="issue-tracker-link" href="http://pr/repo_name/pr/7">PR#7</a> #'), |
|
506 | ('pull request7 #', '<a class="issue-tracker-link" href="http://pr/repo_name/pr/7">PR#7</a> #'), | |
@@ -533,7 +533,7 b' class TestLibs(TestController):' | |||||
533 | with mock.patch('kallithea.CONFIG', config_stub): |
|
533 | with mock.patch('kallithea.CONFIG', config_stub): | |
534 | assert urlify_text(sample, 'repo_name') == expected |
|
534 | assert urlify_text(sample, 'repo_name') == expected | |
535 |
|
535 | |||
536 | @parametrize('test,expected', [ |
|
536 | @base.parametrize('test,expected', [ | |
537 | ("", None), |
|
537 | ("", None), | |
538 | ("/_2", None), |
|
538 | ("/_2", None), | |
539 | ("_2", 2), |
|
539 | ("_2", 2), | |
@@ -542,9 +542,9 b' class TestLibs(TestController):' | |||||
542 | def test_get_permanent_id(self, test, expected): |
|
542 | def test_get_permanent_id(self, test, expected): | |
543 | from kallithea.lib.utils import _get_permanent_id |
|
543 | from kallithea.lib.utils import _get_permanent_id | |
544 | extracted = _get_permanent_id(test) |
|
544 | extracted = _get_permanent_id(test) | |
545 | assert extracted == expected, 'url:%s, got:`%s` expected: `%s`' % (test, _test, expected) |
|
545 | assert extracted == expected, 'url:%s, got:`%s` expected: `%s`' % (test, base._test, expected) | |
546 |
|
546 | |||
547 | @parametrize('test,expected', [ |
|
547 | @base.parametrize('test,expected', [ | |
548 | ("", ""), |
|
548 | ("", ""), | |
549 | ("/", "/"), |
|
549 | ("/", "/"), | |
550 | ("/_ID", '/_ID'), |
|
550 | ("/_ID", '/_ID'), | |
@@ -555,14 +555,14 b' class TestLibs(TestController):' | |||||
555 | ("_IDa", '_IDa'), |
|
555 | ("_IDa", '_IDa'), | |
556 | ]) |
|
556 | ]) | |
557 | def test_fix_repo_id_name(self, test, expected): |
|
557 | def test_fix_repo_id_name(self, test, expected): | |
558 | repo = Repository.get_by_repo_name(HG_REPO) |
|
558 | repo = Repository.get_by_repo_name(base.HG_REPO) | |
559 | test = test.replace('ID', str(repo.repo_id)) |
|
559 | test = test.replace('ID', str(repo.repo_id)) | |
560 | expected = expected.replace('NAME', repo.repo_name).replace('ID', str(repo.repo_id)) |
|
560 | expected = expected.replace('NAME', repo.repo_name).replace('ID', str(repo.repo_id)) | |
561 | from kallithea.lib.utils import fix_repo_id_name |
|
561 | from kallithea.lib.utils import fix_repo_id_name | |
562 | replaced = fix_repo_id_name(test) |
|
562 | replaced = fix_repo_id_name(test) | |
563 | assert replaced == expected, 'url:%s, got:`%s` expected: `%s`' % (test, replaced, expected) |
|
563 | assert replaced == expected, 'url:%s, got:`%s` expected: `%s`' % (test, replaced, expected) | |
564 |
|
564 | |||
565 | @parametrize('canonical,test,expected', [ |
|
565 | @base.parametrize('canonical,test,expected', [ | |
566 | ('http://www.example.org/', '/abc/xyz', 'http://www.example.org/abc/xyz'), |
|
566 | ('http://www.example.org/', '/abc/xyz', 'http://www.example.org/abc/xyz'), | |
567 | ('http://www.example.org', '/abc/xyz', 'http://www.example.org/abc/xyz'), |
|
567 | ('http://www.example.org', '/abc/xyz', 'http://www.example.org/abc/xyz'), | |
568 | ('http://www.example.org', '/abc/xyz/', 'http://www.example.org/abc/xyz/'), |
|
568 | ('http://www.example.org', '/abc/xyz/', 'http://www.example.org/abc/xyz/'), | |
@@ -590,7 +590,7 b' class TestLibs(TestController):' | |||||
590 | with mock.patch('kallithea.CONFIG', config_mock): |
|
590 | with mock.patch('kallithea.CONFIG', config_mock): | |
591 | assert canonical_url(test) == expected |
|
591 | assert canonical_url(test) == expected | |
592 |
|
592 | |||
593 | @parametrize('canonical,expected', [ |
|
593 | @base.parametrize('canonical,expected', [ | |
594 | ('http://www.example.org', 'www.example.org'), |
|
594 | ('http://www.example.org', 'www.example.org'), | |
595 | ('http://www.example.org/repos/', 'www.example.org'), |
|
595 | ('http://www.example.org/repos/', 'www.example.org'), | |
596 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), |
|
596 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), |
@@ -2,7 +2,7 b' import mock' | |||||
2 |
|
2 | |||
3 | import kallithea |
|
3 | import kallithea | |
4 | from kallithea.model.db import User |
|
4 | from kallithea.model.db import User | |
5 |
from kallithea.tests |
|
5 | from kallithea.tests import base | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | class smtplib_mock(object): |
|
8 | class smtplib_mock(object): | |
@@ -25,7 +25,7 b' class smtplib_mock(object):' | |||||
25 |
|
25 | |||
26 |
|
26 | |||
27 | @mock.patch('kallithea.lib.rcmail.smtp_mailer.smtplib', smtplib_mock) |
|
27 | @mock.patch('kallithea.lib.rcmail.smtp_mailer.smtplib', smtplib_mock) | |
28 | class TestMail(TestController): |
|
28 | class TestMail(base.TestController): | |
29 |
|
29 | |||
30 | def test_send_mail_trivial(self): |
|
30 | def test_send_mail_trivial(self): | |
31 | mailserver = 'smtp.mailserver.org' |
|
31 | mailserver = 'smtp.mailserver.org' | |
@@ -66,7 +66,7 b' class TestMail(TestController):' | |||||
66 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): |
|
66 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): | |
67 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) |
|
67 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) | |
68 |
|
68 | |||
69 | assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL, email_to]) |
|
69 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL, email_to]) | |
70 | assert smtplib_mock.lastsender == envelope_from |
|
70 | assert smtplib_mock.lastsender == envelope_from | |
71 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg |
|
71 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg | |
72 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg |
|
72 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg | |
@@ -90,7 +90,7 b' class TestMail(TestController):' | |||||
90 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): |
|
90 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): | |
91 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) |
|
91 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) | |
92 |
|
92 | |||
93 | assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL] + email_to.split(',')) |
|
93 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL] + email_to.split(',')) | |
94 | assert smtplib_mock.lastsender == envelope_from |
|
94 | assert smtplib_mock.lastsender == envelope_from | |
95 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg |
|
95 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg | |
96 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg |
|
96 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg | |
@@ -112,7 +112,7 b' class TestMail(TestController):' | |||||
112 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): |
|
112 | with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): | |
113 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) |
|
113 | kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) | |
114 |
|
114 | |||
115 | assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL]) |
|
115 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL]) | |
116 | assert smtplib_mock.lastsender == envelope_from |
|
116 | assert smtplib_mock.lastsender == envelope_from | |
117 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg |
|
117 | assert 'From: %s' % envelope_from in smtplib_mock.lastmsg | |
118 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg |
|
118 | assert 'Subject: %s' % subject in smtplib_mock.lastmsg | |
@@ -126,7 +126,7 b' class TestMail(TestController):' | |||||
126 | subject = 'subject' |
|
126 | subject = 'subject' | |
127 | body = 'body' |
|
127 | body = 'body' | |
128 | html_body = 'html_body' |
|
128 | html_body = 'html_body' | |
129 | author = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
129 | author = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
130 |
|
130 | |||
131 | config_mock = { |
|
131 | config_mock = { | |
132 | 'smtp_server': mailserver, |
|
132 | 'smtp_server': mailserver, | |
@@ -150,7 +150,7 b' class TestMail(TestController):' | |||||
150 | subject = 'subject' |
|
150 | subject = 'subject' | |
151 | body = 'body' |
|
151 | body = 'body' | |
152 | html_body = 'html_body' |
|
152 | html_body = 'html_body' | |
153 | author = User.get_by_username(TEST_USER_REGULAR_LOGIN) |
|
153 | author = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) | |
154 |
|
154 | |||
155 | config_mock = { |
|
155 | config_mock = { | |
156 | 'smtp_server': mailserver, |
|
156 | 'smtp_server': mailserver, |
@@ -6,7 +6,7 b' from kallithea.model import validators a' | |||||
6 | from kallithea.model.meta import Session |
|
6 | from kallithea.model.meta import Session | |
7 | from kallithea.model.repo_group import RepoGroupModel |
|
7 | from kallithea.model.repo_group import RepoGroupModel | |
8 | from kallithea.model.user_group import UserGroupModel |
|
8 | from kallithea.model.user_group import UserGroupModel | |
9 |
from kallithea.tests |
|
9 | from kallithea.tests import base | |
10 | from kallithea.tests.fixture import Fixture |
|
10 | from kallithea.tests.fixture import Fixture | |
11 |
|
11 | |||
12 |
|
12 | |||
@@ -14,7 +14,7 b' fixture = Fixture()' | |||||
14 |
|
14 | |||
15 |
|
15 | |||
16 | @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods |
|
16 | @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods | |
17 | class TestRepoGroups(TestController): |
|
17 | class TestRepoGroups(base.TestController): | |
18 |
|
18 | |||
19 | def teardown_method(self, method): |
|
19 | def teardown_method(self, method): | |
20 | Session.remove() |
|
20 | Session.remove() | |
@@ -40,7 +40,7 b' class TestRepoGroups(TestController):' | |||||
40 | with pytest.raises(formencode.Invalid): |
|
40 | with pytest.raises(formencode.Invalid): | |
41 | validator.to_python('.,') |
|
41 | validator.to_python('.,') | |
42 | with pytest.raises(formencode.Invalid): |
|
42 | with pytest.raises(formencode.Invalid): | |
43 | validator.to_python(TEST_USER_ADMIN_LOGIN) |
|
43 | validator.to_python(base.TEST_USER_ADMIN_LOGIN) | |
44 | assert 'test' == validator.to_python('test') |
|
44 | assert 'test' == validator.to_python('test') | |
45 |
|
45 | |||
46 | validator = v.ValidUsername(edit=True, old_data={'user_id': 1}) |
|
46 | validator = v.ValidUsername(edit=True, old_data={'user_id': 1}) | |
@@ -49,7 +49,7 b' class TestRepoGroups(TestController):' | |||||
49 | validator = v.ValidRepoUser() |
|
49 | validator = v.ValidRepoUser() | |
50 | with pytest.raises(formencode.Invalid): |
|
50 | with pytest.raises(formencode.Invalid): | |
51 | validator.to_python('nouser') |
|
51 | validator.to_python('nouser') | |
52 | assert TEST_USER_ADMIN_LOGIN == validator.to_python(TEST_USER_ADMIN_LOGIN) |
|
52 | assert base.TEST_USER_ADMIN_LOGIN == validator.to_python(base.TEST_USER_ADMIN_LOGIN) | |
53 |
|
53 | |||
54 | def test_ValidUserGroup(self): |
|
54 | def test_ValidUserGroup(self): | |
55 | validator = v.ValidUserGroup() |
|
55 | validator = v.ValidUserGroup() | |
@@ -82,11 +82,11 b' class TestRepoGroups(TestController):' | |||||
82 | validator = v.ValidRepoGroup() |
|
82 | validator = v.ValidRepoGroup() | |
83 | model = RepoGroupModel() |
|
83 | model = RepoGroupModel() | |
84 | with pytest.raises(formencode.Invalid): |
|
84 | with pytest.raises(formencode.Invalid): | |
85 | validator.to_python({'group_name': HG_REPO, }) |
|
85 | validator.to_python({'group_name': base.HG_REPO, }) | |
86 | gr = model.create(group_name=u'test_gr', group_description=u'desc', |
|
86 | gr = model.create(group_name=u'test_gr', group_description=u'desc', | |
87 | parent=None, |
|
87 | parent=None, | |
88 | just_db=True, |
|
88 | just_db=True, | |
89 | owner=TEST_USER_ADMIN_LOGIN) |
|
89 | owner=base.TEST_USER_ADMIN_LOGIN) | |
90 | with pytest.raises(formencode.Invalid): |
|
90 | with pytest.raises(formencode.Invalid): | |
91 | validator.to_python({'group_name': gr.group_name, }) |
|
91 | validator.to_python({'group_name': gr.group_name, }) | |
92 |
|
92 | |||
@@ -127,8 +127,8 b' class TestRepoGroups(TestController):' | |||||
127 | def test_ValidAuth(self): |
|
127 | def test_ValidAuth(self): | |
128 | validator = v.ValidAuth() |
|
128 | validator = v.ValidAuth() | |
129 | valid_creds = { |
|
129 | valid_creds = { | |
130 | 'username': TEST_USER_REGULAR2_LOGIN, |
|
130 | 'username': base.TEST_USER_REGULAR2_LOGIN, | |
131 | 'password': TEST_USER_REGULAR2_PASS, |
|
131 | 'password': base.TEST_USER_REGULAR2_PASS, | |
132 | } |
|
132 | } | |
133 | invalid_creds = { |
|
133 | invalid_creds = { | |
134 | 'username': 'err', |
|
134 | 'username': 'err', | |
@@ -145,12 +145,12 b' class TestRepoGroups(TestController):' | |||||
145 | validator.to_python({'repo_name': ''}) |
|
145 | validator.to_python({'repo_name': ''}) | |
146 |
|
146 | |||
147 | with pytest.raises(formencode.Invalid): |
|
147 | with pytest.raises(formencode.Invalid): | |
148 | validator.to_python({'repo_name': HG_REPO}) |
|
148 | validator.to_python({'repo_name': base.HG_REPO}) | |
149 |
|
149 | |||
150 | gr = RepoGroupModel().create(group_name=u'group_test', |
|
150 | gr = RepoGroupModel().create(group_name=u'group_test', | |
151 | group_description=u'desc', |
|
151 | group_description=u'desc', | |
152 | parent=None, |
|
152 | parent=None, | |
153 | owner=TEST_USER_ADMIN_LOGIN) |
|
153 | owner=base.TEST_USER_ADMIN_LOGIN) | |
154 | with pytest.raises(formencode.Invalid): |
|
154 | with pytest.raises(formencode.Invalid): | |
155 | validator.to_python({'repo_name': gr.group_name}) |
|
155 | validator.to_python({'repo_name': gr.group_name}) | |
156 |
|
156 | |||
@@ -163,7 +163,7 b' class TestRepoGroups(TestController):' | |||||
163 | # this uses ValidRepoName validator |
|
163 | # this uses ValidRepoName validator | |
164 | assert True |
|
164 | assert True | |
165 |
|
165 | |||
166 | @parametrize('name,expected', [ |
|
166 | @base.parametrize('name,expected', [ | |
167 | ('test', 'test'), ('lolz!', 'lolz'), (' aavv', 'aavv'), |
|
167 | ('test', 'test'), ('lolz!', 'lolz'), (' aavv', 'aavv'), | |
168 | ('ala ma kota', 'ala-ma-kota'), ('@nooo', 'nooo'), |
|
168 | ('ala ma kota', 'ala-ma-kota'), ('@nooo', 'nooo'), | |
169 | ('$!haha lolz !', 'haha-lolz'), ('$$$$$', ''), ('{}OK!', 'OK'), |
|
169 | ('$!haha lolz !', 'haha-lolz'), ('$$$$$', ''), ('{}OK!', 'OK'), | |
@@ -196,7 +196,7 b' class TestRepoGroups(TestController):' | |||||
196 |
|
196 | |||
197 | def test_ValidPath(self): |
|
197 | def test_ValidPath(self): | |
198 | validator = v.ValidPath() |
|
198 | validator = v.ValidPath() | |
199 | assert TESTS_TMP_PATH == validator.to_python(TESTS_TMP_PATH) |
|
199 | assert base.TESTS_TMP_PATH == validator.to_python(base.TESTS_TMP_PATH) | |
200 | with pytest.raises(formencode.Invalid): |
|
200 | with pytest.raises(formencode.Invalid): | |
201 | validator.to_python('/no_such_dir') |
|
201 | validator.to_python('/no_such_dir') | |
202 |
|
202 | |||
@@ -205,20 +205,20 b' class TestRepoGroups(TestController):' | |||||
205 |
|
205 | |||
206 | assert 'mail@python.org' == validator.to_python('MaiL@Python.org') |
|
206 | assert 'mail@python.org' == validator.to_python('MaiL@Python.org') | |
207 |
|
207 | |||
208 | email = TEST_USER_REGULAR2_EMAIL |
|
208 | email = base.TEST_USER_REGULAR2_EMAIL | |
209 | with pytest.raises(formencode.Invalid): |
|
209 | with pytest.raises(formencode.Invalid): | |
210 | validator.to_python(email) |
|
210 | validator.to_python(email) | |
211 |
|
211 | |||
212 | def test_ValidSystemEmail(self): |
|
212 | def test_ValidSystemEmail(self): | |
213 | validator = v.ValidSystemEmail() |
|
213 | validator = v.ValidSystemEmail() | |
214 | email = TEST_USER_REGULAR2_EMAIL |
|
214 | email = base.TEST_USER_REGULAR2_EMAIL | |
215 |
|
215 | |||
216 | assert email == validator.to_python(email) |
|
216 | assert email == validator.to_python(email) | |
217 | with pytest.raises(formencode.Invalid): |
|
217 | with pytest.raises(formencode.Invalid): | |
218 | validator.to_python('err') |
|
218 | validator.to_python('err') | |
219 |
|
219 | |||
220 | def test_LdapLibValidator(self): |
|
220 | def test_LdapLibValidator(self): | |
221 | if ldap_lib_installed: |
|
221 | if base.ldap_lib_installed: | |
222 | validator = v.LdapLibValidator() |
|
222 | validator = v.LdapLibValidator() | |
223 | assert "DN" == validator.to_python('DN') |
|
223 | assert "DN" == validator.to_python('DN') | |
224 | else: |
|
224 | else: |
@@ -44,7 +44,7 b' from kallithea.model.db import CacheInva' | |||||
44 | from kallithea.model.meta import Session |
|
44 | from kallithea.model.meta import Session | |
45 | from kallithea.model.ssh_key import SshKeyModel |
|
45 | from kallithea.model.ssh_key import SshKeyModel | |
46 | from kallithea.model.user import UserModel |
|
46 | from kallithea.model.user import UserModel | |
47 |
from kallithea.tests |
|
47 | from kallithea.tests import base | |
48 | from kallithea.tests.fixture import Fixture |
|
48 | from kallithea.tests.fixture import Fixture | |
49 |
|
49 | |||
50 |
|
50 | |||
@@ -65,12 +65,12 b' class HttpVcsTest(object):' | |||||
65 |
|
65 | |||
66 | class SshVcsTest(object): |
|
66 | class SshVcsTest(object): | |
67 | public_keys = { |
|
67 | public_keys = { | |
68 | TEST_USER_REGULAR_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', |
|
68 | base.TEST_USER_REGULAR_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', | |
69 | TEST_USER_ADMIN_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', |
|
69 | base.TEST_USER_ADMIN_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | @classmethod |
|
72 | @classmethod | |
73 | def repo_url_param(cls, webserver, repo_name, username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS, client_ip=IP_ADDR): |
|
73 | def repo_url_param(cls, webserver, repo_name, username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS, client_ip=base.IP_ADDR): | |
74 | user = User.get_by_username(username) |
|
74 | user = User.get_by_username(username) | |
75 | if user.ssh_keys: |
|
75 | if user.ssh_keys: | |
76 | ssh_key = user.ssh_keys[0] |
|
76 | ssh_key = user.ssh_keys[0] | |
@@ -84,11 +84,11 b' class SshVcsTest(object):' | |||||
84 | # Mixins for using Mercurial and Git |
|
84 | # Mixins for using Mercurial and Git | |
85 | class HgVcsTest(object): |
|
85 | class HgVcsTest(object): | |
86 | repo_type = 'hg' |
|
86 | repo_type = 'hg' | |
87 | repo_name = HG_REPO |
|
87 | repo_name = base.HG_REPO | |
88 |
|
88 | |||
89 | class GitVcsTest(object): |
|
89 | class GitVcsTest(object): | |
90 | repo_type = 'git' |
|
90 | repo_type = 'git' | |
91 | repo_name = GIT_REPO |
|
91 | repo_name = base.GIT_REPO | |
92 |
|
92 | |||
93 | # Combine mixins to give the combinations we want to parameterize tests with |
|
93 | # Combine mixins to give the combinations we want to parameterize tests with | |
94 | class HgHttpVcsTest(HgVcsTest, HttpVcsTest): |
|
94 | class HgHttpVcsTest(HgVcsTest, HttpVcsTest): | |
@@ -119,17 +119,17 b' class GitSshVcsTest(GitVcsTest, SshVcsTe' | |||||
119 | ssh_key.user_ssh_key_id) |
|
119 | ssh_key.user_ssh_key_id) | |
120 | return "ssh://someuser@somehost/%s""" % repo_name |
|
120 | return "ssh://someuser@somehost/%s""" % repo_name | |
121 |
|
121 | |||
122 | parametrize_vcs_test = parametrize('vt', [ |
|
122 | parametrize_vcs_test = base.parametrize('vt', [ | |
123 | HgHttpVcsTest, |
|
123 | HgHttpVcsTest, | |
124 | GitHttpVcsTest, |
|
124 | GitHttpVcsTest, | |
125 | HgSshVcsTest, |
|
125 | HgSshVcsTest, | |
126 | GitSshVcsTest, |
|
126 | GitSshVcsTest, | |
127 | ]) |
|
127 | ]) | |
128 | parametrize_vcs_test_hg = parametrize('vt', [ |
|
128 | parametrize_vcs_test_hg = base.parametrize('vt', [ | |
129 | HgHttpVcsTest, |
|
129 | HgHttpVcsTest, | |
130 | HgSshVcsTest, |
|
130 | HgSshVcsTest, | |
131 | ]) |
|
131 | ]) | |
132 | parametrize_vcs_test_http = parametrize('vt', [ |
|
132 | parametrize_vcs_test_http = base.parametrize('vt', [ | |
133 | HgHttpVcsTest, |
|
133 | HgHttpVcsTest, | |
134 | GitHttpVcsTest, |
|
134 | GitHttpVcsTest, | |
135 | ]) |
|
135 | ]) | |
@@ -167,7 +167,7 b' class Command(object):' | |||||
167 |
|
167 | |||
168 |
|
168 | |||
169 | def _get_tmp_dir(prefix='vcs_operations-', suffix=''): |
|
169 | def _get_tmp_dir(prefix='vcs_operations-', suffix=''): | |
170 | return tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix=prefix, suffix=suffix) |
|
170 | return tempfile.mkdtemp(dir=base.TESTS_TMP_PATH, prefix=prefix, suffix=suffix) | |
171 |
|
171 | |||
172 |
|
172 | |||
173 | def _add_files(vcs, dest_dir, files_no=3): |
|
173 | def _add_files(vcs, dest_dir, files_no=3): | |
@@ -243,7 +243,7 b' def _check_proper_git_push(stdout, stder' | |||||
243 |
|
243 | |||
244 |
|
244 | |||
245 | @pytest.mark.usefixtures("test_context_fixture") |
|
245 | @pytest.mark.usefixtures("test_context_fixture") | |
246 | class TestVCSOperations(TestController): |
|
246 | class TestVCSOperations(base.TestController): | |
247 |
|
247 | |||
248 | @classmethod |
|
248 | @classmethod | |
249 | def setup_class(cls): |
|
249 | def setup_class(cls): | |
@@ -263,16 +263,16 b' class TestVCSOperations(TestController):' | |||||
263 | @pytest.fixture(scope="module") |
|
263 | @pytest.fixture(scope="module") | |
264 | def testfork(self): |
|
264 | def testfork(self): | |
265 | # create fork so the repo stays untouched |
|
265 | # create fork so the repo stays untouched | |
266 | git_fork_name = u'%s_fork%s' % (GIT_REPO, _RandomNameSequence().next()) |
|
266 | git_fork_name = u'%s_fork%s' % (base.GIT_REPO, _RandomNameSequence().next()) | |
267 | fixture.create_fork(GIT_REPO, git_fork_name) |
|
267 | fixture.create_fork(base.GIT_REPO, git_fork_name) | |
268 | hg_fork_name = u'%s_fork%s' % (HG_REPO, _RandomNameSequence().next()) |
|
268 | hg_fork_name = u'%s_fork%s' % (base.HG_REPO, _RandomNameSequence().next()) | |
269 | fixture.create_fork(HG_REPO, hg_fork_name) |
|
269 | fixture.create_fork(base.HG_REPO, hg_fork_name) | |
270 | return {'git': git_fork_name, 'hg': hg_fork_name} |
|
270 | return {'git': git_fork_name, 'hg': hg_fork_name} | |
271 |
|
271 | |||
272 | @parametrize_vcs_test |
|
272 | @parametrize_vcs_test | |
273 | def test_clone_repo_by_admin(self, webserver, vt): |
|
273 | def test_clone_repo_by_admin(self, webserver, vt): | |
274 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
274 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
275 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) |
|
275 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) | |
276 |
|
276 | |||
277 | if vt.repo_type == 'git': |
|
277 | if vt.repo_type == 'git': | |
278 | assert 'Cloning into' in stdout + stderr |
|
278 | assert 'Cloning into' in stdout + stderr | |
@@ -287,26 +287,26 b' class TestVCSOperations(TestController):' | |||||
287 | @parametrize_vcs_test_http |
|
287 | @parametrize_vcs_test_http | |
288 | def test_clone_wrong_credentials(self, webserver, vt): |
|
288 | def test_clone_wrong_credentials(self, webserver, vt): | |
289 | clone_url = vt.repo_url_param(webserver, vt.repo_name, password='bad!') |
|
289 | clone_url = vt.repo_url_param(webserver, vt.repo_name, password='bad!') | |
290 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
|
290 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) | |
291 | if vt.repo_type == 'git': |
|
291 | if vt.repo_type == 'git': | |
292 | assert 'fatal: Authentication failed' in stderr |
|
292 | assert 'fatal: Authentication failed' in stderr | |
293 | elif vt.repo_type == 'hg': |
|
293 | elif vt.repo_type == 'hg': | |
294 | assert 'abort: authorization failed' in stderr |
|
294 | assert 'abort: authorization failed' in stderr | |
295 |
|
295 | |||
296 | def test_clone_git_dir_as_hg(self, webserver): |
|
296 | def test_clone_git_dir_as_hg(self, webserver): | |
297 | clone_url = HgHttpVcsTest.repo_url_param(webserver, GIT_REPO) |
|
297 | clone_url = HgHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) | |
298 | stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
|
298 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute('hg clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) | |
299 | assert 'HTTP Error 404: Not Found' in stderr or "not a valid repository" in stdout and 'abort:' in stderr |
|
299 | assert 'HTTP Error 404: Not Found' in stderr or "not a valid repository" in stdout and 'abort:' in stderr | |
300 |
|
300 | |||
301 | def test_clone_hg_repo_as_git(self, webserver): |
|
301 | def test_clone_hg_repo_as_git(self, webserver): | |
302 | clone_url = GitHttpVcsTest.repo_url_param(webserver, HG_REPO) |
|
302 | clone_url = GitHttpVcsTest.repo_url_param(webserver, base.HG_REPO) | |
303 | stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
|
303 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) | |
304 | assert 'not found' in stderr |
|
304 | assert 'not found' in stderr | |
305 |
|
305 | |||
306 | @parametrize_vcs_test |
|
306 | @parametrize_vcs_test | |
307 | def test_clone_non_existing_path(self, webserver, vt): |
|
307 | def test_clone_non_existing_path(self, webserver, vt): | |
308 | clone_url = vt.repo_url_param(webserver, 'trololo') |
|
308 | clone_url = vt.repo_url_param(webserver, 'trololo') | |
309 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
|
309 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) | |
310 | if vt.repo_type == 'git': |
|
310 | if vt.repo_type == 'git': | |
311 | assert 'not found' in stderr or 'abort: Access to %r denied' % 'trololo' in stderr |
|
311 | assert 'not found' in stderr or 'abort: Access to %r denied' % 'trololo' in stderr | |
312 | elif vt.repo_type == 'hg': |
|
312 | elif vt.repo_type == 'hg': | |
@@ -320,13 +320,13 b' class TestVCSOperations(TestController):' | |||||
320 |
|
320 | |||
321 | # Create an empty server repo using the API |
|
321 | # Create an empty server repo using the API | |
322 | repo_name = u'new_%s_%s' % (vt.repo_type, _RandomNameSequence().next()) |
|
322 | repo_name = u'new_%s_%s' % (vt.repo_type, _RandomNameSequence().next()) | |
323 | usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
323 | usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) | |
324 | params = { |
|
324 | params = { | |
325 | "id": 7, |
|
325 | "id": 7, | |
326 | "api_key": usr.api_key, |
|
326 | "api_key": usr.api_key, | |
327 | "method": 'create_repo', |
|
327 | "method": 'create_repo', | |
328 | "args": dict(repo_name=repo_name, |
|
328 | "args": dict(repo_name=repo_name, | |
329 | owner=TEST_USER_ADMIN_LOGIN, |
|
329 | owner=base.TEST_USER_ADMIN_LOGIN, | |
330 | repo_type=vt.repo_type), |
|
330 | repo_type=vt.repo_type), | |
331 | } |
|
331 | } | |
332 | req = urllib2.Request( |
|
332 | req = urllib2.Request( | |
@@ -342,7 +342,7 b' class TestVCSOperations(TestController):' | |||||
342 | # Create local clone of the empty server repo |
|
342 | # Create local clone of the empty server repo | |
343 | local_clone_dir = _get_tmp_dir() |
|
343 | local_clone_dir = _get_tmp_dir() | |
344 | clone_url = vt.repo_url_param(webserver, repo_name) |
|
344 | clone_url = vt.repo_url_param(webserver, repo_name) | |
345 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, local_clone_dir) |
|
345 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, local_clone_dir) | |
346 |
|
346 | |||
347 | # Make 3 commits and push to the empty server repo. |
|
347 | # Make 3 commits and push to the empty server repo. | |
348 | # The server repo doesn't have any other heads than the |
|
348 | # The server repo doesn't have any other heads than the | |
@@ -379,7 +379,7 b' class TestVCSOperations(TestController):' | |||||
379 |
|
379 | |||
380 | dest_dir = _get_tmp_dir() |
|
380 | dest_dir = _get_tmp_dir() | |
381 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
381 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
382 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
382 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
383 |
|
383 | |||
384 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) |
|
384 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) | |
385 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url=clone_url) |
|
385 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url=clone_url) | |
@@ -401,7 +401,7 b' class TestVCSOperations(TestController):' | |||||
401 | Session().commit() |
|
401 | Session().commit() | |
402 |
|
402 | |||
403 | dest_dir = _get_tmp_dir() |
|
403 | dest_dir = _get_tmp_dir() | |
404 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'init', dest_dir) |
|
404 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'init', dest_dir) | |
405 |
|
405 | |||
406 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
406 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
407 | stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url) |
|
407 | stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url) | |
@@ -429,7 +429,7 b' class TestVCSOperations(TestController):' | |||||
429 |
|
429 | |||
430 | dest_dir = _get_tmp_dir() |
|
430 | dest_dir = _get_tmp_dir() | |
431 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) |
|
431 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) | |
432 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
432 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
433 |
|
433 | |||
434 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, files_no=1, clone_url=clone_url) |
|
434 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, files_no=1, clone_url=clone_url) | |
435 |
|
435 | |||
@@ -447,7 +447,7 b' class TestVCSOperations(TestController):' | |||||
447 | def test_push_wrong_credentials(self, webserver, vt): |
|
447 | def test_push_wrong_credentials(self, webserver, vt): | |
448 | dest_dir = _get_tmp_dir() |
|
448 | dest_dir = _get_tmp_dir() | |
449 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
449 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
450 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
450 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
451 |
|
451 | |||
452 | clone_url = webserver.repo_url(vt.repo_name, username='bad', password='name') |
|
452 | clone_url = webserver.repo_url(vt.repo_name, username='bad', password='name') | |
453 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, |
|
453 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, | |
@@ -464,8 +464,8 b' class TestVCSOperations(TestController):' | |||||
464 | Session().commit() |
|
464 | Session().commit() | |
465 |
|
465 | |||
466 | dest_dir = _get_tmp_dir() |
|
466 | dest_dir = _get_tmp_dir() | |
467 | clone_url = vt.repo_url_param(webserver, vt.repo_name, username=TEST_USER_REGULAR_LOGIN, password=TEST_USER_REGULAR_PASS) |
|
467 | clone_url = vt.repo_url_param(webserver, vt.repo_name, username=base.TEST_USER_REGULAR_LOGIN, password=base.TEST_USER_REGULAR_PASS) | |
468 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
468 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
469 |
|
469 | |||
470 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, ignoreReturnCode=True, clone_url=clone_url) |
|
470 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, ignoreReturnCode=True, clone_url=clone_url) | |
471 |
|
471 | |||
@@ -482,7 +482,7 b' class TestVCSOperations(TestController):' | |||||
482 | def test_push_back_to_wrong_url(self, webserver, vt): |
|
482 | def test_push_back_to_wrong_url(self, webserver, vt): | |
483 | dest_dir = _get_tmp_dir() |
|
483 | dest_dir = _get_tmp_dir() | |
484 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
484 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
485 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
485 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
486 |
|
486 | |||
487 | stdout, stderr = _add_files_and_push( |
|
487 | stdout, stderr = _add_files_and_push( | |
488 | webserver, vt, dest_dir, clone_url='http://%s:%s/tmp' % ( |
|
488 | webserver, vt, dest_dir, clone_url='http://%s:%s/tmp' % ( | |
@@ -499,12 +499,12 b' class TestVCSOperations(TestController):' | |||||
499 | user_model = UserModel() |
|
499 | user_model = UserModel() | |
500 | try: |
|
500 | try: | |
501 | # Add IP constraint that excludes the test context: |
|
501 | # Add IP constraint that excludes the test context: | |
502 | user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
|
502 | user_model.add_extra_ip(base.TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | |
503 | Session().commit() |
|
503 | Session().commit() | |
504 | # IP permissions are cached, need to wait for the cache in the server process to expire |
|
504 | # IP permissions are cached, need to wait for the cache in the server process to expire | |
505 | time.sleep(1.5) |
|
505 | time.sleep(1.5) | |
506 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
506 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
507 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) |
|
507 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) | |
508 | if vt.repo_type == 'git': |
|
508 | if vt.repo_type == 'git': | |
509 | # The message apparently changed in Git 1.8.3, so match it loosely. |
|
509 | # The message apparently changed in Git 1.8.3, so match it loosely. | |
510 | assert re.search(r'\b403\b', stderr) or 'abort: User test_admin from 127.0.0.127 cannot be authorized' in stderr |
|
510 | assert re.search(r'\b403\b', stderr) or 'abort: User test_admin from 127.0.0.127 cannot be authorized' in stderr | |
@@ -519,7 +519,7 b' class TestVCSOperations(TestController):' | |||||
519 | time.sleep(1.5) |
|
519 | time.sleep(1.5) | |
520 |
|
520 | |||
521 | clone_url = vt.repo_url_param(webserver, vt.repo_name) |
|
521 | clone_url = vt.repo_url_param(webserver, vt.repo_name) | |
522 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) |
|
522 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) | |
523 |
|
523 | |||
524 | if vt.repo_type == 'git': |
|
524 | if vt.repo_type == 'git': | |
525 | assert 'Cloning into' in stdout + stderr |
|
525 | assert 'Cloning into' in stdout + stderr | |
@@ -538,9 +538,9 b' class TestVCSOperations(TestController):' | |||||
538 | Ui.create_or_update_hook('preoutgoing.testhook', 'python:kallithea.tests.fixture.failing_test_hook') |
|
538 | Ui.create_or_update_hook('preoutgoing.testhook', 'python:kallithea.tests.fixture.failing_test_hook') | |
539 | Session().commit() |
|
539 | Session().commit() | |
540 | # clone repo |
|
540 | # clone repo | |
541 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS) |
|
541 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) | |
542 | dest_dir = _get_tmp_dir() |
|
542 | dest_dir = _get_tmp_dir() | |
543 | stdout, stderr = Command(TESTS_TMP_PATH) \ |
|
543 | stdout, stderr = Command(base.TESTS_TMP_PATH) \ | |
544 | .execute(vt.repo_type, 'clone', clone_url, dest_dir, ignoreReturnCode=True) |
|
544 | .execute(vt.repo_type, 'clone', clone_url, dest_dir, ignoreReturnCode=True) | |
545 | if vt.repo_type == 'hg': |
|
545 | if vt.repo_type == 'hg': | |
546 | assert 'preoutgoing.testhook hook failed' in stdout |
|
546 | assert 'preoutgoing.testhook hook failed' in stdout | |
@@ -553,9 +553,9 b' class TestVCSOperations(TestController):' | |||||
553 | Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.failing_test_hook') |
|
553 | Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.failing_test_hook') | |
554 | Session().commit() |
|
554 | Session().commit() | |
555 | # clone repo |
|
555 | # clone repo | |
556 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS) |
|
556 | clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) | |
557 | dest_dir = _get_tmp_dir() |
|
557 | dest_dir = _get_tmp_dir() | |
558 | stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) |
|
558 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) | |
559 |
|
559 | |||
560 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url, |
|
560 | stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url, | |
561 | ignoreReturnCode=True) |
|
561 | ignoreReturnCode=True) | |
@@ -596,19 +596,19 b' class TestVCSOperations(TestController):' | |||||
596 |
|
596 | |||
597 | def test_add_submodule_git(self, webserver, testfork): |
|
597 | def test_add_submodule_git(self, webserver, testfork): | |
598 | dest_dir = _get_tmp_dir() |
|
598 | dest_dir = _get_tmp_dir() | |
599 | clone_url = GitHttpVcsTest.repo_url_param(webserver, GIT_REPO) |
|
599 | clone_url = GitHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) | |
600 |
|
600 | |||
601 | fork_url = GitHttpVcsTest.repo_url_param(webserver, testfork['git']) |
|
601 | fork_url = GitHttpVcsTest.repo_url_param(webserver, testfork['git']) | |
602 |
|
602 | |||
603 | # add submodule |
|
603 | # add submodule | |
604 | stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir) |
|
604 | stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir) | |
605 | stdout, stderr = Command(dest_dir).execute('git submodule add', clone_url, 'testsubmodule') |
|
605 | stdout, stderr = Command(dest_dir).execute('git submodule add', clone_url, 'testsubmodule') | |
606 | stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"', EMAIL=TEST_USER_ADMIN_EMAIL) |
|
606 | stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"', EMAIL=base.TEST_USER_ADMIN_EMAIL) | |
607 | stdout, stderr = Command(dest_dir).execute('git push', fork_url, 'master') |
|
607 | stdout, stderr = Command(dest_dir).execute('git push', fork_url, 'master') | |
608 |
|
608 | |||
609 | # check for testsubmodule link in files page |
|
609 | # check for testsubmodule link in files page | |
610 | self.log_user() |
|
610 | self.log_user() | |
611 | response = self.app.get(url(controller='files', action='index', |
|
611 | response = self.app.get(base.url(controller='files', action='index', | |
612 | repo_name=testfork['git'], |
|
612 | repo_name=testfork['git'], | |
613 | revision='tip', |
|
613 | revision='tip', | |
614 | f_path='/')) |
|
614 | f_path='/')) | |
@@ -618,7 +618,7 b' class TestVCSOperations(TestController):' | |||||
618 | response.mustcontain('<a class="submodule-dir" href="%s" target="_blank"><i class="icon-file-submodule"></i><span>testsubmodule @ ' % clone_url) |
|
618 | response.mustcontain('<a class="submodule-dir" href="%s" target="_blank"><i class="icon-file-submodule"></i><span>testsubmodule @ ' % clone_url) | |
619 |
|
619 | |||
620 | # check that following a submodule link actually works - and redirects |
|
620 | # check that following a submodule link actually works - and redirects | |
621 | response = self.app.get(url(controller='files', action='index', |
|
621 | response = self.app.get(base.url(controller='files', action='index', | |
622 | repo_name=testfork['git'], |
|
622 | repo_name=testfork['git'], | |
623 | revision='tip', |
|
623 | revision='tip', | |
624 | f_path='/testsubmodule'), |
|
624 | f_path='/testsubmodule'), |
@@ -15,11 +15,11 b'' | |||||
15 | import pytest |
|
15 | import pytest | |
16 |
|
16 | |||
17 | from kallithea.model.db import Repository |
|
17 | from kallithea.model.db import Repository | |
18 |
from kallithea.tests |
|
18 | from kallithea.tests import base | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | @pytest.mark.skipif("'TEST_PERFORMANCE' not in os.environ", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired") |
|
21 | @pytest.mark.skipif("'TEST_PERFORMANCE' not in os.environ", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired") | |
22 | class TestVCSPerformance(TestController): |
|
22 | class TestVCSPerformance(base.TestController): | |
23 |
|
23 | |||
24 | def graphmod(self, repo): |
|
24 | def graphmod(self, repo): | |
25 | """ Simple test for running the graph_data function for profiling/testing performance. """ |
|
25 | """ Simple test for running the graph_data function for profiling/testing performance. """ | |
@@ -31,7 +31,7 b' class TestVCSPerformance(TestController)' | |||||
31 | jsdata = graph_data(scm_inst, revs) |
|
31 | jsdata = graph_data(scm_inst, revs) | |
32 |
|
32 | |||
33 | def test_graphmod_hg(self, benchmark): |
|
33 | def test_graphmod_hg(self, benchmark): | |
34 | benchmark(self.graphmod, HG_REPO) |
|
34 | benchmark(self.graphmod, base.HG_REPO) | |
35 |
|
35 | |||
36 | def test_graphmod_git(self, benchmark): |
|
36 | def test_graphmod_git(self, benchmark): | |
37 | benchmark(self.graphmod, GIT_REPO) |
|
37 | benchmark(self.graphmod, base.GIT_REPO) |
General Comments 0
You need to be logged in to leave comments.
Login now