Commit c1a5a4ce authored by Christophe Francois's avatar Christophe Francois Committed by Vincent A

[myedenred] Fix js fetching before login

JS filenames are randomized and must be fetched. One of the random
strings has been moved from a <script> tag to another js file that we
need to fetch.
parent cb957a57
......@@ -30,7 +30,7 @@ from import retry
from .pages import (
LoginPage, AccountsPage, TransactionsPage,
JsParamsPage, JsUserPage, HomePage,
JsParamsPage, JsUserPage, JsAppPage, HomePage,
......@@ -60,6 +60,7 @@ class MyedenredBrowser(OAuth2PKCEMixin, PagesBrowser):
params_js = URL(r'<random_str>\w+).js', JsParamsPage)
app_js = URL(r'<random_str>\w+).js', JsAppPage)
connexion_js = URL(r'<random_str>\w+).js', JsUserPage)
authorize = URL(r'', AuthorizePage)
......@@ -76,7 +77,10 @@ class MyedenredBrowser(OAuth2PKCEMixin, PagesBrowser):
def _fetch_auth_parameters(self):
params_random_str ='parameters')
connexion_random_str ='connexion')
app_random_str ='app')
connexion_random_str ='connexion')
js_parameters =
......@@ -56,10 +56,19 @@ class HomePage(RejectableHTMLPage):
# tag on the page. That would require to do something like `//link[25]`
# to get the correct link, and if they modify/add/remove one link then the
# regex is going to crash or give us the wrong result.
href ='link href=/js/%s.(\w+).js' % filename, self.text)
href ='/js/%s.(\w+).js' % filename, self.text)
class JsAppPage(RejectableHTMLPage):
def get_js_randomstring(self, filename):
# Same as get_href_randomstring, some values have been moved to this js file
# It constructs the js url so the regex has several matches,
# we take the first one that isn't just the filename parameter
matches = re.findall(r'%s:"(\w+?)"' % filename, self.text)
return next((m for m in matches if m != filename))
class JsParamsPage(RejectableHTMLPage):
def get_json_content(self):
json_data ="JSON\.parse\('(.*)'\)", self.text)
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