From 5991c69c4e88cd77615593cc28ae353e57fe1a78 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Mon, 7 Sep 2020 18:12:25 +0200 Subject: [PATCH] spplus: handle secret key as string (#46432) --- eopayment/spplus.py | 2 +- tests/test_spplus.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eopayment/spplus.py b/eopayment/spplus.py index 1b8e6db..1f527c7 100644 --- a/eopayment/spplus.py +++ b/eopayment/spplus.py @@ -75,7 +75,7 @@ TEST_STATE = ('99',) def decrypt_ntkey(ntkey): - key = binascii.unhexlify(ntkey.replace(b' ', b'')) + key = binascii.unhexlify(force_byte(ntkey).replace(b' ', b'')) return decrypt_key(key) diff --git a/tests/test_spplus.py b/tests/test_spplus.py index 968c842..3be0db5 100644 --- a/tests/test_spplus.py +++ b/tests/test_spplus.py @@ -15,7 +15,7 @@ # along with this program. If not, see . import eopayment.spplus as spplus -from eopayment import ResponseError +from eopayment import ResponseError, force_text import pytest @@ -41,3 +41,7 @@ def test_spplus(): with pytest.raises(ResponseError, match=r'missing reference, etat or refsfp'): payment.response('foo=bar') + + # make sure key string and bytes representations are understood + spplus.decrypt_ntkey(force_text(ntkey)) + spplus.decrypt_ntkey(ntkey)