From 183f4fba26d9fd7865ebbf7d4731e304bada2ebf Mon Sep 17 00:00:00 2001 From: Damien Mat Date: Thu, 4 Jun 2020 09:11:41 +0200 Subject: [PATCH] [creditdunord/courtois] Fix redirect blocking connections Attempt to access to ProAccountsPage can lead instead to RedirectPage, where we can follow a link. It leads to a code 200 page even when bearing a 'erreur-404' in the URL. This happens only on certain connections as a wrongly activated security feature of the server, as discussed directly with the bank, when there is no accounts on the aimed page. We need to pass through not to block the connection --- modules/creditdunord/browser.py | 10 ++++++---- modules/creditdunord/pages.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/creditdunord/browser.py b/modules/creditdunord/browser.py index 7d24f9ac8e..b609f77126 100644 --- a/modules/creditdunord/browser.py +++ b/modules/creditdunord/browser.py @@ -27,7 +27,7 @@ from .pages import ( LoginPage, ProfilePage, AccountTypePage, AccountsPage, ProAccountsPage, TransactionsPage, IbanPage, RedirectPage, EntryPage, AVPage, ProIbanPage, - ProTransactionsPage, LabelsPage, RgpdPage, LoginConfirmPage, + ProTransactionsPage, LabelsPage, RgpdPage, LoginConfirmPage, NotFoundPage, ) @@ -41,7 +41,8 @@ class CreditDuNordBrowser(LoginBrowser): LoginPage) login_confirm = URL(r'/sec/vk/authent.json', LoginConfirmPage) labels_page = URL(r'/icd/zco/data/public-menu.json', LabelsPage) - redirect = URL('/swm/redirectCDN.html', RedirectPage) + redirect = URL('/swm/redirectCDN.html', '/swm/errorWebCDN.html', RedirectPage) + not_found = URL('/sites/erreur-404', NotFoundPage) entrypage = URL('/icd/zco/#zco', EntryPage) multitype_av = URL('/vos-comptes/IPT/appmanager/transac/professionnels\?_nfpb=true&_eventName=onRestart&_pageLabel=synthese_contrats_assurance_vie', AVPage) loans = URL(r'/vos-comptes/IPT/appmanager/transac/(?P.*)\?_nfpb=true&_eventName=onRestart&_pageLabel=(?P(creditPersoImmobilier|credit_?_en_cours))', ProAccountsPage) @@ -91,8 +92,9 @@ def do_login(self): def _iter_accounts(self): owner_name = self.get_profile().name.upper() self.loans.go(account_type=self.account_type, loans_page_label=self.loans_page_label) - for a in self.page.get_list(): - yield a + if self.loans.is_here(): + for a in self.page.get_list(): + yield a self.accounts.go(account_type=self.account_type, accounts_page_label=self.accounts_page_label) self.multitype_av.go() if self.multitype_av.is_here(): diff --git a/modules/creditdunord/pages.py b/modules/creditdunord/pages.py index 57f979949a..bbf0912b5e 100755 --- a/modules/creditdunord/pages.py +++ b/modules/creditdunord/pages.py @@ -107,7 +107,6 @@ def get_error(self): CleanText('//div[has-class("x-attentionErreur")]/b')(self.doc) - class RedirectPage(HTMLPage): def on_load(self): link = Regexp(CleanText('//script'), 'href="(.*)"', default='')(self.doc) @@ -115,6 +114,19 @@ def on_load(self): self.browser.location(link) +class NotFoundPage(HTMLPage): + """ + Attempt to access to ProAccountsPage can lead + instead to RedirectPage, leading this page. + It is a code 200 request but bear a 'erreur-404' in the URL + We need to pass through not to block the connection. + This happens only on certain connections as a wrongly activated + security feature of the server, + when there is no accounts on the aimed page. + """ + pass + + class EntryPage(LoggedPage, HTMLErrorPage): pass -- GitLab