Skip to content

Commit

Permalink
Workaround for changed login page (by form. Oauth is still broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhed committed Mar 5, 2024
1 parent 6b68a72 commit 8b6f781
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mijnbib/login_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def _log_in(self):
_log.debug("Opening login page ... ")
response = self._br.open(self._url, timeout=TIMEOUT)
html_string_start_page = response.read().decode("utf-8") # type:ignore
# TODO Workaround for mechanize.BrowserStateError: not viewing HTML
self._br._factory.is_html = True
self._br.select_form(nr=0)
self._br["email"] = self._username
self._br["password"] = self._pwd
Expand Down
7 changes: 7 additions & 0 deletions tests/test_mijnbibliotheek.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ def creds_config(scope="module"):
yield dict(**config.defaults())


class X(str):
pass


class FakeMechanizeBrowser:
def __init__(self, form_response: str) -> None:
self._form_response = form_response.encode("utf8")
# trick for nested prop, from https://stackoverflow.com/a/35190607/50899
self._factory = X("_factory")
self._factory.is_html = None # can be whatever

def __setitem__(self, key, value):
pass
Expand Down

0 comments on commit 8b6f781

Please sign in to comment.