wiki.techinc.nl/tests/phpunit/includes/api
Dreamy Jazz 3b3f1d7851 Handle collisions from SerialProvider::acquireIndex
Why:
* When using the TempUserCreator::create or ::acquireAndStashName to
  get temporary account when the chosen username already existed, that
  temporary account is treated as if it doesn't exist. This causes
  confusing "userexists" errors and also causes the user to be logged
  into an already existing temporary account.
* Furthermore, because the user existence check in AuthManager::auto
  CreateUser only checks the local wiki, if an existing temporary
  account exists globally but not on the local wiki then the code
  sign a new user into an existing temporary account.
* This is very bad behaviour, though shouldn't happen unless the
  serialMapping configuration uses a SerialMapping class that could
  provide duplicates and/or the configuration has been changed to
  use a different SerialMapping class.
* There is a need to change the SerialMapping class in use to a
  different class, which means that the code will attempt to use
  temporary account usernames which already exist.
* As such, the code that is generating the temporary account usernames
  based on the SerialMapping and SerialProvider should be aware that
  it may produce an already existing temporary account username, even
  if the SerialMapping class being used is asserted to never provide
  duplicates.
* Therefore, the code that generates temporary account usernames
  should always attempt to verify that a automatically generated
  temporary account name does not already exist on the wiki.

What:
* Update TempUserCreator::acquireName to check to see if the username
  it generates already exists centrally using the CentralIdLookup.
  If it does, then the method returns null. Otherwise, the username
  that hasn't been used yet is returned.
* Create the private method TempUserCreator::attemptAutoCreate that
  attempts an autocreate for a temporary account name, and optionally
  logs the account in.
* Update TempUserCreator::create to use ::attemptAutoCreate to
  first to check if the account can be created and then again once
  the account is created to actually login to that temporary account.
  This is done to prevent logins to existing temporary accounts on
  the local wiki. The second call to actually perform the login is
  necessary as there is no other way to login to a temporary account.
* Update TempUserCreator::acquireAndStashName to respond to the changes
  to ::acquireName, such that it returns null if ::acquireName returns
  null and also does not modify the session.
* Update EditPage::maybeActivateTempUserCreate to return a Status and
  return a good status in all cases except when a temporary account
  name could not be acquired.
* Add IEditObject::AS_UNABLE_TO_ACQUIRE_TEMP_ACCOUNT, and use it as
  the value of the fatal status returned by EditPage
  ::internalAttemptSave if a temporary account name could not be
  acquired. This will cause the display of a useful error to the
  user on edit.
* Update ApiEditPage and ApiAcquireTempUserName to die with an error
  if a temporary account username was unable to be acquired.
* Provide tests for the untested ApiAcquireTempUserName.php file
  including testing the new behaviour.
* Add and update tests for TempUserCreator.php

Bug: T353390
Change-Id: Id3a316ea0eba544d51d4ffcdfb03e35f4b3c54cc
2023-12-21 14:49:42 +00:00
..
format Avoid DB access in non-database tests 2023-08-06 22:57:48 +00:00
query tests: Fix name of class property in ApiQueryImageInfoTest 2023-12-13 20:01:39 +01:00
Validator Bump codesniffer to 42.0.0 2023-09-27 15:06:32 -04:00
ApiAcquireTempUserNameTest.php Handle collisions from SerialProvider::acquireIndex 2023-12-21 14:49:42 +00:00
ApiBaseTest.php Stop using nonexistent DatabaseBlock constructor options 2023-11-06 12:03:51 +11:00
ApiBlockInfoTraitTest.php Support new block schema 2023-11-29 13:31:42 +11:00
ApiBlockTest.php Merge "Replace a few manually crafted assertTrue assertions" 2023-11-30 12:45:42 +00:00
ApiChangeContentModelTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiCheckTokenTest.php
ApiClearHasMsgTest.php Avoid DB access in non-database tests 2023-08-06 22:57:48 +00:00
ApiComparePagesTest.php tests: Use $this->getDb() instead of wfGetDB() in integration tests 2023-09-25 21:08:09 +02:00
ApiContinuationManagerTest.php
ApiCreateTempUserTraitTest.php tests: Use namespaced classes 2023-12-11 15:59:55 +01:00
ApiCSPReportTest.php
ApiDeleteTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiDisabledTest.php
ApiEditPageTest.php tests: Use namespaced classes 2023-12-11 15:59:55 +01:00
ApiErrorFormatterTest.php Use thousands separators in selected integer literals 2023-12-12 09:22:45 +11:00
ApiLoginTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiLogoutTest.php Namespace User under \MediaWiki\User 2023-09-19 19:18:16 +00:00
ApiMainTest.php tests: Use ::class for class name resolution 2023-12-06 20:51:14 +01:00
ApiMessageTest.php
ApiMoveTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiOpenSearchTest.php API: Replace deprecated calls to wfExpandUrl with UrlUtils::expand 2023-06-22 16:49:01 -04:00
ApiOptionsTest.php Move user options related classes into its own namespace 2023-11-29 13:27:13 +01:00
ApiPageSetTest.php Namespace TitleValue under \MediaWiki\Title 2023-09-18 18:24:39 +01:00
ApiParseTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiProtectTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiPurgeTest.php ApiPurge: report permission errors properly 2023-10-09 17:44:20 +00:00
ApiResultTest.php Use thousands separators in selected integer literals 2023-12-12 09:22:45 +11:00
ApiRevisionDeleteTest.php tests: api: Replace Title::newFromText with Title::makeTitle 2023-07-30 17:15:09 +02:00
ApiRollbackTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiSetNotificationTimestampIntegrationTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiStashEditTest.php tests: Use $this->getDb() instead of wfGetDB() in integration tests 2023-09-25 21:08:09 +02:00
ApiTestCase.php phpunit: Avoid TestUser in non-database tests 2023-07-29 14:26:50 +00:00
ApiTestContext.php Reorg: Move WebRequest to includes\Request 2023-09-11 21:44:34 +01:00
ApiUnblockTest.php tests: Use namespaced classes 2023-12-11 15:59:55 +01:00
ApiUndeleteTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiUploadTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
ApiUploadTestCase.php Replace generic new Exception with more generic ones 2023-10-17 07:59:50 +00:00
ApiUsageExceptionTest.php
ApiUserrightsTest.php tests: Use namespaced classes 2023-12-11 15:59:55 +01:00
ApiWatchTest.php Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary 2023-11-21 09:02:48 -05:00
generateRandomImages.php
MockApi.php
MockApiQueryBase.php
RandomImageGenerator.php Replace generic new Exception with more generic ones 2023-10-17 07:59:50 +00:00