annotate tests/test-bugzilla.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 4441705b7111
children fc3cca406b2e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28950
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
1 mock bugzilla driver for testing template output:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
2
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
3 $ cat <<EOF > bzmock.py
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
4 > from __future__ import absolute_import
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
5 > from mercurial import extensions
33432
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
6 > from mercurial import registrar
28950
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
7 >
33432
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
8 > configtable = {}
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
9 > configitem = registrar.configitem(configtable)
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
10 >
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
11 > configitem('bugzilla', 'mocklog',
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
12 > default=None,
fbfecd1dbfb5 configitems: register the 'bugzilla.mocklog' config
Boris Feld <boris.feld@octobus.net>
parents: 29102
diff changeset
13 > )
28950
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
14 > def extsetup(ui):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
15 > bugzilla = extensions.find('bugzilla')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
16 > class bzmock(bugzilla.bzaccess):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
17 > def __init__(self, ui):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
18 > super(bzmock, self).__init__(ui)
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
19 > self._logfile = ui.config('bugzilla', 'mocklog')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
20 > def updatebug(self, bugid, newstate, text, committer):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
21 > with open(self._logfile, 'a') as f:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
22 > f.write('update bugid=%r, newstate=%r, committer=%r\n'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
23 > % (bugid, newstate, committer))
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
24 > f.write('----\n' + text + '\n----\n')
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
25 > def notify(self, bugs, committer):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
26 > with open(self._logfile, 'a') as f:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
27 > f.write('notify bugs=%r, committer=%r\n'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
28 > % (bugs, committer))
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
29 > bugzilla.bugzilla._versions['mock'] = bzmock
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
30 > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
31
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
32 set up mock repository:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
33
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
34 $ hg init mockremote
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
35 $ cat <<EOF > mockremote/.hg/hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
36 > [extensions]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
37 > bugzilla =
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
38 > bzmock = $TESTTMP/bzmock.py
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
39 >
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
40 > [bugzilla]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
41 > version = mock
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
42 > mocklog = $TESTTMP/bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
43 >
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
44 > [hooks]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
45 > incoming.bugzilla = python:hgext.bugzilla.hook
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
46 >
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
47 > [web]
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
48 > baseurl=http://example.org/hg
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
49 >
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
50 > %include $TESTTMP/bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
51 > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
52
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
53 $ hg clone -q mockremote mocklocal
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
54
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
55 push with default template:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
56
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
57 $ echo '[bugzilla]' > bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
58 $ echo foo > mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
59 $ hg ci -R mocklocal -Aqm 'Fixes bug 123'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
60 $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
61 $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
62 update bugid=123, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
63 ----
35393
4441705b7111 tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents: 33432
diff changeset
64 changeset 7875a8342c6f in repo $TESTTMP/mockremote refers to bug 123.
28950
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
65 details:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
66 Fixes bug 123
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
67 ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
68 notify bugs={123: {}}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
69
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
70 push with style:
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
71
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
72 $ cat <<EOF > bzstyle.map
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
73 > changeset = "{node|short} refers to bug {bug}."
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
74 > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
75 $ echo "style = $TESTTMP/bzstyle.map" >> bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
76 $ echo foo >> mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
77 $ hg ci -R mocklocal -qm 'Fixes bug 456'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
78 $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
79 $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
80 update bugid=456, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
81 ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
82 2808b172464b refers to bug 456.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
83 ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
84 notify bugs={456: {}}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
85
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
86 push with template (overrides style):
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
87
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
88 $ cat <<EOF >> bzstyle.hgrc
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
89 > template = Changeset {node|short} in {root|basename}.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
90 > {hgweb}/rev/{node|short}\n
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
91 > {desc}
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
92 > EOF
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
93 $ echo foo >> mocklocal/foo
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
94 $ hg ci -R mocklocal -qm 'Fixes bug 789'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
95 $ hg -R mocklocal push -q
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
96 $ cat bzmock.log && rm bzmock.log
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
97 update bugid=789, newstate={}, committer='test'
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
98 ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
99 Changeset a770f3e409f2 in mockremote.
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
100 http://example.org/hg/rev/a770f3e409f2
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
101
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
102 Fixes bug 789
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
103 ----
9e1c9f016b72 bugzilla: do not load style file if template is specified (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
104 notify bugs={789: {}}, committer='test'