Commit 153dcbd6 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by Vincent A

[caissedepargne] Handle error message when user has no 2fa method enabled

When the user has no 2fa method enabled, there is a specific error
message that needs to be caught.
parent a3f76c45
......@@ -35,6 +35,7 @@ from weboob.browser.switch import SiteSwitch
from weboob.browser.url import URL
from weboob.capabilities.bank import (
Account, AddRecipientStep, Recipient, TransferBankError, Transaction, TransferStep,
AddRecipientBankError,
)
from weboob.capabilities.base import NotAvailable, find_object
from weboob.capabilities.bill import Subscription
......@@ -1480,6 +1481,14 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
self.page.handle_error()
assert False, 'We should not be on this page.'
if self.home.is_here():
# If we land here it might be because the user has no 2fa method
# enabled, and therefore cannot add a recipient.
unavailable_2fa = self.page.get_unavailable_2fa_message()
if unavailable_2fa:
raise AddRecipientBankError(message=unavailable_2fa)
raise AssertionError('Should not be on home page after sending sms when adding new recipient.')
if self.validation_option.is_here():
self.get_auth_mechanisms_validation_info()
......
......@@ -1135,6 +1135,14 @@ class IndexPage(LoggedPage, BasePage):
default=None,
)(self.doc)
def get_unavailable_2fa_message(self):
# The message might be too long, so we retrieve only the first part.
return CleanText(
'''//div[@class="MessageErreur"]
//li[contains(text(), "vous devez disposer d’un moyen d’authentification renforcée")]
/br/preceding-sibling::text()'''
)(self.doc)
class TransactionPopupPage(LoggedPage, HTMLPage):
def is_here(self):
......
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