Django GPG: 3rd party app compatibility update

Update the django_gpg app to work with the latest version of the
python-gnupg package (0.4.3).

The python-gnupg now returns a more clear error message to
differentiate between a bad passphrase and a missing passphrase.
This improments allows the django_gpg to simplify its error
message parsing and remove the literals:
"ERROR_MSG_NEED_PASSPHRASE" and "ERROR_MSG_GOOD_PASSPHRASE".

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-06 02:58:40 -04:00
parent d1a4cb875b
commit d6435b7735
4 changed files with 15 additions and 17 deletions
+7 -8
View File
@@ -11,9 +11,8 @@ from django.utils.translation import ugettext_lazy as _
from .exceptions import NeedPassphrase, PassphraseError
from .literals import (
ERROR_MSG_NEED_PASSPHRASE, ERROR_MSG_BAD_PASSPHRASE,
ERROR_MSG_GOOD_PASSPHRASE, KEY_TYPE_CHOICES, KEY_TYPE_SECRET,
OUTPUT_MESSAGE_CONTAINS_PRIVATE_KEY
ERROR_MSG_BAD_PASSPHRASE, ERROR_MSG_MISSING_PASSPHRASE,
KEY_TYPE_CHOICES, KEY_TYPE_SECRET, OUTPUT_MESSAGE_CONTAINS_PRIVATE_KEY
)
from .managers import KeyManager
from .runtime import gpg_backend
@@ -124,10 +123,10 @@ class Key(models.Model):
logger.debug('file_sign_results.stderr: %s', file_sign_results.stderr)
if ERROR_MSG_NEED_PASSPHRASE in file_sign_results.stderr:
if ERROR_MSG_BAD_PASSPHRASE in file_sign_results.stderr:
raise PassphraseError
elif ERROR_MSG_GOOD_PASSPHRASE not in file_sign_results.stderr:
raise NeedPassphrase
if ERROR_MSG_MISSING_PASSPHRASE in file_sign_results.stderr:
raise NeedPassphrase
if ERROR_MSG_BAD_PASSPHRASE in file_sign_results.stderr:
raise PassphraseError
return file_sign_results