Commit 9cb1daf4 authored by Maxime Gasselin's avatar Maxime Gasselin Committed by Romain Bignon

[fortuneo] Add recipient: Handle validation when the first sms is expired

Here we inform the user to use the new sms code. It happens when user
waits more than 5 minutes to enter its code. We also catch error message
when the code validation is unsuccessful.

Closes: 7689@zendesk
parent 1151a000
...@@ -207,12 +207,16 @@ class Fortuneo(LoginBrowser, StatesMixin): ...@@ -207,12 +207,16 @@ class Fortuneo(LoginBrowser, StatesMixin):
def new_recipient(self, recipient, **params): def new_recipient(self, recipient, **params):
if 'code' in params: if 'code' in params:
self.need_reload_state = None
# to drop and use self.add_recipient_form instead in send_code() # to drop and use self.add_recipient_form instead in send_code()
recipient_form = json.loads(self.add_recipient_form) recipient_form = json.loads(self.add_recipient_form)
self.send_code(recipient_form ,params['code']) self.send_code(recipient_form ,params['code'])
assert self.page.rcpt_after_sms() if self.page.rcpt_after_sms():
return self.copy_recipient(recipient) self.need_reload_state = None
return self.copy_recipient(recipient)
elif self.page.is_code_expired():
self.need_reload_state = True
raise AddRecipientStep(recipient, Value('code', label='Le code sécurité est expiré. Veuillez saisir le nouveau code reçu qui sera valable 5 minutes.'))
assert False, self.page.get_error()
return self.new_recipient_before_otp(recipient, **params) return self.new_recipient_before_otp(recipient, **params)
@need_login @need_login
......
...@@ -116,10 +116,16 @@ class RecipientSMSPage(LoggedPage, PartialHTMLPage): ...@@ -116,10 +116,16 @@ class RecipientSMSPage(LoggedPage, PartialHTMLPage):
form = self.get_form() form = self.get_form()
return form return form
def is_code_expired(self):
return self.doc.xpath('//label[contains(text(), "Le code sécurité est expiré. Veuillez saisir le nouveau code reçu")]')
def rcpt_after_sms(self): def rcpt_after_sms(self):
return self.doc.xpath('//div[@class="confirmationAjoutCompteExterne"]\ return self.doc.xpath('//div[@class="confirmationAjoutCompteExterne"]\
/h2[contains(text(), "ajout de compte externe a bien été prise en compte")]') /h2[contains(text(), "ajout de compte externe a bien été prise en compte")]')
def get_error(self):
return CleanText().filter(self.doc.xpath('//form[@id="CompteExterneActionForm"]//p[@class="container error"]//label[@class="error]'))
class RegisterTransferPage(LoggedPage, HTMLPage): class RegisterTransferPage(LoggedPage, HTMLPage):
@method @method
......
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