diff --git a/rhodecode/controllers/admin/settings.py b/rhodecode/controllers/admin/settings.py
--- a/rhodecode/controllers/admin/settings.py
+++ b/rhodecode/controllers/admin/settings.py
@@ -135,6 +135,7 @@ class SettingsController(BaseController)
c.svn_tag_patterns = model.get_global_svn_tag_patterns()
application_form = ApplicationUiSettingsForm()()
+
try:
form_result = application_form.to_python(dict(request.POST))
except formencode.Invalid as errors:
@@ -151,12 +152,14 @@ class SettingsController(BaseController)
)
try:
- model.update_global_ssl_setting(form_result['web_push_ssl'])
if c.visual.allow_repo_location_change:
model.update_global_path_setting(
form_result['paths_root_path'])
+
+ model.update_global_ssl_setting(form_result['web_push_ssl'])
model.update_global_hook_settings(form_result)
- model.create_global_svn_settings(form_result)
+
+ model.create_or_update_global_svn_settings(form_result)
model.create_or_update_global_hg_settings(form_result)
model.create_or_update_global_pr_settings(form_result)
except Exception:
diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py
--- a/rhodecode/lib/base.py
+++ b/rhodecode/lib/base.py
@@ -276,7 +276,7 @@ def attach_context_attributes(context, r
# Visual options
context.visual = AttributeDict({})
- # DB store
+ # DB stored Visual Items
context.visual.show_public_icon = str2bool(
rc_config.get('rhodecode_show_public_icon'))
context.visual.show_private_icon = str2bool(
diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py
--- a/rhodecode/lib/helpers.py
+++ b/rhodecode/lib/helpers.py
@@ -772,10 +772,10 @@ def get_repo_type_by_name(repo_name):
def is_svn_without_proxy(repository):
- from rhodecode import CONFIG
if is_svn(repository):
- if not CONFIG.get('rhodecode_proxy_subversion_http_requests', False):
- return True
+ 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 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
@@ -22,10 +22,11 @@ import logging
from urlparse import urljoin
import requests
+from webob.exc import HTTPNotAcceptable
-import rhodecode
from rhodecode.lib.middleware import simplevcs
from rhodecode.lib.utils import is_valid_repo
+from rhodecode.lib.utils2 import str2bool
log = logging.getLogger(__name__)
@@ -95,10 +96,21 @@ class SimpleSvnApp(object):
return headers
+class DisabledSimpleSvnApp(object):
+ def __init__(self, config):
+ self.config = config
+
+ def __call__(self, environ, start_response):
+ reason = 'Cannot handle SVN call because: SVN HTTP Proxy is not enabled'
+ log.warning(reason)
+ return HTTPNotAcceptable(reason)(environ, start_response)
+
+
class SimpleSvn(simplevcs.SimpleVCS):
SCM = 'svn'
READ_ONLY_COMMANDS = ('OPTIONS', 'PROPFIND', 'GET', 'REPORT')
+ DEFAULT_HTTP_SERVER = 'http://localhost:8090'
def _get_repository_name(self, environ):
"""
@@ -129,11 +141,19 @@ class SimpleSvn(simplevcs.SimpleVCS):
else 'push')
def _create_wsgi_app(self, repo_path, repo_name, config):
- return SimpleSvnApp(config)
+ if self._is_svn_enabled():
+ return SimpleSvnApp(config)
+ # we don't have http proxy enabled return dummy request handler
+ return DisabledSimpleSvnApp(config)
+
+ def _is_svn_enabled(self):
+ conf = self.repo_vcs_config
+ return str2bool(conf.get('vcs_svn_proxy', 'http_requests_enabled'))
def _create_config(self, extras, repo_name):
- server_url = rhodecode.CONFIG.get(
- 'rhodecode_subversion_http_server_url', '')
- extras['subversion_http_server_url'] = (
- server_url or 'http://localhost/')
+ conf = self.repo_vcs_config
+ server_url = conf.get('vcs_svn_proxy', 'http_server_url')
+ server_url = server_url or self.DEFAULT_HTTP_SERVER
+
+ extras['subversion_http_server_url'] = server_url
return extras
diff --git a/rhodecode/lib/middleware/simplevcs.py b/rhodecode/lib/middleware/simplevcs.py
--- a/rhodecode/lib/middleware/simplevcs.py
+++ b/rhodecode/lib/middleware/simplevcs.py
@@ -46,11 +46,13 @@ from rhodecode.lib.utils import (
is_valid_repo, get_rhodecode_realm, get_rhodecode_base_path)
from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool
from rhodecode.lib.vcs.conf import settings as vcs_settings
+from rhodecode.lib.vcs.backends import base
from rhodecode.model import meta
from rhodecode.model.db import User, Repository
from rhodecode.model.scm import ScmModel
from rhodecode.model.settings import SettingsModel
+
log = logging.getLogger(__name__)
@@ -86,6 +88,8 @@ class SimpleVCS(object):
self.registry = registry
self.application = application
self.config = config
+ # re-populated by specialized middlewares
+ self.repo_vcs_config = base.Config()
# base path of repo locations
self.basepath = get_rhodecode_base_path()
# authenticate this VCS request using authfunc
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
@@ -29,7 +29,8 @@ from rhodecode.lib.middleware.appenlight
from rhodecode.lib.middleware.simplegit import SimpleGit, GIT_PROTO_PAT
from rhodecode.lib.middleware.simplehg import SimpleHg
from rhodecode.lib.middleware.simplesvn import SimpleSvn
-
+from rhodecode.lib.vcs.backends import base
+from rhodecode.model.settings import VcsSettingsModel
log = logging.getLogger(__name__)
@@ -131,22 +132,38 @@ class VCSMiddleware(object):
self.config = config
self.appenlight_client = appenlight_client
self.registry = registry
+ self.repo_vcs_config = base.Config()
+ self.use_gzip = True
+
+ def vcs_config(self, repo_name=None):
+ """
+ returns serialized VcsSettings
+ """
+ return VcsSettingsModel(repo=repo_name).get_ui_settings_as_config_obj()
+
+ def wrap_in_gzip_if_enabled(self, app):
+ if self.use_gzip:
+ app = GunzipMiddleware(app)
+ return app
def _get_handler_app(self, environ):
app = None
+
if is_hg(environ):
app = SimpleHg(self.application, self.config, self.registry)
if is_git(environ):
app = SimpleGit(self.application, self.config, self.registry)
- proxy_svn = rhodecode.CONFIG.get(
- 'rhodecode_proxy_subversion_http_requests', False)
- if proxy_svn and is_svn(environ):
+ if is_svn(environ):
app = SimpleSvn(self.application, self.config, self.registry)
if app:
- app = GunzipMiddleware(app)
+ repo_name = app._get_repository_name(environ)
+ self.repo_vcs_config = self.vcs_config(repo_name)
+ app.repo_vcs_config = self.repo_vcs_config
+
+ app = self.wrap_in_gzip_if_enabled(app)
app, _ = wrap_in_appenlight_if_enabled(
app, self.config, self.appenlight_client)
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py
--- a/rhodecode/model/forms.py
+++ b/rhodecode/model/forms.py
@@ -389,9 +389,9 @@ class _BaseVcsSettingsForm(formencode.Sc
rhodecode_use_outdated_comments = v.StringBoolean(if_missing=False)
rhodecode_hg_use_rebase_for_merging = v.StringBoolean(if_missing=False)
- rhodecode_proxy_subversion_http_requests = v.StringBoolean(if_missing=False)
- rhodecode_subversion_http_server_url = v.UnicodeString(
- strip=True, if_missing=None)
+ vcs_svn_proxy_http_requests_enabled = v.StringBoolean(if_missing=False)
+ vcs_svn_proxy_http_server_url = v.UnicodeString(strip=True, if_missing=None)
+
def ApplicationUiSettingsForm():
class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py
--- a/rhodecode/model/settings.py
+++ b/rhodecode/model/settings.py
@@ -24,9 +24,9 @@ from collections import namedtuple
from functools import wraps
from rhodecode.lib import caches
-from rhodecode.lib.caching_query import FromCache
from rhodecode.lib.utils2 import (
Optional, AttributeDict, safe_str, remove_prefix, str2bool)
+from rhodecode.lib.vcs.backends import base
from rhodecode.model import BaseModel
from rhodecode.model.db import (
RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi, RhodeCodeSetting)
@@ -402,18 +402,25 @@ class VcsSettingsModel(object):
INHERIT_SETTINGS = 'inherit_vcs_settings'
GENERAL_SETTINGS = (
- 'use_outdated_comments', 'pr_merge_enabled',
+ 'use_outdated_comments',
+ 'pr_merge_enabled',
'hg_use_rebase_for_merging')
+
HOOKS_SETTINGS = (
('hooks', 'changegroup.repo_size'),
('hooks', 'changegroup.push_logger'),
('hooks', 'outgoing.pull_logger'))
HG_SETTINGS = (
- ('extensions', 'largefiles'), ('phases', 'publish'))
- GLOBAL_HG_SETTINGS = HG_SETTINGS + (('extensions', 'hgsubversion'), )
+ ('extensions', 'largefiles'),
+ ('phases', 'publish'))
+ GLOBAL_HG_SETTINGS = (
+ ('extensions', 'largefiles'),
+ ('phases', 'publish'),
+ ('extensions', 'hgsubversion'))
GLOBAL_SVN_SETTINGS = (
- 'rhodecode_proxy_subversion_http_requests',
- 'rhodecode_subversion_http_server_url')
+ ('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')
@@ -523,13 +530,10 @@ class VcsSettingsModel(object):
def create_repo_svn_settings(self, data):
return self._create_svn_settings(self.repo_settings, data)
- def create_global_svn_settings(self, data):
- return self._create_svn_settings(self.global_settings, data)
-
@assert_repo_settings
def create_or_update_repo_hg_settings(self, data):
largefiles, phases = self.HG_SETTINGS
- largefiles_key, phases_key = self._get_hg_settings(
+ largefiles_key, phases_key = self._get_settings_keys(
self.HG_SETTINGS, data)
self._create_or_update_ui(
self.repo_settings, *largefiles, value='',
@@ -538,8 +542,8 @@ class VcsSettingsModel(object):
self.repo_settings, *phases, value=safe_str(data[phases_key]))
def create_or_update_global_hg_settings(self, data):
- largefiles, phases, subversion = self.GLOBAL_HG_SETTINGS
- largefiles_key, phases_key, subversion_key = self._get_hg_settings(
+ largefiles, phases, hgsubversion = self.GLOBAL_HG_SETTINGS
+ largefiles_key, phases_key, subversion_key = self._get_settings_keys(
self.GLOBAL_HG_SETTINGS, data)
self._create_or_update_ui(
self.global_settings, *largefiles, value='',
@@ -547,22 +551,22 @@ class VcsSettingsModel(object):
self._create_or_update_ui(
self.global_settings, *phases, value=safe_str(data[phases_key]))
self._create_or_update_ui(
- self.global_settings, *subversion, active=data[subversion_key])
+ self.global_settings, *hgsubversion, active=data[subversion_key])
def create_or_update_global_svn_settings(self, data):
- rhodecode_proxy_subversion_http_requests,
- rhodecode_subversion_http_server_url = self.GLOBAL_SVN_SETTINGS
- rhodecode_proxy_subversion_http_requests_key,
- rhodecode_subversion_http_server_url_key = self._get_svn_settings(
+ # 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,
- *rhodecode_proxy_subversion_http_requests,
- value=safe_str(data[rhodecode_proxy_subversion_http_requests_key]))
+ self.global_settings, *http_requests_enabled,
+ value=safe_str(data[http_requests_enabled_key]))
self._create_or_update_ui(
- self.global_settings,
- *rhodecode_subversion_http_server_url,
- active=data[rhodecode_subversion_http_server_url_key])
+ self.global_settings, *http_server_url,
+ value=data[http_server_url_key])
def update_global_ssl_setting(self, value):
self._create_or_update_ui(
@@ -600,6 +604,16 @@ class VcsSettingsModel(object):
def get_global_ui_settings(self, section=None, key=None):
return self.global_settings.get_ui(section, key)
+ def get_ui_settings_as_config_obj(self, section=None, key=None):
+ config = base.Config()
+
+ ui_settings = self.get_ui_settings(section=section, key=key)
+
+ for entry in ui_settings:
+ config.set(entry.section, entry.key, entry.value)
+
+ return config
+
def get_ui_settings(self, section=None, key=None):
if not self.repo_settings or self.inherit_global_settings:
return self.get_global_ui_settings(section, key)
@@ -707,7 +721,7 @@ class VcsSettingsModel(object):
name, data[data_key], 'bool')
Session().add(setting)
- def _get_hg_settings(self, settings, data):
+ def _get_settings_keys(self, settings, data):
data_keys = [self._get_form_ui_key(*s) for s in settings]
for data_key in data_keys:
if data_key not in data:
diff --git a/rhodecode/templates/base/vcs_settings.html b/rhodecode/templates/base/vcs_settings.html
--- a/rhodecode/templates/base/vcs_settings.html
+++ b/rhodecode/templates/base/vcs_settings.html
@@ -138,16 +138,16 @@
% endif
- % if display_globals or repo_type in ['svn']:
+ % if display_globals:
-
${_('Subversion Settings')}
+ ${_('Global Subversion Settings')}
- ${h.checkbox('rhodecode_proxy_subversion_http_requests' + suffix, 'True', **kwargs)}
-
+ ${h.checkbox('vcs_svn_proxy_http_requests_enabled' + suffix, 'True', **kwargs)}
+
${_('Subversion HTTP Support. Enables communication with SVN over HTTP protocol.')}
@@ -155,17 +155,22 @@
-
+
- ${h.text('rhodecode_subversion_http_server_url',size=59)}
+ ${h.text('vcs_svn_proxy_http_server_url',size=59)}
-
-
- ${_('Url to Apache Proxy, e.g. http://localhost:8080/')}
-
-
+
+
+ % endif
+
+ % if display_globals or repo_type in ['svn']:
+
+
+
${_('Subversion Settings')}
+
+
@@ -232,6 +237,9 @@
${h.hidden('new_svn_tag' + suffix, '')}
% endif
+
+
+
% if display_globals or repo_type in ['hg', 'git']:
diff --git a/rhodecode/tests/functional/test_admin_settings.py b/rhodecode/tests/functional/test_admin_settings.py
--- a/rhodecode/tests/functional/test_admin_settings.py
+++ b/rhodecode/tests/functional/test_admin_settings.py
@@ -347,13 +347,13 @@ class TestAdminSettingsVcs:
with mock.patch.dict(
rhodecode.CONFIG, {'labs_settings_active': 'true'}):
response = self.app.get(url('admin_settings_vcs'))
- response.mustcontain('Labs settings:')
+ response.mustcontain('Labs Settings')
def test_has_not_a_section_for_labs_settings_if_disables(self, app):
with mock.patch.dict(
rhodecode.CONFIG, {'labs_settings_active': 'false'}):
response = self.app.get(url('admin_settings_vcs'))
- response.mustcontain(no='Labs settings:')
+ response.mustcontain(no='Labs Settings')
@pytest.mark.parametrize('new_value', [True, False])
def test_allows_to_change_hg_rebase_merge_strategy(
@@ -444,50 +444,6 @@ class TestLabsSettings(object):
assert '
text help
' in response
assert 'name="rhodecode_text" size="60" type="text"' in response
- @pytest.mark.parametrize('setting_name', [
- 'proxy_subversion_http_requests',
- ])
- def test_update_boolean_settings(self, csrf_token, setting_name):
- self.app.post(
- url('admin_settings_labs'),
- params={
- 'rhodecode_{}'.format(setting_name): 'true',
- 'csrf_token': csrf_token,
- })
- setting = SettingsModel().get_setting_by_name(setting_name)
- assert setting.app_settings_value
-
- self.app.post(
- url('admin_settings_labs'),
- params={
- 'rhodecode_{}'.format(setting_name): 'false',
- 'csrf_token': csrf_token,
- })
- setting = SettingsModel().get_setting_by_name(setting_name)
- assert not setting.app_settings_value
-
- @pytest.mark.parametrize('setting_name', [
- 'subversion_http_server_url',
- ])
- def test_update_string_settings(self, csrf_token, setting_name):
- self.app.post(
- url('admin_settings_labs'),
- params={
- 'rhodecode_{}'.format(setting_name): 'Test 1',
- 'csrf_token': csrf_token,
- })
- setting = SettingsModel().get_setting_by_name(setting_name)
- assert setting.app_settings_value == 'Test 1'
-
- self.app.post(
- url('admin_settings_labs'),
- params={
- 'rhodecode_{}'.format(setting_name): ' Test 2 ',
- 'csrf_token': csrf_token,
- })
- setting = SettingsModel().get_setting_by_name(setting_name)
- assert setting.app_settings_value == 'Test 2'
-
@pytest.mark.usefixtures('app')
class TestOpenSourceLicenses(object):
diff --git a/rhodecode/tests/lib/middleware/test_simplesvn.py b/rhodecode/tests/lib/middleware/test_simplesvn.py
--- a/rhodecode/tests/lib/middleware/test_simplesvn.py
+++ b/rhodecode/tests/lib/middleware/test_simplesvn.py
@@ -78,14 +78,29 @@ class TestSimpleSvn(object):
assert name == repo.repo_name
def test_create_wsgi_app(self):
- with patch('rhodecode.lib.middleware.simplesvn.SimpleSvnApp') as (
- wsgi_app_mock):
- config = Mock()
- wsgi_app = self.app._create_wsgi_app(
- repo_path='', repo_name='', config=config)
+ with patch.object(SimpleSvn, '_is_svn_enabled') as mock_method:
+ mock_method.return_value = False
+ with patch('rhodecode.lib.middleware.simplesvn.DisabledSimpleSvnApp') as (
+ wsgi_app_mock):
+ config = Mock()
+ wsgi_app = self.app._create_wsgi_app(
+ repo_path='', repo_name='', config=config)
+
+ wsgi_app_mock.assert_called_once_with(config)
+ assert wsgi_app == wsgi_app_mock()
- wsgi_app_mock.assert_called_once_with(config)
- assert wsgi_app == wsgi_app_mock()
+ def test_create_wsgi_app_when_enabled(self):
+ with patch.object(SimpleSvn, '_is_svn_enabled') as mock_method:
+ mock_method.return_value = True
+ with patch('rhodecode.lib.middleware.simplesvn.SimpleSvnApp') as (
+ wsgi_app_mock):
+ config = Mock()
+ wsgi_app = self.app._create_wsgi_app(
+ repo_path='', repo_name='', config=config)
+
+ wsgi_app_mock.assert_called_once_with(config)
+ assert wsgi_app == wsgi_app_mock()
+
class TestSimpleSvnApp(object):
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
@@ -22,11 +22,15 @@ from mock import patch, Mock
import rhodecode
from rhodecode.lib.middleware import vcs
+from rhodecode.lib.middleware.simplesvn import (
+ SimpleSvn, DisabledSimpleSvnApp, SimpleSvnApp)
+from rhodecode.tests import SVN_REPO
+svn_repo_path = '/'+ SVN_REPO
def test_is_hg():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
'QUERY_STRING': 'cmd=changegroup',
'HTTP_ACCEPT': 'application/mercurial'
}
@@ -35,7 +39,7 @@ def test_is_hg():
def test_is_hg_no_cmd():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
'QUERY_STRING': '',
'HTTP_ACCEPT': 'application/mercurial'
}
@@ -44,7 +48,7 @@ def test_is_hg_no_cmd():
def test_is_hg_empty_cmd():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
'QUERY_STRING': 'cmd=',
'HTTP_ACCEPT': 'application/mercurial'
}
@@ -53,7 +57,7 @@ def test_is_hg_empty_cmd():
def test_is_svn_returns_true_if_subversion_is_in_a_dav_header():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log-revprops'
}
assert vcs.is_svn(environ) is True
@@ -61,7 +65,7 @@ def test_is_svn_returns_true_if_subversi
def test_is_svn_returns_false_if_subversion_is_not_in_a_dav_header():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
'HTTP_DAV': 'http://stuff.tigris.org/xmlns/dav/svn/log-revprops'
}
assert vcs.is_svn(environ) is False
@@ -69,7 +73,7 @@ def test_is_svn_returns_false_if_subvers
def test_is_svn_returns_false_if_no_dav_header():
environ = {
- 'PATH_INFO': '/rhodecode-dev',
+ 'PATH_INFO': svn_repo_path,
}
assert vcs.is_svn(environ) is False
@@ -95,42 +99,42 @@ def test_is_svn_allows_to_configure_the_
class TestVCSMiddleware(object):
- def test_get_handler_app_retuns_svn_app_when_proxy_enabled(self):
+ def test_get_handler_app_retuns_svn_app_when_proxy_enabled(self, app):
environ = {
- 'PATH_INFO': 'rhodecode-dev',
+ 'PATH_INFO': SVN_REPO,
'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log'
}
- app = Mock()
- config = Mock()
+ application = Mock()
+ config = {'appenlight': False}
registry = Mock()
middleware = vcs.VCSMiddleware(
- app, config=config, appenlight_client=None, registry=registry)
- snv_patch = patch('rhodecode.lib.middleware.vcs.SimpleSvn')
- settings_patch = patch.dict(
- rhodecode.CONFIG,
- {'rhodecode_proxy_subversion_http_requests': True})
- with snv_patch as svn_mock, settings_patch:
- svn_mock.return_value = None
- middleware._get_handler_app(environ)
+ application, config=config,
+ appenlight_client=None, registry=registry)
+ middleware.use_gzip = False
- svn_mock.assert_called_once_with(app, config, registry)
+ with patch.object(SimpleSvn, '_is_svn_enabled') as mock_method:
+ mock_method.return_value = True
+ application = middleware._get_handler_app(environ)
+ assert isinstance(application, SimpleSvn)
+ assert isinstance(application._create_wsgi_app(
+ Mock(), Mock(), Mock()), SimpleSvnApp)
- def test_get_handler_app_retuns_no_svn_app_when_proxy_disabled(self):
+ def test_get_handler_app_retuns_dummy_svn_app_when_proxy_disabled(self, app):
environ = {
- 'PATH_INFO': 'rhodecode-dev',
+ 'PATH_INFO': SVN_REPO,
'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log'
}
- app = Mock()
- config = Mock()
+ application = Mock()
+ config = {'appenlight': False}
registry = Mock()
middleware = vcs.VCSMiddleware(
- app, config=config, appenlight_client=None, registry=registry)
- snv_patch = patch('rhodecode.lib.middleware.vcs.SimpleSvn')
- settings_patch = patch.dict(
- rhodecode.CONFIG,
- {'rhodecode_proxy_subversion_http_requests': False})
- with snv_patch as svn_mock, settings_patch:
- app = middleware._get_handler_app(environ)
+ application, config=config,
+ appenlight_client=None, registry=registry)
+ middleware.use_gzip = False
- assert svn_mock.call_count == 0
- assert app is None
+ with patch.object(SimpleSvn, '_is_svn_enabled') as mock_method:
+ mock_method.return_value = False
+ application = middleware._get_handler_app(environ)
+ assert isinstance(application, SimpleSvn)
+ assert isinstance(application._create_wsgi_app(
+ Mock(), Mock(), Mock()), DisabledSimpleSvnApp)
diff --git a/rhodecode/tests/models/settings/test_vcs_settings.py b/rhodecode/tests/models/settings/test_vcs_settings.py
--- a/rhodecode/tests/models/settings/test_vcs_settings.py
+++ b/rhodecode/tests/models/settings/test_vcs_settings.py
@@ -404,15 +404,6 @@ class TestCreateRepoSvnSettings(object):
assert exc_info.value.message == 'Repository is not specified'
-class TestCreateGlobalSvnSettings(object):
- def test_calls_create_svn_settings(self):
- model = VcsSettingsModel()
- with mock.patch.object(model, '_create_svn_settings') as create_mock:
- model.create_global_svn_settings(SVN_FORM_DATA)
- create_mock.assert_called_once_with(
- model.global_settings, SVN_FORM_DATA)
-
-
class TestCreateSvnSettings(object):
def test_create(self, repo_stub):
model = VcsSettingsModel(repo=repo_stub.repo_name)