spplus: adapt for python3

This commit is contained in:
Frédéric Péters 2018-03-26 20:28:14 +02:00
parent f99d6eeb91
commit 9e1ead2e7c
2 changed files with 7 additions and 7 deletions

View File

@ -14,14 +14,14 @@ import warnings
import Crypto.Cipher.DES
from .common import (PaymentCommon, URL, PaymentResponse, RECEIVED, ACCEPTED,
PAID, ERROR, ResponseError)
PAID, ERROR, ResponseError, force_byte)
def N_(message): return message
__all__ = ['Payment']
KEY_DES_KEY = '\x45\x1f\xba\x4f\x4c\x3f\xd4\x97'
IV = '\x30\x78\x30\x62\x2c\x30\x78\x30'
KEY_DES_KEY = b'\x45\x1f\xba\x4f\x4c\x3f\xd4\x97'
IV = b'\x30\x78\x30\x62\x2c\x30\x78\x30'
REFERENCE = 'reference'
ETAT = 'etat'
SPCHECKOK = 'spcheckok'
@ -56,7 +56,7 @@ TEST_STATE = ('99',)
def decrypt_ntkey(ntkey):
key = binascii.unhexlify(ntkey.replace(' ',''))
key = binascii.unhexlify(ntkey.replace(b' ', b''))
return decrypt_key(key)
def decrypt_key(key):
@ -70,7 +70,7 @@ def extract_values(query_string):
k, v = kv.split('=', 1)
if k != 'hmac':
result.append(v)
return ''.join(result)
return force_byte(''.join(result))
def sign_ntkey_query(ntkey, query):
key = decrypt_ntkey(ntkey)

View File

@ -2,8 +2,8 @@ from unittest import TestCase
import eopayment.spplus as spplus
class SPPlustTest(TestCase):
ntkey = '58 6d fc 9c 34 91 9b 86 3f ' \
'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \
b'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
tests = [('x=coin', 'c04f8266d6ae3ce37551cce996c751be4a95d10a'),
('x=coin&y=toto', 'ef008e02f8dbf5e70e83da416b0b3a345db203de'),