Commit e75a218a authored by Damien Mat's avatar Damien Mat Committed by Vincent A

[caissedepargne] Manage BrowserUnavailable at login

First step for login is to submit login without password and get the
authentification method type before proceeding to it.
For some connections, response JSON returns no auth method, and an
'AUTHENTICATION_FAILED' status right at this step. While there is a
message 'Confirmez votre authentification à votre banque à distance', it
is deceitful. When attempting the connection in a navigator the same
reponse is given but a JS message 'erreur technique, Ce service est
temporairement indisponible' is displayed as well. Hence the
BrowserUnavailable error to be raised.
parent 5194a693
......@@ -705,6 +705,13 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
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,
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment