changeset 8146:042554aec0ac stable

tests: add coverage for SSH and HTTP URLs with extra '/'
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 25 Jan 2020 21:26:01 +0100
parents a12eaa1c265e
children fe93c67afc4d
files kallithea/tests/other/test_vcs_operations.py
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/other/test_vcs_operations.py	Sat Feb 01 14:36:57 2020 +0100
+++ b/kallithea/tests/other/test_vcs_operations.py	Sat Jan 25 21:26:01 2020 +0100
@@ -413,6 +413,38 @@
         action_parts = [ul.action for ul in UserLog.query().order_by(UserLog.user_log_id)]
         assert action_parts == [u'pull']
 
+        # Test handling of URLs with extra '/' around repo_name
+        stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/./%s/' % vt.repo_name), ignoreReturnCode=True)
+        if issubclass(vt, HttpVcsTest):
+            if vt.repo_type == 'git':
+                # NOTE: when pulling from http://hostname/./vcs_test_git/ , the git client will normalize that and issue an HTTP request to /vcs_test_git/info/refs
+                assert 'Already up to date.' in stdout
+            else:
+                assert vt.repo_type == 'hg'
+                assert "abort: HTTP Error 404: Not Found" in stderr
+        else:
+            assert issubclass(vt, SshVcsTest)
+            if vt.repo_type == 'git':
+                assert "abort: Access to './%s/' denied" % vt.repo_name in stderr
+            else:
+                assert "abort: Access to './%s/' denied" % vt.repo_name in stdout
+
+        stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/%s/' % vt.repo_name), ignoreReturnCode=True)
+        if issubclass(vt, HttpVcsTest):
+            if vt.repo_type == 'git':
+                assert 'Already up to date.' in stdout
+            else:
+                assert vt.repo_type == 'hg'
+                assert "no changes found" in stdout
+            assert "denied" not in stderr
+            assert "denied" not in stdout
+            assert "404" not in stdout
+        else:
+            if vt.repo_type == 'git':
+                assert "denied" in stderr
+            else:
+                assert "denied" in stdout
+
     @parametrize_vcs_test
     def test_push_invalidates_cache(self, webserver, testfork, vt):
         pre_cached_tip = [repo.get_api_data()['last_changeset']['short_id'] for repo in Repository.query().filter(Repository.repo_name == testfork[vt.repo_type])]