Commit 3ee11a8f authored by Christophe Francois's avatar Christophe Francois Committed by Vincent A

[cmso] Handle new page in login

There is a call at login to choose which space to consult (particulier,
pro, association). If we don't do it, there is a redirection during the
fetching of  investments that fails.
parent 183f4fba
......@@ -37,7 +37,8 @@ from weboob.tools.json import json
from .pages import (
LogoutPage, AccountsPage, HistoryPage, LifeinsurancePage, MarketPage,
AdvisorPage, LoginPage, ProfilePage, RedirectInsurancePage,
AdvisorPage, LoginPage, ProfilePage, RedirectInsurancePage, SpacesPage,
ChangeSpacePage,
)
from .transfer_pages import TransferInfoPage, RecipientsListPage, TransferPage, AllowedRecipientsPage
......@@ -96,6 +97,10 @@ class CmsoParBrowser(TwoFactorBrowser):
r'https://.*/auth/errorauthn',
LogoutPage
)
spaces = URL(r'/domiapi/oauth/json/accesAbonnement', SpacesPage)
change_space = URL(r'/securityapi/changeSpace', ChangeSpacePage)
accounts = URL(r'/domiapi/oauth/json/accounts/synthese(?P<type>.*)', AccountsPage)
history = URL(r'/domiapi/oauth/json/accounts/(?P<page>.*)', HistoryPage)
loans = URL(r'/creditapi/rest/oauth/v1/synthese', AccountsPage)
......@@ -249,6 +254,15 @@ class CmsoParBrowser(TwoFactorBrowser):
# to know if account can do transfer
accounts_eligibilite_debit = self.page.get_eligibilite_debit()
self.spaces.go(json={'includePart': True})
self.change_space.go(json={
'clientIdSource': self.arkea_client_id,
'espaceDestination': 'PART',
'fromMobile': False,
'numContractDestination': self.page.get_part_space(),
})
self.session.headers['Authorization'] = 'Bearer %s' % self.page.get_access_token()
# First get all checking accounts...
self.accounts.go(json={'typeListeCompte': 'COMPTE_SOLDE_COMPTES_CHEQUES'}, type='comptes')
self.page.check_response()
......
......@@ -58,6 +58,18 @@ class LogoutPage(RawPage):
pass
class SpacesPage(LoggedPage, JsonPage):
def get_part_space(self):
for abo in Dict('listAbonnement')(self.doc):
if Dict('espaceProxy')(abo) == 'PART':
return Dict('numContratBAD')(abo)
class ChangeSpacePage(LoggedPage, JsonPage):
def get_access_token(self):
return Dict('accessToken')(self.doc)
class AccountsPage(LoggedPage, JsonPage):
TYPES = OrderedDict([
('courant', Account.TYPE_CHECKING),
......
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