Show More
@@ -19,7 +19,7 b'' | |||
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import os |
|
22 | ||
|
22 | import mock | |
|
23 | 23 | import pytest |
|
24 | 24 | |
|
25 | 25 | from rhodecode.tests import TESTS_TMP_PATH |
@@ -29,6 +29,7 b' from rhodecode.api.tests.utils import (' | |||
|
29 | 29 | |
|
30 | 30 | @pytest.mark.usefixtures("testuser_api", "app") |
|
31 | 31 | class TestPull(object): |
|
32 | ||
|
32 | 33 | @pytest.mark.backends("git", "hg") |
|
33 | 34 | def test_api_pull(self, backend): |
|
34 | 35 | r = backend.create_repo() |
@@ -37,6 +38,7 b' class TestPull(object):' | |||
|
37 | 38 | r.clone_uri = clone_uri |
|
38 | 39 | |
|
39 | 40 | id_, params = build_data(self.apikey, 'pull', repoid=repo_name,) |
|
41 | with mock.patch('rhodecode.model.scm.url_validator'): | |
|
40 | 42 | response = api_call(self.app, params) |
|
41 | 43 | msg = 'Pulled from url `%s` on repo `%s`' % ( |
|
42 | 44 | clone_uri, repo_name) |
@@ -56,9 +56,15 b' class TestApiUpdateRepo(object):' | |||
|
56 | 56 | ({'clone_uri': ''}, |
|
57 | 57 | {'clone_uri': ''}), |
|
58 | 58 | |
|
59 | ({'clone_uri': 'http://example.com/repo_pull'}, | |
|
60 | {'clone_uri': 'http://example.com/repo_pull'}), | |
|
61 | ||
|
59 | 62 | ({'push_uri': ''}, |
|
60 | 63 | {'push_uri': ''}), |
|
61 | 64 | |
|
65 | ({'push_uri': 'http://example.com/repo_push'}, | |
|
66 | {'push_uri': 'http://example.com/repo_push'}), | |
|
67 | ||
|
62 | 68 | ({'landing_rev': 'rev:tip'}, |
|
63 | 69 | {'landing_rev': ['rev', 'tip']}), |
|
64 | 70 |
@@ -377,7 +377,7 b' class ScmModel(BaseModel):' | |||
|
377 | 377 | self.sa.add(repo) |
|
378 | 378 | return repo |
|
379 | 379 | |
|
380 | def pull_changes(self, repo, username, remote_uri=None): | |
|
380 | def pull_changes(self, repo, username, remote_uri=None, validate_uri=True): | |
|
381 | 381 | dbrepo = self._get_repo(repo) |
|
382 | 382 | remote_uri = remote_uri or dbrepo.clone_uri |
|
383 | 383 | if not remote_uri: |
@@ -390,6 +390,7 b' class ScmModel(BaseModel):' | |||
|
390 | 390 | # NOTE(marcink): add extra validation so we skip invalid urls |
|
391 | 391 | # this is due this tasks can be executed via scheduler without |
|
392 | 392 | # proper validation of remote_uri |
|
393 | if validate_uri: | |
|
393 | 394 | config = make_db_config(clear_session=False) |
|
394 | 395 | url_validator(remote_uri, dbrepo.repo_type, config) |
|
395 | 396 | except InvalidCloneUrl: |
@@ -405,7 +406,7 b' class ScmModel(BaseModel):' | |||
|
405 | 406 | log.error(traceback.format_exc()) |
|
406 | 407 | raise |
|
407 | 408 | |
|
408 | def push_changes(self, repo, username, remote_uri=None): | |
|
409 | def push_changes(self, repo, username, remote_uri=None, validate_uri=True): | |
|
409 | 410 | dbrepo = self._get_repo(repo) |
|
410 | 411 | remote_uri = remote_uri or dbrepo.push_uri |
|
411 | 412 | if not remote_uri: |
@@ -418,6 +419,7 b' class ScmModel(BaseModel):' | |||
|
418 | 419 | # NOTE(marcink): add extra validation so we skip invalid urls |
|
419 | 420 | # this is due this tasks can be executed via scheduler without |
|
420 | 421 | # proper validation of remote_uri |
|
422 | if validate_uri: | |
|
421 | 423 | config = make_db_config(clear_session=False) |
|
422 | 424 | url_validator(remote_uri, dbrepo.repo_type, config) |
|
423 | 425 | except InvalidCloneUrl: |
General Comments 0
You need to be logged in to leave comments.
Login now