diff options
author | Catalin Enache <catalin.enache@windriver.com> | 2016-07-22 11:45:53 +0300 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2016-07-29 11:00:59 +0200 |
commit | ca6edca71a54cdfc91453d3e648d80a98ad1a963 (patch) | |
tree | 1c4b06d3b911cd6bc73b22240b56e1edcbbf6e0a /meta-python/recipes-devtools/python/python-pygpgme | |
parent | 8dca4abac2743bbd241a3fe9e448b797dc561fbd (diff) | |
download | meta-openembedded-ca6edca71a54cdfc91453d3e648d80a98ad1a963.tar.gz |
python-pygpgme: update tests
python-pygpgme tests need to be updated in order to
be compatible with GnuPG 2.1 and newer versions.
Signed-off-by: Catalin Enache <catalin.enache@windriver.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python-pygpgme')
3 files changed, 166 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python-pygpgme/0001-reflect-2.1-reporting-for-key-imports.patch b/meta-python/recipes-devtools/python/python-pygpgme/0001-reflect-2.1-reporting-for-key-imports.patch new file mode 100644 index 0000000000..f5870372a1 --- /dev/null +++ b/meta-python/recipes-devtools/python/python-pygpgme/0001-reflect-2.1-reporting-for-key-imports.patch | |||
@@ -0,0 +1,88 @@ | |||
1 | From 1c1812def711803382cc28caea1f35fb7ef774b0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Kahn Gillmor <dkg@fifthhorseman.net> | ||
3 | Date: Tue, 26 Jan 2016 14:24:26 -0500 | ||
4 | Subject: [PATCH 1/5] reflect 2.1 reporting for key imports | ||
5 | |||
6 | GnuPG 2.1 changes how it reports key imports. These changes should | ||
7 | make the pygpgme test suite compatible with GnuPG 2.1. | ||
8 | |||
9 | See also: | ||
10 | https://lists.gnupg.org/pipermail/gnupg-devel/2016-January/030718.html | ||
11 | |||
12 | Upstream-Status: Backport | ||
13 | |||
14 | Signed-off-by: Catalin Enache <catalin.enache@windriver.com> | ||
15 | --- | ||
16 | tests/test_import.py | 22 +++++++++++----------- | ||
17 | 1 file changed, 11 insertions(+), 11 deletions(-) | ||
18 | |||
19 | diff --git a/tests/test_import.py b/tests/test_import.py | ||
20 | index 10eb816..597eb47 100644 | ||
21 | --- a/tests/test_import.py | ||
22 | +++ b/tests/test_import.py | ||
23 | @@ -55,7 +55,7 @@ class ImportTestCase(GpgHomeTestCase): | ||
24 | ctx = gpgme.Context() | ||
25 | with self.keyfile('key1.sec') as fp: | ||
26 | result = ctx.import_(fp) | ||
27 | - self.assertEqual(result.considered, 1) | ||
28 | + self.assertEqual(result.considered, 3) | ||
29 | self.assertEqual(result.no_user_id, 0) | ||
30 | self.assertEqual(result.imported, 1) | ||
31 | self.assertEqual(result.imported_rsa, 0) | ||
32 | @@ -64,18 +64,18 @@ class ImportTestCase(GpgHomeTestCase): | ||
33 | self.assertEqual(result.new_sub_keys, 0) | ||
34 | self.assertEqual(result.new_signatures, 0) | ||
35 | self.assertEqual(result.new_revocations, 0) | ||
36 | - self.assertEqual(result.secret_read, 1) | ||
37 | - self.assertEqual(result.secret_imported, 1) | ||
38 | + self.assertEqual(result.secret_read, 3) | ||
39 | + self.assertEqual(result.secret_imported, 2) | ||
40 | self.assertEqual(result.secret_unchanged, 0) | ||
41 | self.assertEqual(result.skipped_new_keys, 0) | ||
42 | self.assertEqual(result.not_imported, 0) | ||
43 | self.assertEqual(len(result.imports), 2) | ||
44 | self.assertEqual(result.imports[0], | ||
45 | ('E79A842DA34A1CA383F64A1546BB55F0885C65A4', | ||
46 | - None, gpgme.IMPORT_NEW | gpgme.IMPORT_SECRET)) | ||
47 | + None, gpgme.IMPORT_NEW)) | ||
48 | self.assertEqual(result.imports[1], | ||
49 | ('E79A842DA34A1CA383F64A1546BB55F0885C65A4', | ||
50 | - None, gpgme.IMPORT_NEW)) | ||
51 | + None, gpgme.IMPORT_NEW | gpgme.IMPORT_SECRET)) | ||
52 | # can we get the public key? | ||
53 | key = ctx.get_key('E79A842DA34A1CA383F64A1546BB55F0885C65A4') | ||
54 | # can we get the secret key? | ||
55 | @@ -102,17 +102,17 @@ class ImportTestCase(GpgHomeTestCase): | ||
56 | fp = BytesIO(b'\n'.join(keys)) | ||
57 | ctx = gpgme.Context() | ||
58 | result = ctx.import_(fp) | ||
59 | - self.assertEqual(result.considered, 3) | ||
60 | + self.assertEqual(result.considered, 5) | ||
61 | self.assertEqual(result.no_user_id, 0) | ||
62 | self.assertEqual(result.imported, 2) | ||
63 | - self.assertEqual(result.imported_rsa, 1) | ||
64 | + self.assertEqual(result.imported_rsa, 0) | ||
65 | self.assertEqual(result.unchanged, 0) | ||
66 | self.assertEqual(result.new_user_ids, 0) | ||
67 | self.assertEqual(result.new_sub_keys, 0) | ||
68 | self.assertEqual(result.new_signatures, 1) | ||
69 | self.assertEqual(result.new_revocations, 0) | ||
70 | - self.assertEqual(result.secret_read, 1) | ||
71 | - self.assertEqual(result.secret_imported, 1) | ||
72 | + self.assertEqual(result.secret_read, 3) | ||
73 | + self.assertEqual(result.secret_imported, 2) | ||
74 | self.assertEqual(result.secret_unchanged, 0) | ||
75 | self.assertEqual(result.skipped_new_keys, 0) | ||
76 | self.assertEqual(result.not_imported, 0) | ||
77 | @@ -122,10 +122,10 @@ class ImportTestCase(GpgHomeTestCase): | ||
78 | None, gpgme.IMPORT_NEW)) | ||
79 | self.assertEqual(result.imports[1], | ||
80 | ('E79A842DA34A1CA383F64A1546BB55F0885C65A4', | ||
81 | - None, gpgme.IMPORT_NEW | gpgme.IMPORT_SECRET)) | ||
82 | + None, gpgme.IMPORT_SIG)) | ||
83 | self.assertEqual(result.imports[2], | ||
84 | ('E79A842DA34A1CA383F64A1546BB55F0885C65A4', | ||
85 | - None, gpgme.IMPORT_SIG)) | ||
86 | + None, gpgme.IMPORT_NEW | gpgme.IMPORT_SECRET)) | ||
87 | self.assertEqual(result.imports[3], | ||
88 | ('93C2240D6B8AA10AB28F701D2CF46B7FC97E6B0F', | ||
diff --git a/meta-python/recipes-devtools/python/python-pygpgme/0002-passphrase_cb-is-deprecated.patch b/meta-python/recipes-devtools/python/python-pygpgme/0002-passphrase_cb-is-deprecated.patch new file mode 100644 index 0000000000..ccd941f7bb --- /dev/null +++ b/meta-python/recipes-devtools/python/python-pygpgme/0002-passphrase_cb-is-deprecated.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | From dc75482af095d667a4a92655c4e7eb312e80c42d Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Kahn Gillmor <dkg@fifthhorseman.net> | ||
3 | Date: Mon, 1 Feb 2016 19:25:12 -0500 | ||
4 | Subject: [PATCH 2/5] passphrase_cb is deprecated | ||
5 | |||
6 | https://bugs.gnupg.org/gnupg/issue767 indicates that | ||
7 | gpgme_set_passphrase_cb is a deprecated corner of the API and that | ||
8 | developers using gpgme should really rely on the gpg-agent to handle | ||
9 | this stuff. This should actually simplify things for most | ||
10 | installations -- just strip out all passphrase handling from your | ||
11 | application entirely, relying on gpg to figure out how to find the | ||
12 | agent, and relying on the agent figuring out how to prompt the user | ||
13 | (if necessary). | ||
14 | |||
15 | However, if a developer really wants to use the passphrase callback | ||
16 | approach, they'll have to use loopback pinentry. This sets up the | ||
17 | test suite to be able to make those tests. | ||
18 | |||
19 | Upstream-Status: Backport | ||
20 | |||
21 | Signed-off-by: Catalin Enache <catalin.enache@windriver.com> | ||
22 | --- | ||
23 | tests/util.py | 8 +++++++- | ||
24 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/tests/util.py b/tests/util.py | ||
27 | index cd803c2..86892ca 100644 | ||
28 | --- a/tests/util.py | ||
29 | +++ b/tests/util.py | ||
30 | @@ -28,7 +28,9 @@ keydir = os.path.join(os.path.dirname(__file__), 'keys') | ||
31 | |||
32 | class GpgHomeTestCase(unittest.TestCase): | ||
33 | |||
34 | - gpg_conf_contents = '' | ||
35 | + gpg_conf_contents = 'pinentry-mode loopback' | ||
36 | + gpg_agent_conf_contents = 'allow-loopback-pinentry' | ||
37 | + | ||
38 | import_keys = [] | ||
39 | |||
40 | def keyfile(self, key): | ||
41 | @@ -41,6 +43,10 @@ class GpgHomeTestCase(unittest.TestCase): | ||
42 | fp.write(self.gpg_conf_contents.encode('UTF-8')) | ||
43 | fp.close() | ||
44 | |||
45 | + fp = open(os.path.join(self._gpghome, 'gpg-agent.conf'), 'wb') | ||
46 | + fp.write(self.gpg_agent_conf_contents.encode('UTF-8')) | ||
47 | + fp.close() | ||
48 | + | ||
49 | # import requested keys into the keyring | ||
50 | ctx = gpgme.Context() | ||
diff --git a/meta-python/recipes-devtools/python/python-pygpgme/0003-handle-generic-error-when-no-passphrase-callback-pre.patch b/meta-python/recipes-devtools/python/python-pygpgme/0003-handle-generic-error-when-no-passphrase-callback-pre.patch new file mode 100644 index 0000000000..462f442286 --- /dev/null +++ b/meta-python/recipes-devtools/python/python-pygpgme/0003-handle-generic-error-when-no-passphrase-callback-pre.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | From 024fe219582143017b2f02bc924c0ed107b63619 Mon Sep 17 00:00:00 2001 | ||
2 | From: Daniel Kahn Gillmor <dkg@fifthhorseman.net> | ||
3 | Date: Mon, 1 Feb 2016 19:27:59 -0500 | ||
4 | Subject: [PATCH 3/5] handle generic error when no passphrase callback present | ||
5 | |||
6 | apparently gpg 2.1 returns ERR_GENERAL right now if the pinentry was | ||
7 | in loopback mode and no passphrase callback was supplied. Earlier | ||
8 | versions supplied ERR_BAD_PASSPHRASE. | ||
9 | |||
10 | Upstream-Status: Backport | ||
11 | |||
12 | Signed-off-by: Catalin Enache <catalin.enache@windriver.com> | ||
13 | --- | ||
14 | tests/test_passphrase.py | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/tests/test_passphrase.py b/tests/test_passphrase.py | ||
18 | index 0a235e9..35b3c59 100644 | ||
19 | --- a/tests/test_passphrase.py | ||
20 | +++ b/tests/test_passphrase.py | ||
21 | @@ -41,7 +41,7 @@ class PassphraseTestCase(GpgHomeTestCase): | ||
22 | new_sigs = ctx.sign(plaintext, signature, gpgme.SIG_MODE_CLEAR) | ||
23 | except gpgme.GpgmeError as exc: | ||
24 | self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_GPGME) | ||
25 | - self.assertEqual(exc.args[1], gpgme.ERR_BAD_PASSPHRASE) | ||
26 | + self.assertEqual(exc.args[1], gpgme.ERR_GENERAL) | ||
27 | else: | ||
28 | self.fail('gpgme.GpgmeError not raised') | ||