Show More
@@ -0,0 +1,28 b'' | |||
|
1 | # -*- coding: utf-8 -*- | |
|
2 | ||
|
3 | # Copyright (C) 2016-2016 RhodeCode GmbH | |
|
4 | # | |
|
5 | # This program is free software: you can redistribute it and/or modify | |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
|
7 | # (only), as published by the Free Software Foundation. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
|
16 | # | |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
|
20 | ||
|
21 | ||
|
22 | # Definition of setting keys used to configure this module. Defined here to | |
|
23 | # avoid repetition of keys throughout the module. | |
|
24 | config_file_path = 'svn.proxy.config_file_path' | |
|
25 | generate_config = 'svn.proxy.generate_config' | |
|
26 | list_parent_path = 'svn.proxy.list_parent_path' | |
|
27 | location_root = 'svn.proxy.location_root' | |
|
28 | parent_path_root = 'svn.proxy.parent_path_root' |
@@ -25,7 +25,7 b' from rhodecode import events' | |||
|
25 | 25 | from rhodecode.lib.utils2 import str2bool |
|
26 | 26 | |
|
27 | 27 | from .subscribers import generate_config_subscriber |
|
28 | from . import keys | |
|
28 | from . import config_keys | |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 | log = logging.getLogger(__name__) |
@@ -35,7 +35,7 b' def includeme(config):' | |||
|
35 | 35 | settings = config.registry.settings |
|
36 | 36 | _sanitize_settings_and_apply_defaults(settings) |
|
37 | 37 | |
|
38 | if settings[keys.generate_config]: | |
|
38 | if settings[config_keys.generate_config]: | |
|
39 | 39 | config.add_subscriber( |
|
40 | 40 | generate_config_subscriber, events.RepoGroupEvent) |
|
41 | 41 | |
@@ -45,25 +45,25 b' def _sanitize_settings_and_apply_default' | |||
|
45 | 45 | Set defaults, convert to python types and validate settings. |
|
46 | 46 | """ |
|
47 | 47 | # Convert bool settings from string to bool. |
|
48 | settings[keys.generate_config] = str2bool( | |
|
49 | settings.get(keys.generate_config, 'false')) | |
|
50 | settings[keys.list_parent_path] = str2bool( | |
|
51 | settings.get(keys.list_parent_path, 'true')) | |
|
48 | settings[config_keys.generate_config] = str2bool( | |
|
49 | settings.get(config_keys.generate_config, 'false')) | |
|
50 | settings[config_keys.list_parent_path] = str2bool( | |
|
51 | settings.get(config_keys.list_parent_path, 'true')) | |
|
52 | 52 | |
|
53 | 53 | # Set defaults if key not present. |
|
54 | settings.setdefault(keys.config_file_path, None) | |
|
55 | settings.setdefault(keys.location_root, '/') | |
|
56 | settings.setdefault(keys.parent_path_root, None) | |
|
54 | settings.setdefault(config_keys.config_file_path, None) | |
|
55 | settings.setdefault(config_keys.location_root, '/') | |
|
56 | settings.setdefault(config_keys.parent_path_root, None) | |
|
57 | 57 | |
|
58 | 58 | # Append path separator to paths. |
|
59 | settings[keys.location_root] = _append_path_sep( | |
|
60 | settings[keys.location_root]) | |
|
61 | settings[keys.parent_path_root] = _append_path_sep( | |
|
62 | settings[keys.parent_path_root]) | |
|
59 | settings[config_keys.location_root] = _append_path_sep( | |
|
60 | settings[config_keys.location_root]) | |
|
61 | settings[config_keys.parent_path_root] = _append_path_sep( | |
|
62 | settings[config_keys.parent_path_root]) | |
|
63 | 63 | |
|
64 | 64 | # Validate settings. |
|
65 | if settings[keys.generate_config]: | |
|
66 | assert settings[keys.config_file_path] is not None | |
|
65 | if settings[config_keys.generate_config]: | |
|
66 | assert settings[config_keys.config_file_path] is not None | |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | def _append_path_sep(path): |
@@ -26,7 +26,7 b' import tempfile' | |||
|
26 | 26 | |
|
27 | 27 | from pyramid import testing |
|
28 | 28 | |
|
29 | from rhodecode.svn_support import keys | |
|
29 | from rhodecode.svn_support import config_keys | |
|
30 | 30 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config |
|
31 | 31 | |
|
32 | 32 | |
@@ -60,10 +60,10 b' class TestModDavSvnConfig(object):' | |||
|
60 | 60 | config_file_path = tempfile.mkstemp( |
|
61 | 61 | suffix='mod-dav-svn.conf', dir=cls.tempdir)[1] |
|
62 | 62 | return { |
|
63 | keys.config_file_path: config_file_path, | |
|
64 | keys.location_root: '/location/root/', | |
|
65 | keys.parent_path_root: '/parent/path/root/', | |
|
66 | keys.list_parent_path: True, | |
|
63 | config_keys.config_file_path: config_file_path, | |
|
64 | config_keys.location_root: '/location/root/', | |
|
65 | config_keys.parent_path_root: '/parent/path/root/', | |
|
66 | config_keys.list_parent_path: True, | |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | @classmethod |
@@ -86,7 +86,7 b' class TestModDavSvnConfig(object):' | |||
|
86 | 86 | generate_mod_dav_svn_config(settings) |
|
87 | 87 | |
|
88 | 88 | # Read generated file. |
|
89 | with open(settings[keys.config_file_path], 'r') as file_: | |
|
89 | with open(settings[config_keys.config_file_path], 'r') as file_: | |
|
90 | 90 | content = file_.read() |
|
91 | 91 | |
|
92 | 92 | # Assert that one location block exists for each repository group. |
@@ -109,11 +109,11 b' class TestModDavSvnConfig(object):' | |||
|
109 | 109 | |
|
110 | 110 | # Execute the method under test. |
|
111 | 111 | settings = self.get_settings() |
|
112 | settings[keys.list_parent_path] = True | |
|
112 | settings[config_keys.list_parent_path] = True | |
|
113 | 113 | generate_mod_dav_svn_config(settings) |
|
114 | 114 | |
|
115 | 115 | # Read generated file. |
|
116 | with open(settings[keys.config_file_path], 'r') as file_: | |
|
116 | with open(settings[config_keys.config_file_path], 'r') as file_: | |
|
117 | 117 | content = file_.read() |
|
118 | 118 | |
|
119 | 119 | # Make assertions. |
@@ -126,11 +126,11 b' class TestModDavSvnConfig(object):' | |||
|
126 | 126 | |
|
127 | 127 | # Execute the method under test. |
|
128 | 128 | settings = self.get_settings() |
|
129 | settings[keys.list_parent_path] = False | |
|
129 | settings[config_keys.list_parent_path] = False | |
|
130 | 130 | generate_mod_dav_svn_config(settings) |
|
131 | 131 | |
|
132 | 132 | # Read generated file. |
|
133 | with open(settings[keys.config_file_path], 'r') as file_: | |
|
133 | with open(settings[config_keys.config_file_path], 'r') as file_: | |
|
134 | 134 | content = file_.read() |
|
135 | 135 | |
|
136 | 136 | # Make assertions. |
@@ -23,7 +23,7 b' import os' | |||
|
23 | 23 | from pyramid.renderers import render |
|
24 | 24 | |
|
25 | 25 | from rhodecode.model.db import RepoGroup |
|
26 | from . import keys | |
|
26 | from . import config_keys | |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | def generate_mod_dav_svn_config(settings): |
@@ -33,10 +33,10 b' def generate_mod_dav_svn_config(settings' | |||
|
33 | 33 | available repository group because the mod_dav_svn module does not support |
|
34 | 34 | repositories organized in sub folders. |
|
35 | 35 | """ |
|
36 | filepath = settings[keys.config_file_path] | |
|
37 | parent_path_root = settings[keys.parent_path_root] | |
|
38 | list_parent_path = settings[keys.list_parent_path] | |
|
39 | location_root = settings[keys.location_root] | |
|
36 | filepath = settings[config_keys.config_file_path] | |
|
37 | parent_path_root = settings[config_keys.parent_path_root] | |
|
38 | list_parent_path = settings[config_keys.list_parent_path] | |
|
39 | location_root = settings[config_keys.location_root] | |
|
40 | 40 | |
|
41 | 41 | # Render the configuration to string. |
|
42 | 42 | template = 'rhodecode:svn_support/templates/mod-dav-svn.conf.mako' |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now