Show More
@@ -34,6 +34,7 b' from paste.httpheaders import REMOTE_USE' | |||||
34 | # TODO(marcink): check if we should use webob.exc here ? |
|
34 | # TODO(marcink): check if we should use webob.exc here ? | |
35 | from pyramid.httpexceptions import ( |
|
35 | from pyramid.httpexceptions import ( | |
36 | HTTPNotFound, HTTPForbidden, HTTPNotAcceptable, HTTPInternalServerError) |
|
36 | HTTPNotFound, HTTPForbidden, HTTPNotAcceptable, HTTPInternalServerError) | |
|
37 | from zope.cachedescriptors.property import Lazy as LazyProperty | |||
37 |
|
38 | |||
38 | import rhodecode |
|
39 | import rhodecode | |
39 | from rhodecode.authentication.base import ( |
|
40 | from rhodecode.authentication.base import ( | |
@@ -121,12 +122,28 b' class SimpleVCS(object):' | |||||
121 | auth_ret_code_detection) |
|
122 | auth_ret_code_detection) | |
122 | self.ip_addr = '0.0.0.0' |
|
123 | self.ip_addr = '0.0.0.0' | |
123 |
|
124 | |||
|
125 | @LazyProperty | |||
|
126 | def global_vcs_config(self): | |||
|
127 | try: | |||
|
128 | return VcsSettingsModel().get_ui_settings_as_config_obj() | |||
|
129 | except Exception: | |||
|
130 | return base.Config() | |||
|
131 | ||||
124 | @property |
|
132 | @property | |
125 | def base_path(self): |
|
133 | def base_path(self): | |
126 |
settings_path = self.repo_vcs_config.get( |
|
134 | settings_path = self.repo_vcs_config.get( | |
|
135 | *VcsSettingsModel.PATH_SETTING) | |||
|
136 | ||||
|
137 | if not settings_path: | |||
|
138 | settings_path = self.global_vcs_config.get( | |||
|
139 | *VcsSettingsModel.PATH_SETTING) | |||
|
140 | ||||
127 | if not settings_path: |
|
141 | if not settings_path: | |
128 | # try, maybe we passed in explicitly as config option |
|
142 | # try, maybe we passed in explicitly as config option | |
129 | settings_path = self.config.get('base_path') |
|
143 | settings_path = self.config.get('base_path') | |
|
144 | ||||
|
145 | if not settings_path: | |||
|
146 | raise ValueError('FATAL: base_path is empty') | |||
130 | return settings_path |
|
147 | return settings_path | |
131 |
|
148 | |||
132 | def set_repo_names(self, environ): |
|
149 | def set_repo_names(self, environ): |
@@ -48,6 +48,7 b' def test_is_hg_no_cmd():' | |||||
48 |
|
48 | |||
49 | def test_is_hg_empty_cmd(): |
|
49 | def test_is_hg_empty_cmd(): | |
50 | environ = { |
|
50 | environ = { | |
|
51 | 'REQUEST_METHOD': 'GET', | |||
51 | 'PATH_INFO': svn_repo_path, |
|
52 | 'PATH_INFO': svn_repo_path, | |
52 | 'QUERY_STRING': 'cmd=', |
|
53 | 'QUERY_STRING': 'cmd=', | |
53 | 'HTTP_ACCEPT': 'application/mercurial' |
|
54 | 'HTTP_ACCEPT': 'application/mercurial' | |
@@ -57,6 +58,7 b' def test_is_hg_empty_cmd():' | |||||
57 |
|
58 | |||
58 | def test_is_svn_returns_true_if_subversion_is_in_a_dav_header(): |
|
59 | def test_is_svn_returns_true_if_subversion_is_in_a_dav_header(): | |
59 | environ = { |
|
60 | environ = { | |
|
61 | 'REQUEST_METHOD': 'GET', | |||
60 | 'PATH_INFO': svn_repo_path, |
|
62 | 'PATH_INFO': svn_repo_path, | |
61 | 'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log-revprops' |
|
63 | 'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log-revprops' | |
62 | } |
|
64 | } | |
@@ -65,6 +67,7 b' def test_is_svn_returns_true_if_subversi' | |||||
65 |
|
67 | |||
66 | def test_is_svn_returns_false_if_subversion_is_not_in_a_dav_header(): |
|
68 | def test_is_svn_returns_false_if_subversion_is_not_in_a_dav_header(): | |
67 | environ = { |
|
69 | environ = { | |
|
70 | 'REQUEST_METHOD': 'GET', | |||
68 | 'PATH_INFO': svn_repo_path, |
|
71 | 'PATH_INFO': svn_repo_path, | |
69 | 'HTTP_DAV': 'http://stuff.tigris.org/xmlns/dav/svn/log-revprops' |
|
72 | 'HTTP_DAV': 'http://stuff.tigris.org/xmlns/dav/svn/log-revprops' | |
70 | } |
|
73 | } | |
@@ -73,6 +76,7 b' def test_is_svn_returns_false_if_subvers' | |||||
73 |
|
76 | |||
74 | def test_is_svn_returns_false_if_no_dav_header(): |
|
77 | def test_is_svn_returns_false_if_no_dav_header(): | |
75 | environ = { |
|
78 | environ = { | |
|
79 | 'REQUEST_METHOD': 'GET', | |||
76 | 'PATH_INFO': svn_repo_path, |
|
80 | 'PATH_INFO': svn_repo_path, | |
77 | } |
|
81 | } | |
78 | assert vcs.is_svn(environ) is False |
|
82 | assert vcs.is_svn(environ) is False | |
@@ -85,6 +89,14 b' def test_is_svn_returns_true_if_magic_pa' | |||||
85 | assert vcs.is_svn(environ) |
|
89 | assert vcs.is_svn(environ) | |
86 |
|
90 | |||
87 |
|
91 | |||
|
92 | def test_is_svn_returns_true_if_propfind(): | |||
|
93 | environ = { | |||
|
94 | 'REQUEST_METHOD': 'PROPFIND', | |||
|
95 | 'PATH_INFO': svn_repo_path, | |||
|
96 | } | |||
|
97 | assert vcs.is_svn(environ) is True | |||
|
98 | ||||
|
99 | ||||
88 | def test_is_svn_allows_to_configure_the_magic_path(monkeypatch): |
|
100 | def test_is_svn_allows_to_configure_the_magic_path(monkeypatch): | |
89 | """ |
|
101 | """ | |
90 | This is intended as a fallback in case someone has configured his |
|
102 | This is intended as a fallback in case someone has configured his | |
@@ -93,6 +105,7 b' def test_is_svn_allows_to_configure_the_' | |||||
93 | monkeypatch.setitem( |
|
105 | monkeypatch.setitem( | |
94 | rhodecode.CONFIG, 'rhodecode_subversion_magic_path', '/!my-magic') |
|
106 | rhodecode.CONFIG, 'rhodecode_subversion_magic_path', '/!my-magic') | |
95 | environ = { |
|
107 | environ = { | |
|
108 | 'REQUEST_METHOD': 'POST', | |||
96 | 'PATH_INFO': '/stub-repository/!my-magic/rev/4', |
|
109 | 'PATH_INFO': '/stub-repository/!my-magic/rev/4', | |
97 | } |
|
110 | } | |
98 | assert vcs.is_svn(environ) |
|
111 | assert vcs.is_svn(environ) |
General Comments 0
You need to be logged in to leave comments.
Login now