Merge pull request #29047 from schwing/fix-gpg-exception

Fix salt.modules.gpg.import_key exception: 'GPG_1_3_1 referenced before assignment'
This commit is contained in:
Mike Place 2015-11-19 12:07:36 -07:00
commit b692ab1cfb
2 changed files with 4 additions and 5 deletions

View File

@ -651,11 +651,6 @@ def import_key(user=None,
imported_data = gpg.import_keys(text)
# include another check for Salt unit tests
gnupg_version = distutils.version.LooseVersion(gnupg.__version__)
if gnupg_version >= '1.3.1':
GPG_1_3_1 = True
if GPG_1_3_1:
counts = imported_data.counts
if counts.get('imported') or counts.get('imported_rsa'):

View File

@ -336,6 +336,10 @@ class GpgTestCase(TestCase):
self.assertRaises(SaltInvocationError, gpg.import_key,
filename='/path/to/public-key-file')
gpg.GPG_1_3_1 = True
self.assertDictEqual(gpg.import_key(text='-BEGIN PGP PUBLIC KEY BLOCK-'), ret)
gpg.GPG_1_3_1 = False
self.assertDictEqual(gpg.import_key(text='-BEGIN PGP PUBLIC KEY BLOCK-'), ret)
# 'export_key' function tests: 1