From 2721e516468a29f6959b6c4a4025151459054557 Mon Sep 17 00:00:00 2001 From: Fong NGO Date: Mon, 14 Dec 2020 18:42:48 +0100 Subject: [PATCH] [bp] don't raise BrowserUnavailable when login is successful The pro website has changed, and an url '.*voscomptes/identification/identification.ea.*' that was once handled as a temporary unvailability page is now an expected page of the login process. I don't know if this url has to be treated the same way or differently for the par website, so I decided to override the parent attribute in the subclass BProBrowser. We can also notice the following requests don't work because the pro website has changed (a wrong request will typically lead to a deconnection, for ex. the next_request auth_page() fails this way), but not for all connections (strange), meaning for some connections, the current requests work fine. So far I have noticed the current code still works for connections from users who have already validated the SCA (but I might have missed something else). --- modules/bp/browser.py | 19 ++++++++++++++++++- modules/bp/pages/pro.py | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/bp/browser.py b/modules/bp/browser.py index 794e37754d..adaef9fb21 100644 --- a/modules/bp/browser.py +++ b/modules/bp/browser.py @@ -62,7 +62,7 @@ from .pages.accountlist import ( MarketLoginPage, UselessPage, ProfilePage, MarketCheckPage, MarketHomePage, ) -from .pages.pro import RedirectPage, ProAccountsList, ProAccountHistory, DownloadRib, RibPage +from .pages.pro import RedirectPage, ProAccountsList, ProAccountHistory, DownloadRib, RibPage, RedirectAfterVKPage from .pages.mandate import MandateAccountsList, PreMandate, PreMandateBis, MandateLife, MandateMarket from .linebourse_browser import LinebourseAPIBrowser @@ -1027,6 +1027,15 @@ def iter_emitters(self): class BProBrowser(BPBrowser): login_url = "https://banqueenligne.entreprises.labanquepostale.fr/wsost/OstBrokerWeb/loginform?TAM_OP=login&ERROR_CODE=0x00000000&URL=%2Fws_q47%2Fvoscomptes%2Fidentification%2Fidentification.ea%3Forigin%3Dprofessionnels" + + # Landing page after virtual keyboard. The response is a redirection to + # switch_q5c only if an SCA is activated (TODO: check), and just a standard + # page for connections without SCA + redirect_after_vk = URL( + r'.*voscomptes/identification/identification.ea.*', + RedirectAfterVKPage + ) + accounts_and_loans_url = None pro_accounts_list = URL(r'.*voscomptes/synthese/synthese.ea', ProAccountsList) @@ -1052,6 +1061,14 @@ class BProBrowser(BPBrowser): DownloadPage ) + # Redefined from BPBrowser.redirect_page because + # 'voscomptes/identification/identification.ea' is an expected page and + # we shouldn't raise a BrowserUnavailable, at least for pro website + redirect_page = URL( + r'.*voscomptes/synthese/3-synthese.ea', + RedirectPage + ) + BASEURL = 'https://banqueenligne.entreprises.labanquepostale.fr' def set_variables(self): diff --git a/modules/bp/pages/pro.py b/modules/bp/pages/pro.py index 16d9d4eb8a..b6975e9d16 100644 --- a/modules/bp/pages/pro.py +++ b/modules/bp/pages/pro.py @@ -157,3 +157,7 @@ class get_profile(ItemElement): obj_name = CleanText('//table[@class="datalistecart"]//td[@class="nom"]') obj_address = CleanText('//table[@class="datalistecart"]//td[@class="adr"]') + + +class RedirectAfterVKPage(MyHTMLPage): + pass -- GitLab