summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2020-09-07 16:12:25 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2020-09-09 10:19:02 (GMT)
commit5991c69c4e88cd77615593cc28ae353e57fe1a78 (patch)
tree404d935dd49edbd1fafb2c34ac90e5aa8b8eb249
parent1ee8871edacc119e8a2462571ed2b59c375523e5 (diff)
downloadeopayment-5991c69c4e88cd77615593cc28ae353e57fe1a78.zip
eopayment-5991c69c4e88cd77615593cc28ae353e57fe1a78.tar.gz
eopayment-5991c69c4e88cd77615593cc28ae353e57fe1a78.tar.bz2
spplus: handle secret key as string (#46432)v1.53
-rw-r--r--eopayment/spplus.py2
-rw-r--r--tests/test_spplus.py6
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 <http://www.gnu.org/licenses/>.
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)