subversion: Detect requests also based on magic path.

This commit is contained in:
Johannes Bornhold 2016-07-13 09:15:54 +02:00
parent 2421154553
commit 00ec4381f9
2 changed files with 25 additions and 1 deletions

View file

@ -72,7 +72,11 @@ def is_svn(environ):
Returns True if requests target is Subversion server
"""
http_dav = environ.get('HTTP_DAV', '')
is_svn_path = 'subversion' in http_dav
magic_path_segment = rhodecode.CONFIG.get(
'rhodecode_subversion_magic_path', '/!svn')
is_svn_path = (
'subversion' in http_dav or
magic_path_segment in environ['PATH_INFO'])
log.debug(
'request path: `%s` detected as SVN PROTOCOL %s', environ['PATH_INFO'],
is_svn_path)

View file

@ -74,6 +74,26 @@ def test_is_svn_returns_false_if_no_dav_header():
assert vcs.is_svn(environ) is False
def test_is_svn_returns_true_if_magic_path_segment():
environ = {
'PATH_INFO': '/stub-repository/!svn/rev/4',
}
assert vcs.is_svn(environ)
def test_is_svn_allows_to_configure_the_magic_path(monkeypatch):
"""
This is intended as a fallback in case someone has configured his
Subversion server with a different magic path segment.
"""
monkeypatch.setitem(
rhodecode.CONFIG, 'rhodecode_subversion_magic_path', '/!my-magic')
environ = {
'PATH_INFO': '/stub-repository/!my-magic/rev/4',
}
assert vcs.is_svn(environ)
class TestVCSMiddleware(object):
def test_get_handler_app_retuns_svn_app_when_proxy_enabled(self):
environ = {