From d8b21645786b1133f86c963605c80b1d1c926728 Mon Sep 17 00:00:00 2001 From: Ilyas Semmaoui Date: Thu, 24 Jun 2021 18:41:55 +0200 Subject: [PATCH] [caissedepargne] raise ActionNeeded on specific AUTHENTICATION_FAILED error Closes: 108@sibi --- modules/caissedepargne/browser.py | 7 ++++++- modules/caissedepargne/pages.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index 7e47e05ca4..f4e31d42b8 100644 --- a/modules/caissedepargne/browser.py +++ b/modules/caissedepargne/browser.py @@ -24,6 +24,7 @@ import time import re import datetime +from base64 import b64decode from hashlib import sha256 from uuid import uuid4 from collections import OrderedDict @@ -47,7 +48,7 @@ from woob.exceptions import ( BrowserIncorrectPassword, BrowserUnavailable, BrowserHTTPError, BrowserPasswordExpired, AuthMethodNotImplemented, AppValidation, AppValidationExpired, BrowserQuestion, - NeedInteractiveFor2FA, + NeedInteractiveFor2FA, ActionNeeded, ) from woob.tools.capabilities.bank.transactions import ( sorted_transactions, FrenchTransaction, keep_only_card_transactions, @@ -870,6 +871,10 @@ def do_new_login(self, authentification_data=''): pre_login_status = self.page.get_wrong_pre_login_status() if pre_login_status == 'AUTHENTICATION_FAILED': + saml_response = self.page.get_saml_response() + if 'NoPlugin' in b64decode(saml_response).decode('utf8'): + # The message is hardcoded in the javascript obfuscated + raise ActionNeeded("L'accès à votre espace bancaire est impossible en raison de données manquantes. Merci de bien vouloir vous rapprocher de votre conseiller.") # failing at this step means no password has been submitted yet # and no auth method type cannot be recovered # corresponding to 'erreur technique' on website diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 49af06b270..f9be2c20a7 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -170,6 +170,9 @@ def get_wrong_pre_login_status(self): ) return status + def get_saml_response(self): + return self.doc['response'].get('saml2_post', {}).get('samlResponse', '') + @property def validation_units(self): units = Coalesce( -- GitLab