# HG changeset patch # User Johannes Bornhold # Date 2016-07-13 07:15:54 # Node ID 28802ace13d7dd2a9ff692a04ff4c2d691b11178 # Parent 6048dd9a1124f1c7d2b16c2be59558d8e08af777 subversion: Detect requests also based on magic path. diff --git a/rhodecode/lib/middleware/vcs.py b/rhodecode/lib/middleware/vcs.py --- a/rhodecode/lib/middleware/vcs.py +++ b/rhodecode/lib/middleware/vcs.py @@ -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) diff --git a/rhodecode/tests/lib/middleware/test_vcs.py b/rhodecode/tests/lib/middleware/test_vcs.py --- a/rhodecode/tests/lib/middleware/test_vcs.py +++ b/rhodecode/tests/lib/middleware/test_vcs.py @@ -74,6 +74,26 @@ def test_is_svn_returns_false_if_no_dav_ 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 = {