Show More
@@ -96,7 +96,9 b' class TestApiUpdateRepo(object):' | |||
|
96 | 96 | |
|
97 | 97 | id_, params = build_data( |
|
98 | 98 | self.apikey, 'update_repo', repoid=repo_name, **updates) |
|
99 | response = api_call(self.app, params) | |
|
99 | ||
|
100 | with mock.patch('rhodecode.model.validation_schema.validators.url_validator'): | |
|
101 | response = api_call(self.app, params) | |
|
100 | 102 | |
|
101 | 103 | if updates.get('repo_name'): |
|
102 | 104 | repo_name = updates['repo_name'] |
@@ -655,6 +655,7 b' def create_repo(' | |||
|
655 | 655 | |
|
656 | 656 | schema = repo_schema.RepoSchema().bind( |
|
657 | 657 | repo_type_options=rhodecode.BACKENDS.keys(), |
|
658 | repo_type=repo_type, | |
|
658 | 659 | # user caller |
|
659 | 660 | user=apiuser) |
|
660 | 661 | |
@@ -892,16 +893,18 b' def update_repo(' | |||
|
892 | 893 | request.translate, repo=repo) |
|
893 | 894 | |
|
894 | 895 | old_values = repo.get_api_data() |
|
896 | repo_type = repo.repo_type | |
|
895 | 897 | schema = repo_schema.RepoSchema().bind( |
|
896 | 898 | repo_type_options=rhodecode.BACKENDS.keys(), |
|
897 | 899 | repo_ref_options=ref_choices, |
|
900 | repo_type=repo_type, | |
|
898 | 901 | # user caller |
|
899 | 902 | user=apiuser, |
|
900 | 903 | old_values=old_values) |
|
901 | 904 | try: |
|
902 | 905 | schema_data = schema.deserialize(dict( |
|
903 | 906 | # we save old value, users cannot change type |
|
904 |
repo_type= |
|
|
907 | repo_type=repo_type, | |
|
905 | 908 | |
|
906 | 909 | repo_name=updates['repo_name'], |
|
907 | 910 | repo_owner=updates['user'], |
@@ -1050,6 +1053,7 b' def fork_repo(request, apiuser, repoid, ' | |||
|
1050 | 1053 | |
|
1051 | 1054 | schema = repo_schema.RepoSchema().bind( |
|
1052 | 1055 | repo_type_options=rhodecode.BACKENDS.keys(), |
|
1056 | repo_type=repo.repo_type, | |
|
1053 | 1057 | # user caller |
|
1054 | 1058 | user=apiuser) |
|
1055 | 1059 |
@@ -319,7 +319,7 b' class RepoSchema(colander.MappingSchema)' | |||
|
319 | 319 | |
|
320 | 320 | repo_clone_uri = colander.SchemaNode( |
|
321 | 321 | colander.String(), |
|
322 | validator=colander.All(colander.Length(min=1)), | |
|
322 | validator=deferred_clone_uri_validator, | |
|
323 | 323 | preparers=[preparers.strip_preparer], |
|
324 | 324 | missing='') |
|
325 | 325 |
@@ -117,6 +117,11 b' def url_validator(url, repo_type, config' | |||
|
117 | 117 | % (url, ','.join(allowed_prefixes))) |
|
118 | 118 | exc.allowed_prefixes = allowed_prefixes |
|
119 | 119 | raise exc |
|
120 | elif repo_type == 'svn': | |
|
121 | # no validation for SVN yet | |
|
122 | return | |
|
123 | ||
|
124 | raise InvalidCloneUrl('No repo type specified') | |
|
120 | 125 | |
|
121 | 126 | |
|
122 | 127 | class CloneUriValidator(object): |
@@ -124,16 +129,14 b' class CloneUriValidator(object):' | |||
|
124 | 129 | self.repo_type = repo_type |
|
125 | 130 | |
|
126 | 131 | def __call__(self, node, value): |
|
132 | ||
|
127 | 133 | from rhodecode.lib.utils import make_db_config |
|
128 | 134 | try: |
|
129 | 135 | config = make_db_config(clear_session=False) |
|
130 | 136 | url_validator(value, self.repo_type, config) |
|
131 | 137 | except InvalidCloneUrl as e: |
|
132 | 138 | log.warning(e) |
|
133 | msg = _(u'Invalid clone url, provide a valid clone ' | |
|
134 | u'url starting with one of {allowed_prefixes}').format( | |
|
135 | allowed_prefixes=e.allowed_prefixes) | |
|
136 | raise colander.Invalid(node, msg) | |
|
139 | raise colander.Invalid(node, e.message) | |
|
137 | 140 | except Exception: |
|
138 | 141 | log.exception('Url validation failed') |
|
139 | 142 | msg = _(u'invalid clone url for {repo_type} repository').format( |
@@ -53,6 +53,7 b' class TestRepoSchema(object):' | |||
|
53 | 53 | def test_deserialize(self, app, user_admin): |
|
54 | 54 | schema = repo_schema.RepoSchema().bind( |
|
55 | 55 | repo_type_options=['hg'], |
|
56 | repo_type='hg', | |
|
56 | 57 | user=user_admin |
|
57 | 58 | ) |
|
58 | 59 | |
@@ -78,6 +79,7 b' class TestRepoSchema(object):' | |||
|
78 | 79 | |
|
79 | 80 | schema = repo_schema.RepoSchema().bind( |
|
80 | 81 | repo_type_options=['hg'], |
|
82 | repo_type='hg', | |
|
81 | 83 | user=user_admin |
|
82 | 84 | ) |
|
83 | 85 | |
@@ -93,6 +95,7 b' class TestRepoSchema(object):' | |||
|
93 | 95 | def test_deserialize_with_group_name(self, app, user_admin, test_repo_group): |
|
94 | 96 | schema = repo_schema.RepoSchema().bind( |
|
95 | 97 | repo_type_options=['hg'], |
|
98 | repo_type='hg', | |
|
96 | 99 | user=user_admin |
|
97 | 100 | ) |
|
98 | 101 | |
@@ -114,6 +117,7 b' class TestRepoSchema(object):' | |||
|
114 | 117 | self, app, user_regular, test_repo_group): |
|
115 | 118 | schema = repo_schema.RepoSchema().bind( |
|
116 | 119 | repo_type_options=['hg'], |
|
120 | repo_type='hg', | |
|
117 | 121 | user=user_regular |
|
118 | 122 | ) |
|
119 | 123 |
General Comments 0
You need to be logged in to leave comments.
Login now