~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_sign_my_commits.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    gpg,
22
22
    tests,
23
23
    )
 
24
from bzrlib.tests.matchers import ContainsNoVfsCalls
24
25
 
25
26
 
26
27
class SignMyCommits(tests.TestCaseWithTransport):
137
138
                           '0 commits with unknown keys\n'
138
139
                           '0 commits not valid\n'
139
140
                           '1 commit not signed\n', ''), out)
 
141
 
 
142
 
 
143
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
 
144
 
 
145
    def monkey_patch_gpg(self):
 
146
        """Monkey patch the gpg signing strategy to be a loopback.
 
147
 
 
148
        This also registers the cleanup, so that we will revert to
 
149
        the original gpg strategy when done.
 
150
        """
 
151
        # monkey patch gpg signing mechanism
 
152
        self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
 
153
 
 
154
    def test_sign_single_commit(self):
 
155
        self.setup_smart_server_with_call_log()
 
156
        t = self.make_branch_and_tree('branch')
 
157
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
158
        t.add("foo")
 
159
        t.commit("message")
 
160
        self.reset_smart_call_log()
 
161
        self.monkey_patch_gpg()
 
162
        out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
 
163
        # This figure represent the amount of work to perform this use case. It
 
164
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
165
        # being too low. If rpc_count increases, more network roundtrips have
 
166
        # become necessary for this use case. Please do not adjust this number
 
167
        # upwards without agreement from bzr's network support maintainers.
 
168
        self.assertLength(15, self.hpss_calls)
 
169
        self.assertLength(1, self.hpss_connections)
 
170
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
171
 
 
172
    def test_verify_commits(self):
 
173
        self.setup_smart_server_with_call_log()
 
174
        t = self.make_branch_and_tree('branch')
 
175
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
176
        t.add("foo")
 
177
        t.commit("message")
 
178
        self.monkey_patch_gpg()
 
179
        out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
 
180
        self.reset_smart_call_log()
 
181
        self.run_bzr('sign-my-commits')
 
182
        out = self.run_bzr(['verify-signatures', self.get_url('branch')])
 
183
        # This figure represent the amount of work to perform this use case. It
 
184
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
185
        # being too low. If rpc_count increases, more network roundtrips have
 
186
        # become necessary for this use case. Please do not adjust this number
 
187
        # upwards without agreement from bzr's network support maintainers.
 
188
        self.assertLength(10, self.hpss_calls)
 
189
        self.assertLength(1, self.hpss_connections)
 
190
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)