# HG changeset patch # User Serhii Ilin # Date 2024-02-28 07:34:14 # Node ID b35a3661a7992b33c8c62837ad584c3be1126e64 # Parent 585ee4508a3a79a32b324f4e064ecfa80dd63112 feat(svn-config): moved svn related config keys to *.ini file. Fixes: RCCE-60 diff --git a/configs/development.ini b/configs/development.ini --- a/configs/development.ini +++ b/configs/development.ini @@ -615,6 +615,12 @@ vcs.connection_timeout = 3600 ; Legacy available options are: pre-1.4-compatible, pre-1.5-compatible, pre-1.6-compatible, pre-1.8-compatible, pre-1.9-compatible #vcs.svn.compatible_version = 1.8 +; Enable SVN proxy of requests over HTTP +vcs.svn.proxy.enabled = true + +; host to connect to running SVN subsystem +vcs.svn.proxy.host = http://svn:8090 + ; Cache flag to cache vcsserver remote calls locally ; It uses cache_region `cache_repo` vcs.methods.cache = true diff --git a/configs/production.ini b/configs/production.ini --- a/configs/production.ini +++ b/configs/production.ini @@ -566,6 +566,12 @@ vcs.connection_timeout = 3600 ; Legacy available options are: pre-1.4-compatible, pre-1.5-compatible, pre-1.6-compatible, pre-1.8-compatible, pre-1.9-compatible #vcs.svn.compatible_version = 1.8 +; Enable SVN proxy of requests over HTTP +vcs.svn.proxy.enabled = true + +; host to connect to running SVN subsystem +vcs.svn.proxy.host = http://svn:8090 + ; Cache flag to cache vcsserver remote calls locally ; It uses cache_region `cache_repo` vcs.methods.cache = true diff --git a/rhodecode/apps/repository/tests/test_repo_summary.py b/rhodecode/apps/repository/tests/test_repo_summary.py --- a/rhodecode/apps/repository/tests/test_repo_summary.py +++ b/rhodecode/apps/repository/tests/test_repo_summary.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -52,13 +51,13 @@ def assert_clone_url(response, server, r @pytest.mark.usefixtures('app') class TestSummaryView(object): + def test_index(self, autologin_user, backend, http_host_only_stub): repo_id = backend.repo.repo_id repo_name = backend.repo_name - with mock.patch('rhodecode.lib.helpers.is_svn_without_proxy', - return_value=False): - response = self.app.get( - route_path('repo_summary', repo_name=repo_name)) + + response = self.app.get( + route_path('repo_summary', repo_name=repo_name)) # repo type response.mustcontain( @@ -71,37 +70,43 @@ class TestSummaryView(object): # clone url... assert_clone_url(response, http_host_only_stub, repo_name) - assert_clone_url(response, http_host_only_stub, '_{}'.format(repo_id)) + assert_clone_url(response, http_host_only_stub, f'_{repo_id}') def test_index_svn_without_proxy( self, autologin_user, backend_svn, http_host_only_stub): + repo_id = backend_svn.repo.repo_id repo_name = backend_svn.repo_name - response = self.app.get(route_path('repo_summary', repo_name=repo_name)) - # clone url... + + # by default the SVN is enabled now, this is how inputs look when it's disabled + with mock.patch('rhodecode.lib.helpers.is_svn_without_proxy', return_value=True): + response = self.app.get( + route_path('repo_summary', repo_name=repo_name), + status=200) + + # clone url test... assert_clone_url(response, http_host_only_stub, repo_name, disabled=True) - assert_clone_url(response, http_host_only_stub, '_{}'.format(repo_id), disabled=True) + assert_clone_url(response, http_host_only_stub, f'_{repo_id}', disabled=True) def test_index_with_trailing_slash( self, autologin_user, backend, http_host_only_stub): repo_id = backend.repo.repo_id repo_name = backend.repo_name - with mock.patch('rhodecode.lib.helpers.is_svn_without_proxy', - return_value=False): - response = self.app.get( - route_path('repo_summary', repo_name=repo_name) + '/', - status=200) + trailing_slash = '/' + response = self.app.get( + route_path('repo_summary', repo_name=repo_name) + trailing_slash, + status=200) # clone url... assert_clone_url(response, http_host_only_stub, repo_name) - assert_clone_url(response, http_host_only_stub, '_{}'.format(repo_id)) + assert_clone_url(response, http_host_only_stub, f'_{repo_id}') def test_index_by_id(self, autologin_user, backend): repo_id = backend.repo.repo_id response = self.app.get( - route_path('repo_summary', repo_name='_%s' % (repo_id,))) + route_path('repo_summary', repo_name=f'_{repo_id}')) # repo type response.mustcontain( diff --git a/rhodecode/apps/ssh_support/lib/backends/svn.py b/rhodecode/apps/ssh_support/lib/backends/svn.py --- a/rhodecode/apps/ssh_support/lib/backends/svn.py +++ b/rhodecode/apps/ssh_support/lib/backends/svn.py @@ -244,9 +244,10 @@ class SubversionServer(VcsServer): # if exit_code: # return exit_code, False - req = self.env['request'] - server_url = req.host_url + req.script_name - extras['server_url'] = server_url + req = self.env.get('request') + if req: + server_url = req.host_url + req.script_name + extras['server_url'] = server_url log.debug('Using %s binaries from path %s', self.backend, self._path) exit_code = self.tunnel.run(extras) diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -542,6 +542,8 @@ def sanitize_settings_and_apply_defaults settings_maker.make_setting('statsd.statsd_ipv6', False, parser='bool') settings_maker.make_setting('vcs.svn.compatible_version', '') + settings_maker.make_setting('vcs.svn.proxy.enabled', 'true', parser='bool') + settings_maker.make_setting('vcs.svn.proxy.host', 'http://svn:8090') settings_maker.make_setting('vcs.hooks.protocol', 'http') settings_maker.make_setting('vcs.hooks.host', '*') settings_maker.make_setting('vcs.scm_app_implementation', 'http') diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -74,6 +74,7 @@ from webhelpers2.html.tags import ( from webhelpers2.number import format_byte_size # python3.11 backport fixes for webhelpers2 +from rhodecode import ConfigGet from rhodecode.lib._vendor.webhelpers_backports import raw_select from rhodecode.lib.action_parser import action_parser @@ -916,9 +917,7 @@ def get_repo_type_by_name(repo_name): def is_svn_without_proxy(repository): if is_svn(repository): - from rhodecode.model.settings import VcsSettingsModel - conf = VcsSettingsModel().get_ui_settings_as_config_obj() - return not str2bool(conf.get('vcs_svn_proxy', 'http_requests_enabled')) + return not ConfigGet().get_bool('vcs.svn.proxy.enabled') return False diff --git a/rhodecode/lib/middleware/simplesvn.py b/rhodecode/lib/middleware/simplesvn.py --- a/rhodecode/lib/middleware/simplesvn.py +++ b/rhodecode/lib/middleware/simplesvn.py @@ -27,6 +27,7 @@ import urllib.parse import requests from pyramid.httpexceptions import HTTPNotAcceptable +from rhodecode import ConfigGet from rhodecode.lib import rc_cache from rhodecode.lib.middleware import simplevcs from rhodecode.lib.middleware.utils import get_path_info @@ -232,12 +233,10 @@ class SimpleSvn(simplevcs.SimpleVCS): return DisabledSimpleSvnApp(config) def _is_svn_enabled(self): - conf = self.repo_vcs_config - return str2bool(conf.get('vcs_svn_proxy', 'http_requests_enabled')) + return ConfigGet().get_bool('vcs.svn.proxy.enabled') def _create_config(self, extras, repo_name, scheme='http'): - conf = self.repo_vcs_config - server_url = conf.get('vcs_svn_proxy', 'http_server_url') + server_url = ConfigGet().get_str('vcs.svn.proxy.host') server_url = server_url or self.DEFAULT_HTTP_SERVER extras['subversion_http_server_url'] = server_url diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -421,10 +421,6 @@ class _BaseVcsSettingsForm(formencode.Sc rhodecode_git_use_rebase_for_merging = v.StringBoolean(if_missing=False) rhodecode_git_close_branch_before_merging = v.StringBoolean(if_missing=False) - # svn - vcs_svn_proxy_http_requests_enabled = v.StringBoolean(if_missing=False) - vcs_svn_proxy_http_server_url = v.UnicodeString(strip=True, if_missing=None) - # cache rhodecode_diff_cache = v.StringBoolean(if_missing=False) diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py --- a/rhodecode/model/settings.py +++ b/rhodecode/model/settings.py @@ -499,11 +499,6 @@ class VcsSettingsModel(object): ('vcs_git_lfs', 'store_location') ) - GLOBAL_SVN_SETTINGS = ( - ('vcs_svn_proxy', 'http_requests_enabled'), - ('vcs_svn_proxy', 'http_server_url') - ) - SVN_BRANCH_SECTION = 'vcs_svn_branch' SVN_TAG_SECTION = 'vcs_svn_tag' SSL_SETTING = ('web', 'push_ssl') @@ -718,17 +713,6 @@ class VcsSettingsModel(object): # branch/tags patterns self._create_svn_settings(self.global_settings, data) - http_requests_enabled, http_server_url = self.GLOBAL_SVN_SETTINGS - http_requests_enabled_key, http_server_url_key = self._get_settings_keys( - self.GLOBAL_SVN_SETTINGS, data) - - self._create_or_update_ui( - self.global_settings, *http_requests_enabled, - value=safe_str(data[http_requests_enabled_key])) - self._create_or_update_ui( - self.global_settings, *http_server_url, - value=data[http_server_url_key]) - def update_global_ssl_setting(self, value): self._create_or_update_ui( self.global_settings, *self.SSL_SETTING, value=value) diff --git a/rhodecode/templates/base/vcs_settings.mako b/rhodecode/templates/base/vcs_settings.mako --- a/rhodecode/templates/base/vcs_settings.mako +++ b/rhodecode/templates/base/vcs_settings.mako @@ -170,42 +170,6 @@ % endif - - % if display_globals: -
-
-

${_('Global Subversion Settings')}

-
-
-
-
- ${h.checkbox('vcs_svn_proxy_http_requests_enabled' + suffix, 'True', **kwargs)} - -
-
- - ${_('Subversion HTTP Support. Enables communication with SVN over HTTP protocol.')} - ${_('SVN Protocol setup Documentation')}. - -
-
-
-
-
-
-
- ${h.text('vcs_svn_proxy_http_server_url',size=59)} - % if c.svn_proxy_generate_config: - - - - % endif -
-
-
-
- % endif - % if display_globals or repo_type in ['svn']:
diff --git a/rhodecode/tests/fixture_mods/fixture_pyramid.py b/rhodecode/tests/fixture_mods/fixture_pyramid.py --- a/rhodecode/tests/fixture_mods/fixture_pyramid.py +++ b/rhodecode/tests/fixture_mods/fixture_pyramid.py @@ -108,6 +108,7 @@ def ini_config(request, tmpdir_factory, 'vcs.server.protocol': 'http', 'vcs.scm_app_implementation': 'http', + 'vcs.svn.proxy.enabled': 'true', 'vcs.hooks.protocol': 'http', 'vcs.hooks.host': '*', 'app.service_api.token': 'service_secret_token',