Commit 19fa36b1 authored by Victor Kannemacher's avatar Victor Kannemacher Committed by Romain Bignon

[bnporc] Handle new error at login with website error message

When we face an error at login, bnp gives us a code. This code's signification
is explained on at documentation page.
This commit gets the message directly from the website.
parent c79eef16
......@@ -42,7 +42,7 @@ from .pages import (
LifeInsurancesDetailPage, NatioVieProPage, CapitalisationPage,
MarketListPage, MarketPage, MarketHistoryPage, MarketSynPage,
RecipientsPage, ValidateTransferPage, RegisterTransferPage, AdvisorPage,
AddRecipPage, ActivateRecipPage, ProfilePage, ListDetailCardPage,
AddRecipPage, ActivateRecipPage, ProfilePage, ListDetailCardPage, ListErrorPage,
)
......@@ -75,6 +75,8 @@ class BNPParibasBrowser(JsonBrowserMixin, LoginBrowser):
'SEEA-pa01/devServer/seeaserver',
'https://mabanqueprivee.bnpparibas.net/fr/espace-prive/comptes-et-contrats\?u=%2FSEEA-pa01%2FdevServer%2Fseeaserver',
LoginPage)
list_error_page = URL('/rsc/contrib/document/properties/identification-fr-part-V1.json', ListErrorPage)
con_threshold = URL('/fr/connexion/100-connexions',
'/fr/connexion/mot-de-passe-expire',
'/fr/espace-prive/100-connexions.*',
......
......@@ -157,6 +157,12 @@ class BNPKeyboard(GridVirtKeyboard):
self.check_symbols(self.symbols, page.browser.responses_dirname)
class ListErrorPage(JsonPage):
def get_error_message(self, error):
key = 'app.identification.erreur.' + str(error)
return self.doc[key]
class LoginPage(JsonPage):
@staticmethod
def render_template(tmpl, **values):
......@@ -188,6 +194,7 @@ class LoginPage(JsonPage):
error = cast(self.get('errorCode'), int, 0)
# you can find api documentation on errors here : https://mabanque.bnpparibas/rsc/contrib/document/properties/identification-fr-part-V1.json
if error:
error_page = self.browser.list_error_page.open()
codes = [201, 21510, 203, 202]
msg = self.get('message')
if error in codes:
......@@ -200,6 +207,8 @@ class LoginPage(JsonPage):
raise ActionNeeded(msg)
elif error == 21: # "Ce service est momentanément indisponible. Veuillez renouveler votre demande ultérieurement." -> In reality, account is blocked because of too much wrongpass
raise ActionNeeded(u"Compte bloqué")
elif error == 4:
raise ActionNeeded(error_page.get_error_message(error))
self.logger.debug('Unexpected error at login: "%s" (code=%s)' % (msg, error))
......
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