##// END OF EJS Templates
git-lfs: report returned data as 'application/vnd.git-lfs+json' instead of plain json
marcink -
r204:b0f7b2ca stable
parent child Browse files
Show More
@@ -38,7 +38,7 b" GIT_LFS_PROTO_PAT = re.compile(r'^/(.+)/"
38 38
39 39
40 40 def write_response_error(http_exception, text=None):
41 content_type = 'application/json'
41 content_type = GIT_LFS_CONTENT_TYPE + '+json'
42 42 _exception = http_exception(content_type=content_type)
43 43 _exception.content_type = content_type
44 44 if text:
@@ -85,10 +85,9 b' def lfs_objects_batch(request):'
85 85 oid - String OID of the LFS object.
86 86 size - Integer byte size of the LFS object. Must be at least zero.
87 87 """
88 request.response.content_type = GIT_LFS_CONTENT_TYPE + '+json'
88 89 auth = request.authorization
89
90 90 repo = request.matchdict.get('repo')
91
92 91 data = request.json
93 92 operation = data.get('operation')
94 93 if operation not in ('download', 'upload'):
@@ -143,6 +142,7 b' def lfs_objects_batch(request):'
143 142
144 143
145 144 def lfs_objects_oid_upload(request):
145 request.response.content_type = GIT_LFS_CONTENT_TYPE + '+json'
146 146 repo = request.matchdict.get('repo')
147 147 oid = request.matchdict.get('oid')
148 148 store = LFSOidStore(
@@ -178,6 +178,7 b' def lfs_objects_oid_download(request):'
178 178
179 179
180 180 def lfs_objects_verify(request):
181 request.response.content_type = GIT_LFS_CONTENT_TYPE + '+json'
181 182 repo = request.matchdict.get('repo')
182 183
183 184 data = request.json
@@ -18,6 +18,7 b''
18 18 import os
19 19 import pytest
20 20 from webtest.app import TestApp as WebObTestApp
21 import simplejson as json
21 22
22 23 from vcsserver.git_lfs.app import create_app
23 24
@@ -43,18 +44,18 b' class TestLFSApplication(object):'
43 44 def test_app_deprecated_endpoint(self, git_lfs_app):
44 45 response = git_lfs_app.post('/repo/info/lfs/objects', status=501)
45 46 assert response.status_code == 501
46 assert response.json == {u'message': u'LFS: v1 api not supported'}
47 assert json.loads(response.text) == {u'message': u'LFS: v1 api not supported'}
47 48
48 49 def test_app_lock_verify_api_not_available(self, git_lfs_app):
49 50 response = git_lfs_app.post('/repo/info/lfs/locks/verify', status=501)
50 51 assert response.status_code == 501
51 assert response.json == {
52 assert json.loads(response.text) == {
52 53 u'message': u'GIT LFS locking api not supported'}
53 54
54 55 def test_app_lock_api_not_available(self, git_lfs_app):
55 56 response = git_lfs_app.post('/repo/info/lfs/locks', status=501)
56 57 assert response.status_code == 501
57 assert response.json == {
58 assert json.loads(response.text) == {
58 59 u'message': u'GIT LFS locking api not supported'}
59 60
60 61 def test_app_batch_api_missing_auth(self, git_lfs_app,):
@@ -65,14 +66,14 b' class TestLFSApplication(object):'
65 66 response = git_lfs_app.post_json(
66 67 '/repo/info/lfs/objects/batch', params={}, status=400,
67 68 extra_environ=http_auth)
68 assert response.json == {
69 assert json.loads(response.text) == {
69 70 u'message': u'unsupported operation mode: `None`'}
70 71
71 72 def test_app_batch_api_missing_objects(self, git_lfs_app, http_auth):
72 73 response = git_lfs_app.post_json(
73 74 '/repo/info/lfs/objects/batch', params={'operation': 'download'},
74 75 status=400, extra_environ=http_auth)
75 assert response.json == {
76 assert json.loads(response.text) == {
76 77 u'message': u'missing objects data'}
77 78
78 79 def test_app_batch_api_unsupported_data_in_objects(
@@ -82,7 +83,7 b' class TestLFSApplication(object):'
82 83 response = git_lfs_app.post_json(
83 84 '/repo/info/lfs/objects/batch', params=params, status=400,
84 85 extra_environ=http_auth)
85 assert response.json == {
86 assert json.loads(response.text) == {
86 87 u'message': u'unsupported data in objects'}
87 88
88 89 def test_app_batch_api_download_missing_object(
@@ -101,7 +102,7 b' class TestLFSApplication(object):'
101 102 u'oid': u'123',
102 103 u'size': u'1024'}
103 104 ]
104 assert response.json == {
105 assert json.loads(response.text) == {
105 106 'objects': expected_objects, 'transfer': 'basic'}
106 107
107 108 def test_app_batch_api_download(self, git_lfs_app, http_auth):
@@ -128,7 +129,7 b' class TestLFSApplication(object):'
128 129 u'oid': u'456',
129 130 u'size': u'1024'}
130 131 ]
131 assert response.json == {
132 assert json.loads(response.text) == {
132 133 'objects': expected_objects, 'transfer': 'basic'}
133 134
134 135 def test_app_batch_api_upload(self, git_lfs_app, http_auth):
@@ -150,7 +151,7 b' class TestLFSApplication(object):'
150 151 u'oid': u'123',
151 152 u'size': u'1024'}
152 153 ]
153 assert response.json == {
154 assert json.loads(response.text) == {
154 155 'objects': expected_objects, 'transfer': 'basic'}
155 156
156 157 def test_app_verify_api_missing_data(self, git_lfs_app):
@@ -159,7 +160,7 b' class TestLFSApplication(object):'
159 160 '/repo/info/lfs/verify', params=params,
160 161 status=400)
161 162
162 assert response.json == {
163 assert json.loads(response.text) == {
163 164 u'message': u'missing oid and size in request data'}
164 165
165 166 def test_app_verify_api_missing_obj(self, git_lfs_app):
@@ -168,7 +169,7 b' class TestLFSApplication(object):'
168 169 '/repo/info/lfs/verify', params=params,
169 170 status=404)
170 171
171 assert response.json == {
172 assert json.loads(response.text) == {
172 173 u'message': u'oid `missing` does not exists in store'}
173 174
174 175 def test_app_verify_api_size_mismatch(self, git_lfs_app):
@@ -183,7 +184,7 b' class TestLFSApplication(object):'
183 184 response = git_lfs_app.post_json(
184 185 '/repo/info/lfs/verify', params=params, status=422)
185 186
186 assert response.json == {
187 assert json.loads(response.text) == {
187 188 u'message': u'requested file size mismatch '
188 189 u'store size:11 requested:1024'}
189 190
@@ -199,7 +200,7 b' class TestLFSApplication(object):'
199 200 response = git_lfs_app.post_json(
200 201 '/repo/info/lfs/verify', params=params)
201 202
202 assert response.json == {
203 assert json.loads(response.text) == {
203 204 u'message': {u'size': u'ok', u'in_store': u'ok'}}
204 205
205 206 def test_app_download_api_oid_not_existing(self, git_lfs_app):
@@ -208,7 +209,7 b' class TestLFSApplication(object):'
208 209 response = git_lfs_app.get(
209 210 '/repo/info/lfs/objects/{oid}'.format(oid=oid), status=404)
210 211
211 assert response.json == {
212 assert json.loads(response.text) == {
212 213 u'message': u'requested file with oid `missing` not found in store'}
213 214
214 215 def test_app_download_api(self, git_lfs_app):
@@ -229,7 +230,7 b' class TestLFSApplication(object):'
229 230 response = git_lfs_app.put(
230 231 '/repo/info/lfs/objects/{oid}'.format(oid=oid), params='CONTENT')
231 232
232 assert response.json == {u'upload': u'ok'}
233 assert json.loads(response.text) == {u'upload': u'ok'}
233 234
234 235 # verify that we actually wrote that OID
235 236 oid_path = os.path.join(git_lfs_app._store, oid)
General Comments 0
You need to be logged in to leave comments. Login now