diff --git a/configs/development.ini b/configs/development.ini --- a/configs/development.ini +++ b/configs/development.ini @@ -587,6 +587,8 @@ svn.proxy.generate_config = false svn.proxy.list_parent_path = true ## Set location and file name of generated config file. svn.proxy.config_file_path = %(here)s/mod_dav_svn.conf +## alternative mod_dav config template. This needs to be a mako template +#svn.proxy.config_template = ~/.rccontrol/enterprise-1/custom_svn_conf.mako ## Used as a prefix to the `Location` block in the generated config file. ## In most cases it should be set to `/`. svn.proxy.location_root = / diff --git a/configs/production.ini b/configs/production.ini --- a/configs/production.ini +++ b/configs/production.ini @@ -556,6 +556,8 @@ svn.proxy.generate_config = false svn.proxy.list_parent_path = true ## Set location and file name of generated config file. svn.proxy.config_file_path = %(here)s/mod_dav_svn.conf +## alternative mod_dav config template. This needs to be a mako template +#svn.proxy.config_template = ~/.rccontrol/enterprise-1/custom_svn_conf.mako ## Used as a prefix to the `Location` block in the generated config file. ## In most cases it should be set to `/`. svn.proxy.location_root = / diff --git a/rhodecode/apps/svn_support/__init__.py b/rhodecode/apps/svn_support/__init__.py --- a/rhodecode/apps/svn_support/__init__.py +++ b/rhodecode/apps/svn_support/__init__.py @@ -66,6 +66,7 @@ def _sanitize_settings_and_apply_default _string_setting(settings, config_keys.config_file_path, '', lower=False) _string_setting(settings, config_keys.location_root, '/', lower=False) _string_setting(settings, config_keys.reload_command, '', lower=False) + _string_setting(settings, config_keys.template, '', lower=False) # Convert negative timeout values to zero. if settings[config_keys.reload_timeout] < 0: diff --git a/rhodecode/apps/svn_support/config_keys.py b/rhodecode/apps/svn_support/config_keys.py --- a/rhodecode/apps/svn_support/config_keys.py +++ b/rhodecode/apps/svn_support/config_keys.py @@ -27,3 +27,4 @@ list_parent_path = 'svn.proxy.list_paren location_root = 'svn.proxy.location_root' reload_command = 'svn.proxy.reload_cmd' reload_timeout = 'svn.proxy.reload_timeout' +template = 'svn.proxy.config_template' diff --git a/rhodecode/apps/svn_support/templates/mod-dav-svn.conf.mako b/rhodecode/apps/svn_support/templates/mod-dav-svn.conf.mako --- a/rhodecode/apps/svn_support/templates/mod-dav-svn.conf.mako +++ b/rhodecode/apps/svn_support/templates/mod-dav-svn.conf.mako @@ -28,7 +28,7 @@ # # # Depending on the apache configuration you may encounter the following error if -# you are using speecial characters in your repository or repository group +# you are using special characters in your repository or repository group # names. # # ``Error converting entry in directory '/path/to/repo' to UTF-8`` diff --git a/rhodecode/apps/svn_support/tests/test_mod_dav_svn_config.py b/rhodecode/apps/svn_support/tests/test_mod_dav_svn_config.py --- a/rhodecode/apps/svn_support/tests/test_mod_dav_svn_config.py +++ b/rhodecode/apps/svn_support/tests/test_mod_dav_svn_config.py @@ -18,10 +18,10 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ - +import re +import os import mock import pytest -import re from pyramid import testing @@ -69,7 +69,8 @@ class TestModDavSvnConfig(object): location_root=self.location_root, repo_groups=repo_groups, realm=self.realm, - use_ssl=True + use_ssl=True, + template='' ) # Assert that one location directive exists for each repository group. for group in repo_groups: @@ -79,6 +80,23 @@ class TestModDavSvnConfig(object): # Assert that the root location directive exists. self.assert_root_location_directive(generated_config) + def test_render_mod_dav_svn_config_with_alternative_template(self, tmpdir): + repo_groups = self.get_repo_group_mocks(count=10) + test_file_path = os.path.join(str(tmpdir), 'example.mako') + with open(test_file_path, 'wb') as f: + f.write('TEST_EXAMPLE\n') + + generated_config = utils._render_mod_dav_svn_config( + parent_path_root=self.parent_path_root, + list_parent_path=True, + location_root=self.location_root, + repo_groups=repo_groups, + realm=self.realm, + use_ssl=True, + template=test_file_path + ) + assert 'TEST_EXAMPLE' in generated_config + @pytest.mark.parametrize('list_parent_path', [True, False]) @pytest.mark.parametrize('use_ssl', [True, False]) def test_list_parent_path(self, list_parent_path, use_ssl): @@ -88,7 +106,8 @@ class TestModDavSvnConfig(object): location_root=self.location_root, repo_groups=self.get_repo_group_mocks(count=10), realm=self.realm, - use_ssl=use_ssl + use_ssl=use_ssl, + template='' ) # Assert that correct configuration directive is present. diff --git a/rhodecode/apps/svn_support/utils.py b/rhodecode/apps/svn_support/utils.py --- a/rhodecode/apps/svn_support/utils.py +++ b/rhodecode/apps/svn_support/utils.py @@ -51,7 +51,7 @@ def generate_mod_dav_svn_config(registry list_parent_path=settings[config_keys.list_parent_path], location_root=settings[config_keys.location_root], repo_groups=RepoGroup.get_all_repo_groups(), - realm=get_rhodecode_realm()) + realm=get_rhodecode_realm(), template=settings[config_keys.template]) _write_mod_dav_svn_config(config, settings[config_keys.config_file_path]) # Trigger an event on mod dav svn configuration change. @@ -60,7 +60,7 @@ def generate_mod_dav_svn_config(registry def _render_mod_dav_svn_config( parent_path_root, list_parent_path, location_root, repo_groups, realm, - use_ssl): + use_ssl, template): """ Render mod_dav_svn configuration to string. """ @@ -77,11 +77,11 @@ def _render_mod_dav_svn_config( 'repo_group_paths': repo_group_paths, 'svn_list_parent_path': list_parent_path, 'rhodecode_realm': realm, - 'use_https': use_ssl + 'use_https': use_ssl, } - + template = template or \ + 'rhodecode:apps/svn_support/templates/mod-dav-svn.conf.mako' # Render the configuration template to string. - template = 'rhodecode:apps/svn_support/templates/mod-dav-svn.conf.mako' return render(template, context)