~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-08-04 13:30:30 UTC
  • mfrom: (6050 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6052.
  • Revision ID: jelmer@samba.org-20110804133030-uwo00unp8b0n782c
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Black-box tests for bzr sign-my-commits."""
19
19
 
20
 
import os
21
 
 
22
20
from bzrlib import (
23
21
    gpg,
24
22
    tests,
25
23
    )
26
 
from bzrlib.testament import Testament
27
 
from bzrlib.workingtree import WorkingTree
28
24
 
29
25
 
30
26
class SignMyCommits(tests.TestCaseWithTransport):
45
41
        wt.commit("base C", allow_pointless=True, rev_id='C')
46
42
        wt.commit("base D", allow_pointless=True, rev_id='D',
47
43
                committer='Alternate <alt@foo.com>')
48
 
 
 
44
        wt.add_parent_tree_id("aghost")
 
45
        wt.commit("base E", allow_pointless=True, rev_id='E')
49
46
        return wt
50
47
 
51
48
    def assertUnsigned(self, repo, revision_id):
109
106
 
110
107
        out = self.run_bzr('sign-my-commits --dry-run')[0]
111
108
 
112
 
        self.assertEquals('A\nB\nC\nSigned 3 revisions\n', out)
 
109
        outlines = out.splitlines()
 
110
        self.assertEquals(5, len(outlines))
 
111
        self.assertEquals('Signed 4 revisions', outlines[-1])
113
112
        self.assertUnsigned(repo, 'A')
114
113
        self.assertUnsigned(repo, 'B')
115
114
        self.assertUnsigned(repo, 'C')
116
115
        self.assertUnsigned(repo, 'D')
 
116
        self.assertUnsigned(repo, 'E')
 
117
 
 
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 unknown keys\n'
 
125
                           '0 commits not valid\n'
 
126
                           '1 commit not signed\n', ''), out)
 
127
 
 
128
    def test_verify_commits_acceptable_key(self):
 
129
        wt = self.setup_tree()
 
130
        self.monkey_patch_gpg()
 
131
        self.run_bzr('sign-my-commits')
 
132
        out = self.run_bzr(['verify-signatures', '--acceptable-keys=foo,bar'],
 
133
                            retcode=1)
 
134
        self.assertEquals(('4 commits with valid signatures\n'
 
135
                           '0 commits with unknown keys\n'
 
136
                           '0 commits not valid\n'
 
137
                           '1 commit not signed\n', ''), out)