aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/auth/ThrottlePreAuthenticationProviderTest.php
Commit message (Collapse)AuthorAgeFilesLines
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-1/+1
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* tests: More use statements in auth testsReedy2024-02-161-9/+12
| | | | Change-Id: Ic57b19a779065a18112334d79ede395ced1a202b
* tests: Add Tests to PHP namespacingReedy2024-02-161-1/+4
| | | | Change-Id: I849268172751d50292e93aa75abe8094873f56bc
* Make use of assertStatusGood/Error and such in teststhiemowmde2023-10-041-7/+5
| | | | Change-Id: I11eace3d9823ca28a1d9a64f959f5f8ca2945821
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-1/+1
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-7/+8
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Do not use UTSysop directly in auth testsDaimona Eaytoy2023-08-161-6/+6
| | | | | | | | | | | | | | | | | | | | These tests are all making two assumptions: - That the sysop test account exists - That its name is UTSysop Both assumptions happen to be true right now, but the first one will no longer be after change I30861742. The second one will probably remain true for a while, but still, tests shouldn't rely on this implementation detail when possible. If a test needs an exiting test user, it should call getTestUser / getTestSysop. Use mocks or different usernames where the user actually doesn't matter, e.g. in non-Database tests where UTSysop already doesn't exist. Bug: T342428 Change-Id: Ie77e72f5a5ee6a2ef4ec9dceaa9044bb690f68b2
* tests: Use MainConfigNames consts to refer config namesUmherirrender2023-06-191-16/+17
| | | | | | PasswordSalt was dropped in 2e909bcb Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
* Fix more PHPStorm inspections (#2)Tim Starling2023-03-251-1/+1
| | | | | | | | | | | | | | | * Illegal string offset and invalid argument supplied to foreach, due to incorrect type information * Array internal pointer reset is unnecessary * $hookData unused since MW 1.35 due to incomplete revert * array_push() with single element * Unnecessary sprintf() * for loop can be replaced with str_repeat() * preg_replace() can be replaced with rtrim() * array_values() call is redundant * Unnecessary cast to string * Unnecessary ternary. Often the result relies on short-circuit evaluation, but I find it more readable nonetheless. Change-Id: I4c45bdb59b51b243fa96286bec8b58deb097d707
* Tests: treat wgHooks like a regular config variable.daniel2023-03-091-10/+9
| | | | | | | | Prepare phpunit tests for a world where $wgHooks behaves like other config variables: on-the-fly manipulation doesn't have an effect, service objects need to be reset after changing it. Change-Id: I34385f4c52febfe1c91bd7ea4100c06d1331adc8
* Add convenience methods for asserting status.daniel2022-03-161-1/+1
| | | | | | | This ensures that assertions work in a uniform way, and provides meaningful messages in cause of failure. Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
* Create AuthenticationProviderTestTrait to facilitate testing of an ↵vladshapik2021-05-251-51/+31
| | | | | | | | | | | AuthenticationProvider Create new AuthenticationProviderTestTrait and AuthenticationProviderTestTrait ::initProvider method. Replace uses of AbstractAuthenticationProvider::init with new method in tests. Bug: T282781 Change-Id: Ie65c7558bfbacbf6678eea77e4a9b2cf68026456
* Implement injecting of dependencies to an AuthenticationProvidervladshapik2021-04-261-38/+79
| | | | | | | | | | | | | init() method was added to AuthenticationProvider. It helps to inject dependecies. Overridable postInitSetup() method was added to AbstractAuthenticationProvider. A provider can override this to do any necessary setup. AbstractAuthenticationProvider ::setLogger(), ::setManager(), ::setConfig(), ::setHookContainer() were soft deprecated. Now developers must use AbstractAuthenticationProvider::init(). Bug: T275030 Change-Id: I6ca63eddac1b177eeadbdcce992e71c44a480160
* Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-221-2/+2
| | | | | | | | | | | | It's the same and makes the test code much more readable, I would like to argue. Because of the was I split all the changes I made into smaller patches this patch contains some other changes in the same lines where I could not split them off. E.g. removal of ->any(), which is the default anyway and doesn't do anything. Change-Id: Ib297b989d4aec33b31a4e33fe9d5032865b39be0
* phpunit: Mass-replace setMethods with onlyMethods and adjustDaimona Eaytoy2021-04-161-1/+1
| | | | | | | | | | | | Ended up using grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g' special-casing setMethods( null ) -> onlyMethods( [] ) and then manual fix of failing test (from PS2 onwards). Bug: T278010 Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-301-1/+1
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* Use MediaWikiServices::getAuthManager instead of AuthManager::singletonUmherirrender2020-06-221-5/+5
| | | | Change-Id: I92c31b963095eab751df9f8c1715e8e23b7e8485
* Hooks::run() call site migrationTim Starling2020-05-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUseJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
* Coding style: Auto-fix MediaWiki.Usage.PHPUnit*James D. Forrester2020-01-101-4/+4
| | | | Change-Id: I86fc55a4fc8ceafe368692173211bbcd6d8581d7
* Fix undefined NS with @covers tags in /includes/auth/Alangi Derick2018-11-011-1/+2
| | | | | | Should MW Codesniffer also handle these as well? Change-Id: Ieb493bddd5f3674fb889b4a780d51b50d89c4f65
* Use ::class to resolve class names in testsUmherirrender2018-01-261-1/+1
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* Switch to librarized version of TestingAccessWrapperGergő Tisza2017-04-201-7/+9
| | | | | | | | | | | | | | | Replaces \TestingAccessWrapper (defined in core) with \Wikimedia\TestingAccessWrapper (defined in the composer package wikimedia/testing-access-wrapper). See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper for downstream patches. The core version of the class is kept around for a while to avoid circular dependency problems. Bug: T163434 Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
* phpunit: Avoid use of deprecated getMock for PHPUnit 5 compatTimo Tijhof2017-04-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | The default will remain PHPUnit 4.x due to PHP 5.5 support. But, we should allow developers to run tests with newer PHPUnit versions which are noticably faster (especially for code coverage reports). * <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0> PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock(). It instead introduces the shortcut createMock() which has better defaults than getMockBuilder(). For example, it sets 'disableArgumentCloning' and other things by default. Going forward, code should either use getMockBuilder directly and configure it using the setter methods (instead of the confusing variadic arguments of getMock) or simply use the new minimalistic createMock method. This patch backports the createMock method to MediaWikiTestCase so that we can start using it. Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
* Demote "throttler data not found" logs to info levelGergő Tisza2017-02-171-1/+1
| | | | | Bug: T158364 Change-Id: I049c2d6da4720341ef2a380879ac19aff444b1d0
* Support multiple limits and arbitrary periods in account creation throttlecenarium2016-09-221-8/+14
| | | | | | | | | | This adds support for multiple count-per-period limits and arbitrary period durations in the AuthManager account creation throttle in the wiki settings. The $wgAccountCreationThrottle config variable becomes an array like $wgPasswordAttemptThrottle. Bug: T146290 Change-Id: Iea182a92a1199b0ce7103ab9ae24f1c87b01985c
* Remove $wgDisableAuthManagerGergő Tisza2016-08-091-9/+0
| | | | Change-Id: I2b2c9693a275fcc026916bd97f303e7a5c8df341
* Add AuthManagerBrad Jorsch2016-05-161-0/+235
This implements the AuthManager class and its needed interfaces and subclasses, and integrates them into the backend portion of MediaWiki. Integration with frontend portions of MediaWiki (e.g. ApiLogin, Special:Login) is left for a followup. Bug: T91699 Bug: T71589 Bug: T111299 Co-Authored-By: Gergő Tisza <gtisza@wikimedia.org> Change-Id: If89d24838e326fe25fe867d02181eebcfbb0e196