##// END OF EJS Templates
feat(repo_path-config): moved main storage location path into ini file. Fixes: RCCE-61
ilin.s -
r5356:99a91100 default
parent child Browse files
Show More
@@ -261,8 +261,8 b' auth_ret_code_detection = false'
261 ; codes don't break the transactions while 4XX codes do
261 ; codes don't break the transactions while 4XX codes do
262 lock_ret_code = 423
262 lock_ret_code = 423
263
263
264 ; allows to change the repository location in settings page
264 ; Filesystem location were repositories should be stored
265 allow_repo_location_change = true
265 repo_store.path = /var/opt/rhodecode_repo_store
266
266
267 ; allows to setup custom hooks in settings page
267 ; allows to setup custom hooks in settings page
268 allow_custom_hooks_settings = true
268 allow_custom_hooks_settings = true
@@ -212,8 +212,8 b' auth_ret_code_detection = false'
212 ; codes don't break the transactions while 4XX codes do
212 ; codes don't break the transactions while 4XX codes do
213 lock_ret_code = 423
213 lock_ret_code = 423
214
214
215 ; allows to change the repository location in settings page
215 ; Filesystem location were repositories should be stored
216 allow_repo_location_change = true
216 repo_store.path = /var/opt/rhodecode_repo_store
217
217
218 ; allows to setup custom hooks in settings page
218 ; allows to setup custom hooks in settings page
219 allow_custom_hooks_settings = true
219 allow_custom_hooks_settings = true
@@ -25,7 +25,7 b' from rhodecode.api import ('
25
25
26 from rhodecode.api.utils import (
26 from rhodecode.api.utils import (
27 Optional, OAttr, has_superadmin_permission, get_user_or_error)
27 Optional, OAttr, has_superadmin_permission, get_user_or_error)
28 from rhodecode.lib.utils import repo2db_mapper
28 from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_repo_store_path
29 from rhodecode.lib import system_info
29 from rhodecode.lib import system_info
30 from rhodecode.lib import user_sessions
30 from rhodecode.lib import user_sessions
31 from rhodecode.lib import exc_tracking
31 from rhodecode.lib import exc_tracking
@@ -33,7 +33,6 b' from rhodecode.lib.ext_json import json'
33 from rhodecode.lib.utils2 import safe_int
33 from rhodecode.lib.utils2 import safe_int
34 from rhodecode.model.db import UserIpMap
34 from rhodecode.model.db import UserIpMap
35 from rhodecode.model.scm import ScmModel
35 from rhodecode.model.scm import ScmModel
36 from rhodecode.model.settings import VcsSettingsModel
37 from rhodecode.apps.file_store import utils
36 from rhodecode.apps.file_store import utils
38 from rhodecode.apps.file_store.exceptions import FileNotAllowedException, \
37 from rhodecode.apps.file_store.exceptions import FileNotAllowedException, \
39 FileOverSizeException
38 FileOverSizeException
@@ -103,7 +102,7 b' def get_repo_store(request, apiuser):'
103 if not has_superadmin_permission(apiuser):
102 if not has_superadmin_permission(apiuser):
104 raise JSONRPCForbidden()
103 raise JSONRPCForbidden()
105
104
106 path = VcsSettingsModel().get_repos_location()
105 path = get_rhodecode_repo_store_path()
107 return {"path": path}
106 return {"path": path}
108
107
109
108
@@ -38,7 +38,7 b' from rhodecode.lib.auth import ('
38 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
38 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
39 from rhodecode.lib.celerylib import tasks, run_task
39 from rhodecode.lib.celerylib import tasks, run_task
40 from rhodecode.lib.str_utils import safe_str
40 from rhodecode.lib.str_utils import safe_str
41 from rhodecode.lib.utils import repo2db_mapper
41 from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_repo_store_path
42 from rhodecode.lib.utils2 import str2bool, AttributeDict
42 from rhodecode.lib.utils2 import str2bool, AttributeDict
43 from rhodecode.lib.index import searcher_from_config
43 from rhodecode.lib.index import searcher_from_config
44
44
@@ -167,9 +167,6 b' class AdminSettingsView(BaseAppView):'
167 return Response(html)
167 return Response(html)
168
168
169 try:
169 try:
170 if c.visual.allow_repo_location_change:
171 model.update_global_path_setting(form_result['paths_root_path'])
172
173 model.update_global_ssl_setting(form_result['web_push_ssl'])
170 model.update_global_ssl_setting(form_result['web_push_ssl'])
174 model.update_global_hook_settings(form_result)
171 model.update_global_hook_settings(form_result)
175
172
@@ -217,7 +214,7 b' class AdminSettingsView(BaseAppView):'
217 def settings_mapping(self):
214 def settings_mapping(self):
218 c = self.load_default_context()
215 c = self.load_default_context()
219 c.active = 'mapping'
216 c.active = 'mapping'
220 c.storage_path = VcsSettingsModel().get_repos_location()
217 c.storage_path = get_rhodecode_repo_store_path()
221 data = render('rhodecode:templates/admin/settings/settings.mako',
218 data = render('rhodecode:templates/admin/settings/settings.mako',
222 self._get_template_context(c), self.request)
219 self._get_template_context(c), self.request)
223 html = formencode.htmlfill.render(
220 html = formencode.htmlfill.render(
@@ -22,7 +22,7 b' import os'
22 from pyramid.renderers import render
22 from pyramid.renderers import render
23
23
24 from rhodecode.events import trigger
24 from rhodecode.events import trigger
25 from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_base_path
25 from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_repo_store_path
26 from rhodecode.lib.utils2 import str2bool
26 from rhodecode.lib.utils2 import str2bool
27 from rhodecode.model.db import RepoGroup
27 from rhodecode.model.db import RepoGroup
28
28
@@ -38,7 +38,7 b' def write_mod_dav_svn_config(settings):'
38 file_path = settings[config_keys.config_file_path]
38 file_path = settings[config_keys.config_file_path]
39 config = _render_mod_dav_svn_config(
39 config = _render_mod_dav_svn_config(
40 use_ssl=use_ssl,
40 use_ssl=use_ssl,
41 parent_path_root=get_rhodecode_base_path(),
41 parent_path_root=get_rhodecode_repo_store_path(),
42 list_parent_path=settings[config_keys.list_parent_path],
42 list_parent_path=settings[config_keys.list_parent_path],
43 location_root=settings[config_keys.location_root],
43 location_root=settings[config_keys.location_root],
44 repo_groups=RepoGroup.get_all_repo_groups(),
44 repo_groups=RepoGroup.get_all_repo_groups(),
@@ -117,6 +117,8 b' def sanitize_settings_and_apply_defaults'
117
117
118 settings_maker.make_setting('vcs.methods.cache', True, parser='bool')
118 settings_maker.make_setting('vcs.methods.cache', True, parser='bool')
119
119
120 # repo_store path
121 settings_maker.make_setting('repo_store.path', '/var/opt/rhodecode_repo_store')
120 # Support legacy values of vcs.scm_app_implementation. Legacy
122 # Support legacy values of vcs.scm_app_implementation. Legacy
121 # configurations may use 'rhodecode.lib.middleware.utils.scm_app_http', or
123 # configurations may use 'rhodecode.lib.middleware.utils.scm_app_http', or
122 # disabled since 4.13 'vcsserver.scm_app' which is now mapped to 'http'.
124 # disabled since 4.13 'vcsserver.scm_app' which is now mapped to 'http'.
@@ -81,7 +81,6 b' def load_pyramid_environment(global_conf'
81 rhodecode.PYRAMID_SETTINGS = settings_merged
81 rhodecode.PYRAMID_SETTINGS = settings_merged
82 rhodecode.CONFIG = settings_merged
82 rhodecode.CONFIG = settings_merged
83 rhodecode.CONFIG['default_user_id'] = utils.get_default_user_id()
83 rhodecode.CONFIG['default_user_id'] = utils.get_default_user_id()
84 rhodecode.CONFIG['default_base_path'] = utils.get_default_base_path()
85
84
86 if vcs_server_enabled:
85 if vcs_server_enabled:
87 connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(settings))
86 connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(settings))
@@ -102,15 +102,3 b' def get_default_user_id():'
102 user_id = result.first()[0]
102 user_id = result.first()[0]
103
103
104 return user_id
104 return user_id
105
106
107 def get_default_base_path():
108 from sqlalchemy import text
109 from rhodecode.model import meta
110
111 engine = meta.get_engine()
112 with meta.SA_Session(engine) as session:
113 result = session.execute(text("SELECT ui_value from rhodecode_ui where ui_key = '/'"))
114 base_path = result.first()[0]
115
116 return base_path
@@ -347,8 +347,6 b' def attach_context_attributes(context, r'
347 context.ssh_key_generator_enabled = str2bool(
347 context.ssh_key_generator_enabled = str2bool(
348 config.get('ssh.enable_ui_key_generator', 'true'))
348 config.get('ssh.enable_ui_key_generator', 'true'))
349
349
350 context.visual.allow_repo_location_change = str2bool(
351 config.get('allow_repo_location_change', True))
352 context.visual.allow_custom_hooks_settings = str2bool(
350 context.visual.allow_custom_hooks_settings = str2bool(
353 config.get('allow_custom_hooks_settings', True))
351 config.get('allow_custom_hooks_settings', True))
354 context.debug_style = str2bool(config.get('debug_style', False))
352 context.debug_style = str2bool(config.get('debug_style', False))
@@ -156,17 +156,10 b' class SimpleVCS(object):'
156
156
157 @property
157 @property
158 def base_path(self):
158 def base_path(self):
159 settings_path = self.repo_vcs_config.get(*VcsSettingsModel.PATH_SETTING)
159 settings_path = self.config.get('repo_store.path')
160
161 if not settings_path:
162 settings_path = self.global_vcs_config.get(*VcsSettingsModel.PATH_SETTING)
163
160
164 if not settings_path:
161 if not settings_path:
165 # try, maybe we passed in explicitly as config option
162 raise ValueError('FATAL: repo_store.path is empty')
166 settings_path = self.config.get('base_path')
167
168 if not settings_path:
169 raise ValueError('FATAL: base_path is empty')
170 return settings_path
163 return settings_path
171
164
172 def set_repo_names(self, environ):
165 def set_repo_names(self, environ):
@@ -331,8 +331,8 b' def cpu():'
331 @register_sysinfo
331 @register_sysinfo
332 def storage():
332 def storage():
333 from rhodecode.lib.helpers import format_byte_size_binary
333 from rhodecode.lib.helpers import format_byte_size_binary
334 from rhodecode.model.settings import VcsSettingsModel
334 from rhodecode.lib.utils import get_rhodecode_repo_store_path
335 path = VcsSettingsModel().get_repos_location()
335 path = get_rhodecode_repo_store_path()
336
336
337 value = dict(percent=0, used=0, total=0, path=path, text='')
337 value = dict(percent=0, used=0, total=0, path=path, text='')
338 state = STATE_OK_DEFAULT
338 state = STATE_OK_DEFAULT
@@ -364,8 +364,8 b' def storage():'
364
364
365 @register_sysinfo
365 @register_sysinfo
366 def storage_inodes():
366 def storage_inodes():
367 from rhodecode.model.settings import VcsSettingsModel
367 from rhodecode.lib.utils import get_rhodecode_repo_store_path
368 path = VcsSettingsModel().get_repos_location()
368 path = get_rhodecode_repo_store_path()
369
369
370 value = dict(percent=0.0, free=0, used=0, total=0, path=path, text='')
370 value = dict(percent=0.0, free=0, used=0, total=0, path=path, text='')
371 state = STATE_OK_DEFAULT
371 state = STATE_OK_DEFAULT
@@ -442,11 +442,10 b' def storage_archives():'
442 @register_sysinfo
442 @register_sysinfo
443 def storage_gist():
443 def storage_gist():
444 from rhodecode.model.gist import GIST_STORE_LOC
444 from rhodecode.model.gist import GIST_STORE_LOC
445 from rhodecode.model.settings import VcsSettingsModel
445 from rhodecode.lib.utils import safe_str, get_rhodecode_repo_store_path
446 from rhodecode.lib.utils import safe_str
447 from rhodecode.lib.helpers import format_byte_size_binary
446 from rhodecode.lib.helpers import format_byte_size_binary
448 path = safe_str(os.path.join(
447 path = safe_str(os.path.join(
449 VcsSettingsModel().get_repos_location(), GIST_STORE_LOC))
448 get_rhodecode_repo_store_path(), GIST_STORE_LOC))
450
449
451 # gist storage
450 # gist storage
452 value = dict(percent=0, used=0, total=0, items=0, path=path, text='')
451 value = dict(percent=0, used=0, total=0, items=0, path=path, text='')
@@ -472,14 +472,14 b' def get_rhodecode_realm():'
472 return safe_str(realm.app_settings_value)
472 return safe_str(realm.app_settings_value)
473
473
474
474
475 def get_rhodecode_base_path():
475 def get_rhodecode_repo_store_path():
476 """
476 """
477 Returns the base path. The base path is the filesystem path which points
477 Returns the base path. The base path is the filesystem path which points
478 to the repository store.
478 to the repository store.
479 """
479 """
480
480
481 import rhodecode
481 import rhodecode
482 return rhodecode.CONFIG['default_base_path']
482 return rhodecode.CONFIG['repo_store.path']
483
483
484
484
485 def map_groups(path):
485 def map_groups(path):
@@ -21,6 +21,7 b' import logging'
21
21
22 import rhodecode
22 import rhodecode
23 from rhodecode.model import meta, db
23 from rhodecode.model import meta, db
24 from rhodecode.lib.utils import get_rhodecode_repo_store_path
24 from rhodecode.lib.utils2 import obfuscate_url_pw, get_encryption_key
25 from rhodecode.lib.utils2 import obfuscate_url_pw, get_encryption_key
25
26
26 log = logging.getLogger(__name__)
27 log = logging.getLogger(__name__)
@@ -138,3 +139,11 b' class BaseModel(object):'
138 Returns all instances of what is defined in `cls` class variable
139 Returns all instances of what is defined in `cls` class variable
139 """
140 """
140 return cls.cls.getAll()
141 return cls.cls.getAll()
142
143 @property
144 def repos_path(self):
145 """
146 Gets the repositories root path from *ini file
147 """
148
149 return get_rhodecode_repo_store_path()
@@ -1942,8 +1942,8 b' class Repository(Base, BaseModel):'
1942
1942
1943 :param cls:
1943 :param cls:
1944 """
1944 """
1945 from rhodecode.lib.utils import get_rhodecode_base_path
1945 from rhodecode.lib.utils import get_rhodecode_repo_store_path
1946 return get_rhodecode_base_path()
1946 return get_rhodecode_repo_store_path()
1947
1947
1948 @classmethod
1948 @classmethod
1949 def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None),
1949 def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None),
@@ -2009,16 +2009,13 b' class Repository(Base, BaseModel):'
2009 def groups_and_repo(self):
2009 def groups_and_repo(self):
2010 return self.groups_with_parents, self
2010 return self.groups_with_parents, self
2011
2011
2012 @LazyProperty
2012 @property
2013 def repo_path(self):
2013 def repo_path(self):
2014 """
2014 """
2015 Returns base full path for that repository means where it actually
2015 Returns base full path for that repository means where it actually
2016 exists on a filesystem
2016 exists on a filesystem
2017 """
2017 """
2018 q = Session().query(RhodeCodeUi).filter(
2018 return self.base_path()
2019 RhodeCodeUi.ui_key == self.NAME_SEP)
2020 q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
2021 return q.one().ui_value
2022
2019
2023 @property
2020 @property
2024 def repo_full_path(self):
2021 def repo_full_path(self):
@@ -434,10 +434,6 b' def ApplicationUiSettingsForm(localizer)'
434
434
435 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
435 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
436 web_push_ssl = v.StringBoolean(if_missing=False)
436 web_push_ssl = v.StringBoolean(if_missing=False)
437 paths_root_path = All(
438 v.ValidPath(localizer),
439 v.UnicodeString(strip=True, min=1, not_empty=True)
440 )
441 largefiles_usercache = All(
437 largefiles_usercache = All(
442 v.ValidPath(localizer),
438 v.ValidPath(localizer),
443 v.UnicodeString(strip=True, min=2, not_empty=True))
439 v.UnicodeString(strip=True, min=2, not_empty=True))
@@ -83,14 +83,6 b' class RepoModel(BaseModel):'
83
83
84 return repo_to_perm
84 return repo_to_perm
85
85
86 @LazyProperty
87 def repos_path(self):
88 """
89 Gets the repositories root path from database
90 """
91 settings_model = VcsSettingsModel(sa=self.sa)
92 return settings_model.get_repos_location()
93
94 def get(self, repo_id):
86 def get(self, repo_id):
95 repo = self.sa.query(Repository) \
87 repo = self.sa.query(Repository) \
96 .filter(Repository.repo_id == repo_id)
88 .filter(Repository.repo_id == repo_id)
@@ -62,15 +62,6 b' class RepoGroupModel(BaseModel):'
62 def get_repo_group(self, repo_group):
62 def get_repo_group(self, repo_group):
63 return self._get_repo_group(repo_group)
63 return self._get_repo_group(repo_group)
64
64
65 @LazyProperty
66 def repos_path(self):
67 """
68 Gets the repositories root path from database
69 """
70
71 settings_model = VcsSettingsModel(sa=self.sa)
72 return settings_model.get_repos_location()
73
74 def get_by_group_name(self, repo_group_name, cache=None):
65 def get_by_group_name(self, repo_group_name, cache=None):
75 repo = self.sa.query(RepoGroup) \
66 repo = self.sa.query(RepoGroup) \
76 .filter(RepoGroup.group_name == repo_group_name)
67 .filter(RepoGroup.group_name == repo_group_name)
@@ -189,15 +189,6 b' class ScmModel(BaseModel):'
189 Generic Scm Model
189 Generic Scm Model
190 """
190 """
191
191
192 @LazyProperty
193 def repos_path(self):
194 """
195 Gets the repositories root path from database
196 """
197
198 settings_model = VcsSettingsModel(sa=self.sa)
199 return settings_model.get_repos_location()
200
201 def repo_scan(self, repos_path=None):
192 def repo_scan(self, repos_path=None):
202 """
193 """
203 Listing of repositories in given path. This path should not be a
194 Listing of repositories in given path. This path should not be a
@@ -811,9 +811,6 b' class VcsSettingsModel(object):'
811 else:
811 else:
812 return self.get_repo_general_settings()
812 return self.get_repo_general_settings()
813
813
814 def get_repos_location(self):
815 return self.global_settings.get_ui_by_key('/').ui_value
816
817 def _filter_ui_settings(self, settings):
814 def _filter_ui_settings(self, settings):
818 filtered_settings = [
815 filtered_settings = [
819 s for s in settings if self._should_keep_setting(s)]
816 s for s in settings if self._should_keep_setting(s)]
@@ -116,8 +116,9 b' def scan_repositories_if_enabled(event):'
116 import_on_startup = settings['startup.import_repos']
116 import_on_startup = settings['startup.import_repos']
117 if vcs_server_enabled and import_on_startup:
117 if vcs_server_enabled and import_on_startup:
118 from rhodecode.model.scm import ScmModel
118 from rhodecode.model.scm import ScmModel
119 from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_base_path
119 from rhodecode.lib.utils import repo2db_mapper
120 repositories = ScmModel().repo_scan(get_rhodecode_base_path())
120 scm = ScmModel()
121 repositories = scm.repo_scan(scm.repos_path)
121 repo2db_mapper(repositories, remove_obsolete=False)
122 repo2db_mapper(repositories, remove_obsolete=False)
122
123
123
124
@@ -6,8 +6,7 b''
6 suffix='',
6 suffix='',
7 svn_tag_patterns=c.svn_tag_patterns,
7 svn_tag_patterns=c.svn_tag_patterns,
8 svn_branch_patterns=c.svn_branch_patterns,
8 svn_branch_patterns=c.svn_branch_patterns,
9 display_globals=True,
9 display_globals=True
10 allow_repo_location_change=c.visual.allow_repo_location_change
11 )}
10 )}
12 <div class="buttons">
11 <div class="buttons">
13 ${h.submit('save',_('Save settings'),class_="btn")}
12 ${h.submit('save',_('Save settings'),class_="btn")}
@@ -3,7 +3,7 b''
3 ## <%namespace name="vcss" file="/base/vcssettings.mako"/>
3 ## <%namespace name="vcss" file="/base/vcssettings.mako"/>
4 ## ${vcss.vcs_settings_fields()}
4 ## ${vcss.vcs_settings_fields()}
5
5
6 <%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, allow_repo_location_change=False, **kwargs)">
6 <%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, **kwargs)">
7 % if display_globals:
7 % if display_globals:
8 <div class="panel panel-default">
8 <div class="panel panel-default">
9 <div class="panel-heading" id="general">
9 <div class="panel-heading" id="general">
@@ -23,34 +23,6 b''
23 </div>
23 </div>
24 % endif
24 % endif
25
25
26 % if display_globals:
27 <div class="panel panel-default">
28 <div class="panel-heading" id="vcs-storage-options">
29 <h3 class="panel-title">${_('Main Storage Location')}<a class="permalink" href="#vcs-storage-options"></a></h3>
30 </div>
31 <div class="panel-body">
32 <div class="field">
33 <div class="inputx locked_input">
34 %if allow_repo_location_change:
35 ${h.text('paths_root_path',size=59,readonly="readonly", class_="disabled")}
36 <span id="path_unlock" class="tooltip"
37 title="${h.tooltip(_('Click to unlock. You must restart RhodeCode in order to make this setting take effect.'))}">
38 <div class="btn btn-default lock_input_button"><i id="path_unlock_icon" class="icon-lock"></i></div>
39 </span>
40 %else:
41 ${_('Repository location change is disabled. You can enable this by changing the `allow_repo_location_change` inside .ini file.')}
42 ## form still requires this but we cannot internally change it anyway
43 ${h.hidden('paths_root_path',size=30,readonly="readonly", class_="disabled")}
44 %endif
45 </div>
46 </div>
47 <div class="label">
48 <span class="help-block">${_('Filesystem location where repositories should be stored. After changing this value a restart and rescan of the repository folder are required.')}</span>
49 </div>
50 </div>
51 </div>
52 % endif
53
54 % if display_globals or repo_type in ['git', 'hg']:
26 % if display_globals or repo_type in ['git', 'hg']:
55 <div class="panel panel-default">
27 <div class="panel panel-default">
56 <div class="panel-heading" id="vcs-hooks-options">
28 <div class="panel-heading" id="vcs-hooks-options">
@@ -27,6 +27,7 b' import urllib.parse'
27
27
28 import pytest
28 import pytest
29
29
30 import rhodecode
30 from rhodecode.model.db import User
31 from rhodecode.model.db import User
31 from rhodecode.lib import auth
32 from rhodecode.lib import auth
32 from rhodecode.lib import helpers as h
33 from rhodecode.lib import helpers as h
@@ -53,8 +54,11 b' log = logging.getLogger(__name__)'
53
54
54 # SOME GLOBALS FOR TESTS
55 # SOME GLOBALS FOR TESTS
55 TEST_DIR = tempfile.gettempdir()
56 TEST_DIR = tempfile.gettempdir()
57 if os.getenv("RC_TEST"):
58 rhodecode.CONFIG['repo_store.path'] = TEST_DIR
56
59
57 TESTS_TMP_PATH = jn(TEST_DIR, 'rc_test_{}'.format(next(tempfile._RandomNameSequence())))
60 # Once repo_store.path in test config will be changed update TEST_TMP_PATH accordingly
61 TESTS_TMP_PATH = jn(TEST_DIR, 'rc_test_a0hmmrva')
58 TEST_USER_ADMIN_LOGIN = 'test_admin'
62 TEST_USER_ADMIN_LOGIN = 'test_admin'
59 TEST_USER_ADMIN_PASS = 'test12'
63 TEST_USER_ADMIN_PASS = 'test12'
60 TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com'
64 TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com'
@@ -111,7 +115,7 b' def get_new_dir(title):'
111 hex_str = sha1_safe(f'{os.getpid()} {time.time()}')
115 hex_str = sha1_safe(f'{os.getpid()} {time.time()}')
112 name_parts.append(hex_str)
116 name_parts.append(hex_str)
113 name = '-'.join(name_parts)
117 name = '-'.join(name_parts)
114 path = os.path.join(TEST_DIR, name)
118 path = jn(TEST_DIR, name)
115 return get_normalized_path(path)
119 return get_normalized_path(path)
116
120
117
121
@@ -23,16 +23,16 b' import pytest'
23 from unittest.mock import patch, Mock, MagicMock
23 from unittest.mock import patch, Mock, MagicMock
24
24
25 from rhodecode.lib.middleware.simplesvn import SimpleSvn, SimpleSvnApp
25 from rhodecode.lib.middleware.simplesvn import SimpleSvn, SimpleSvnApp
26 from rhodecode.lib.utils import get_rhodecode_base_path
26 from rhodecode.lib.utils import get_rhodecode_repo_store_path
27 from rhodecode.tests import SVN_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
27 from rhodecode.tests import SVN_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
28
28
29
29
30 class TestSimpleSvn(object):
30 class TestSimpleSvn(object):
31 @pytest.fixture(autouse=True)
31 @pytest.fixture(autouse=True)
32 def simple_svn(self, baseapp, request_stub):
32 def simple_svn(self, baseapp, request_stub):
33 base_path = get_rhodecode_base_path()
33 base_path = get_rhodecode_repo_store_path()
34 self.app = SimpleSvn(
34 self.app = SimpleSvn(
35 config={'auth_ret_code': '', 'base_path': base_path},
35 config={'auth_ret_code': '', 'repo_store.path': base_path},
36 registry=request_stub.registry)
36 registry=request_stub.registry)
37
37
38 def test_get_config(self):
38 def test_get_config(self):
@@ -126,7 +126,7 b' class TestSimpleSvnApp(object):'
126 def setup_method(self, method):
126 def setup_method(self, method):
127 # note(marcink): this is hostname from docker compose used for testing...
127 # note(marcink): this is hostname from docker compose used for testing...
128 self.host = 'http://svn:8090'
128 self.host = 'http://svn:8090'
129 base_path = get_rhodecode_base_path()
129 base_path = get_rhodecode_repo_store_path()
130 self.app = SimpleSvnApp(
130 self.app = SimpleSvnApp(
131 config={'subversion_http_server_url': self.host,
131 config={'subversion_http_server_url': self.host,
132 'base_path': base_path})
132 'base_path': base_path})
@@ -1004,21 +1004,6 b' class TestGetSvnPatterns(object):'
1004 settings_mock.assert_called_once_with(*args)
1004 settings_mock.assert_called_once_with(*args)
1005
1005
1006
1006
1007 class TestGetReposLocation(object):
1008 def test_returns_repos_location(self, repo_stub):
1009 model = VcsSettingsModel()
1010
1011 result_mock = mock.Mock()
1012 result_mock.ui_value = '/tmp'
1013
1014 with mock.patch.object(model, 'global_settings') as settings_mock:
1015 settings_mock.get_ui_by_key.return_value = result_mock
1016 result = model.get_repos_location()
1017
1018 settings_mock.get_ui_by_key.assert_called_once_with('/')
1019 assert result == '/tmp'
1020
1021
1022 class TestCreateOrUpdateRepoSettings(object):
1007 class TestCreateOrUpdateRepoSettings(object):
1023 FORM_DATA = {
1008 FORM_DATA = {
1024 'inherit_global_settings': False,
1009 'inherit_global_settings': False,
@@ -121,20 +121,20 b' class TestRepoModel(object):'
121 def test_create_filesystem_repo_installs_hooks(self, tmpdir, backend):
121 def test_create_filesystem_repo_installs_hooks(self, tmpdir, backend):
122 repo = backend.create_repo()
122 repo = backend.create_repo()
123 repo_name = repo.repo_name
123 repo_name = repo.repo_name
124 model = RepoModel()
124 with mock.patch('rhodecode.model.repo.RepoModel.repos_path',
125 repo_location = tempfile.mkdtemp()
125 new_callable=mock.PropertyMock) as mocked_models_property:
126 model.repos_path = repo_location
126 mocked_models_property.return_value = tempfile.mkdtemp()
127 repo = model._create_filesystem_repo(
127 repo = RepoModel()._create_filesystem_repo(
128 repo_name, backend.alias, repo_group='', clone_uri=None)
128 repo_name, backend.alias, repo_group='', clone_uri=None)
129
129
130 hooks = {
130 hooks = {
131 'svn': ('pre-commit', 'post-commit'),
131 'svn': ('pre-commit', 'post-commit'),
132 'git': ('pre-receive', 'post-receive'),
132 'git': ('pre-receive', 'post-receive'),
133 }
133 }
134 for hook in hooks[backend.alias]:
134 for hook in hooks[backend.alias]:
135 with open(os.path.join(repo.path, 'hooks', hook)) as f:
135 with open(os.path.join(repo.path, 'hooks', hook)) as f:
136 data = f.read()
136 data = f.read()
137 assert 'RC_HOOK_VER' in data
137 assert 'RC_HOOK_VER' in data
138
138
139 @pytest.mark.parametrize("use_global_config, repo_name_passed", [
139 @pytest.mark.parametrize("use_global_config, repo_name_passed", [
140 (True, False),
140 (True, False),
@@ -207,9 +207,6 b' auth_ret_code_detection = false'
207 ; codes don't break the transactions while 4XX codes do
207 ; codes don't break the transactions while 4XX codes do
208 lock_ret_code = 423
208 lock_ret_code = 423
209
209
210 ; allows to change the repository location in settings page
211 allow_repo_location_change = true
212
213 ; allows to setup custom hooks in settings page
210 ; allows to setup custom hooks in settings page
214 allow_custom_hooks_settings = true
211 allow_custom_hooks_settings = true
215
212
General Comments 0
You need to be logged in to leave comments. Login now