~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: 2011-11-28 19:07:58 UTC
  • mfrom: (6318 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6319.
  • Revision ID: martin.packman@canonical.com-20111128190758-5gj44o5uzwz5sjfq
Merge bzr.dev to resolve conflicts with updated registry help strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
                           '0 commits with unknown keys\n'
138
138
                           '0 commits not valid\n'
139
139
                           '1 commit not signed\n', ''), out)
 
140
 
 
141
 
 
142
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
 
143
 
 
144
    def monkey_patch_gpg(self):
 
145
        """Monkey patch the gpg signing strategy to be a loopback.
 
146
 
 
147
        This also registers the cleanup, so that we will revert to
 
148
        the original gpg strategy when done.
 
149
        """
 
150
        # monkey patch gpg signing mechanism
 
151
        self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
 
152
 
 
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')])
 
157
        t.add("foo")
 
158
        t.commit("message")
 
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)
 
168
 
 
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')])
 
173
        t.add("foo")
 
174
        t.commit("message")
 
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.
 
185
 
 
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
 
188
        # variation:
 
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))