29
29
class TestSignatures(per_repository.TestCaseWithRepository):
32
super(TestSignatures, self).setUp()
33
if not self.repository_format.supports_revision_signatures:
34
raise tests.TestNotApplicable(
35
"repository does not support signing revisions")
31
37
# TODO 20051003 RBC:
32
38
# compare the gpg-to-sign info for a commit with a ghost and
33
39
# an identical tree without a ghost
34
40
# fetch missing should rewrite the TOC of weaves to list newly available parents.
37
super(TestSignatures, self).setUp()
38
if not self.repository_format.supports_revision_signatures:
39
raise tests.TestNotApplicable(
40
"repository does not support signing revisions")
42
42
def test_sign_existing_revision(self):
43
43
wt = self.make_branch_and_tree('.')
44
44
wt.commit("base", allow_pointless=True, rev_id='A')
100
100
self.assertEqual(repo.get_signature_text('A'),
101
101
d2.open_repository().get_signature_text('A'))
103
def test_verify_revision_signature_not_signed(self):
104
wt = self.make_branch_and_tree('.')
105
wt.commit("base", allow_pointless=True, rev_id='A')
106
strategy = gpg.LoopbackGPGStrategy(None)
108
(gpg.SIGNATURE_NOT_SIGNED, None),
109
wt.branch.repository.verify_revision_signature('A', strategy))
111
def test_verify_revision_signature(self):
112
wt = self.make_branch_and_tree('.')
113
wt.commit("base", allow_pointless=True, rev_id='A')
114
strategy = gpg.LoopbackGPGStrategy(None)
115
repo = wt.branch.repository
116
self.addCleanup(repo.lock_write().unlock)
117
repo.start_write_group()
118
repo.sign_revision('A', strategy)
119
repo.commit_write_group()
120
self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' +
121
Testament.from_revision(repo,
122
'A').as_short_text() +
123
'-----END PSEUDO-SIGNED CONTENT-----\n',
124
repo.get_signature_text('A'))
126
(gpg.SIGNATURE_VALID, None, ),
127
repo.verify_revision_signature('A', strategy))
104
130
class TestUnsupportedSignatures(per_repository.TestCaseWithRepository):