Debian Codegraph @

tests/test-lfs-serve-access.t

raw
1 #require serve no-chg
2
3 $ cat >> $HGRCPATH <<EOF
4 > [extensions]
5 > lfs=
6 > [lfs]
7 > track=all()
8 > [web]
9 > push_ssl = False
10 > allow-push = *
11 > EOF
12
13 Serving LFS files can experimentally be turned off. The long term solution is
14 to support the 'verify' action in both client and server, so that the server can
15 tell the client to store files elsewhere.
16
17 $ hg init server
18 $ hg --config "lfs.usercache=$TESTTMP/servercache" \
19 > --config experimental.lfs.serve=False -R server serve -d \
20 > --config experimental.lfs.worker-enable=False \
21 > -p $HGPORT --pid-file=hg.pid -A $TESTTMP/access.log -E $TESTTMP/errors.log
22 $ cat hg.pid >> $DAEMON_PIDS
23
24 Uploads fail...
25
26 $ hg init client
27 $ echo 'this-is-an-lfs-file' > client/lfs.bin
28 $ hg -R client ci -Am 'initial commit'
29 adding lfs.bin
30 $ hg -R client push http://localhost:$HGPORT
31 pushing to http://localhost:$HGPORT/
32 searching for changes
33 abort: LFS HTTP error: HTTP Error 400: method not found
34 (check that lfs serving is enabled on http://localhost:$HGPORT/.git/info/lfs and "upload" is supported)
35 [50]
36
37 ... so do a local push to make the data available. Remove the blob from the
38 default cache, so it attempts to download.
39 $ hg --config "lfs.usercache=$TESTTMP/servercache" \
40 > --config "lfs.url=null://" \
41 > -R client push -q server
42 $ mv `hg config lfs.usercache` $TESTTMP/servercache
43
44 Downloads fail...
45
46 $ hg clone http://localhost:$HGPORT httpclone
47 (remote is using large file support (lfs); lfs will be enabled for this repository)
48 requesting all changes
49 adding changesets
50 adding manifests
51 adding file changes
52 added 1 changesets with 1 changes to 1 files
53 new changesets 525251863cad
54 updating to branch default
55 abort: LFS HTTP error: HTTP Error 400: method not found
56 (check that lfs serving is enabled on http://localhost:$HGPORT/.git/info/lfs and "download" is supported)
57 [50]
58
59 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
60
61 $ cat $TESTTMP/access.log $TESTTMP/errors.log
62 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
63 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D525251863cad618e55d483555f3d00a2ca99597e x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
64 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
65 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
66 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 400 - (glob)
67 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
68 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
69 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
70 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 400 - (glob)
71
72 $ rm -f $TESTTMP/access.log $TESTTMP/errors.log
73 $ hg --config "lfs.usercache=$TESTTMP/servercache" -R server serve -d \
74 > -p $HGPORT --pid-file=hg.pid --prefix=subdir/mount/point \
75 > -A $TESTTMP/access.log -E $TESTTMP/errors.log
76 $ cat hg.pid >> $DAEMON_PIDS
77
78 Reasonable hint for a misconfigured blob server
79
80 $ hg -R httpclone update default --config lfs.url=http://localhost:$HGPORT/missing
81 abort: LFS HTTP error: HTTP Error 404: Not Found
82 (the "lfs.url" config may be used to override http://localhost:$HGPORT/missing)
83 [50]
84
85 $ hg -R httpclone update default --config lfs.url=http://localhost:$HGPORT2/missing
86 abort: LFS error: *onnection *refused* (glob) (?)
87 abort: LFS error: $ECONNREFUSED$ (?)
88 abort: LFS error: $EADDRNOTAVAIL$ (glob) (?)
89 abort: LFS error: No route to host (?)
90 (the "lfs.url" config may be used to override http://localhost:$HGPORT2/missing)
91 [50]
92
93 Blob URIs are correct when --prefix is used
94
95 $ hg clone --debug http://localhost:$HGPORT/subdir/mount/point cloned2
96 using http://localhost:$HGPORT/subdir/mount/point
97 sending capabilities command
98 (remote is using large file support (lfs); lfs will be enabled for this repository)
99 query 1; heads
100 sending batch command
101 requesting all changes
102 sending getbundle command
103 bundle2-input-bundle: with-transaction
104 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
105 adding changesets
106 add changeset 525251863cad
107 adding manifests
108 adding file changes
109 adding lfs.bin revisions
110 bundle2-input-part: total payload size 648
111 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
112 bundle2-input-part: "phase-heads" supported
113 bundle2-input-part: total payload size 24
114 bundle2-input-bundle: 3 parts total
115 checking for updated bookmarks
116 updating the branch cache
117 added 1 changesets with 1 changes to 1 files
118 new changesets 525251863cad
119 updating to branch default
120 resolving manifests
121 branchmerge: False, force: False, partial: False
122 ancestor: 000000000000, local: 000000000000+, remote: 525251863cad
123 lfs: assuming remote store: http://localhost:$HGPORT/subdir/mount/point/.git/info/lfs
124 Status: 200
125 Content-Length: 371
126 Content-Type: application/vnd.git-lfs+json
127 Date: $HTTP_DATE$
128 Server: testing stub value
129 {
130 "objects": [
131 {
132 "actions": {
133 "download": {
134 "expires_at": "$ISO_8601_DATE_TIME$"
135 "header": {
136 "Accept": "application/vnd.git-lfs"
137 }
138 "href": "http://localhost:$HGPORT/subdir/mount/point/.hg/lfs/objects/f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e"
139 }
140 }
141 "oid": "f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e"
142 "size": 20
143 }
144 ]
145 "transfer": "basic"
146 }
147 lfs: downloading f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e (20 bytes)
148 Status: 200
149 Content-Length: 20
150 Content-Type: application/octet-stream
151 Date: $HTTP_DATE$
152 Server: testing stub value
153 lfs: adding f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e to the usercache
154 lfs: processed: f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e
155 lfs: downloaded 1 files (20 bytes)
156 lfs.bin: remote created -> g
157 getting lfs.bin
158 lfs: found f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e in the local lfs store
159 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 updating the branch cache
161 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
162
163 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
164
165 $ cat $TESTTMP/access.log $TESTTMP/errors.log
166 $LOCALIP - - [$LOGDATE$] "POST /missing/objects/batch HTTP/1.1" 404 - (glob)
167 $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point?cmd=capabilities HTTP/1.1" 200 - (glob)
168 $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
169 $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
170 $LOCALIP - - [$LOGDATE$] "POST /subdir/mount/point/.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
171 $LOCALIP - - [$LOGDATE$] "GET /subdir/mount/point/.hg/lfs/objects/f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e HTTP/1.1" 200 - (glob)
172
173 Blobs that already exist in the usercache are linked into the repo store, even
174 though the client doesn't send the blob.
175
176 $ hg init server2
177 $ hg --config "lfs.usercache=$TESTTMP/servercache" -R server2 serve -d \
178 > -p $HGPORT --pid-file=hg.pid \
179 > -A $TESTTMP/access.log -E $TESTTMP/errors.log
180 $ cat hg.pid >> $DAEMON_PIDS
181
182 $ hg --config "lfs.usercache=$TESTTMP/servercache" -R cloned2 --debug \
183 > push http://localhost:$HGPORT | grep '^[{} ]'
184 {
185 "objects": [
186 {
187 "oid": "f03217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e"
188 "size": 20
189 }
190 ]
191 "transfer": "basic"
192 }
193 $ find server2/.hg/store/lfs/objects | sort
194 server2/.hg/store/lfs/objects
195 server2/.hg/store/lfs/objects/f0
196 server2/.hg/store/lfs/objects/f0/3217a32529a28a42d03b1244fe09b6e0f9fd06d7b966d4d50567be2abe6c0e
197 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
198 $ cat $TESTTMP/errors.log
199
200 $ cat >> $TESTTMP/lfsstoreerror.py <<EOF
201 > import errno
202 > from hgext.lfs import blobstore
203 >
204 > _numverifies = 0
205 > _readerr = True
206 >
207 > def reposetup(ui, repo):
208 > # Nothing to do with a remote repo
209 > if not repo.local():
210 > return
211 >
212 > store = repo.svfs.lfslocalblobstore
213 > class badstore(store.__class__):
214 > def download(self, oid, src, contentlength):
215 > '''Called in the server to handle reading from the client in a
216 > PUT request.'''
217 > origread = src.read
218 > def _badread(nbytes):
219 > # Simulate bad data/checksum failure from the client
220 > return b'0' * len(origread(nbytes))
221 > src.read = _badread
222 > super(badstore, self).download(oid, src, contentlength)
223 >
224 > def _read(self, vfs, oid, verify):
225 > '''Called in the server to read data for a GET request, and then
226 > calls self._verify() on it before returning.'''
227 > global _readerr
228 > # One time simulation of a read error
229 > if _readerr:
230 > _readerr = False
231 > raise IOError(errno.EIO, r'%s: I/O error' % oid.decode("utf-8"))
232 > # Simulate corrupt content on client download
233 > blobstore._verify(oid, b'dummy content')
234 >
235 > def verify(self, oid):
236 > '''Called in the server to populate the Batch API response,
237 > letting the client re-upload if the file is corrupt.'''
238 > # Fail verify in Batch API for one clone command and one push
239 > # command with an IOError. Then let it through to access other
240 > # functions. Checksum failure is tested elsewhere.
241 > global _numverifies
242 > _numverifies += 1
243 > if _numverifies <= 2:
244 > raise IOError(errno.EIO, r'%s: I/O error' % oid.decode("utf-8"))
245 > return super(badstore, self).verify(oid)
246 >
247 > store.__class__ = badstore
248 > EOF
249
250 $ rm -rf `hg config lfs.usercache`
251 $ rm -f $TESTTMP/access.log $TESTTMP/errors.log
252 $ hg --config "lfs.usercache=$TESTTMP/servercache" \
253 > --config extensions.lfsstoreerror=$TESTTMP/lfsstoreerror.py \
254 > -R server serve -d \
255 > -p $HGPORT1 --pid-file=hg.pid -A $TESTTMP/access.log -E $TESTTMP/errors.log
256 $ cat hg.pid >> $DAEMON_PIDS
257
258 Test an I/O error in localstore.verify() (Batch API) with GET
259
260 $ hg clone http://localhost:$HGPORT1 httpclone2
261 (remote is using large file support (lfs); lfs will be enabled for this repository)
262 requesting all changes
263 adding changesets
264 adding manifests
265 adding file changes
266 added 1 changesets with 1 changes to 1 files
267 new changesets 525251863cad
268 updating to branch default
269 abort: LFS server error for "lfs.bin": Internal server error
270 [50]
271
272 Test an I/O error in localstore.verify() (Batch API) with PUT
273
274 $ echo foo > client/lfs.bin
275 $ hg -R client ci -m 'mod lfs'
276 $ hg -R client push http://localhost:$HGPORT1
277 pushing to http://localhost:$HGPORT1/
278 searching for changes
279 abort: LFS server error for "unknown": Internal server error
280 [50]
281 TODO: figure out how to associate the file name in the error above
282
283 Test a bad checksum sent by the client in the transfer API
284
285 $ hg -R client push http://localhost:$HGPORT1
286 pushing to http://localhost:$HGPORT1/
287 searching for changes
288 abort: LFS HTTP error: HTTP Error 422: corrupt blob (oid=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c, action=upload)
289 [50]
290
291 $ echo 'test lfs file' > server/lfs3.bin
292 $ hg --config experimental.lfs.disableusercache=True \
293 > -R server ci -Aqm 'another lfs file'
294 $ hg -R client pull -q http://localhost:$HGPORT1
295
296 Test an I/O error during the processing of the GET request
297
298 $ hg --config lfs.url=http://localhost:$HGPORT1/.git/info/lfs \
299 > -R client update -r tip
300 abort: LFS HTTP error: HTTP Error 500: Internal Server Error (oid=276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d, action=download)
301 [50]
302
303 Test a checksum failure during the processing of the GET request
304
305 $ hg --config lfs.url=http://localhost:$HGPORT1/.git/info/lfs \
306 > -R client update -r tip
307 abort: LFS HTTP error: HTTP Error 422: corrupt blob (oid=276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d, action=download)
308 [50]
309
310 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
311
312 $ cat $TESTTMP/access.log
313 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
314 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
315 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
316 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
317 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
318 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D392c05922088bacf8e68a6939b480017afbf245d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
319 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
320 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
321 $LOCALIP - - [$LOGDATE$] "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
322 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
323 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
324 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
325 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D392c05922088bacf8e68a6939b480017afbf245d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
326 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
327 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
328 $LOCALIP - - [$LOGDATE$] "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
329 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
330 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
331 $LOCALIP - - [$LOGDATE$] "PUT /.hg/lfs/objects/b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c HTTP/1.1" 422 - (glob)
332 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
333 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D392c05922088bacf8e68a6939b480017afbf245d x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
334 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=525251863cad618e55d483555f3d00a2ca99597e&heads=506bf3d83f78c54b89e81c6411adee19fdf02156+525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
335 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
336 $LOCALIP - - [$LOGDATE$] "GET /.hg/lfs/objects/276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d HTTP/1.1" 500 - (glob)
337 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
338 $LOCALIP - - [$LOGDATE$] "GET /.hg/lfs/objects/276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d HTTP/1.1" 422 - (glob)
339
340 $ grep 'hgext.lfs.blobstore.LfsCorruptionError' $TESTTMP/errors.log
341 $LOCALIP - - [$ERRDATE$] HG error: hgext.lfs.blobstore.LfsCorruptionError: corrupt remote lfs object: b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c (glob)
342 $LOCALIP - - [$ERRDATE$] HG error: hgext.lfs.blobstore.LfsCorruptionError: detected corrupt lfs object: 276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d (glob)
343
344
345 Basic Authorization headers are returned by the Batch API, and sent back with
346 the GET/PUT request.
347
348 $ rm -f $TESTTMP/access.log $TESTTMP/errors.log
349
350 $ cat >> $HGRCPATH << EOF
351 > [experimental]
352 > lfs.disableusercache = True
353 > [auth]
354 > l.schemes=http
355 > l.prefix=lo
356 > l.username=user
357 > l.password=pass
358 > EOF
359
360 $ hg --config extensions.x=$TESTDIR/httpserverauth.py \
361 > -R server serve -d -p $HGPORT1 --pid-file=hg.pid \
362 > -A $TESTTMP/access.log -E $TESTTMP/errors.log
363 $ mv hg.pid $DAEMON_PIDS
364
365 $ hg clone --debug http://localhost:$HGPORT1 auth_clone | grep -E '^[{}]| '
366 {
367 "objects": [
368 {
369 "actions": {
370 "download": {
371 "expires_at": "$ISO_8601_DATE_TIME$"
372 "header": {
373 "Accept": "application/vnd.git-lfs"
374 "Authorization": "Basic dXNlcjpwYXNz"
375 }
376 "href": "http://localhost:$HGPORT1/.hg/lfs/objects/276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d"
377 }
378 }
379 "oid": "276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d"
380 "size": 14
381 }
382 ]
383 "transfer": "basic"
384 }
385
386 $ echo 'another blob' > auth_clone/lfs.blob
387 $ hg -R auth_clone ci -Aqm 'add blob'
388
389 $ cat > use_digests.py << EOF
390 > from mercurial import (
391 > exthelper,
392 > url,
393 > )
394 >
395 > eh = exthelper.exthelper()
396 > uisetup = eh.finaluisetup
397 >
398 > @eh.wrapfunction(url, 'opener')
399 > def urlopener(orig, *args, **kwargs):
400 > opener = orig(*args, **kwargs)
401 > opener.addheaders.append((r'X-HgTest-AuthType', r'Digest'))
402 > return opener
403 > EOF
404
405 Test that Digest Auth fails gracefully before testing the successful Basic Auth
406
407 $ hg -R auth_clone push --config extensions.x=use_digests.py
408 pushing to http://localhost:$HGPORT1/
409 searching for changes
410 abort: LFS HTTP error: HTTP Error 401: the server must support Basic Authentication
411 (api=http://localhost:$HGPORT1/.git/info/lfs/objects/batch, action=upload)
412 [50]
413
414 $ hg -R auth_clone --debug push | grep -E '^[{}]| '
415 {
416 "objects": [
417 {
418 "actions": {
419 "upload": {
420 "expires_at": "$ISO_8601_DATE_TIME$"
421 "header": {
422 "Accept": "application/vnd.git-lfs"
423 "Authorization": "Basic dXNlcjpwYXNz"
424 }
425 "href": "http://localhost:$HGPORT1/.hg/lfs/objects/df14287d8d75f076a6459e7a3703ca583ca9fb3f4918caed10c77ac8622d49b3"
426 }
427 }
428 "oid": "df14287d8d75f076a6459e7a3703ca583ca9fb3f4918caed10c77ac8622d49b3"
429 "size": 13
430 }
431 ]
432 "transfer": "basic"
433 }
434
435 $ "$PYTHON" $RUNTESTDIR/killdaemons.py $DAEMON_PIDS
436
437 $ cat $TESTTMP/access.log $TESTTMP/errors.log
438 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 401 - (glob)
439 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
440 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
441 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=506bf3d83f78c54b89e81c6411adee19fdf02156+525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
442 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 401 - (glob)
443 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
444 $LOCALIP - - [$LOGDATE$] "GET /.hg/lfs/objects/276f73cfd75f9fb519810df5f5d96d6594ca2521abd86cbcd92122f7d51a1f3d HTTP/1.1" 200 - (glob)
445 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 401 - x-hgtest-authtype:Digest (glob)
446 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest (glob)
447 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 401 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D525251863cad618e55d483555f3d00a2ca99597e+4d9397055dc0c205f3132f331f36353ab1a525a3 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
448 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D525251863cad618e55d483555f3d00a2ca99597e+4d9397055dc0c205f3132f331f36353ab1a525a3 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
449 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
450 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
451 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
452 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
453 $LOCALIP - - [$LOGDATE$] "GET /?cmd=branchmap HTTP/1.1" 401 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
454 $LOCALIP - - [$LOGDATE$] "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
455 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
456 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (glob)
457 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 401 - x-hgtest-authtype:Digest (glob)
458 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 401 - (glob)
459 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
460 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D525251863cad618e55d483555f3d00a2ca99597e+4d9397055dc0c205f3132f331f36353ab1a525a3 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
461 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
462 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
463 $LOCALIP - - [$LOGDATE$] "GET /?cmd=branchmap HTTP/1.1" 200 - x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
464 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
465 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 401 - (glob)
466 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 200 - (glob)
467 $LOCALIP - - [$LOGDATE$] "PUT /.hg/lfs/objects/df14287d8d75f076a6459e7a3703ca583ca9fb3f4918caed10c77ac8622d49b3 HTTP/1.1" 201 - (glob)
468 $LOCALIP - - [$LOGDATE$] "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=666f726365 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
469 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)