319
319
class TestFormatSignatureValidity(tests.TestCaseWithTransport):
320
class UTFLoopbackGPGStrategy(gpg.LoopbackGPGStrategy):
321
def verify(self, content, testament):
322
return (gpg.SIGNATURE_VALID,
323
u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>')
325
def has_signature_for_revision_id(self, revision_id):
328
def get_signature_text(self, revision_id):
321
def verify_revision_signature(self, revid, gpg_strategy):
322
return (gpg.SIGNATURE_VALID,
323
u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>')
331
325
def test_format_signature_validity_utf(self):
332
326
"""Check that GPG signatures containing UTF-8 names are formatted
334
# Monkey patch to use our UTF-8 generating GPGStrategy
335
self.overrideAttr(gpg, 'GPGStrategy', self.UTFLoopbackGPGStrategy)
336
328
wt = self.make_branch_and_tree('.')
337
329
revid = wt.commit('empty commit')
338
330
repo = wt.branch.repository
339
331
# Monkey patch out checking if this rev is actually signed, since we
340
332
# can't sign it without a heavier TestCase and LoopbackGPGStrategy
341
333
# doesn't care anyways.
342
self.overrideAttr(repo, 'has_signature_for_revision_id',
343
self.has_signature_for_revision_id)
344
self.overrideAttr(repo, 'get_signature_text', self.get_signature_text)
334
self.overrideAttr(repo, 'verify_revision_signature',
335
self.verify_revision_signature)
345
336
out = log.format_signature_validity(revid, wt.branch)
346
337
self.assertEqual(
347
338
u'valid signature from UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>',