From: Henryk Plötz Date: Tue, 10 Sep 2019 00:35:24 +0000 (+0200) Subject: Implement a pure offline mode X-Git-Tag: v3.0.0~2^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fac6caf7277bbf30a9a009f393121cf2391e189b;p=thirdparty%2Fpython-fints.git Implement a pure offline mode The idea is that in the future get_information, get_tan_*, and, for convenience, get_sepa_accounts will be answered from data cached in the FinTSClient object if possible. This information in stored and retrieved with deconstruct()/from_data= The stay_offline mode allows to inspect this cached data without risking opening a dialogue (and maybe triggering Strong Customer Authentication) --- diff --git a/fints/client.py b/fints/client.py index 2183025..712e52a 100644 --- a/fints/client.py +++ b/fints/client.py @@ -155,7 +155,8 @@ class FinTS3Client: def __init__(self, bank_identifier, user_id, customer_id=None, from_data: bytes=None, - product_id=None, product_version=version[:5]): + product_id=None, product_version=version[:5], + stay_offline=False): self.accounts = [] if isinstance(bank_identifier, BankIdentifier): self.bank_identifier = bank_identifier @@ -179,6 +180,7 @@ class FinTS3Client: self.product_name = product_id self.product_version = product_version self.response_callbacks = [] + self.stay_offline = stay_offline self._standing_dialog = None if from_data: diff --git a/fints/dialog.py b/fints/dialog.py index 7b221ee..46d060b 100644 --- a/fints/dialog.py +++ b/fints/dialog.py @@ -48,6 +48,11 @@ class FinTSDialog: if self.paused: raise FinTSDialogStateError("Cannot init() a paused dialog") + if self.client.stay_offline: + raise FinTSDialogOfflineError("Cannot open a dialog with stay_offline=True. " + "This is a control flow error, no online functionality " + "should have been attempted with this FinTSClient object.") + if self.need_init and not self.open: segments = [ HKIDN2( diff --git a/fints/exceptions.py b/fints/exceptions.py index 4d6919e..37bf98c 100644 --- a/fints/exceptions.py +++ b/fints/exceptions.py @@ -22,6 +22,10 @@ class FinTSDialogStateError(FinTSDialogError): pass +class FinTSDialogOfflineError(FinTSDialogError): + pass + + class FinTSDialogInitError(FinTSDialogError): pass