Since T25227: Use token when logging out was resolved and pushed on live WMF wikis, pywikibot.Site().logout() fails with pywikibot.data.api.APIError: notoken: The "token" parameter must be set..
Description
Details
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T229364 CSRF token issues (tracking) | |||
Resolved | Xqt | T222508 action=logout needs CSRF token, since API breaking change | |||
Resolved | BUG REPORT | Xqt | T224712 Attempt to login fails several times | ||
Resolved | BUG REPORT | Dvorapa | T248767 login loop 2: userinfo calls _relogin calls login calls userinfo |
Event Timeline
Change 508072 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [bugfix] add CSRF token in sitelogout() api call
Change 508072 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] add CSRF token in sitelogout() api call
=================================== FAILURES =================================== ______________________ TestLoginLogout.test_login_logout _______________________ self = <tests.site_tests.TestLoginLogout testMethod=test_login_logout> def test_login_logout(self): """Validate login and logout methods by toggling the state.""" site = self.get_site() loginstatus = pywikibot.site.LoginStatus self.assertFalse(site.logged_in()) site.login() self.assertTrue(site.logged_in()) > self.assertGreaterEqual(site._loginstatus, loginstatus.AS_USER) E AssertionError: -2 not greater than or equal to 0 tests/site_tests.py:3719: AssertionError
Change 508094 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [TEST] fix test_login_logout
Change 508094 merged by jenkins-bot:
[pywikibot/core@master] [TEST] fix test_login_logout
Still fails for several wikis: https://travis-ci.org/wikimedia/pywikibot/builds/528251139
Change 508111 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [TEST] fix test_login_logout, OAuth case
Change 508111 merged by jenkins-bot:
[pywikibot/core@master] [TEST] fix test_login_logout, OAuth case
There are two remaining issues for wsbeta and musicbrainz: https://travis-ci.org/wikimedia/pywikibot/builds/528404683
Since the very first patch it also fails on AppVeyor with the following error:
====================================================================== ERROR: test_login_logout (tests.site_tests.TestLoginLogout) Validate login and logout methods by toggling the state. ---------------------------------------------------------------------- Traceback (most recent call last): File "c:\projects\pywikibot-g4xqx\tests\site_tests.py", line 3717, in test_login_logout site.login() File "c:\projects\pywikibot-g4xqx\pywikibot\site.py", line 2101, in login if login_manager.login(retry=True, autocreate=autocreate): File "c:\projects\pywikibot-g4xqx\pywikibot\login.py", line 306, in login self.check_user_exists() File "c:\projects\pywikibot-g4xqx\pywikibot\login.py", line 155, in check_user_exists % (main_username, self.site)) NoUsername: Username 'None' does not exist on wikipedia:en ----------------------------------------------------------------------
Perhaps this should be skipped on AppVeyor as we have no chance to add password/env variable in AppVeyor config?
Change 508893 had a related patch set uploaded (by Framawiki; owner: Framawiki):
[pywikibot/core@master] [bugfix] clear tokens on logout()
The later patch also intents to skip test on AppVeyor.
I'm not sure how to deal with the pywikibot.data.api.APIError: Failed: You have made too many recent login attempts. Please wait 5 minutes before trying again. present on Travis.
Apart from the wsbeta and musicbrainz on Travis there sometimes occur infinite loops:
https://travis-ci.org/wikimedia/pywikibot/jobs/530930561
https://travis-ci.org/wikimedia/pywikibot/jobs/530930559
Change 508893 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] clear tokens on logout()
Change 510520 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] Skip TestLoginLogout unless it is running on Travis
Change 510520 merged by jenkins-bot:
[pywikibot/core@master] Skip TestLoginLogout if it is running on Appveyor
Okay, Appveyor tests skipped, en:wsbeta test account created. Last fails:
- en:musicbrainz - test account created, but still failing (weird)
- zh:wikisource - sometimes some login_logout test timeouts
For en:musicbrainz I see pywikibot.data.api.APIError: Failed: Incorrect username or password entered. Please try again. and it is full of
Logging in to musicbrainz:en as Pywikibot-test ERROR: Login failed (Failed).
Probably travis username/password settings does not match the musicbrainz test account?
The username and general password do match. What else should be set to make it work? OAuth? Some preferences?
My stupidity: I created the Pywikibot-test account on musicbrainz, not musicbrainz wiki :D
Wouldn't it be better to mark the test with a user = True attribute instead of skipIf(os.environ.get('APPVEYOR', ...?
Credentials added to AppVeyor, but Appveyor failing to load settings currently. Anyway, we can enable tests once Upstream issue solved or workarounded
Tests are failing now due to this https://travis-ci.com/github/wikimedia/pywikibot/jobs/521442547
https://github.com/xqt/pwb/runs/4761389285?check_suite_focus=true
====================================================================== ERROR: test_clear_cookies (tests.site_tests.TestClearCookies) Test cookies are cleared (T224712). ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/runner/work/pwb/pwb/tests/site_tests.py", line 3633, in test_clear_cookies site.logout() File "/home/runner/work/pwb/pwb/pywikibot/site/_apisite.py", line 430, in logout uirequest.submit() File "/home/runner/work/pwb/pwb/pywikibot/data/api.py", line 1868, in submit raise pywikibot.exceptions.APIError(**result['error']) pywikibot.exceptions.APIError: missingparam: The "token" parameter must be set. [help: See https://zh.wikisource.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes.]