Changeset - 98f007b3fd9a
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-12-26 15:21:51
mads@kiilerich.com
Grafted from: 9186bf36b145
tests: update test_git_cmd_injection - something with only reproducible with file:, and better error handling raising RepositoryError
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/vcs/test_git.py
Show inline comments
 
import datetime
 
import os
 
import sys
 
import urllib.error
 

	
 
import mock
 
import pytest
 

	
 
from kallithea.lib.vcs.backends.git import GitChangeset, GitRepository
 
from kallithea.lib.vcs.exceptions import NodeDoesNotExistError, RepositoryError, VCSError
 
@@ -28,14 +27,14 @@ class TestGitRepository(object):
 
    def test_wrong_repo_path(self):
 
        wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo')
 
        with pytest.raises(RepositoryError):
 
            GitRepository(wrong_repo_path)
 

	
 
    def test_git_cmd_injection(self):
 
        repo_inject_path = TEST_GIT_REPO + '; echo "Cake";'
 
        with pytest.raises(urllib.error.URLError):
 
        repo_inject_path = 'file:/%s; echo "Cake";' % TEST_GIT_REPO
 
        with pytest.raises(RepositoryError):
 
            # Should fail because URL will contain the parts after ; too
 
            GitRepository(get_new_dir('injection-repo'), src_url=repo_inject_path, update_after_clone=True, create=True)
 

	
 
        with pytest.raises(RepositoryError):
 
            # Should fail on direct clone call, which as of this writing does not happen outside of class
 
            clone_fail_repo = GitRepository(get_new_dir('injection-repo'), create=True)
0 comments (0 inline, 0 general)