Commit bb4bc60b authored by Maxime Gasselin's avatar Maxime Gasselin Committed by Vincent A

[fortuneo] New action needed URL

In this new url found in the iframe, we have to skip it
(réglementation en matière de lutte contre le blanchiment). It's not
accountpage, consequently a ActionNeededPage is add.

Closes: 46647@sibi
parent a04819e1
......@@ -32,7 +32,10 @@ from weboob.tools.value import Value
from .pages.login import LoginPage, TwoFaPage, UnavailablePage
from .pages.accounts_list import (
AccountsList, AccountHistoryPage, CardHistoryPage, InvestmentHistoryPage, PeaHistoryPage, LoanPage, ProfilePage, ProfilePageCSV, SecurityPage, FakeActionPage,
AccountsList, AccountHistoryPage, CardHistoryPage,
InvestmentHistoryPage, PeaHistoryPage, LoanPage,
ProfilePage, ProfilePageCSV, SecurityPage, FakeActionPage,
InformationsPage, ActionNeededPage,
)
from .pages.transfer import (
RegisterTransferPage, ValidateTransferPage, ConfirmTransferPage, RecipientsPage, RecipientSMSPage
......@@ -69,6 +72,7 @@ class Fortuneo(TwoFactorBrowser):
loan_contract = URL(r'/fr/prive/mes-comptes/credit-immo/contrat-credit-immo/contrat-pret-immobilier.jsp.*', LoanPage)
unavailable = URL(r'/customError/indispo.html', UnavailablePage)
security_page = URL(r'/fr/prive/identification-carte-securite-forte.jsp.*', SecurityPage)
informations_page = URL(r'/fr/prive/accueil-informations-client-partiel.jsp', InformationsPage)
# transfer
recipients = URL(
......@@ -218,10 +222,14 @@ class Fortuneo(TwoFactorBrowser):
'Veuillez contacter le Service Clients pour renseigner vos coordonnées téléphoniques.')
# if there are skippable CGUs, skip them
if self.accounts_page.is_here() and self.page.has_action_needed():
# Look for the request in the event listener registered to the button
# can be harcoded, no variable part. It is a POST request without data.
self.location(self.absurl('ReloadContext?action=1&', base=True), method='POST')
if isinstance(self.page, ActionNeededPage):
if self.page.has_skippable_action_needed():
# Look for the request in the event listener registered to the button
# can be harcoded, no variable part. It is a POST request without data.
self.location(self.absurl('ReloadContext?action=1&', base=True), method='POST')
elif self.page.get_action_needed_message():
raise ActionNeeded(self.page.get_action_needed_message())
self.accounts_page.go() # go back to the accounts page whenever there was an iframe or not
self.action_needed_processed = True
......
......@@ -62,6 +62,30 @@ class Transaction(FrenchTransaction):
]
class ActionNeededPage(LoggedPage, HTMLPage):
def has_skippable_action_needed(self):
# NB: The CGUs happens on every page as long as it is not skipped or
# validated. The implementation is done in the Accounts page because
# we decide to skip the CGUs in browser.iter_accounts()
return bool(self.doc.xpath(u'//input[@class="bouton_valid01" and contains(@title, "Me le demander ultérieurement")]'))
def get_action_needed_message(self):
warning = self.doc.xpath(
'''
//div[@id="message_renouvellement_mot_passe"] |
//span[contains(text(), "Votre identifiant change")] |
//span[contains(text(), "Nouveau mot de passe")] |
//span[contains(text(), "Renouvellement de votre mot de passe")] |
//span[contains(text(), "Mieux vous connaître")] |
//span[contains(text(), "Souscrivez au Livret + en quelques clics")] |
//p[@class="warning" and contains(text(),
"Cette opération sensible doit être validée par un code sécurité envoyé par SMS")]
'''
)
if warning:
return warning[0].text
class PeaHistoryPage(LoggedPage, HTMLPage):
COL_LABEL = 0
COL_UNITVALUE = 1
......@@ -360,26 +384,7 @@ class CardHistoryPage(LoggedPage, HTMLPage):
return bool(self.doc.xpath('//span[@class="loading"]'))
class AccountsList(LoggedPage, HTMLPage):
def has_action_needed(self):
# NB: The CGUs happens on every page as long as it is not skipped or
# validated. The implementation is done in the Accounts page because
# we decide to skip the CGUs in browser.iter_accounts()
skip_button = self.doc.xpath(u'//input[@class="bouton_valid01" and contains(@title, "Me le demander ultérieurement")]')
if skip_button:
return True
else:
warning = self.doc.xpath(u'//div[@id="message_renouvellement_mot_passe"] | \
//span[contains(text(), "Votre identifiant change")] | \
//span[contains(text(), "Nouveau mot de passe")] | \
//span[contains(text(), "Renouvellement de votre mot de passe")] |\
//span[contains(text(), "Mieux vous connaître")] |\
//span[contains(text(), "Souscrivez au Livret + en quelques clics")] |\
//p[@class="warning" and contains(text(), "Cette opération sensible doit être validée par un code sécurité envoyé par SMS ou serveur vocal")]'
)
if warning:
raise ActionNeeded(warning[0].text)
class AccountsList(ActionNeededPage):
@method
class fill_person_name(ItemElement):
klass = Account
......@@ -625,3 +630,7 @@ class ProfilePageCSV(LoggedPage, CsvPage):
class SecurityPage(LoggedPage, HTMLPage):
pass
class InformationsPage(ActionNeededPage):
pass
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