Romain Bignon
Committed by Romain Bignon
Builds for 1 pipeline failed in 2 minutes 28 seconds

bnporc: add parameter to disable password rotation

......@@ -65,8 +65,8 @@ class BNPEnterprise(LoginBrowser):
renew_pass = URL('/sommaire/PseRedirectPasswordConnect', ActionNeededPage)
def __init__(self, *args, **kwargs):
super(BNPEnterprise, self).__init__(*args, **kwargs)
def __init__(self, config, *args, **kwargs):
super(BNPEnterprise, self).__init__(config['login'].get(), config['password'].get(), *args, **kwargs)
def do_login(self):
self.login.go()
......
......@@ -32,7 +32,7 @@ from weboob.capabilities.contact import CapContact
from weboob.capabilities.profile import CapProfile
from weboob.capabilities.base import find_object
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value
from weboob.tools.value import ValueBackendPassword, Value, ValueBool
from .enterprise.browser import BNPEnterprise
from .company.browser import BNPCompany
......@@ -52,9 +52,7 @@ class BNPorcModule(Module, CapBankWealth, CapBankTransferAddRecipient, CapMessag
CONFIG = BackendConfig(
ValueBackendPassword('login', label=u'Numéro client', masked=False),
ValueBackendPassword('password', label=u'Code secret', regexp='^(\d{6})$'),
#ValueBackendPassword('rotating_password', default='',
# label='Password to set when the allowed uses are exhausted (6 digits)',
# regexp='^(\d{6}|)$'),
ValueBool('rotating_password', label=u'Automatically renew password every 100 connections', default=False),
Value('website', label='Type de compte', default='pp',
choices={'pp': 'Particuliers/Professionnels',
'hbank': 'HelloBank',
......@@ -73,10 +71,7 @@ class BNPorcModule(Module, CapBankWealth, CapBankTransferAddRecipient, CapMessag
def create_default_browser(self):
b = {'ent': BNPEnterprise, 'ent2': BNPCompany, 'pp': BNPPartPro, 'hbank': HelloBank}
self.BROWSER = b[self.config['website'].get()]
if self.BROWSER is BNPPartPro:
return self.create_browser(self.config)
return self.create_browser(self.config['login'].get(),
self.config['password'].get())
return self.create_browser(self.config)
def iter_accounts(self):
for account in self.browser.get_accounts_list():
......
......@@ -114,10 +114,11 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser):
profile = URL(r'/kyc-wspl/rest/informationsClient', ProfilePage)
list_detail_card = URL(r'/udcarte-wspl/rest/listeDetailCartes', ListDetailCardPage)
def __init__(self, *args, **kwargs):
super(BNPParibasBrowser, self).__init__(*args, **kwargs)
def __init__(self, config, *args, **kwargs):
super(BNPParibasBrowser, self).__init__(config['login'].get(), config['password'].get(), *args, **kwargs)
self.accounts_list = None
self.card_to_transaction_type = {}
self.rotating_password = config['rotating_password']
@retry(ConnectionError, tries=3)
def open(self, *args, **kwargs):
......@@ -406,9 +407,7 @@ class BNPPartPro(BNPParibasBrowser):
def __init__(self, config=None, *args, **kwargs):
self.config = config
kwargs['username'] = self.config['login'].get()
kwargs['password'] = self.config['password'].get()
super(BNPPartPro, self).__init__(*args, **kwargs)
super(BNPPartPro, self).__init__(self.config, *args, **kwargs)
def switch(self, subdomain):
self.BASEURL = self.BASEURL_TEMPLATE % subdomain
......
......@@ -102,6 +102,9 @@ class ConnectionThresholdPage(HTMLPage):
msg = CleanText('//div[@class="confirmation"]//span[span]')(self.doc)
self.logger.warning('Password expired.')
if not self.browser.rotating_password:
raise BrowserPasswordExpired(msg)
if not self.looks_legit(self.browser.password):
# we may not be able to restore the password, so reject it
self.logger.warning('Unable to restore it, it is not legit.')
......