python: Workaround for a regression in GnuPG 2.2.21
* lang/python/tests/support.py (is_gpg_version): New. * lang/python/tests/t-encrypt-sym.py: Add workaround. -- GnuPG-bug-id: 4991 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
88f3202521
commit
32b80cf3c7
@ -38,6 +38,12 @@ def assert_gpg_version(version=(2, 1, 0)):
|
|||||||
c.engine_info.version, '.'.join(map(str, version))))
|
c.engine_info.version, '.'.join(map(str, version))))
|
||||||
sys.exit(77)
|
sys.exit(77)
|
||||||
|
|
||||||
|
def is_gpg_version(version):
|
||||||
|
with gpg.Context() as c:
|
||||||
|
clean_version = re.match(r'\d+\.\d+\.\d+',
|
||||||
|
c.engine_info.version).group(0)
|
||||||
|
return tuple(map(int, clean_version.split('.'))) == version
|
||||||
|
|
||||||
|
|
||||||
def have_tofu_support(ctx, some_uid):
|
def have_tofu_support(ctx, some_uid):
|
||||||
keys = list(
|
keys = list(
|
||||||
|
@ -44,8 +44,16 @@ for passphrase in ("abc", b"abc"):
|
|||||||
c.set_passphrase_cb(passphrase_cb, None)
|
c.set_passphrase_cb(passphrase_cb, None)
|
||||||
|
|
||||||
c.op_encrypt([], 0, source, cipher)
|
c.op_encrypt([], 0, source, cipher)
|
||||||
assert passphrase_cb_called == 1, \
|
# gpg 2.2.21 has a bug in that for a new passphrase the callback
|
||||||
"Callback called {} times".format(passphrase_cb_called)
|
# is called twice. This is fixed in 2.2.22 but a patch was also
|
||||||
|
# distributed so that we allow both.
|
||||||
|
if support.is_gpg_version((2,2,21)):
|
||||||
|
print("Enabling GnuPG 2.2.21 bug 4991 test workaround.")
|
||||||
|
assert passphrase_cb_called == 1 or passphrase_cb_called == 2, \
|
||||||
|
"Callback called {} times".format(passphrase_cb_called)
|
||||||
|
else:
|
||||||
|
assert passphrase_cb_called == 1, \
|
||||||
|
"Callback called {} times".format(passphrase_cb_called)
|
||||||
support.print_data(cipher)
|
support.print_data(cipher)
|
||||||
|
|
||||||
c = gpg.Context()
|
c = gpg.Context()
|
||||||
|
Loading…
Reference in New Issue
Block a user