comparison tests/test-http-bundle1.t @ 25377:ebbf5b0c945a

test: copy test-http.t to test-http-bundle1.t We want to keep both code paths tested. The test is a bit too extensive to simply introduce dual testing in it so we make a copy for each protocol version.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 27 May 2015 12:03:31 -0700
parents tests/test-http.t@6f15114bdcc3
children d19787db6fe0
comparison
equal deleted inserted replaced
25376:2c14ab597353 25377:ebbf5b0c945a
1 #require serve
2
3 This test is a duplicate of 'test-http.t', feel free to factor out
4 parts that are not bundle1/bundle2 specific.
5
6 $ cat << EOF >> $HGRCPATH
7 > [experimental]
8 > # This test is dedicated to interaction through old bundle
9 > bundle2-exp = False
10 > EOF
11
12 $ hg init test
13 $ cd test
14 $ echo foo>foo
15 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
16 $ echo foo>foo.d/foo
17 $ echo bar>foo.d/bAr.hg.d/BaR
18 $ echo bar>foo.d/baR.d.hg/bAR
19 $ hg commit -A -m 1
20 adding foo
21 adding foo.d/bAr.hg.d/BaR
22 adding foo.d/baR.d.hg/bAR
23 adding foo.d/foo
24 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log
25 $ hg --config server.uncompressed=False serve -p $HGPORT1 -d --pid-file=../hg2.pid
26
27 Test server address cannot be reused
28
29 #if windows
30 $ hg serve -p $HGPORT1 2>&1
31 abort: cannot start server at ':$HGPORT1': * (glob)
32 [255]
33 #else
34 $ hg serve -p $HGPORT1 2>&1
35 abort: cannot start server at ':$HGPORT1': Address already in use
36 [255]
37 #endif
38 $ cd ..
39 $ cat hg1.pid hg2.pid >> $DAEMON_PIDS
40
41 clone via stream
42
43 $ hg clone --uncompressed http://localhost:$HGPORT/ copy 2>&1
44 streaming all changes
45 6 files to transfer, 606 bytes of data
46 transferred * bytes in * seconds (*/sec) (glob)
47 searching for changes
48 no changes found
49 updating to branch default
50 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 $ hg verify -R copy
52 checking changesets
53 checking manifests
54 crosschecking files in changesets and manifests
55 checking files
56 4 files, 1 changesets, 4 total revisions
57
58 try to clone via stream, should use pull instead
59
60 $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2
61 requesting all changes
62 adding changesets
63 adding manifests
64 adding file changes
65 added 1 changesets with 4 changes to 4 files
66 updating to branch default
67 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
68
69 clone via pull
70
71 $ hg clone http://localhost:$HGPORT1/ copy-pull
72 requesting all changes
73 adding changesets
74 adding manifests
75 adding file changes
76 added 1 changesets with 4 changes to 4 files
77 updating to branch default
78 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
79 $ hg verify -R copy-pull
80 checking changesets
81 checking manifests
82 crosschecking files in changesets and manifests
83 checking files
84 4 files, 1 changesets, 4 total revisions
85 $ cd test
86 $ echo bar > bar
87 $ hg commit -A -d '1 0' -m 2
88 adding bar
89 $ cd ..
90
91 clone over http with --update
92
93 $ hg clone http://localhost:$HGPORT1/ updated --update 0
94 requesting all changes
95 adding changesets
96 adding manifests
97 adding file changes
98 added 2 changesets with 5 changes to 5 files
99 updating to branch default
100 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 $ hg log -r . -R updated
102 changeset: 0:8b6053c928fe
103 user: test
104 date: Thu Jan 01 00:00:00 1970 +0000
105 summary: 1
106
107 $ rm -rf updated
108
109 incoming via HTTP
110
111 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
112 adding changesets
113 adding manifests
114 adding file changes
115 added 1 changesets with 4 changes to 4 files
116 updating to branch default
117 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
118 $ cd partial
119 $ touch LOCAL
120 $ hg ci -qAm LOCAL
121 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
122 comparing with http://localhost:$HGPORT1/
123 searching for changes
124 2
125 $ cd ..
126
127 pull
128
129 $ cd copy-pull
130 $ echo '[hooks]' >> .hg/hgrc
131 $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc
132 $ hg pull
133 pulling from http://localhost:$HGPORT1/
134 searching for changes
135 adding changesets
136 adding manifests
137 adding file changes
138 added 1 changesets with 1 changes to 1 files
139 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=http://localhost:$HGPORT1/ (glob)
140 (run 'hg update' to get a working copy)
141 $ cd ..
142
143 clone from invalid URL
144
145 $ hg clone http://localhost:$HGPORT/bad
146 abort: HTTP Error 404: Not Found
147 [255]
148
149 test http authentication
150 + use the same server to test server side streaming preference
151
152 $ cd test
153 $ cat << EOT > userpass.py
154 > import base64
155 > from mercurial.hgweb import common
156 > def perform_authentication(hgweb, req, op):
157 > auth = req.env.get('HTTP_AUTHORIZATION')
158 > if not auth:
159 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who',
160 > [('WWW-Authenticate', 'Basic Realm="mercurial"')])
161 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']:
162 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no')
163 > def extsetup():
164 > common.permhooks.insert(0, perform_authentication)
165 > EOT
166 $ hg --config extensions.x=userpass.py serve -p $HGPORT2 -d --pid-file=pid \
167 > --config server.preferuncompressed=True \
168 > --config web.push_ssl=False --config web.allow_push=* -A ../access.log
169 $ cat pid >> $DAEMON_PIDS
170
171 $ cat << EOF > get_pass.py
172 > import getpass
173 > def newgetpass(arg):
174 > return "pass"
175 > getpass.getpass = newgetpass
176 > EOF
177
178 $ hg id http://localhost:$HGPORT2/
179 abort: http authorization required for http://localhost:$HGPORT2/
180 [255]
181 $ hg id http://localhost:$HGPORT2/
182 abort: http authorization required for http://localhost:$HGPORT2/
183 [255]
184 $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/
185 http authorization required for http://localhost:$HGPORT2/
186 realm: mercurial
187 user: user
188 password: 5fed3813f7f5
189 $ hg id http://user:pass@localhost:$HGPORT2/
190 5fed3813f7f5
191 $ echo '[auth]' >> .hg/hgrc
192 $ echo 'l.schemes=http' >> .hg/hgrc
193 $ echo 'l.prefix=lo' >> .hg/hgrc
194 $ echo 'l.username=user' >> .hg/hgrc
195 $ echo 'l.password=pass' >> .hg/hgrc
196 $ hg id http://localhost:$HGPORT2/
197 5fed3813f7f5
198 $ hg id http://localhost:$HGPORT2/
199 5fed3813f7f5
200 $ hg id http://user@localhost:$HGPORT2/
201 5fed3813f7f5
202 $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
203 streaming all changes
204 7 files to transfer, 916 bytes of data
205 transferred * bytes in * seconds (*/sec) (glob)
206 searching for changes
207 no changes found
208 updating to branch default
209 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
210 --pull should override server's preferuncompressed
211 $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1
212 requesting all changes
213 adding changesets
214 adding manifests
215 adding file changes
216 added 2 changesets with 5 changes to 5 files
217 updating to branch default
218 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
219
220 $ hg id http://user2@localhost:$HGPORT2/
221 abort: http authorization required for http://localhost:$HGPORT2/
222 [255]
223 $ hg id http://user:pass2@localhost:$HGPORT2/
224 abort: HTTP Error 403: no
225 [255]
226
227 $ hg -R dest tag -r tip top
228 $ hg -R dest push http://user:pass@localhost:$HGPORT2/
229 pushing to http://user:***@localhost:$HGPORT2/
230 searching for changes
231 remote: adding changesets
232 remote: adding manifests
233 remote: adding file changes
234 remote: added 1 changesets with 1 changes to 1 files
235 $ hg rollback -q
236
237 $ cut -c38- ../access.log
238 "GET /?cmd=capabilities HTTP/1.1" 200 -
239 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
240 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
241 "GET /?cmd=capabilities HTTP/1.1" 200 -
242 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
243 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
244 "GET /?cmd=capabilities HTTP/1.1" 200 -
245 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
246 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
247 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces
248 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
249 "GET /?cmd=capabilities HTTP/1.1" 200 -
250 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
251 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
252 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces
253 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
254 "GET /?cmd=capabilities HTTP/1.1" 200 -
255 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
256 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
257 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces
258 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
259 "GET /?cmd=capabilities HTTP/1.1" 200 -
260 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
261 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
262 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces
263 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
264 "GET /?cmd=capabilities HTTP/1.1" 200 -
265 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
266 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
267 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces
268 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
269 "GET /?cmd=capabilities HTTP/1.1" 200 -
270 "GET /?cmd=branchmap HTTP/1.1" 200 -
271 "GET /?cmd=stream_out HTTP/1.1" 401 -
272 "GET /?cmd=stream_out HTTP/1.1" 200 -
273 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
274 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d
275 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
276 "GET /?cmd=capabilities HTTP/1.1" 200 -
277 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks
278 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
279 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D
280 "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d
281 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
282 "GET /?cmd=capabilities HTTP/1.1" 200 -
283 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
284 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
285 "GET /?cmd=capabilities HTTP/1.1" 200 -
286 "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip
287 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces
288 "GET /?cmd=listkeys HTTP/1.1" 403 - x-hgarg-1:namespace=namespaces
289 "GET /?cmd=capabilities HTTP/1.1" 200 -
290 "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872
291 "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=phases
292 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
293 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
294 "GET /?cmd=branchmap HTTP/1.1" 200 -
295 "GET /?cmd=branchmap HTTP/1.1" 200 -
296 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks
297 "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=686173686564+5eb5abfefeea63c80dd7553bcc3783f37e0c5524
298 "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases
299
300 $ cd ..
301
302 clone of serve with repo in root and unserved subrepo (issue2970)
303
304 $ hg --cwd test init sub
305 $ echo empty > test/sub/empty
306 $ hg --cwd test/sub add empty
307 $ hg --cwd test/sub commit -qm 'add empty'
308 $ hg --cwd test/sub tag -r 0 something
309 $ echo sub = sub > test/.hgsub
310 $ hg --cwd test add .hgsub
311 $ hg --cwd test commit -qm 'add subrepo'
312 $ hg clone http://localhost:$HGPORT noslash-clone
313 requesting all changes
314 adding changesets
315 adding manifests
316 adding file changes
317 added 3 changesets with 7 changes to 7 files
318 updating to branch default
319 abort: HTTP Error 404: Not Found
320 [255]
321 $ hg clone http://localhost:$HGPORT/ slash-clone
322 requesting all changes
323 adding changesets
324 adding manifests
325 adding file changes
326 added 3 changesets with 7 changes to 7 files
327 updating to branch default
328 abort: HTTP Error 404: Not Found
329 [255]
330
331 check error log
332
333 $ cat error.log