Mercurial > hg-stable
comparison tests/test-lfs-serve-access.t @ 37250:dfb38c4850a9
lfs: add an experimental knob to disable blob serving
The use case here is the server admin may want to store the blobs elsewhere. As
it stands now, the `lfs.url` config on the client side is all that enforces this
(the web.allow-* permissions aren't able to block LFS blobs without also
blocking normal hg traffic). The real solution to this is to implement the
'verify' action on the client and server, but that's not a near term goal.
Whether this is useful in its own right, and should be promoted out of
experimental at some point is TBD.
Since the other two tests that deal with LFS and `hg serve` are already complex
and have #testcases, this seems like a good time to start a new test dedicated
to access checks against the server. Instead of conditionally wrapping the
wire protocol handler, I put this in the handler because I'd still like to bring
the annotations in from the evolve extension in order to set up the wrapping.
The 400 status probably isn't great, but that's what it would be for existing
`hg serve` instances without support for serving blobs.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 31 Mar 2018 15:20:43 -0400 |
parents | |
children | f4e84dfc06fd |
comparison
equal
deleted
inserted
replaced
37249:2ed180117f76 | 37250:dfb38c4850a9 |
---|---|
1 #require serve | |
2 | |
3 $ cat >> $HGRCPATH <<EOF | |
4 > [extensions] | |
5 > lfs= | |
6 > [lfs] | |
7 > url=http://localhost:$HGPORT/.git/info/lfs | |
8 > track=all() | |
9 > [web] | |
10 > push_ssl = False | |
11 > allow-push = * | |
12 > EOF | |
13 | |
14 Serving LFS files can experimentally be turned off. The long term solution is | |
15 to support the 'verify' action in both client and server, so that the server can | |
16 tell the client to store files elsewhere. | |
17 | |
18 $ hg init server | |
19 $ hg --config "lfs.usercache=$TESTTMP/servercache" \ | |
20 > --config experimental.lfs.serve=False -R server serve -d \ | |
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: no such method: .git (action=upload)! | |
34 [255] | |
35 | |
36 ... so do a local push to make the data available. Remove the blob from the | |
37 default cache, so it attempts to download. | |
38 $ hg --config "lfs.usercache=$TESTTMP/servercache" \ | |
39 > --config "lfs.url=null://" \ | |
40 > -R client push -q server | |
41 $ rm -rf `hg config lfs.usercache` | |
42 | |
43 Downloads fail... | |
44 | |
45 $ hg clone http://localhost:$HGPORT httpclone | |
46 requesting all changes | |
47 adding changesets | |
48 adding manifests | |
49 adding file changes | |
50 added 1 changesets with 1 changes to 1 files | |
51 new changesets 525251863cad | |
52 updating to branch default | |
53 abort: LFS HTTP error: HTTP Error 400: no such method: .git (action=download)! | |
54 [255] | |
55 | |
56 $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS | |
57 | |
58 $ cat $TESTTMP/access.log $TESTTMP/errors.log | |
59 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) | |
60 $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$ (glob) | |
61 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob) | |
62 $LOCALIP - - [$LOGDATE$] "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob) | |
63 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 400 - (glob) | |
64 $LOCALIP - - [$LOGDATE$] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) | |
65 $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$ (glob) | |
66 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&bundlecaps=HG20%2Cbundle2%3DHG20%250Abookmarks%250Achangegroup%253D01%252C02%252C03%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Aphases%253Dheads%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps%250Arev-branch-cache%250Astream%253Dv2&cg=1&common=0000000000000000000000000000000000000000&heads=525251863cad618e55d483555f3d00a2ca99597e&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ (glob) | |
67 $LOCALIP - - [$LOGDATE$] "POST /.git/info/lfs/objects/batch HTTP/1.1" 400 - (glob) |