##// END OF EJS Templates
git-lfs: fixed bug #5399 git-lfs application failed to generate HTTPS urls properly.
dan -
r700:43af4e52 default
parent child Browse files
Show More
@@ -90,6 +90,8 b' def lfs_objects_batch(request):'
90 repo = request.matchdict.get('repo')
90 repo = request.matchdict.get('repo')
91 data = request.json
91 data = request.json
92 operation = data.get('operation')
92 operation = data.get('operation')
93 http_scheme = request.registry.git_lfs_http_scheme
94
93 if operation not in ('download', 'upload'):
95 if operation not in ('download', 'upload'):
94 log.debug('LFS: unsupported operation:%s', operation)
96 log.debug('LFS: unsupported operation:%s', operation)
95 return write_response_error(
97 return write_response_error(
@@ -114,8 +116,10 b' def lfs_objects_batch(request):'
114
116
115 obj_data = {'oid': oid}
117 obj_data = {'oid': oid}
116
118
117 obj_href = request.route_url('lfs_objects_oid', repo=repo, oid=oid)
119 obj_href = request.route_url('lfs_objects_oid', repo=repo, oid=oid,
118 obj_verify_href = request.route_url('lfs_objects_verify', repo=repo)
120 _scheme=http_scheme)
121 obj_verify_href = request.route_url('lfs_objects_verify', repo=repo,
122 _scheme=http_scheme)
119 store = LFSOidStore(
123 store = LFSOidStore(
120 oid, repo, store_location=request.registry.git_lfs_store_path)
124 oid, repo, store_location=request.registry.git_lfs_store_path)
121 handler = OidHandler(
125 handler = OidHandler(
@@ -274,11 +278,12 b' def git_lfs_app(config):'
274 config.add_notfound_view(not_found, renderer='json')
278 config.add_notfound_view(not_found, renderer='json')
275
279
276
280
277 def create_app(git_lfs_enabled, git_lfs_store_path):
281 def create_app(git_lfs_enabled, git_lfs_store_path, git_lfs_http_scheme):
278 config = Configurator()
282 config = Configurator()
279 if git_lfs_enabled:
283 if git_lfs_enabled:
280 config.include(git_lfs_app)
284 config.include(git_lfs_app)
281 config.registry.git_lfs_store_path = git_lfs_store_path
285 config.registry.git_lfs_store_path = git_lfs_store_path
286 config.registry.git_lfs_http_scheme = git_lfs_http_scheme
282 else:
287 else:
283 # not found handler for API, reporting disabled LFS support
288 # not found handler for API, reporting disabled LFS support
284 config.add_notfound_view(lfs_disabled, renderer='json')
289 config.add_notfound_view(lfs_disabled, renderer='json')
@@ -26,7 +26,17 b' from vcsserver.git_lfs.app import create'
26 @pytest.fixture(scope='function')
26 @pytest.fixture(scope='function')
27 def git_lfs_app(tmpdir):
27 def git_lfs_app(tmpdir):
28 custom_app = WebObTestApp(create_app(
28 custom_app = WebObTestApp(create_app(
29 git_lfs_enabled=True, git_lfs_store_path=str(tmpdir)))
29 git_lfs_enabled=True, git_lfs_store_path=str(tmpdir),
30 git_lfs_http_scheme='http'))
31 custom_app._store = str(tmpdir)
32 return custom_app
33
34
35 @pytest.fixture(scope='function')
36 def git_lfs_https_app(tmpdir):
37 custom_app = WebObTestApp(create_app(
38 git_lfs_enabled=True, git_lfs_store_path=str(tmpdir),
39 git_lfs_http_scheme='https'))
30 custom_app._store = str(tmpdir)
40 custom_app._store = str(tmpdir)
31 return custom_app
41 return custom_app
32
42
@@ -58,7 +68,7 b' class TestLFSApplication(object):'
58 assert json.loads(response.text) == {
68 assert json.loads(response.text) == {
59 u'message': u'GIT LFS locking api not supported'}
69 u'message': u'GIT LFS locking api not supported'}
60
70
61 def test_app_batch_api_missing_auth(self, git_lfs_app,):
71 def test_app_batch_api_missing_auth(self, git_lfs_app):
62 git_lfs_app.post_json(
72 git_lfs_app.post_json(
63 '/repo/info/lfs/objects/batch', params={}, status=403)
73 '/repo/info/lfs/objects/batch', params={}, status=403)
64
74
@@ -155,8 +165,31 b' class TestLFSApplication(object):'
155 assert json.loads(response.text) == {
165 assert json.loads(response.text) == {
156 'objects': expected_objects, 'transfer': 'basic'}
166 'objects': expected_objects, 'transfer': 'basic'}
157
167
168 def test_app_batch_api_upload_for_https(self, git_lfs_https_app, http_auth):
169 params = {'operation': 'upload',
170 'objects': [{'oid': '123', 'size': '1024'}]}
171 response = git_lfs_https_app.post_json(
172 '/repo/info/lfs/objects/batch', params=params,
173 extra_environ=http_auth)
174 expected_objects = [
175 {u'authenticated': True,
176 u'actions': {
177 u'upload': {
178 u'header': {u'Authorization': u'Basic XXXXX',
179 u'Transfer-Encoding': u'chunked'},
180 u'href': u'https://localhost/repo/info/lfs/objects/123'},
181 u'verify': {
182 u'header': {u'Authorization': u'Basic XXXXX'},
183 u'href': u'https://localhost/repo/info/lfs/verify'}
184 },
185 u'oid': u'123',
186 u'size': u'1024'}
187 ]
188 assert json.loads(response.text) == {
189 'objects': expected_objects, 'transfer': 'basic'}
190
158 def test_app_verify_api_missing_data(self, git_lfs_app):
191 def test_app_verify_api_missing_data(self, git_lfs_app):
159 params = {'oid': 'missing',}
192 params = {'oid': 'missing'}
160 response = git_lfs_app.post_json(
193 response = git_lfs_app.post_json(
161 '/repo/info/lfs/verify', params=params,
194 '/repo/info/lfs/verify', params=params,
162 status=400)
195 status=400)
@@ -218,8 +218,8 b' class GitLFSHandler(object):'
218 self.git_path = git_path
218 self.git_path = git_path
219 self.update_server_info = update_server_info
219 self.update_server_info = update_server_info
220
220
221 def get_app(self, git_lfs_enabled, git_lfs_store_path):
221 def get_app(self, git_lfs_enabled, git_lfs_store_path, git_lfs_http_scheme):
222 app = git_lfs.create_app(git_lfs_enabled, git_lfs_store_path)
222 app = git_lfs.create_app(git_lfs_enabled, git_lfs_store_path, git_lfs_http_scheme)
223 return app
223 return app
224
224
225
225
@@ -228,7 +228,8 b' def create_git_lfs_wsgi_app(repo_path, r'
228 update_server_info = config.pop('git_update_server_info')
228 update_server_info = config.pop('git_update_server_info')
229 git_lfs_enabled = config.pop('git_lfs_enabled')
229 git_lfs_enabled = config.pop('git_lfs_enabled')
230 git_lfs_store_path = config.pop('git_lfs_store_path')
230 git_lfs_store_path = config.pop('git_lfs_store_path')
231 git_lfs_http_scheme = config.pop('git_lfs_http_scheme', 'http')
231 app = GitLFSHandler(
232 app = GitLFSHandler(
232 repo_path, repo_name, git_path, update_server_info, config)
233 repo_path, repo_name, git_path, update_server_info, config)
233
234
234 return app.get_app(git_lfs_enabled, git_lfs_store_path)
235 return app.get_app(git_lfs_enabled, git_lfs_store_path, git_lfs_http_scheme)
General Comments 0
You need to be logged in to leave comments. Login now