109
110
outlines = out.splitlines()
110
111
self.assertEquals(5, len(outlines))
111
self.assertEquals('Signed 4 revisions', outlines[-1])
112
self.assertEquals('Signed 4 revisions.', outlines[-1])
112
113
self.assertUnsigned(repo, 'A')
113
114
self.assertUnsigned(repo, 'B')
114
115
self.assertUnsigned(repo, 'C')
115
116
self.assertUnsigned(repo, 'D')
116
117
self.assertUnsigned(repo, 'E')
118
def test_verify_commits(self):
119
wt = self.setup_tree()
120
self.monkey_patch_gpg()
121
self.run_bzr('sign-my-commits')
122
out = self.run_bzr('verify-signatures', retcode=1)
123
self.assertEquals(('4 commits with valid signatures\n'
124
'0 commits with key now expired\n'
125
'0 commits with unknown keys\n'
126
'0 commits not valid\n'
127
'1 commit not signed\n', ''), out)
129
def test_verify_commits_acceptable_key(self):
130
wt = self.setup_tree()
131
self.monkey_patch_gpg()
132
self.run_bzr('sign-my-commits')
133
out = self.run_bzr(['verify-signatures', '--acceptable-keys=foo,bar'],
135
self.assertEquals(('4 commits with valid signatures\n'
136
'0 commits with key now expired\n'
137
'0 commits with unknown keys\n'
138
'0 commits not valid\n'
139
'1 commit not signed\n', ''), out)
120
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
122
def monkey_patch_gpg(self):
123
"""Monkey patch the gpg signing strategy to be a loopback.
125
This also registers the cleanup, so that we will revert to
126
the original gpg strategy when done.
128
# monkey patch gpg signing mechanism
129
self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
131
def test_sign_single_commit(self):
132
self.setup_smart_server_with_call_log()
133
t = self.make_branch_and_tree('branch')
134
self.build_tree_contents([('branch/foo', 'thecontents')])
137
self.reset_smart_call_log()
138
self.monkey_patch_gpg()
139
out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
140
# This figure represent the amount of work to perform this use case. It
141
# is entirely ok to reduce this number if a test fails due to rpc_count
142
# being too low. If rpc_count increases, more network roundtrips have
143
# become necessary for this use case. Please do not adjust this number
144
# upwards without agreement from bzr's network support maintainers.
145
self.assertLength(15, self.hpss_calls)
146
self.assertLength(1, self.hpss_connections)
147
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)