Mercurial > kallithea
changeset 5988:110dcae69d7d stable
protocols: fix assertion error when accessing repositories with "permanent" urls (Issue #202)
I am not aware of any good way to test this, so it is tested with a Mercurial only hack.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 29 Jun 2016 16:45:15 +0200 |
parents | 6754597990cb |
children | 02cfb2197c63 cc21a2b86a30 |
files | kallithea/lib/base.py kallithea/lib/middleware/simplehg.py kallithea/tests/functional/test_admin_repos.py |
diffstat | 3 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/base.py Mon May 30 15:33:19 2016 +0200 +++ b/kallithea/lib/base.py Wed Jun 29 16:45:15 2016 +0200 @@ -201,7 +201,7 @@ from kallithea.lib.utils import get_repo_by_id by_id_match = get_repo_by_id(repo_name) if by_id_match: - data[1] = by_id_match + data[1] = safe_str(by_id_match) return '/'.join(data)
--- a/kallithea/lib/middleware/simplehg.py Mon May 30 15:33:19 2016 +0200 +++ b/kallithea/lib/middleware/simplehg.py Wed Jun 29 16:45:15 2016 +0200 @@ -84,7 +84,7 @@ #====================================================================== try: str_repo_name = environ['REPO_NAME'] = self.__get_repository(environ) - assert isinstance(str_repo_name, str) + assert isinstance(str_repo_name, str), str_repo_name repo_name = safe_unicode(str_repo_name) assert safe_str(repo_name) == str_repo_name, (str_repo_name, repo_name) log.debug('Extracted repo name is %s', repo_name)
--- a/kallithea/tests/functional/test_admin_repos.py Mon May 30 15:33:19 2016 +0200 +++ b/kallithea/tests/functional/test_admin_repos.py Wed Jun 29 16:45:15 2016 +0200 @@ -4,6 +4,8 @@ import mock import urllib +import pytest + from kallithea.lib import vcs from kallithea.model.db import Repository, RepoGroup, UserRepoToPerm, User,\ Permission @@ -654,3 +656,8 @@ NEW_REPO = NEW_HG_REPO OTHER_TYPE_REPO = GIT_REPO OTHER_TYPE = 'git' + + def test_permanent_url_protocol_access(self): + with pytest.raises(Exception) as e: + self.app.get(url('summary_home', repo_name='_1'), extra_environ={'HTTP_ACCEPT': 'application/mercurial'}) + assert 'Unable to detect pull/push action' in str(e)