Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fints/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,14 @@ def __init__(self, bank_identifier, user_id, pin, server, customer_id=None, tan_
self._bootstrap_mode = True
super().__init__(bank_identifier=bank_identifier, user_id=user_id, customer_id=customer_id, *args, **kwargs)

def __enter__(self):
retval = super().__enter__()
# The bootstrap (fetch_tan_mechanisms(), get_tan_media()) is done
# without a standing dialog: errors like 9075 are not expected anymore
# once the standing dialog has been initialized
self._bootstrap_mode = False
return retval

def _new_dialog(self, lazy_init=False):
if self.pin is None:
enc = None
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def make_answer(self, dialog_id, message):

result = []

hkidn_user = re.search(rb"'HKIDN:\d+:2\+280:12345678\+([^+]+)\+", message)
if hkidn_user:
datadict['user'] = hkidn_user.group(1)

# Some banks require a strong customer authentication for fetching
# the transactions
hkkaz_sca = re.search(rb"'HKKAZ:(\d+):\d+\+", message)
if hkkaz_sca and datadict.get('user') == b'test-sca':
result.append(b"HIRMG::2+9050::Nachricht teilweise fehlerhaft.'")
result.append("HIRMS::2:{}+9075::Starke Authentifizierung erforderlich.'".format(hkkaz_sca.group(1).decode('us-ascii')).encode('us-ascii'))
return b"".join(result)

result.append(b"HIRMG::2+0010::Nachricht entgegengenommen'")

hkvvb = re.search(rb"'HKVVB:(\d+):3\+(\d+)\+(\d+)", message)
Expand Down
19 changes: 18 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fints.client import FinTS3PinTanClient, TransactionResponse, NeedTANResponse, ResponseStatus, NeedRetryResponse
from fints.exceptions import FinTSClientPINError, FinTSClientTemporaryAuthError
from fints.exceptions import FinTSClientPINError, FinTSClientTemporaryAuthError, FinTSSCARequiredError
from datetime import date
from decimal import Decimal
import pytest

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


def test_sca_required(fints_server):
"""A 9075 response to a command raises FinTSSCARequiredError, also for a
client that never called get_tan_media()"""
client = FinTS3PinTanClient(
'12345678',
'test-sca',
'1234',
fints_server,
product_id="TEST-123", product_version="1.2.3",
)
with pytest.raises(FinTSSCARequiredError):
with client:
accounts = client.get_sepa_accounts()
client.get_transactions(accounts[0], date(2026, 10, 1), date(2026, 10, 2))


def test_pin_wrong(fints_server):
client = FinTS3PinTanClient(
'12345678',
Expand Down