Logging into KenPom with MechanicalSoup is a bit wonky in that the service seems to always return 200 OK status code even on a credential-related failure. This leads to confusion like in #15 where one might assume a login was successful as no exception was thrown, but downstream encounters issues trying to pull data requiring a valid session.
On further inspection, it seems the difference the response for a successful login and an unsuccessful one (due to incorrect credentials) is that the Set-Cookie response header returns a PHPSESSID for successful logins, and cookie invalidation information otherwise. As such, I've updated utils.py to look for the string "PHPSESSID=" in the response header value for Set-Cookie and, in its absence, throw the Logging in to kenpom.com failed Exception. I've also added logic into tests/conftest.py to ensure that pytest aborts when the login fails (as most tests will begin failing without a successful login anyway).
If you can, I could use some help testing this in verifying that everyone does indeed get a Set-Cookie: "PHPSESSID=..." header on successful login before this gets merged in.
Logging into KenPom with MechanicalSoup is a bit wonky in that the service seems to always return
200 OK
status code even on a credential-related failure. This leads to confusion like in #15 where one might assume a login was successful as no exception was thrown, but downstream encounters issues trying to pull data requiring a valid session.On further inspection, it seems the difference the response for a successful login and an unsuccessful one (due to incorrect credentials) is that the
Set-Cookie
response header returns aPHPSESSID
for successful logins, and cookie invalidation information otherwise. As such, I've updatedutils.py
to look for the string"PHPSESSID="
in the response header value forSet-Cookie
and, in its absence, throw theLogging in to kenpom.com failed
Exception. I've also added logic intotests/conftest.py
to ensure thatpytest
aborts when the login fails (as most tests will begin failing without a successful login anyway).If you can, I could use some help testing this in verifying that everyone does indeed get a
Set-Cookie: "PHPSESSID=..."
header on successful login before this gets merged in.