Show More
@@ -51,7 +51,8 b' class SimpleSvnApp(object):' | |||
|
51 | 51 | data = environ['wsgi.input'] |
|
52 | 52 | req_method = environ['REQUEST_METHOD'] |
|
53 | 53 | has_content_length = 'CONTENT_LENGTH' in environ |
|
54 |
path_info = self._get_url( |
|
|
54 | path_info = self._get_url( | |
|
55 | self.config.get('subversion_http_server_url', ''), environ['PATH_INFO']) | |
|
55 | 56 | transfer_encoding = environ.get('HTTP_TRANSFER_ENCODING', '') |
|
56 | 57 | log.debug('Handling: %s method via `%s`', req_method, path_info) |
|
57 | 58 | |
@@ -117,9 +118,9 b' class SimpleSvnApp(object):' | |||
|
117 | 118 | response_headers) |
|
118 | 119 | return response.iter_content(chunk_size=1024) |
|
119 | 120 | |
|
120 | def _get_url(self, path): | |
|
121 | url_path = urlparse.urljoin( | |
|
122 | self.config.get('subversion_http_server_url', ''), path) | |
|
121 | def _get_url(self, svn_http_server, path): | |
|
122 | svn_http_server_url = (svn_http_server or '').rstrip('/') | |
|
123 | url_path = urlparse.urljoin(svn_http_server_url + '/', (path or '').lstrip('/')) | |
|
123 | 124 | url_path = urllib.quote(url_path, safe="/:=~+!$,;'") |
|
124 | 125 | return url_path |
|
125 | 126 |
@@ -161,9 +161,17 b' class TestSimpleSvnApp(object):' | |||
|
161 | 161 | response_headers = self.app._get_response_headers(headers) |
|
162 | 162 | assert sorted(response_headers) == sorted(expected_headers) |
|
163 | 163 | |
|
164 | def test_get_url(self): | |
|
165 | url = self.app._get_url(self.path) | |
|
166 | expected_url = '{}{}'.format(self.host.strip('/'), self.path) | |
|
164 | @pytest.mark.parametrize('svn_http_url, path_info, expected_url', [ | |
|
165 | ('http://localhost:8200', '/repo_name', 'http://localhost:8200/repo_name'), | |
|
166 | ('http://localhost:8200///', '/repo_name', 'http://localhost:8200/repo_name'), | |
|
167 | ('http://localhost:8200', '/group/repo_name', 'http://localhost:8200/group/repo_name'), | |
|
168 | ('http://localhost:8200/', '/group/repo_name', 'http://localhost:8200/group/repo_name'), | |
|
169 | ('http://localhost:8200/prefix', '/repo_name', 'http://localhost:8200/prefix/repo_name'), | |
|
170 | ('http://localhost:8200/prefix', 'repo_name', 'http://localhost:8200/prefix/repo_name'), | |
|
171 | ('http://localhost:8200/prefix', '/group/repo_name', 'http://localhost:8200/prefix/group/repo_name') | |
|
172 | ]) | |
|
173 | def test_get_url(self, svn_http_url, path_info, expected_url): | |
|
174 | url = self.app._get_url(svn_http_url, path_info) | |
|
167 | 175 | assert url == expected_url |
|
168 | 176 | |
|
169 | 177 | def test_call(self): |
General Comments 0
You need to be logged in to leave comments.
Login now