From e8cf64e3ff74120045e46ab872778e3d80b64add Mon Sep 17 00:00:00 2001 From: Florian Duguet Date: Fri, 25 Jun 2021 10:55:50 +0200 Subject: [PATCH] [edfparticulier] wrong password handling has changed a little bit Closes: 2456@sibi --- modules/edfparticulier/browser.py | 6 +++--- modules/edfparticulier/pages.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/edfparticulier/browser.py b/modules/edfparticulier/browser.py index f76fb7172f..5a4b389802 100644 --- a/modules/edfparticulier/browser.py +++ b/modules/edfparticulier/browser.py @@ -50,7 +50,7 @@ class EdfParticulierBrowser(LoginBrowser, StatesMixin): authorize = URL(r'https://espace-client.edf.fr/sso/oauth2/INTERNET/authorize', AuthorizePage) wrong_password = URL( - r'https://espace-client.edf.fr/connexion/mon-espace-client/templates/openam/authn/PasswordAuth2.html', + r'https://espace-client.edf.fr/sso/XUI/templates/openam/authn/PasswordAuth2.html', WrongPasswordPage ) check_authenticate = URL('/services/rest/openid/checkAuthenticate', CheckAuthenticatePage) @@ -170,8 +170,8 @@ def do_login(self): # should be SetPasAuth2 if password is ok if self.page.get_data()['stage'] == 'PasswordAuth2': - attempt_number = self.page.get_data()['callbacks'][1]['output'][0]['value'] - # attempt_number is the number of wrong password + attempt_number = int(self.page.get_data()['callbacks'][1]['output'][0]['value']) + # attempt_number is the number of wrong password that remains before blocking msg = self.wrong_password.go().get_wrongpass_message(attempt_number) raise BrowserIncorrectPassword(msg) diff --git a/modules/edfparticulier/pages.py b/modules/edfparticulier/pages.py index 6dc2efa3c9..cdc0a4929e 100644 --- a/modules/edfparticulier/pages.py +++ b/modules/edfparticulier/pages.py @@ -26,7 +26,7 @@ from woob.browser.filters.html import Attr from woob.browser.pages import LoggedPage, JsonPage, HTMLPage, RawPage -from woob.browser.filters.standard import Env, Format, Date, Eval, CleanText, Regexp +from woob.browser.filters.standard import Env, Format, Date, Eval, CleanText from woob.browser.elements import ItemElement, DictElement, method from woob.browser.filters.json import Dict from woob.capabilities.bill import Bill, Subscription @@ -63,15 +63,16 @@ class WrongPasswordPage(HTMLPage): def get_wrongpass_message(self, attempt_number): # edf website block access after 5 wrong password, and user will have to change his password # this is very important because it can tell to user how much attempt it remains - script = CleanText('//script[contains(text(), "Mot de passe incorrect")]') + msg = CleanText('//p[@id="error1"]')(self.doc) + msg_remain_attemp = CleanText('//p[strong[@id="attempt-number"]]', default='')(self.doc) + msg_remain_attemp = msg_remain_attemp.replace('{{theme.settings.spaceName.texte}} ', '') if attempt_number > 0: - return Format( - '%s %s %s', - Regexp(script, r">(Mot de passe incorrect.*?)<"), - CleanText('//div[@class="arrow_box--content"]', children=False), int(attempt_number) - )(self.doc) - return Regexp(script, r">(Vous avez atteint.*?)<")(self.doc) + msg += ' ' + msg_remain_attemp.replace( + 'Tentatives restantes : X', 'Tentatives restantes : %d' % attempt_number + ) + + return msg class OTPTemplatePage(HTMLPage): -- GitLab