Commit 92bb56c0 authored by Ilyas Semmaoui's avatar Ilyas Semmaoui Committed by Vincent A

[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
parent f3f020cc
......@@ -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:
......
......@@ -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)
......
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