137
137
'0 commits with unknown keys\n'
138
138
'0 commits not valid\n'
139
139
'1 commit not signed\n', ''), out)
142
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
144
def monkey_patch_gpg(self):
145
"""Monkey patch the gpg signing strategy to be a loopback.
147
This also registers the cleanup, so that we will revert to
148
the original gpg strategy when done.
150
# monkey patch gpg signing mechanism
151
self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
153
def test_sign_single_commit(self):
154
self.setup_smart_server_with_call_log()
155
t = self.make_branch_and_tree('branch')
156
self.build_tree_contents([('branch/foo', 'thecontents')])
159
self.reset_smart_call_log()
160
self.monkey_patch_gpg()
161
out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
162
# This figure represent the amount of work to perform this use case. It
163
# is entirely ok to reduce this number if a test fails due to rpc_count
164
# being too low. If rpc_count increases, more network roundtrips have
165
# become necessary for this use case. Please do not adjust this number
166
# upwards without agreement from bzr's network support maintainers.
167
self.assertLength(54, self.hpss_calls)
169
def test_verify_commits(self):
170
self.setup_smart_server_with_call_log()
171
t = self.make_branch_and_tree('branch')
172
self.build_tree_contents([('branch/foo', 'thecontents')])
175
self.monkey_patch_gpg()
176
out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
177
self.reset_smart_call_log()
178
self.run_bzr('sign-my-commits')
179
out = self.run_bzr(['verify-signatures', self.get_url('branch')])
180
# This figure represent the amount of work to perform this use case. It
181
# is entirely ok to reduce this number if a test fails due to rpc_count
182
# being too low. If rpc_count increases, more network roundtrips have
183
# become necessary for this use case. Please do not adjust this number
184
# upwards without agreement from bzr's network support maintainers.
186
# The number of readv requests seems to vary depending on the generated
187
# repository and how well it compresses, so allow for a bit of
189
if len(self.hpss_calls) not in (18, 19):
190
self.fail("Incorrect length: wanted 18 or 19, got %d for %r" % (
191
len(self.hpss_calls), self.hpss_calls))