Rev 6594: (richard-wilbur) Fix bug LP: #1123460, in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 11 02:21:29 UTC 2014
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6594 [merge]
revision-id: pqm at pqm.ubuntu.com-20140411022129-msotfyulqna1qc4m
parent: pqm at pqm.ubuntu.com-20140409133625-s24spv3kha2w2860
parent: vexofp at gmail.com-20130811203516-4ov9oo4s5bgkk98g
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2014-04-11 02:21:29 +0000
message:
(richard-wilbur) Fix bug LP: #1123460,
verify-signature crashes on non ascii characters (and on -v) (Reagan Sanders)
added:
bzrlib/tests/blackbox/test_verify_signatures.py test_verify_signatur-20130811180758-13ilxttapkpjx8cw-1
modified:
bzrlib/commit_signature_commands.py sign_my_commits.py-20060215152201-5a6363365180e671
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
bzrlib/tests/blackbox/test_sign_my_commits.py test_sign_my_commits.py-20060215152957-270238a1ffacc841
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
=== modified file 'bzrlib/commit_signature_commands.py'
--- a/bzrlib/commit_signature_commands.py 2012-03-11 16:51:49 +0000
+++ b/bzrlib/commit_signature_commands.py 2013-07-28 14:41:57 +0000
@@ -165,7 +165,8 @@
if all_verifiable:
write(gettext("All commits signed with verifiable keys"))
if verbose:
- write(gpg.verbose_valid_message(result))
+ for message in gpg.verbose_valid_message(result):
+ write_verbose(message)
return 0
else:
write(gpg.valid_commits_message(count))
=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py 2012-03-14 11:30:42 +0000
+++ b/bzrlib/log.py 2013-08-11 20:22:29 +0000
@@ -334,7 +334,7 @@
gpg_strategy = gpg.GPGStrategy(None)
result = repo.verify_revision_signature(rev_id, gpg_strategy)
if result[0] == gpg.SIGNATURE_VALID:
- return "valid signature from {0}".format(result[1])
+ return u"valid signature from {0}".format(result[1])
if result[0] == gpg.SIGNATURE_KEY_MISSING:
return "unknown key {0}".format(result[1])
if result[0] == gpg.SIGNATURE_NOT_VALID:
=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py 2012-09-08 13:26:18 +0000
+++ b/bzrlib/tests/blackbox/__init__.py 2013-08-11 20:31:42 +0000
@@ -118,6 +118,7 @@
'test_shell_complete',
'test_shelve',
'test_sign_my_commits',
+ 'test_verify_signatures',
'test_split',
'test_status',
'test_switch',
=== modified file 'bzrlib/tests/blackbox/test_sign_my_commits.py'
--- a/bzrlib/tests/blackbox/test_sign_my_commits.py 2012-03-11 16:51:49 +0000
+++ b/bzrlib/tests/blackbox/test_sign_my_commits.py 2013-08-11 20:31:42 +0000
@@ -116,29 +116,6 @@
self.assertUnsigned(repo, 'D')
self.assertUnsigned(repo, 'E')
- def test_verify_commits(self):
- wt = self.setup_tree()
- self.monkey_patch_gpg()
- self.run_bzr('sign-my-commits')
- out = self.run_bzr('verify-signatures', retcode=1)
- self.assertEquals(('4 commits with valid signatures\n'
- '0 commits with key now expired\n'
- '0 commits with unknown keys\n'
- '0 commits not valid\n'
- '1 commit not signed\n', ''), out)
-
- def test_verify_commits_acceptable_key(self):
- wt = self.setup_tree()
- self.monkey_patch_gpg()
- self.run_bzr('sign-my-commits')
- out = self.run_bzr(['verify-signatures', '--acceptable-keys=foo,bar'],
- retcode=1)
- self.assertEquals(('4 commits with valid signatures\n'
- '0 commits with key now expired\n'
- '0 commits with unknown keys\n'
- '0 commits not valid\n'
- '1 commit not signed\n', ''), out)
-
class TestSmartServerSignMyCommits(tests.TestCaseWithTransport):
@@ -168,23 +145,3 @@
self.assertLength(15, self.hpss_calls)
self.assertLength(1, self.hpss_connections)
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
-
- def test_verify_commits(self):
- self.setup_smart_server_with_call_log()
- t = self.make_branch_and_tree('branch')
- self.build_tree_contents([('branch/foo', 'thecontents')])
- t.add("foo")
- t.commit("message")
- self.monkey_patch_gpg()
- out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
- self.reset_smart_call_log()
- self.run_bzr('sign-my-commits')
- out = self.run_bzr(['verify-signatures', self.get_url('branch')])
- # This figure represent the amount of work to perform this use case. It
- # is entirely ok to reduce this number if a test fails due to rpc_count
- # being too low. If rpc_count increases, more network roundtrips have
- # become necessary for this use case. Please do not adjust this number
- # upwards without agreement from bzr's network support maintainers.
- self.assertLength(10, self.hpss_calls)
- self.assertLength(1, self.hpss_connections)
- self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
=== added file 'bzrlib/tests/blackbox/test_verify_signatures.py'
--- a/bzrlib/tests/blackbox/test_verify_signatures.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_verify_signatures.py 2013-08-11 20:31:42 +0000
@@ -0,0 +1,124 @@
+# Copyright (C) 2005 Canonical Ltd
+# -*- coding: utf-8 -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Black-box tests for bzr verify-signatures."""
+
+from bzrlib import (
+ gpg,
+ tests,
+ )
+from bzrlib.tests.matchers import ContainsNoVfsCalls
+
+
+class TestVerifySignatures(tests.TestCaseWithTransport):
+
+ def monkey_patch_gpg(self):
+ """Monkey patch the gpg signing strategy to be a loopback.
+
+ This also registers the cleanup, so that we will revert to
+ the original gpg strategy when done.
+ """
+ # monkey patch gpg signing mechanism
+ self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
+
+ def setup_tree(self, location='.'):
+ wt = self.make_branch_and_tree(location)
+ wt.commit("base A", allow_pointless=True, rev_id='A')
+ wt.commit("base B", allow_pointless=True, rev_id='B')
+ wt.commit("base C", allow_pointless=True, rev_id='C')
+ wt.commit("base D", allow_pointless=True, rev_id='D',
+ committer='Alternate <alt at foo.com>')
+ wt.add_parent_tree_id("aghost")
+ wt.commit("base E", allow_pointless=True, rev_id='E')
+ return wt
+
+ def test_verify_signatures(self):
+ wt = self.setup_tree()
+ self.monkey_patch_gpg()
+ self.run_bzr('sign-my-commits')
+ out = self.run_bzr('verify-signatures', retcode=1)
+ self.assertEquals(('4 commits with valid signatures\n'
+ '0 commits with key now expired\n'
+ '0 commits with unknown keys\n'
+ '0 commits not valid\n'
+ '1 commit not signed\n', ''), out)
+
+ def test_verify_signatures_acceptable_key(self):
+ wt = self.setup_tree()
+ self.monkey_patch_gpg()
+ self.run_bzr('sign-my-commits')
+ out = self.run_bzr(['verify-signatures', '--acceptable-keys=foo,bar'],
+ retcode=1)
+ self.assertEquals(('4 commits with valid signatures\n'
+ '0 commits with key now expired\n'
+ '0 commits with unknown keys\n'
+ '0 commits not valid\n'
+ '1 commit not signed\n', ''), out)
+
+ def test_verify_signatures_verbose(self):
+ wt = self.setup_tree()
+ self.monkey_patch_gpg()
+ self.run_bzr('sign-my-commits')
+ out = self.run_bzr('verify-signatures --verbose', retcode=1)
+ self.assertEquals(('4 commits with valid signatures\n'
+ ' None signed 4 commits\n'
+ '0 commits with key now expired\n'
+ '0 commits with unknown keys\n'
+ '0 commits not valid\n'
+ '1 commit not signed\n'
+ ' 1 commit by author Alternate <alt at foo.com>\n', ''), out)
+
+ def test_verify_signatures_verbose_all_valid(self):
+ wt = self.setup_tree()
+ self.monkey_patch_gpg()
+ self.run_bzr('sign-my-commits')
+ self.run_bzr(['sign-my-commits', '.', 'Alternate <alt at foo.com>'])
+ out = self.run_bzr('verify-signatures --verbose')
+ self.assertEquals(('All commits signed with verifiable keys\n'
+ ' None signed 5 commits\n', ''), out)
+
+
+class TestSmartServerVerifySignatures(tests.TestCaseWithTransport):
+
+ def monkey_patch_gpg(self):
+ """Monkey patch the gpg signing strategy to be a loopback.
+
+ This also registers the cleanup, so that we will revert to
+ the original gpg strategy when done.
+ """
+ # monkey patch gpg signing mechanism
+ self.overrideAttr(gpg, 'GPGStrategy', gpg.LoopbackGPGStrategy)
+
+ def test_verify_signatures(self):
+ self.setup_smart_server_with_call_log()
+ t = self.make_branch_and_tree('branch')
+ self.build_tree_contents([('branch/foo', 'thecontents')])
+ t.add("foo")
+ t.commit("message")
+ self.monkey_patch_gpg()
+ out, err = self.run_bzr(['sign-my-commits', self.get_url('branch')])
+ self.reset_smart_call_log()
+ self.run_bzr('sign-my-commits')
+ out = self.run_bzr(['verify-signatures', self.get_url('branch')])
+ # This figure represent the amount of work to perform this use case. It
+ # is entirely ok to reduce this number if a test fails due to rpc_count
+ # being too low. If rpc_count increases, more network roundtrips have
+ # become necessary for this use case. Please do not adjust this number
+ # upwards without agreement from bzr's network support maintainers.
+ self.assertLength(10, self.hpss_calls)
+ self.assertLength(1, self.hpss_connections)
+ self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py 2012-08-04 14:27:47 +0000
+++ b/bzrlib/tests/test_log.py 2013-08-11 20:35:16 +0000
@@ -25,6 +25,8 @@
revision,
revisionspec,
tests,
+ gpg,
+ trace,
)
@@ -281,6 +283,38 @@
self.checkDelta(logentry.delta, added=['file1', 'file2'])
+class TestFormatSignatureValidity(tests.TestCaseWithTransport):
+ class UTFLoopbackGPGStrategy(gpg.LoopbackGPGStrategy):
+ def verify(self, content, testament):
+ return (gpg.SIGNATURE_VALID,
+ u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom at example.com>')
+
+ def has_signature_for_revision_id(self, revision_id):
+ return True
+
+ def get_signature_text(self, revision_id):
+ return ''
+
+ def test_format_signature_validity_utf(self):
+ """Check that GPG signatures containing UTF-8 names are formatted
+ correctly."""
+ # Monkey patch to use our UTF-8 generating GPGStrategy
+ self.overrideAttr(gpg, 'GPGStrategy', self.UTFLoopbackGPGStrategy)
+ wt = self.make_branch_and_tree('.')
+ revid = wt.commit('empty commit')
+ repo = wt.branch.repository
+ # Monkey patch out checking if this rev is actually signed, since we
+ # can't sign it without a heavier TestCase and LoopbackGPGStrategy
+ # doesn't care anyways.
+ self.overrideAttr(repo, 'has_signature_for_revision_id',
+ self.has_signature_for_revision_id)
+ self.overrideAttr(repo, 'get_signature_text', self.get_signature_text)
+ out = log.format_signature_validity(revid, repo)
+ self.assertEqual(
+u'valid signature from UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom at example.com>',
+ out)
+
+
class TestShortLogFormatter(TestCaseForLogFormatter):
def test_trailing_newlines(self):
More information about the bazaar-commits
mailing list