Commit 9e78dcc9 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by ntome

[afer] Corrected wrongpass detection & handled ActionNeeded

The wrongpass page changed since the recent website migration,
the new URL and message xpath had to be handled.

Customers who updated their password now have a message inviting them to
connect to the Aviva website, although some customers may still be using
the Afer website.

Closes: 13778@zendesk, 13827@zendesk, 13841@zendesk, 13885@zendesk
parent eb80d54a
......@@ -25,27 +25,24 @@ from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, Brow
from weboob.tools.compat import basestring
from .pages import (
LoginPage, IndexPage, BadLogin, AccountDetailPage, AccountHistoryPage, MigrationPage
LoginPage, IndexPage, WrongPasswordPage, WrongWebsitePage,
AccountDetailPage, AccountHistoryPage, MigrationPage,
)
class AferBrowser(LoginBrowser):
BASEURL = 'https://adherent.gie-afer.fr'
login = URL(r'/espaceadherent/MonCompte/Connexion', LoginPage)
login = URL(r'/espaceadherent/MonCompte/Connexion$', LoginPage)
wrong_password = URL(r'/espaceadherent/MonCompte/Connexion\?err=6001', WrongPasswordPage)
wrong_website = URL(r'/espaceadherent/MonCompte/Connexion\?err=6008', WrongWebsitePage)
migration = URL(r'/espaceadherent/MonCompte/Migration', MigrationPage)
# TODO check all following urls once users have migrated to new credentials
bad_login = URL('/names.nsf\?Login', BadLogin)
index = URL('/web/ega.nsf/listeAdhesions\?OpenForm', IndexPage)
account_detail = URL('/web/ega.nsf/soldeEpargne\?openForm', AccountDetailPage)
account_history = URL('/web/ega.nsf/generationSearchModule\?OpenAgent', AccountHistoryPage)
history_detail = URL('/web/ega.nsf/WOpendetailOperation\?OpenAgent', AccountHistoryPage)
def do_login(self):
"""
Attempt to log in.
Note: this method does nothing if we are already logged in.
"""
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
self.login.go()
......@@ -58,13 +55,11 @@ class AferBrowser(LoginBrowser):
if self.migration.is_here():
raise BrowserPasswordExpired(self.page.get_error())
if self.bad_login.is_here():
if self.wrong_password.is_here():
error = self.page.get_error()
if "La saisie de l’identifiant ou du code confidentiel est incorrecte" in error or \
"Veuillez-vous identifier" in error:
if error:
raise BrowserIncorrectPassword(error)
else:
assert False, "Message d'erreur inconnu: %s" % error
assert False, 'We landed on WrongPasswordPage but no error message was fetched.'
@need_login
......
......@@ -39,15 +39,27 @@ class LoginPage(HTMLPage):
form.submit()
class BadLogin(HTMLPage):
class WrongPasswordPage(HTMLPage):
def get_error(self):
return CleanText('//div[@id="idDivErrorLogin"]')(self.doc)
return CleanText('//p[contains(text(), "Votre saisie est erronée")]')(self.doc)
class WrongWebsitePage(HTMLPage):
# We land on this page when the website indicates that
# an account is already created on the 'Aviva et moi' space,
# So we check the message and raise ActionNeeded with it
def on_load(self):
message = CleanText('//p[contains(text(), "Vous êtes déjà inscrit")]')(self.doc)
if message:
raise ActionNeeded(message)
assert False, 'We landed on WrongWebsitePage but no message was fetched.'
class MigrationPage(HTMLPage):
def get_error(self):
return CleanText('//h1[contains(text(), "Votre nouvel identifiant et mot de passe")]')(self.doc)
class IndexPage(LoggedPage, HTMLPage):
def on_load(self):
HTMLPage.on_load(self)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment