This commit is contained in:
Romain Bignon 2013-04-01 15:17:04 +02:00
commit 9f9f8edc01
3 changed files with 9 additions and 24 deletions

View file

@ -42,8 +42,9 @@ class BoursoramaBackend(BaseBackend, ICapBank):
DESCRIPTION = u'Boursorama French bank website' DESCRIPTION = u'Boursorama French bank website'
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False), CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False),
ValueBackendPassword('password', label='Password'), ValueBackendPassword('password', label='Password'),
ValueBool('enable_twofactors', label='Send validation sms', default=False), ValueBool('enable_twofactors', label='Send validation sms', default=False),
Value('device', label='Device name', regexp='\w*'),) Value('device', label='Device name', regexp='\w*', default=''),
)
BROWSER = Boursorama BROWSER = Boursorama
def create_default_browser(self): def create_default_browser(self):

View file

@ -61,9 +61,10 @@ class Boursorama(BaseBrowser):
if self.enable_twofactors: if self.enable_twofactors:
self.page.authenticate(self.device) self.page.authenticate(self.device)
else: else:
print \ raise BrowserIncorrectAuthenticationCode(
"""Boursorama - activate the two factor authentication in boursorama config."""\ """Boursorama - activate the two factor authentication in boursorama config."""\
""" You will receive SMS code but are limited in request per day (around 15)""" """ You will receive SMS code but are limited in request per day (around 15)"""
)
def login(self): def login(self):
assert isinstance(self.username, basestring) assert isinstance(self.username, basestring)
@ -72,9 +73,6 @@ class Boursorama(BaseBrowser):
assert isinstance(self.enable_twofactors, bool) assert isinstance(self.enable_twofactors, bool)
assert self.password.isdigit() assert self.password.isdigit()
#for debug, save requested pages to tmp dir
#self.SAVE_RESPONSES = True
if not self.is_on_page(LoginPage): if not self.is_on_page(LoginPage):
self.location('https://' + self.DOMAIN + '/connexion.phtml') self.location('https://' + self.DOMAIN + '/connexion.phtml')
@ -93,12 +91,8 @@ class Boursorama(BaseBrowser):
#if the login was correct but authentication code failed, #if the login was correct but authentication code failed,
#we need to verify if bourso redirect us to login page or authentication page #we need to verify if bourso redirect us to login page or authentication page
if self.is_on_page(LoginPage): if self.is_on_page(LoginPage):
#print "not correct after handling authentication"
raise BrowserIncorrectAuthenticationCode() raise BrowserIncorrectAuthenticationCode()
#print "login over"
def get_accounts_list(self): def get_accounts_list(self):
if not self.is_on_page(AccountsList): if not self.is_on_page(AccountsList):
self.location('/comptes/synthese.phtml') self.location('/comptes/synthese.phtml')

View file

@ -22,20 +22,15 @@ from weboob.tools.browser import BasePage, BrowserIncorrectPassword
import urllib2 import urllib2
import re import re
__all__ = ['AuthenticationPage'] __all__ = ['AuthenticationPage']
class BrowserAuthenticationCodeMaxLimit(BrowserIncorrectPassword): class BrowserAuthenticationCodeMaxLimit(BrowserIncorrectPassword):
pass pass
def write_debug(string, fi):
f = open(fi, "w")
f.write(string)
class AuthenticationPage(BasePage): class AuthenticationPage(BasePage):
MAX_LIMIT = "vous avez atteint le nombre maximum "\ MAX_LIMIT = "vous avez atteint le nombre maximum "\
"d'utilisation de l'authentification forte." "d'utilisation de l'authentification forte."
@ -81,12 +76,10 @@ class AuthenticationPage(BasePage):
#extrat authentication token from response (in form) #extrat authentication token from response (in form)
info = response.read() info = response.read()
#write_debug(info, "step1.html")
regex = re.compile(r"vous avez atteint le nombre maximum d'utilisation de l'authentification forte.") regex = re.compile(r"vous avez atteint le nombre maximum d'utilisation de l'authentification forte.")
r = regex.search(info) r = regex.search(info)
if r: if r:
print "Boursorama - Vous avez atteint le nombre maximum d'utilisation de l'authentification forte" self.logger.info("Boursorama - Vous avez atteint le nombre maximum d'utilisation de l'authentification forte")
raise BrowserAuthenticationCodeMaxLimit() raise BrowserAuthenticationCodeMaxLimit()
#print "Response from initial request,", len(info), response.info() #print "Response from initial request,", len(info), response.info()
@ -105,7 +98,6 @@ class AuthenticationPage(BasePage):
#info = response.read() #info = response.read()
#print "after asking to send token authentification" \ #print "after asking to send token authentification" \
# ,len(info), response.info() # ,len(info), response.info()
#write_debug(info, "step2.html")
#self.print_cookies() #self.print_cookies()
@ -117,7 +109,6 @@ class AuthenticationPage(BasePage):
response = self.browser.open(req) response = self.browser.open(req)
#info = response.read() #info = response.read()
#print "after pin authentification", len(info), response.info() #print "after pin authentification", len(info), response.info()
#write_debug(info, "step3.html")
#self.print_cookies() #self.print_cookies()
@ -128,7 +119,6 @@ class AuthenticationPage(BasePage):
#result = response.read() #result = response.read()
#print response, "\n", response.info() #print response, "\n", response.info()
#write_debug(result, "step4.html")
#self.print_cookies() #self.print_cookies()