def make_answer(self, dialog_id, message):
datadict = dialogs[dialog_id]
+ pin = None
+ tan = None
+ pinmatch = re.search(rb"HNSHA:\d+:\d+\+[^+]*\+[^+]*\+([^:+?']+)(?::([^:+?']+))?'", message)
+ if pinmatch:
+ pin = pinmatch.group(1).decode('us-ascii')
+
+ if pinmatch.group(2):
+ tan = pinmatch.group(2).decode('us-ascii')
+
+ if pin != '1234':
+ return "HIRMG::2+9910::Pin ungültig'".encode('utf-8')
+
result = []
result.append(b"HIRMG::2+0010::Nachricht entgegengenommen'")
'amount': amountmatch.group(1),
}
result.append("HIRMS::2:{}+0030::Auftragsfreigabe erforderlich'".format(hktan.group(1).decode('us-ascii')).encode('us-ascii'))
- result.append("HITAN::{}:{}+2++{}+Geben Sie die TAN an'".format(hktan.group(2).decode('us-ascii'), hktan.group(1).decode('us-ascii'), ref).encode('us-ascii'))
+ result.append("HITAN::{}:{}+2++{}+Geben Sie TAN 123456 an'".format(hktan.group(2).decode('us-ascii'), hktan.group(1).decode('us-ascii'), ref).encode('us-ascii'))
hktan = re.search(rb"'HKTAN:(\d+):(\d+)\+2\+\+\+\+([^+]+)\+", message)
if hktan:
task = datadict.setdefault('pending', {}).get(ref, None)
if task:
- result.append("HIRMS::2:{}+0010::Transfer {} to {} re {}'".format(segno, task['amount'], task['recv'], repr(task['memo']).replace("'", "?'")).encode('iso-8859-1'))
+ if tan == '123456':
+ result.append("HIRMS::2:{}+0010::Transfer {} to {} re {}'".format(segno, task['amount'], task['recv'], repr(task['memo']).replace("'", "?'")).encode('iso-8859-1'))
+ else:
+ result.append("HIRMS::2:{}+9941::TAN ungültig'".format(segno).encode('iso-8859-1'))
datadict['pending'].pop(ref, None)
from fints.client import FinTS3PinTanClient, TransactionResponse, NeedTANResponse, ResponseStatus
+from fints.exceptions import FinTSClientPINError
from decimal import Decimal
import pytest
assert information["bank"]["name"] == 'Test Bank'
+def test_pin_wrong(fints_server):
+ client = FinTS3PinTanClient(
+ '12345678',
+ 'test1',
+ '99999',
+ fints_server,
+ )
+ with pytest.raises(FinTSClientPINError):
+ with client:
+ pass
+
+ assert client.pin.blocked
+
+ with pytest.raises(Exception):
+ with client:
+ pass
+
+ with pytest.raises(Exception, match="Refusing"):
+ str(client.pin)
+
def test_resume(fints_client, fints_server):
with fints_client:
system_id = fints_client.system_id
b = fints_client.send_tan(a, '123456')
assert b.status == ResponseStatus.SUCCESS
assert b.responses[0].text == "Transfer 2.34 to DE111234567800000002 re 'Test transfer 2step'"
+
+def test_tan_wrong(fints_client):
+ with fints_client:
+ accounts = fints_client.get_sepa_accounts()
+ a = fints_client.simple_sepa_transfer(
+ accounts[0],
+ 'DE111234567800000002',
+ 'GENODE00TES',
+ 'Test Receiver',
+ Decimal('2.34'),
+ 'Test Sender',
+ 'Test transfer 2step'
+ )
+
+ b = fints_client.send_tan(a, '99881')
+ assert b.status == ResponseStatus.ERROR