Skip to content
Snippets Groups Projects
Commit e7c51daa authored by Adam Williamson's avatar Adam Williamson Committed by Adam Williamson
Browse files

Make logged_in more accurate


I found this while writing integration tests. If you try to login
with an incorrect username and password, mwclient correctly raises
mwclient.errors.LoginError...but if you then check logged_in, it
is True. Clearly that's wrong.

The logic for setting logged_in will basically consider us logged
in any time we process an API call and there is no 'anon' key in
the userinfo dict *or there is no userinfo dict at all*. The last
API call processed on a failed login attempt has no userinfo
dict.

This tweaks it so we only changed the logged_in value (in either
direction) if the API call we're handling has a userinfo dict.

We also fix the type of the empty userinfo we create if there
isn't one in the call (no idea why it was a tuple, it doesn't
really matter but it's weird) and explicitly set self.logged_in
to False in Site initialization. I don't think this is strictly
necessary as we can expect the init process to result in at least
one API call with a userinfo dict, but it feels more correct.

Signed-off-by: default avatarAdam Williamson <awilliam@redhat.com>
parent 3c7244ed
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment