aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/user/BotPasswordTest.php
Commit message (Collapse)AuthorAgeFilesLines
* BotPasswordTest: Add a few more test cases provideCanonicalizeLoginDataReedy2025-03-131-0/+4
| | | | | Bug: T388255 Change-Id: I6e1a6fa8e75f519ccbf3c2bb4de7334f620e2a8e
* user: Add filtered versions of CentralIdLookup::lookupUserNamesTim Starling2025-03-061-2/+2
| | | | | | | | | | | | | | | | * Add a batch version of CentralIdLookup::isOwned(), to support the linked bug. * Add test. * Fix error in LocalIdLookupTest::provideIsAttachedShared() which failed to provide the shared case due to an incorrect loop bound. This test has been non-functional since it was introduced in 2015. * Fix error in LocalIdLookupTest::newLookup() which failed to override the config. Bug: T386584 Depends-On: Ie63ed1f14c9ba4f9cefcceef05d5585a6676f111 Depends-On: I83716f7930bd0d2de4761cc5b04d9d3ff4172da2 Change-Id: I99dd733547f46e635c2f363166ce111e76e06a5e
* Use real type hints for services etc. in includes/auth/, session/, user/Bartosz Dziewoński2024-11-021-2/+1
| | | | | | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 More could be done, but to keep this patch reasonably sized, I only changed the most obvious and unambiguously correct cases. In some cases, I also removed redundant doc comments on the constructor, and re-ordered the properties to match the constructor. Bonus: Fix some todos in AuthManagerTest. Change-Id: Ife5313b821cf537984f6de364bfe1d9b4b992a07
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-0/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-0/+1
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* tests: Use namespaced classes (1)Umherirrender2024-06-141-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
* Merge "Use constants provided by MainConfigNames for config names"jenkins-bot2024-05-191-1/+1
|\
| * Use constants provided by MainConfigNames for config namesFunc2024-05-181-1/+1
| | | | | | | | Change-Id: I2f29ea8227da64b79b70fcce3decb6e34ea8da5b
* | Namespace includes/passwordReedy2024-05-181-0/+1
|/ | | | | Bug: T353458 Change-Id: I1a701b5b7ff65356692abb0efde9a2207b6135b6
* StatusValue: Document and deprecate broken ways to search/replace messagesBartosz Dziewoński2024-05-031-8/+5
| | | | | | | | | | | | | StatusValue::replaceMessage() doesn't really work if given a MessageSpecifier, and doesn't work at all if given a MessageValue. StatusValue::hasMessage() and ::hasMessagesExcept() ignore the message parameters when searching if given a MessageSpecifier or MessageValue. Therefore, deprecate passing anything other than strings representing message keys to these methods. Change-Id: Icb4effc6c5319c12ba4ebeab447a0cef54f8e255
* tests: Migrate to IDatabase::newInsertQueryBuilderUmherirrender2024-04-141-22/+20
| | | | | | | | | Changed some inserts to use multi-row insert for small performance benefit where possible and not already used. InsertQueryBuilder does not return a value, deprecated since 1.33 Bug: T353219 Change-Id: I2380ebc8ec8db178dd790247aefbdd798b6d62ff
* Remove IDBAccessObject from being implemented in many classesAmir Sarabadani2024-02-191-4/+4
| | | | | | | | | | | | This is inconsistent with the access pattern of other constants in MediaWiki. it's also confusing (e.g. it's unclear to a newcomer why UserFactory is implementing IDBAccessObject) and it's prone to clashes (e.g. BagOStuff class has a clashing constant). It has been already announced: https://w.wiki/9DAX Bug: T354194 Change-Id: Ic2357634b8385d65b55db2b557191419b06c40e0
* tests: Add Tests to PHP namespacingReedy2024-02-161-2/+3
| | | | Change-Id: I849268172751d50292e93aa75abe8094873f56bc
* Migrate bot passwords to virtual domainsAmir Sarabadani2024-02-011-1/+0
| | | | | Bug: T351559 Change-Id: I645f1e4a4517b9177286e834236b0c047bef928c
* tests: Use namespaced class names in @covers annotationsUmherirrender2024-01-271-1/+1
| | | | | | Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733 Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
* Introduce StatusFormatterdaniel2023-10-271-6/+6
| | | | | | | | | | | | | | | This takes us one step closer to deprecating Status, so we can isolate StatusValue from presentation logic. FormatterFactory is introduced as a mechanism for getting instance of formatters that need access to the user interface language and other request dependent information. Usage is demonstrated in thumb.php, SpecialCreateAccount, and SearchHandler. The examples indicates that there is no work do be done around ErrorPageError and LocalizedHttpException. Change-Id: I7fe5fee24cadf934e578c36856cc5d45fb9d0981
* Make use of assertStatusGood/Error and such in teststhiemowmde2023-10-041-17/+7
| | | | Change-Id: I11eace3d9823ca28a1d9a64f959f5f8ca2945821
* tests: Use $this->getDb() instead of wfGetDB() in integration testsAmir Sarabadani2023-09-251-2/+2
| | | | | | | Deprecated long time ago. Bug: T330641 Change-Id: Ia57f12d350c3346029aafae25534c9ed262a7e98
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-0/+2
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* Namespace remaining User-related classes under \MediaWiki\UserJames D. Forrester2023-09-201-0/+2
| | | | | Bug: T166010 Change-Id: Ibda1e8be0f23c6262a32b607f8260cad36f188fc
* In query builders, use insertInto() and deleteFrom() instead of insert() and ↵Tim Starling2023-09-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | delete() The design principle for SelectQueryBuilder was to make the chained builder calls look as much like SQL as possible, so that developers could leverage their knowledge of SQL to understand what the query builder is doing. That's why SelectQueryBuilder::select() takes a list of fields, and by the same principle, it makes sense for UpdateQueryBuilder::update() to take a table. However with "insert" and "delete", the SQL designers chose to add prepositions "into" and "from", and I think it makes sense to follow that here. In terms of natural language, we update a table, but we don't delete a table, or insert a table. We delete rows from a table, or insert rows into a table. The table is not the object of the verb. So, add insertInto() as an alias for insert(), and add deleteFrom() as an alias for delete(). Use the new methods in MW core callers where PHPStorm knows the type. Change-Id: Idb327a54a57a0fb2288ea067472c1e9727016000
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-251-0/+1
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* Fix space after comma in single-line array declarationAmir Sarabadani2023-07-241-1/+1
| | | | | | | | | We are introducing a new phpcs sniff to make sure this doesn't happen That sniff found this so far. Bug: T342297 Change-Id: Ibce3f3d28e7d2cb5b0ff7230f584e76446965ddc
* tests: Migrate calls to Database::update to UpdateQueryBuilderAmir Sarabadani2023-07-141-6/+5
| | | | | Bug: T330640 Change-Id: I30f9e84658fbd996b5512e96dda3f6412ebf3a20
* tests: Migrate Database::delete calls to DeleteQueryBuilderAmir Sarabadani2023-07-141-5/+4
| | | | | Bug: T340065 Change-Id: I92e85efd5d23d100a5df38aedb8edaecc5cbfc65
* tests: Use MainConfigNames consts to refer config namesUmherirrender2023-06-191-1/+1
| | | | | | PasswordSalt was dropped in 2e909bcb Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
* Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-1/+0
| | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-1/+1
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* tests: Simplify some nested ->will( $this->return assertionsReedy2022-11-121-1/+1
| | | | Change-Id: Ic861ce5604784b7fa600844d81387b84230bc0e1
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-281-0/+1
| | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-1/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+1
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* tests: Migrate away from `setMwGlobals()` to `overrideConfigValue(s)()`Derick Alangi2022-08-141-14/+11
| | | | Change-Id: I1b0e8e2cf4d85ae5ce8ad090cfc47f5086350702
* Get the MainConfig from MediaWikiServices instead of RequestContextUmherirrender2022-05-241-2/+2
| | | | | | | | | The getConfig of a ContextSource should only be used, if the ContextSource is available. Getting the global context just for the config looks harder to fix/inject as using the MainConfig from MediaWikiServices Change-Id: Iaf14bfc7bd68cc315672e1c256887faf87e22542
* BotPasswordSessionProvider: inject GrantsInfoAlexander Vorwerk2022-04-121-0/+1
| | | | | | | | MWGrants is deprecated and should be replaced with the GrantsInfo and the GrantsLocalization services. Bug: T253077 Change-Id: I3cbf568b6de654acb6b06b4ab5d9d97a09f78ece
* Add convenience methods for asserting status.daniel2022-03-161-2/+2
| | | | | | | This ensures that assertions work in a uniform way, and provides meaningful messages in cause of failure. Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-3/+2
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Remove or replace usages of "sanity"Reedy2021-11-211-10/+8
| | | | | Bug: T254646 Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Make CentralIdLookup a servicePetr Pchelko2021-06-241-2/+0
| | | | | | | | | | | This commit is a combination of work done by Tgr in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/571411 and MaxSem in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/594533 It was just easier to create a brand new patch then rebase old ones. Bug: T265767 Change-Id: I3930dab70846e95154d9089905c446e721ef4ee7
* Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-291-2/+2
| | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-221-9/+9
| | | | | | | | | | | | 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
* Tests: Mark more more closures as staticUmherirrender2021-02-091-2/+2
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Validate max length of bp_restrictions and bp_grantsReedy2020-12-051-6/+54
| | | | | | Bug: T260631 Bug: T260633 Change-Id: Ifc35e01c711f1394f45748f693e7a46695b2d471
* 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
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Hard deprecate Password::equals()Max Semenik2019-04-121-4/+8
| | | | Change-Id: I8d655a4f7a57f2186b1457d956af74bf21d4db08
* Improve ApiLogin test coverageAryeh Gregor2018-10-101-4/+4
| | | | | | | | | | | | | Coverage is 100% except for one session-related bit that seems a bit involved to test right now. It looks like it will be easier once SessionManager becomes a service. I removed the third parameter from the return value of canonicalizeLoginData, since af37a4c7 made it always return true. I also removed three lines of dead code from ApiLogin.php. Change-Id: Ia0073eddd27c82827518e0031e3c313f83cfd7cc
* Add PasswordFactory to MediaWikiServicesKunal Mehta2018-08-021-4/+3
| | | | | | | | | | | | | | | Instead of having basically every caller do: $pf = new PasswordFactory(); $pf->init( RequestContext::getMain()->getConfig() ); Just create a single PasswordFactory via MediaWikiServices and pass that around. Things that want to use their own config can still pass settings via the new constructor. This will eventually let us remove the init() function, removing the only hard dependency upon MediaWiki, to make it easier to librarize (T89742). Change-Id: I0fc7520dc023b11a7fa66083eff7b88ebfe49c7b