Mercurial > hg
annotate tests/test-extensions-afterloaded.t @ 37048:fc5e261915b9
wireproto: require POST for all HTTPv2 requests
Wire protocol version 1 transfers argument data via request
headers by default. This has historically caused problems because
servers institute limits on the length of individual HTTP headers
as well as the total size of all request headers. Mercurial servers
can advertise the maximum length of an individual header. But
there's no guarantee any intermediate HTTP agents will accept
headers up to that length.
In the existing wire protocol, server operators typically also
key off the HTTP request method to implement authentication.
For example, GET requests translate to read-only requests and
can be allowed. But read-write commands must use POST and require
authentication. This has typically worked because the only wire
protocol commands that use POST modify the repo (e.g. the
"unbundle" command).
There is an experimental feature to enable clients to transmit
argument data via POST request bodies. This is technically a
better and more robust solution. But we can't enable it by default
because of servers assuming POST means write access.
In version 2 of the wire protocol, the permissions of a request
are encoded in the URL. And with it being a new protocol in a new
URL space, we're not constrained by backwards compatibility
requirements.
This commit adopts the technically superior mechanism of using
HTTP request bodies to send argument data by requiring POST for
all commands. Strictly speaking, it may be possible to send
request bodies on GET requests. But my experience is that not all
HTTP stacks support this. POST pretty much always works. Using POST
for read-only operations does sacrifice some RESTful design
purity. But this API cares about practicality, not about being
in Roy T. Fielding's REST ivory tower.
There's a chance we may relax this restriction in the future. But
for now, I want to see how far we can get with a POST only API.
Differential Revision: https://phab.mercurial-scm.org/D2837
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 11:57:43 -0700 |
parents | 80a5d237a4ae |
children | d1a49a94c324 |
rev | line source |
---|---|
33014
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
1 Test the extensions.afterloaded() function |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
2 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
3 $ cat > foo.py <<EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
4 > from mercurial import extensions |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
5 > def uisetup(ui): |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
6 > ui.write("foo.uisetup\\n") |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
7 > ui.flush() |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
8 > def bar_loaded(loaded): |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
9 > ui.write("foo: bar loaded: %r\\n" % (loaded,)) |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
10 > ui.flush() |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
11 > extensions.afterloaded('bar', bar_loaded) |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
12 > EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
13 $ cat > bar.py <<EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
14 > def uisetup(ui): |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
15 > ui.write("bar.uisetup\\n") |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
16 > ui.flush() |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
17 > EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
18 $ basepath=`pwd` |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
19 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
20 $ hg init basic |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
21 $ cd basic |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
22 $ echo foo > file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
23 $ hg add file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
24 $ hg commit -m 'add file' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
25 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
26 $ echo '[extensions]' >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
27 $ echo "foo = $basepath/foo.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
28 $ echo "bar = $basepath/bar.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
29 $ hg log -r. -T'{rev}\n' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
30 foo.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
31 foo: bar loaded: True |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
32 bar.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
33 0 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
34 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
35 Test afterloaded with the opposite extension load order |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
36 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
37 $ cd .. |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
38 $ hg init basic_reverse |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
39 $ cd basic_reverse |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
40 $ echo foo > file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
41 $ hg add file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
42 $ hg commit -m 'add file' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
43 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
44 $ echo '[extensions]' >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
45 $ echo "bar = $basepath/bar.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
46 $ echo "foo = $basepath/foo.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
47 $ hg log -r. -T'{rev}\n' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
48 bar.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
49 foo.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
50 foo: bar loaded: True |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
51 0 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
52 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
53 Test the extensions.afterloaded() function when the requested extension is not |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
54 loaded |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
55 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
56 $ cd .. |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
57 $ hg init notloaded |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
58 $ cd notloaded |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
59 $ echo foo > file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
60 $ hg add file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
61 $ hg commit -m 'add file' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
62 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
63 $ echo '[extensions]' >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
64 $ echo "foo = $basepath/foo.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
65 $ hg log -r. -T'{rev}\n' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
66 foo.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
67 foo: bar loaded: False |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
68 0 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
69 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
70 Test the extensions.afterloaded() function when the requested extension is not |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
71 configured but fails the minimum version check |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
72 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
73 $ cd .. |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
74 $ cat > minvers.py <<EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
75 > minimumhgversion = '9999.9999' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
76 > def uisetup(ui): |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
77 > ui.write("minvers.uisetup\\n") |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
78 > ui.flush() |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
79 > EOF |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
80 $ hg init minversion |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
81 $ cd minversion |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
82 $ echo foo > file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
83 $ hg add file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
84 $ hg commit -m 'add file' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
85 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
86 $ echo '[extensions]' >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
87 $ echo "foo = $basepath/foo.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
88 $ echo "bar = $basepath/minvers.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
89 $ hg log -r. -T'{rev}\n' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
90 (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling) |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
91 foo.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
92 foo: bar loaded: False |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
93 0 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
94 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
95 Test the extensions.afterloaded() function when the requested extension is not |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
96 configured but fails the minimum version check, using the opposite load order |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
97 for the two extensions. |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
98 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
99 $ cd .. |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
100 $ hg init minversion_reverse |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
101 $ cd minversion_reverse |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
102 $ echo foo > file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
103 $ hg add file |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
104 $ hg commit -m 'add file' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
105 |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
106 $ echo '[extensions]' >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
107 $ echo "bar = $basepath/minvers.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
108 $ echo "foo = $basepath/foo.py" >> .hg/hgrc |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
109 $ hg log -r. -T'{rev}\n' |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
110 (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling) |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
111 foo.uisetup |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
112 foo: bar loaded: False |
80a5d237a4ae
extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff
changeset
|
113 0 |