From 92bb56c0af7081a1777acae26c84dc3a24d7cdca Mon Sep 17 00:00:00 2001 From: Ilyas Semmaoui Date: Thu, 20 May 2021 12:55:56 +0200 Subject: [PATCH] [lcl] fix crash with incomplete redirection from external websites The redirection from life insurance or bourse websites to the base account was missing one step to complete and thus creating issues while trying to access to the accounts since after failing the redirection we are logged out --- modules/lcl/browser.py | 15 +++++++++++---- modules/lcl/pages.py | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/lcl/browser.py b/modules/lcl/browser.py index adadaaf6f7..2bcc75f660 100644 --- a/modules/lcl/browser.py +++ b/modules/lcl/browser.py @@ -53,7 +53,7 @@ Form2Page, DocumentsPage, ClientPage, SendTokenPage, CaliePage, ProfilePage, DepositPage, AVHistoryPage, AVInvestmentsPage, CardsPage, AVListPage, CalieContractsPage, RedirectPage, MarketOrdersPage, AVNotAuthorized, AVReroute, TwoFAPage, AuthentStatusPage, FinalizeTwoFAPage, - PasswordExpiredPage, + PasswordExpiredPage, ContractRedirectionPage, ) @@ -80,8 +80,8 @@ class LCLBrowser(TwoFactorBrowser): r'/outil/UAUT/Contract/getContract.*', r'/outil/UAUT/Contract/selectContracts.*', r'/outil/UAUT/Accueil/preRoutageLogin', - r'/outil/UAUT/Contract/redirection', ContractsPage) + contract_redirection_page = URL(r'/outil/UAUT/Contract/redirection', ContractRedirectionPage) contracts_choice = URL(r'.*outil/UAUT/Contract/routing', ContractsChoicePage) home = URL(r'/outil/UWHO/Accueil/', HomePage) accounts = URL(r'/outil/UWSP/Synthese', AccountsPage) @@ -268,8 +268,11 @@ def init_login(self): if self.password_expired_page.is_here(): raise BrowserPasswordExpired(self.page.get_message()) - if (not self.contracts and not self.parsed_contracts - and (self.contracts_choice.is_here() or self.contracts_page.is_here())): + if ( + not self.contracts and not self.parsed_contracts + and (self.contracts_choice.is_here() or self.contracts_page.is_here() + or self.contract_redirection_page.is_here()) + ): # On the preRoutageLogin page we gather the list of available contracts for this account self.contracts = self.page.get_contracts_list() # If there is not multiple contracts then self.contracts will be empty @@ -357,6 +360,8 @@ def connexion_bourse(self): def deconnexion_bourse(self): self.disc.stay_or_go() + if self.contract_redirection_page.is_here() and self.page.should_submit_redirect_form(): + self.page.submit_redirect_form() self.accounts.go() if self.login.is_here(): # When we logout we can be disconnected from the main site @@ -385,6 +390,8 @@ def update_life_insurance_account(self, life_insurance): def go_back_from_life_insurance_website(self): self.avdetail.stay_or_go() self.page.come_back() + if self.contract_redirection_page.is_here() and self.page.should_submit_redirect_form(): + self.page.submit_redirect_form() def select_contract(self, id_contract): if self.current_contract and id_contract != self.current_contract: diff --git a/modules/lcl/pages.py b/modules/lcl/pages.py index 768c50bd35..d999483dc1 100644 --- a/modules/lcl/pages.py +++ b/modules/lcl/pages.py @@ -228,6 +228,15 @@ def select_contract(self, id_contract=None): form.submit() +class ContractRedirectionPage(ContractsPage): + def should_submit_redirect_form(self): + return bool(self.doc.xpath('//body[contains(@onload, "envoyerJeton()")]/form')) + + def submit_redirect_form(self): + form = self.get_form(id='form') + form.submit() + + class PasswordExpiredPage(LoggedPage, HTMLPage): def get_message(self): return CleanText('//form[@id="changementCodeForm"]//span[contains(., "nouveau code d’accès")]')(self.doc) -- GitLab