Commit 1f930449 authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Vincent A

[ing] better fix for 500 errors encountered after visiting life insurances

First, don't go on a non-LoggedPage at the end of iter_accounts, it can only
lead to being delogged mindlessly.

The real problem is the site fails with a 500 when a Referer doesn not point
to /secure (what a bunch of idiots), and the life insurances URL doesn't
have /secure, so after visiting them with go(), we set a bad Referer.
Use open() instead, so the Referer is not set to a "bad" URL.
parent bac4113c
......@@ -309,20 +309,18 @@ class IngAPIBrowser(LoginBrowser, StatesMixin):
# If the balance is 0, the details page throws an error 500
if account.type == Account.TYPE_LIFE_INSURANCE:
if account.balance != 0:
self.life_insurance.go(
# Prefer do an open() NOT to set the life insurance url as next Referer.
# If the Referer doesn't point to /secure, the site might do error 500...
page = self.life_insurance.open(
account_uid=account._uid,
headers={
'Authorization': 'Bearer %s' % self.get_invest_token(),
}
)
self.page.fill_account(obj=account)
page.fill_account(obj=account)
yield account
# The life insurance page is on a different space,
# sometimes we get an error 500 if we don't go back to this page
self.context.go()
@need_login
def iter_matching_accounts(self):
"""Do accounts matching for old and new website"""
......
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