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
9 changes: 8 additions & 1 deletion fints/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,14 @@ def _process_response(self, dialog, segment, response):
# Fail-safe block all further attempts with this PIN
if self.pin:
self.pin.block()
raise FinTSClientPINError("Error during dialog initialization, PIN wrong?")
error = FinTSClientPINError(
"Error during dialog initialization, PIN wrong? Bank response: {} - {}".format(
response.code, response.text
)
)
error.response_code = response.code
error.response_text = response.text
raise error

if response.code == '3938':
# Account locked, e.g. after three wrong password attempts. Theoretically, the bank might allow us to
Expand Down
8 changes: 7 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ def test_pin_wrong(fints_server):
fints_server,
product_id="TEST-123", product_version="1.2.3",
)
with pytest.raises(FinTSClientPINError):
with pytest.raises(FinTSClientPINError) as excinfo:
with client:
pass

# The bank's own response is passed on, since the error is raised for
# any 9xxx code during initialization and not only for a wrong PIN.
assert excinfo.value.response_code == '9910'
assert excinfo.value.response_text.startswith('Pin ung')
assert '9910' in str(excinfo.value)

assert client.pin.blocked

with pytest.raises(Exception):
Expand Down