From def92556bb972393792413cd9e75b693f4843da2 Mon Sep 17 00:00:00 2001 From: Martin Sicot Date: Thu, 28 Feb 2019 16:14:37 +0100 Subject: [PATCH] [banquetarneaud] Fix login when rgpd pops Sometimes, an rgpd pages pop when trying to logging, causing an ActionNeeded. This page (that the user don't see) can be by-passed by going on the bypass_rgpd url. This is what we do every time now when we try to logging if we retrieve this page. closes: 9023@zendesk closes: 9529@zendesk --- modules/creditdunord/browser.py | 14 +++++++++++--- modules/creditdunord/pages.py | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/creditdunord/browser.py b/modules/creditdunord/browser.py index 2514ea3730..b61c661d6e 100644 --- a/modules/creditdunord/browser.py +++ b/modules/creditdunord/browser.py @@ -20,14 +20,14 @@ from __future__ import unicode_literals from weboob.browser import LoginBrowser, URL, need_login -from weboob.exceptions import BrowserIncorrectPassword, BrowserPasswordExpired +from weboob.exceptions import BrowserIncorrectPassword, BrowserPasswordExpired, ActionNeeded from weboob.capabilities.bank import Account from weboob.capabilities.base import find_object from weboob.tools.capabilities.bank.investments import create_french_liquidity from .pages import ( LoginPage, ProfilePage, AccountTypePage, AccountsPage, ProAccountsPage, TransactionsPage, IbanPage, RedirectPage, EntryPage, AVPage, ProIbanPage, - ProTransactionsPage, LabelsPage, + ProTransactionsPage, LabelsPage, RgpdPage, ) class CreditDuNordBrowser(LoginBrowser): @@ -50,6 +50,7 @@ class CreditDuNordBrowser(LoginBrowser): account_type_page = URL("/icd/zco/public-data/public-ws-menuespaceperso.json", AccountTypePage) labels_page = URL("/icd/zco/public-data/ws-menu.json", LabelsPage) profile_page = URL("/icd/zco/data/user.json", ProfilePage) + bypass_rgpd = URL('/icd/zcd/data/gdpr-get-out-zs-client.json', RgpdPage) def __init__(self, website, *args, **kwargs): self.weboob = kwargs['weboob'] @@ -104,7 +105,14 @@ def _iter_accounts(self): @need_login def get_pages_labels(self): - self.labels_page.go() + # When retrieving labels_page, + # If GDPR was accepted partially the website throws a page that we treat + # as an ActionNeeded. Sometime we can by-pass it. Hence this fix + try: + self.labels_page.go() + except ActionNeeded: + self.bypass_rgpd.go() + self.labels_page.go() return self.page.get_labels() @need_login diff --git a/modules/creditdunord/pages.py b/modules/creditdunord/pages.py index 8b9571c596..c3085c477a 100755 --- a/modules/creditdunord/pages.py +++ b/modules/creditdunord/pages.py @@ -169,7 +169,7 @@ def on_load(self): if Dict('commun/statut', default='')(self.doc) == 'nok': reason = Dict('commun/raison')(self.doc) assert reason == 'GDPR', 'Labels page is not available with message %s' % reason - raise ActionNeeded() + raise ActionNeeded(reason) def get_labels(self): synthesis_labels = ["synthèse"] @@ -794,3 +794,7 @@ def get_history(self, account): continue yield t + + +class RgpdPage(LoggedPage, CDNBasePage): + pass -- GitLab