wiki.techinc.nl/tests/phpunit/includes/auth
Gergő Tisza 04bdfa50f0
Fix block handling in CheckBlocksSecondaryAuthenticationProvider
The authentication provider's testUserForCreation() method is for
checking whether a given user name is available. The current
user being IP-blocked has nothing to do with that username's
availability so stop checking that. (AuthManager will check it
via AuthManager::authorizeCreateAccount() elsewhere. Although
that method doesn't seem to be doing anything useful and could
probably just be replaced with a direct call to
PermissionManager, but that's left for a separate, less risky
patch.)

Special-case autocreation though, which doesn't use
the more appropiate AuthManager::authorizeCreateAccount() for
performance reasons so it does need an IP block check.
(At least I think it is for performance reasons. Maybe it's
just an unintentional omission, and that should be used instead?)

While we are at it, also fix a TODO in AuthManager where partial
blocks were taken into account for $wgBlockDisablesLogin, and
clarify in the config schema that they aren't, improve some
comments to make it more obvious why some things are/aren't
done in CheckBlocksSecondaryAuthenticationProvider, and make
the logic more similar to the one in testUserForCreation().

Functional changes:
* Partial blocks are ignored for authentication, account
  creation and autocreation.
* On $wgBlockDisablesLogin wikis IP blocks won't prevent
  login anymore.
* On $wgBlockDisablesLogin wikis, blocks will now prevent
  account autocreation even if they are not configured to
  prevent account creation. The assumption is that on such
  wikis account creation is restricted via some means.
  This probably isn't necessary as blocks should also prevent
  the conditions needed for autocreation (e.g. log the user
  out centrally), but can serve as defense in depth.
  Along with the special-casing of autocreation, this means
  on such wikis any IP block will prevent autocreation, which
  is not great but seems not worth even more code complexity
  to avoid.
* The action=query&list=users&usprop=cancreate API won't take
  blocks into account anymore.

Bug: T306018
Bug: T208895
Change-Id: Ie94d61640301192b287275311f3452e606469d25
2022-08-30 19:06:16 -07:00
..
AbstractPasswordPrimaryAuthenticationProviderTest.php tests: Migrate setMwGlobals() to overrideConfigValue(s)() 2022-07-19 15:42:15 +01:00
AbstractPreAuthenticationProviderTest.php
AbstractPrimaryAuthenticationProviderTest.php Tests: Cleanup some unnecessary nested function calls 2022-06-06 01:02:34 +01:00
AuthenticationRequestTest.php Replace PHPUnit ->returnValue() with ->willReturn() shortcut 2021-04-22 10:37:45 +02:00
AuthenticationRequestTestCase.php
AuthManagerTest.php tests: Use MainConfigNames constants on overrideConfigValue 2022-07-12 19:34:54 +02:00
ButtonAuthenticationRequestTest.php
CheckBlocksSecondaryAuthenticationProviderTest.php Fix block handling in CheckBlocksSecondaryAuthenticationProvider 2022-08-30 19:06:16 -07:00
ConfirmLinkAuthenticationRequestTest.php Replace PHPUnit ->returnValue() with ->willReturn() shortcut 2021-04-22 10:37:45 +02:00
ConfirmLinkSecondaryAuthenticationProviderTest.php Inline a few more trivial createMock() calls in tests 2022-08-08 09:50:50 +02:00
CreatedAccountAuthenticationRequestTest.php
CreateFromLoginAuthenticationRequestTest.php
CreationReasonAuthenticationRequestTest.php
EmailNotificationSecondaryAuthenticationProviderTest.php Inline a few more trivial createMock() calls in tests 2022-08-08 09:50:50 +02:00
LocalPasswordPrimaryAuthenticationProviderTest.php tests: Migrate setMwGlobals() to overrideConfigValue(s)() 2022-07-19 15:42:15 +01:00
PasswordAuthenticationRequestTest.php
PasswordDomainAuthenticationRequestTest.php
RememberMeAuthenticationRequestTest.php Make RememberMe authentication behavior configurable. 2021-03-14 12:31:41 -04:00
ResetPasswordSecondaryAuthenticationProviderTest.php Inline a few more trivial createMock() calls in tests 2022-08-08 09:50:50 +02:00
TemporaryPasswordAuthenticationRequestTest.php tests: Use MainConfigNames constants on overrideConfigValue 2022-07-12 19:34:54 +02:00
TemporaryPasswordPrimaryAuthenticationProviderTest.php Tests: Cleanup some unnecessary nested function calls 2022-06-06 01:02:34 +01:00
ThrottlePreAuthenticationProviderTest.php Add convenience methods for asserting status. 2022-03-16 22:44:25 +01:00
ThrottlerTest.php tests: Migrate setMwGlobals() to overrideConfigValue(s)() 2022-07-19 15:42:15 +01:00
UserDataAuthenticationRequestTest.php tests: Change multiple calls from overrideConfigValue to overrideConfigValues 2022-08-17 12:08:50 +00:00
UsernameAuthenticationRequestTest.php