diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index 25298febf706d7dc5aaaff035933ccae8186e49a..65ba427bb4a29936a5d754a70e3dcfca6a79d3c4 100644 --- a/modules/caissedepargne/browser.py +++ b/modules/caissedepargne/browser.py @@ -705,6 +705,13 @@ def do_new_login(self, data): if self.response.headers.get('Page_Erreur', '') == 'INDISPO': raise BrowserUnavailable() + pre_login_status = self.page.get_wrong_pre_login_status() + if pre_login_status == 'AUTHENTICATION_FAILED': + # 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 + raise BrowserUnavailable() + authentication_method = self.page.get_authentication_method_type() self.do_authentication_validation( authentication_method=authentication_method, diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 153f78dc760c317e9e4ae1506e38e19e805c9341..dee24d03203de19b39e8eff009f41d7e09bbba7c 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -120,6 +120,17 @@ class AuthenticationMethodPage(JsonPage): def get_validation_id(self): return Dict('id')(self.doc) + def get_wrong_pre_login_status(self): + if ( + not Dict('step/validationUnits', default=None)(self.doc) + and not Dict('validationUnits', default=None)(self.doc) + ): + # 'validationUnits' informs about auth method + # not having any is faulty for the connection + status = self.doc['response']['status'] + assert status in ('AUTHENTICATION_FAILED',), 'Unhandled status when checking if authentication method is informed: %s' % status + return status + @property def validation_units(self): units = Coalesce(