summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachi King <nakato@nakato.io>2015-06-05 15:55:07 +1000
committerSachi King <nakato@nakato.io>2015-06-05 16:39:35 +1000
commit1ccd6cd090becc9472952ddaa6eb217f04088797 (patch)
treeb5a69a6353223e1204661c99d9898c76e6da43d7
parent74f61ed2f9cce2b4b7bbd60adce0384f6e17b1bf (diff)
downloadpbr-1ccd6cd090becc9472952ddaa6eb217f04088797.tar.gz
Fix test case to be runnable with gnupg 2.1
In gnupg 2.1 %no-ask-passphrase is a no-op. As a result gpg attempts to prompt for a passphrase and as the shell is not interactive it fails. To allow gnupg 2.1 to create passphrase-less keys we enable two options new to gnupg 2.1. %no-protection %transient-key Change-Id: If687ff005cf968133fc1fa12b1259a127c464e5b
-rw-r--r--pbr/tests/test_packaging.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 9e846d8..81701d1 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -99,12 +99,27 @@ class GPGKeyFixture(fixtures.Fixture):
def setUp(self):
super(GPGKeyFixture, self).setUp()
tempdir = self.useFixture(fixtures.TempDir())
+ gnupg_version_re = re.compile('^gpg\s.*\s([\d+])\.([\d+])\.([\d+])')
+ 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 = (int(gnupg_version.group(1)),
+ int(gnupg_version.group(2)),
+ int(gnupg_version.group(3)))
+ break
+ else:
+ if gnupg_version is None:
+ gnupg_version = (0, 0, 0)
config_file = tempdir.path + '/key-config'
f = open(config_file, 'wt')
try:
+ if gnupg_version[0] == 2 and gnupg_version[1] >= 1:
+ f.write("""
+ %no-protection
+ %transient-key
+ """)
f.write("""
- #%no-protection -- these would be ideal but they are documented
- #%transient-key -- but not implemented in gnupg!
%no-ask-passphrase
Key-Type: RSA
Name-Real: Example Key
@@ -119,16 +134,9 @@ class GPGKeyFixture(fixtures.Fixture):
# 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':
+ if gnupg_version[0] == 1:
gnupg_random = '--quick-random'
- elif gnupg_version == '2':
+ elif gnupg_version[0] >= 2:
gnupg_random = '--debug-quick-random'
else:
gnupg_random = ''