Merge lp:~salgado/launchpad/update-pygpgme into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/update-pygpgme
Merge into: lp:launchpad
Diff against target: 249 lines (+31/-35)
8 files modified
lib/canonical/launchpad/doc/emailauthentication.txt (+1/-1)
lib/canonical/launchpad/doc/gpghandler.txt (+6/-6)
lib/canonical/launchpad/utilities/gpghandler.py (+2/-2)
lib/lp/archivepublisher/tests/archive-signing.txt (+1/-2)
lib/lp/archiveuploader/tests/nascentuploadfile.txt (+4/-4)
lib/lp/registry/doc/gpg-signatures.txt (+14/-13)
lib/lp/soyuz/doc/soyuz-upload.txt (+2/-6)
utilities/sourcedeps.conf (+1/-1)
To merge this branch: bzr merge lp:~salgado/launchpad/update-pygpgme
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+23790@code.launchpad.net

Description of the change

Use the latest pygpgme, in preparation for switching to python2.6.

The last pygpgme revision (r49) includes a merge from trunk, which
brings http://bazaar.launchpad.net/~jamesh/pygpgme/trunk/revision/57
that was responsible for turning gpgmekey.fpr into a unicode. That
exposed a bug in our code where we were not ascii-encoding the
fingerprint before passing it to gpgme.Context.export(), like all other
callsites on that module do.

Another alternative here would be to change PymeKey._buildFromGpgmeKey()
to store the ascii-encoded fingerprint, instead of the unicode one, in
an instance variable. I'd be in favour of this, I think.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/utilities/gpghandler.py
  lib/lp/archiveuploader/tests/nascentuploadfile.txt
  lib/lp/registry/doc/gpg-signatures.txt
  lib/canonical/launchpad/doc/emailauthentication.txt
  lib/canonical/launchpad/doc/gpghandler.txt
  lib/lp/soyuz/doc/soyuz-upload.txt
  utilities/sourcedeps.conf

== Pylint notices ==

lib/canonical/launchpad/utilities/gpghandler.py
    25: [F0401] Unable to import 'gpgme'
    26: [F0401] Unable to import 'gpgme'
    30: [F0401] Unable to import 'canonical.config'
    31: [F0401] Unable to import 'lp.registry.interfaces.gpg'
    33: [F0401] Unable to import 'canonical.launchpad.interfaces.gpghandler'
    37: [F0401] Unable to import 'canonical.launchpad.validators.email'

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the fix Salgado.

To get around the unicode marker in test output we decided to do:

>>> print name
Salgado

instead of

>>> name
u'Salgado'

I think that is less fragile. Would you make the change? Of course you can't do anything about the unicode inside the exceptions.

review: Approve (code)
Revision history for this message
Guilherme Salgado (salgado) wrote :

On Tue, 2010-04-20 at 20:07 +0000, Brad Crittenden wrote:
> Review: Approve code
> Thanks for the fix Salgado.

Thank you for the review!

>
> To get around the unicode marker in test output we decided to do:
>
> >>> print name
> Salgado
>
> instead of
>
> >>> name
> u'Salgado'
>
> I think that is less fragile. Would you make the change? Of course you can't do anything about the unicode inside the exceptions.

I didn't know we have a policy for that, but I'm happy to change that,
except for the cases where the string is empty or contains non-ascii
characters. Attached is the incremental diff.

1=== modified file 'lib/canonical/launchpad/doc/gpghandler.txt'
2--- lib/canonical/launchpad/doc/gpghandler.txt 2010-04-20 18:49:36 +0000
3+++ lib/canonical/launchpad/doc/gpghandler.txt 2010-04-20 20:57:31 +0000
4@@ -59,8 +59,8 @@
5 >>> verifyObject(IPymeKey, key)
6 True
7
8- >>> key.fingerprint
9- u'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
10+ >>> print key.fingerprint
11+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
12
13 >>> print key.secret
14 False
15@@ -119,8 +119,8 @@
16 >>> assert key is not None
17 >>> verifyObject(IPymeKey, key)
18 True
19- >>> key.fingerprint
20- u'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
21+ >>> print key.fingerprint
22+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
23
24 But we get an error if the damage is big:
25 (what probably happened in bug #2547)
26
27=== modified file 'lib/lp/archiveuploader/tests/nascentuploadfile.txt'
28--- lib/lp/archiveuploader/tests/nascentuploadfile.txt 2010-04-20 18:49:36 +0000
29+++ lib/lp/archiveuploader/tests/nascentuploadfile.txt 2010-04-20 20:58:13 +0000
30@@ -468,8 +468,8 @@
31
32 The IGPGKey fingerprint used to sign this ChangesFile:
33
34- >>> ed_mixed_changes.fingerprint
35- u'340CA3BB270E2716C9EE0B768E7EB7086C64A8C5'
36+ >>> print ed_mixed_changes.fingerprint
37+ 340CA3BB270E2716C9EE0B768E7EB7086C64A8C5
38
39
40 == DSCFile ==
41@@ -530,8 +530,8 @@
42
43 The IGPGKey fingerprint used to sign this DSC:
44
45- >>> ed_mixed_dsc.fingerprint
46- u'340CA3BB270E2716C9EE0B768E7EB7086C64A8C5'
47+ >>> print ed_mixed_dsc.fingerprint
48+ 340CA3BB270E2716C9EE0B768E7EB7086C64A8C5
49
50 A DSCFile provides a verification API similiar to what we have in
51 ChangesFile itself:
52
53=== modified file 'lib/lp/registry/doc/gpg-signatures.txt'
54--- lib/lp/registry/doc/gpg-signatures.txt 2010-04-20 18:55:06 +0000
55+++ lib/lp/registry/doc/gpg-signatures.txt 2010-04-20 20:59:25 +0000
56@@ -39,8 +39,8 @@
57 ... """
58
59 >>> master_sig = gpghandler.verifySignature(content)
60- >>> master_sig.fingerprint
61- u'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
62+ >>> print master_sig.fingerprint
63+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
64
65 The text below was "clear signed" by a 0x02BA5EF6, a subkey of 0xDFD20543
66
67@@ -59,8 +59,8 @@
68 >>>
69
70 >>> subkey_sig = gpghandler.verifySignature(content)
71- >>> subkey_sig.fingerprint
72- u'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
73+ >>> print subkey_sig.fingerprint
74+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
75
76
77 >>> master_sig.fingerprint == subkey_sig.fingerprint
78@@ -109,22 +109,22 @@
79 >>> content = """
80 ... -----BEGIN PGP SIGNED MESSAGE-----
81 ... Hash: SHA1
82- ...
83+ ...
84 ... Test Message.
85 ... -----BEGIN PGP SIGNATURE-----
86 ... Version: GnuPG v1.4.1 (GNU/Linux)
87- ...
88+ ...
89 ... iD8DBQFD3xV52yWXVgK6XvYRAtJQAJ4ojuLC4aap4R9T0og17RkPYoND+ACfbCA3
90 ... yrZD6MZcqzyaGNy1s28Co2Q=
91 ... =5QGd
92 ... -----END PGP SIGNATURE-----
93 ... -----BEGIN PGP SIGNED MESSAGE-----
94 ... Hash: SHA1
95- ...
96+ ...
97 ... Some data appended by foo.bar@canonical.com
98 ... -----BEGIN PGP SIGNATURE-----
99 ... Version: GnuPG v1.4.1 (GNU/Linux)
100- ...
101+ ...
102 ... iD8DBQFD3xWpjn63CGxkqMURAmi6AJ4yHAnhIpt49VlYDG1uxpGy9BmHwwCeKbFM
103 ... aHIJLqhWVf8bGLHZBIH5odw=
104 ... =iUSC
105
106=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt'
107--- lib/lp/soyuz/doc/soyuz-upload.txt 2010-04-20 18:55:06 +0000
108+++ lib/lp/soyuz/doc/soyuz-upload.txt 2010-04-20 20:59:49 +0000
109@@ -220,8 +220,8 @@
110 >>> key_data = open(key_path).read()
111 >>> key = gpg_handler.importPublicKey(key_data)
112 >>> assert key is not None
113- >>> key.fingerprint
114- u'33C0A61893A5DC5EB325B29E415A12CAC2F30234'
115+ >>> print key.fingerprint
116+ 33C0A61893A5DC5EB325B29E415A12CAC2F30234
117
118
119 Create the katie user and register it in a team that is allowed to
120

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/emailauthentication.txt'
2--- lib/canonical/launchpad/doc/emailauthentication.txt 2009-02-19 23:55:18 +0000
3+++ lib/canonical/launchpad/doc/emailauthentication.txt 2010-04-21 11:58:24 +0000
4@@ -116,7 +116,7 @@
5 ... msg.signedContent, msg.signature)
6 Traceback (most recent call last):
7 ...
8- GPGVerificationError: (7, 8, 'Bad signature')
9+ GPGVerificationError: (7, 8, u'Bad signature')
10
11 >>> getUtility(IGPGHandler).getVerifiedSignature(
12 ... msg.signedContent.replace('\n', '\r\n'), msg.signature)
13
14=== modified file 'lib/canonical/launchpad/doc/gpghandler.txt'
15--- lib/canonical/launchpad/doc/gpghandler.txt 2009-01-19 16:15:15 +0000
16+++ lib/canonical/launchpad/doc/gpghandler.txt 2010-04-21 11:58:24 +0000
17@@ -59,8 +59,8 @@
18 >>> verifyObject(IPymeKey, key)
19 True
20
21- >>> key.fingerprint
22- 'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
23+ >>> print key.fingerprint
24+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
25
26 >>> print key.secret
27 False
28@@ -119,8 +119,8 @@
29 >>> assert key is not None
30 >>> verifyObject(IPymeKey, key)
31 True
32- >>> key.fingerprint
33- 'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
34+ >>> print key.fingerprint
35+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
36
37 But we get an error if the damage is big:
38 (what probably happened in bug #2547)
39@@ -230,10 +230,10 @@
40 Launchpad PPA for Celso áéíóú Providelo
41
42 >>> uid.comment
43- ''
44+ u''
45
46 >>> uid.email
47- ''
48+ u''
49
50 The public key is also available.
51
52
53=== modified file 'lib/canonical/launchpad/utilities/gpghandler.py'
54--- lib/canonical/launchpad/utilities/gpghandler.py 2010-03-12 19:56:06 +0000
55+++ lib/canonical/launchpad/utilities/gpghandler.py 2010-04-21 11:58:24 +0000
56@@ -374,7 +374,7 @@
57
58 # Sign the text.
59 try:
60- result = context.sign(plaintext, signature, mode)
61+ context.sign(plaintext, signature, mode)
62 except gpgme.GpgmeError:
63 return None
64
65@@ -620,7 +620,7 @@
66 context = gpgme.Context()
67 context.armor = True
68 keydata = StringIO()
69- context.export(self.fingerprint, keydata)
70+ context.export(self.fingerprint.encode('ascii'), keydata)
71
72 return keydata.getvalue()
73
74
75=== modified file 'lib/lp/archivepublisher/tests/archive-signing.txt'
76--- lib/lp/archivepublisher/tests/archive-signing.txt 2010-03-11 16:09:29 +0000
77+++ lib/lp/archivepublisher/tests/archive-signing.txt 2010-04-21 11:58:24 +0000
78@@ -230,8 +230,7 @@
79
80 >>> [uid] = retrieved_key.uids
81 >>> uid.name
82- 'Launchpad PPA for
83- Celso \xc3\xa1\xc3\xa9\xc3\xad\xc3\xb3\xc3\xba Providelo'
84+ u'Launchpad PPA for Celso \xe1\xe9\xed\xf3\xfa Providelo'
85
86 The secret key is securily stored in the designed configuration
87 path. So only the IGPGHandler itself can access it.
88
89=== modified file 'lib/lp/archiveuploader/tests/nascentuploadfile.txt'
90--- lib/lp/archiveuploader/tests/nascentuploadfile.txt 2009-12-14 13:49:03 +0000
91+++ lib/lp/archiveuploader/tests/nascentuploadfile.txt 2010-04-21 11:58:24 +0000
92@@ -468,8 +468,8 @@
93
94 The IGPGKey fingerprint used to sign this ChangesFile:
95
96- >>> ed_mixed_changes.fingerprint
97- '340CA3BB270E2716C9EE0B768E7EB7086C64A8C5'
98+ >>> print ed_mixed_changes.fingerprint
99+ 340CA3BB270E2716C9EE0B768E7EB7086C64A8C5
100
101
102 == DSCFile ==
103@@ -530,8 +530,8 @@
104
105 The IGPGKey fingerprint used to sign this DSC:
106
107- >>> ed_mixed_dsc.fingerprint
108- '340CA3BB270E2716C9EE0B768E7EB7086C64A8C5'
109+ >>> print ed_mixed_dsc.fingerprint
110+ 340CA3BB270E2716C9EE0B768E7EB7086C64A8C5
111
112 A DSCFile provides a verification API similiar to what we have in
113 ChangesFile itself:
114
115=== modified file 'lib/lp/registry/doc/gpg-signatures.txt'
116--- lib/lp/registry/doc/gpg-signatures.txt 2009-04-17 10:32:16 +0000
117+++ lib/lp/registry/doc/gpg-signatures.txt 2010-04-21 11:58:24 +0000
118@@ -23,8 +23,6 @@
119 >>> from zope.component import getUtility
120 >>> gpghandler = getUtility(IGPGHandler)
121
122- >>> from canonical.launchpad.interfaces import GPGVerificationError
123-
124 The text below was "clear signed" by 0xDFD20543 master key:
125
126 >>> content = """-----BEGIN PGP SIGNED MESSAGE-----
127@@ -41,8 +39,8 @@
128 ... """
129
130 >>> master_sig = gpghandler.verifySignature(content)
131- >>> master_sig.fingerprint
132- 'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
133+ >>> print master_sig.fingerprint
134+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
135
136 The text below was "clear signed" by a 0x02BA5EF6, a subkey of 0xDFD20543
137
138@@ -61,8 +59,8 @@
139 >>>
140
141 >>> subkey_sig = gpghandler.verifySignature(content)
142- >>> subkey_sig.fingerprint
143- 'A419AE861E88BC9E04B9C26FBA2B9389DFD20543'
144+ >>> print subkey_sig.fingerprint
145+ A419AE861E88BC9E04B9C26FBA2B9389DFD20543
146
147
148 >>> master_sig.fingerprint == subkey_sig.fingerprint
149@@ -86,7 +84,7 @@
150 >>> master_sig = gpghandler.getVerifiedSignature(content)
151 Traceback (most recent call last):
152 ...
153- GPGVerificationError: (7, 8, 'Bad signature')
154+ GPGVerificationError: (7, 8, u'Bad signature')
155
156 If no signed content is found, an exception is raised:
157
158@@ -111,22 +109,22 @@
159 >>> content = """
160 ... -----BEGIN PGP SIGNED MESSAGE-----
161 ... Hash: SHA1
162- ...
163+ ...
164 ... Test Message.
165 ... -----BEGIN PGP SIGNATURE-----
166 ... Version: GnuPG v1.4.1 (GNU/Linux)
167- ...
168+ ...
169 ... iD8DBQFD3xV52yWXVgK6XvYRAtJQAJ4ojuLC4aap4R9T0og17RkPYoND+ACfbCA3
170 ... yrZD6MZcqzyaGNy1s28Co2Q=
171 ... =5QGd
172 ... -----END PGP SIGNATURE-----
173 ... -----BEGIN PGP SIGNED MESSAGE-----
174 ... Hash: SHA1
175- ...
176+ ...
177 ... Some data appended by foo.bar@canonical.com
178 ... -----BEGIN PGP SIGNATURE-----
179 ... Version: GnuPG v1.4.1 (GNU/Linux)
180- ...
181+ ...
182 ... iD8DBQFD3xWpjn63CGxkqMURAmi6AJ4yHAnhIpt49VlYDG1uxpGy9BmHwwCeKbFM
183 ... aHIJLqhWVf8bGLHZBIH5odw=
184 ... =iUSC
185@@ -166,7 +164,7 @@
186 >>> gpghandler.getVerifiedSignature(content)
187 Traceback (most recent call last):
188 ...
189- GPGVerificationError: (7, 9, 'No public key')
190+ GPGVerificationError: (7, 9, u'No public key')
191
192 Due to unpredictable behaviour between the production system and
193 the external keyserver, we have a resilient signature verifier,
194@@ -179,4 +177,7 @@
195 >>> gpghandler.getVerifiedSignatureResilient(content)
196 Traceback (most recent call last):
197 ...
198- GPGVerificationError: Verification failed 3 times: ["(7, 9, 'No public key')", "(7, 9, 'No public key')", "(7, 9, 'No public key')"]
199+ GPGVerificationError: Verification failed 3 times:
200+ ["(7, 9, u'No public key')",
201+ "(7, 9, u'No public key')",
202+ "(7, 9, u'No public key')"]
203
204=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt'
205--- lib/lp/soyuz/doc/soyuz-upload.txt 2010-04-15 02:09:00 +0000
206+++ lib/lp/soyuz/doc/soyuz-upload.txt 2010-04-21 11:58:24 +0000
207@@ -70,10 +70,7 @@
208
209 >>> from lp.archiveuploader.tagfiles import parse_tagfile
210 >>> from canonical.config import config
211- >>> from cStringIO import StringIO
212 >>> import glob
213- >>> import time
214- >>>
215 >>> test_files_dir = os.path.join(config.root,
216 ... "lib/lp/soyuz/scripts/"
217 ... "tests/upload_test_files/")
218@@ -223,8 +220,8 @@
219 >>> key_data = open(key_path).read()
220 >>> key = gpg_handler.importPublicKey(key_data)
221 >>> assert key is not None
222- >>> key.fingerprint
223- '33C0A61893A5DC5EB325B29E415A12CAC2F30234'
224+ >>> print key.fingerprint
225+ 33C0A61893A5DC5EB325B29E415A12CAC2F30234
226
227
228 Create the katie user and register it in a team that is allowed to
229@@ -532,7 +529,6 @@
230
231 >>> from canonical.launchpad.database import (
232 ... SourcePackagePublishingHistory as SSPPH)
233- >>> from canonical.launchpad.interfaces import PackagePublishingStatus
234 >>> package_names.sort()
235 >>> for name in package_names:
236 ... spn = SourcePackageName.selectOneBy(name=name)
237
238=== modified file 'utilities/sourcedeps.conf'
239--- utilities/sourcedeps.conf 2010-04-20 00:57:04 +0000
240+++ utilities/sourcedeps.conf 2010-04-21 11:58:24 +0000
241@@ -11,7 +11,7 @@
242 mailman lp:~launchpad-pqm/mailman/2.1;revno=976
243 old_xmlplus lp:~launchpad-pqm/dtdparser/trunk;revno=4
244 pygettextpo lp:~launchpad-pqm/pygettextpo/trunk;revno=23
245-pygpgme lp:~launchpad-pqm/pygpgme/devel;revno=48
246+pygpgme lp:~launchpad-pqm/pygpgme/devel;revno=49
247 subvertpy lp:~launchpad-pqm/subvertpy/trunk;revno=2040
248 testresources lp:~launchpad-pqm/testresources/dev;revno=16
249 shipit lp:~launchpad-pqm/shipit/trunk;revno=8904 optional