summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Stanley <fungi@yuggoth.org>2014-12-18 19:15:19 +0000
committerJeremy Stanley <fungi@yuggoth.org>2014-12-23 16:16:12 +0000
commit4151d5c89ad808fc87c3c45eadfbb33c964182a7 (patch)
tree71657d5376cee507f168e3df2435345a7544d4fa
parent3ec9f0e809f8588fd9110f2b0426a495a44e7a2f (diff)
downloadpbr-4151d5c89ad808fc87c3c45eadfbb33c964182a7.tar.gz
Use unsafe OpenPGP keys for testing
* pbr/tests/test_packaging.py(GPGKeyFixture.setUp): Testing signed tags requires an OpenPGP key, but doesn't actually require one entropic enough for safe production use. When generating a test key with gpg add the little-known --quick-random/--debug-quick-random option used by GnuPG's own testsuite. You can find it by searching the source code, or in the NEWS file entry for the rather ancient GnuPG 0.2.3 release, or in the debug option summary for 2.x. Change-Id: I589f5c7db04b8e715c7a53cfa2fa18d37e20c66d Closes-Bug:#1369768
-rw-r--r--pbr/tests/test_packaging.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 948255d..d048a3c 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -39,6 +39,7 @@
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
import os
+import re
import sys
import tempfile
@@ -120,8 +121,25 @@ class GPGKeyFixture(fixtures.Fixture):
""")
finally:
f.close()
+ # Note that --quick-random (--debug-quick-random in GnuPG 2.x)
+ # does not have a corresponding preferences file setting and
+ # must be passed explicitly on the command line instead
+ gnupg_version_re = re.compile('gpg .* ([12])\.')
+ gnupg_version = base._run_cmd(['gpg', '--version'], tempdir.path)
+ for line in gnupg_version[0].split('\n'):
+ gnupg_version = gnupg_version_re.match(line)
+ if gnupg_version:
+ gnupg_version = gnupg_version.group(1)
+ break
+ if gnupg_version == '1':
+ gnupg_random = '--quick-random'
+ elif gnupg_version == '2':
+ gnupg_random = '--debug-quick-random'
+ else:
+ gnupg_random = ''
base._run_cmd(
- ['gpg', '--gen-key', '--batch', config_file], tempdir.path)
+ ['gpg', '--gen-key', '--batch', gnupg_random, config_file],
+ tempdir.path)
class TestPackagingInGitRepoWithCommit(base.BaseTestCase):