Skip to content

Commit fbe4c4e

Browse files
End the bootstrap mode once the standing dialog is initialized
1 parent eda20b4 commit fbe4c4e

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎fints/client.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,14 @@ def __init__(self, bank_identifier, user_id, pin, server, customer_id=None, tan_
12731273
self._bootstrap_mode = True
12741274
super().__init__(bank_identifier=bank_identifier, user_id=user_id, customer_id=customer_id, *args, **kwargs)
12751275

1276+
def __enter__(self):
1277+
retval = super().__enter__()
1278+
# The bootstrap (fetch_tan_mechanisms(), get_tan_media()) is done
1279+
# without a standing dialog: errors like 9075 are not expected anymore
1280+
# once the standing dialog has been initialized
1281+
self._bootstrap_mode = False
1282+
return retval
1283+
12761284
def _new_dialog(self, lazy_init=False):
12771285
if self.pin is None:
12781286
enc = None

‎tests/conftest.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ def make_answer(self, dialog_id, message):
5050

5151
result = []
5252

53+
hkidn_user = re.search(rb"'HKIDN:\d+:2\+280:12345678\+([^+]+)\+", message)
54+
if hkidn_user:
55+
datadict['user'] = hkidn_user.group(1)
56+
57+
# Some banks require a strong customer authentication for fetching
58+
# the transactions
59+
hkkaz_sca = re.search(rb"'HKKAZ:(\d+):\d+\+", message)
60+
if hkkaz_sca and datadict.get('user') == b'test-sca':
61+
result.append(b"HIRMG::2+9050::Nachricht teilweise fehlerhaft.'")
62+
result.append("HIRMS::2:{}+9075::Starke Authentifizierung erforderlich.'".format(hkkaz_sca.group(1).decode('us-ascii')).encode('us-ascii'))
63+
return b"".join(result)
64+
5365
result.append(b"HIRMG::2+0010::Nachricht entgegengenommen'")
5466

5567
hkvvb = re.search(rb"'HKVVB:(\d+):3\+(\d+)\+(\d+)", message)

‎tests/test_client.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from fints.client import FinTS3PinTanClient, TransactionResponse, NeedTANResponse, ResponseStatus, NeedRetryResponse
2-
from fints.exceptions import FinTSClientPINError, FinTSClientTemporaryAuthError
2+
from fints.exceptions import FinTSClientPINError, FinTSClientTemporaryAuthError, FinTSSCARequiredError
3+
from datetime import date
34
from decimal import Decimal
45
import pytest
56

@@ -29,6 +30,22 @@ def test_get_information(fints_client):
2930
assert information["bank"]["name"] == 'Test Bank'
3031

3132

33+
def test_sca_required(fints_server):
34+
"""A 9075 response to a command raises FinTSSCARequiredError, also for a
35+
client that never called get_tan_media()"""
36+
client = FinTS3PinTanClient(
37+
'12345678',
38+
'test-sca',
39+
'1234',
40+
fints_server,
41+
product_id="TEST-123", product_version="1.2.3",
42+
)
43+
with pytest.raises(FinTSSCARequiredError):
44+
with client:
45+
accounts = client.get_sepa_accounts()
46+
client.get_transactions(accounts[0], date(2026, 10, 1), date(2026, 10, 2))
47+
48+
3249
def test_pin_wrong(fints_server):
3350
client = FinTS3PinTanClient(
3451
'12345678',

0 commit comments

Comments
 (0)