aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/integration/includes/user
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove or replace usages of "sanity"Reedy2021-11-213-6/+6
| | | | | | | Still some more to go... Bug: T254646 Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
* Replace `new stdClass` with more compact array syntaxThiemo Kreuz2021-11-021-9/+10
| | | | | | | It does the exact same. The resulting object is still an stdClass instance. Change-Id: Ief68609943ee30aa95732d24021c921dfbad166c
* phpunit: Fix parameter order on two assertSame() callsAlexander Vorwerk2021-10-121-3/+3
| | | | | | | The first parameter of assertSame() is the expected value, the second one the actual value. Change-Id: I5a411403443f18b30c93ab9552f625a70c75f75c
* tests: Avoid non-namespaced aliases for Wikimedia\Rdbms namespaceUmherirrender2021-09-181-1/+1
| | | | Change-Id: I49cb151f64c578f41dc1236b2a8906694ca97b93
* Merge "Make UserRightsProxy implement UserIdentity"jenkins-bot2021-09-091-1/+29
|\
| * Make UserRightsProxy implement UserIdentityAlexander Vorwerk2021-09-051-1/+29
| | | | | | | | | | | | | | This is done to allow a more easy transition away from UserRightsProxy. Bug: T255309 Change-Id: I730d28c12ad389e001f18c12662d220cb74f998e
* | tests: Use service container in integration tests casesDerick Alangi2021-09-051-2/+1
|/ | | | | | | | Since MediaWiki 1.36, this method is provisioned to replace creating new instances of the services object. If one is already created and seen by the service locator, just use it. Change-Id: I9509497a8380194aa93310343b1896521070fc31
* Add typehints to several methodsDaimona Eaytoy2021-08-311-3/+3
| | | | | | | | | | | | | These not only make the code more robust, but also help a lot when writing unit tests: if a method is return-typehinted and its class is mocked, the mock method will automatically return a mock of its declared return type. Otherwise it will return null, and developers are forced to manually mock the method if the return value is used by the SUT in a way that doesn't accept null. Depends-On: I628fcb1807133390c7b9b47984f512f5b1ae58d0 Depends-On: I7080bc505f5838b2f51a368da562104e206063b0 Change-Id: I59068cfed10aabf6c6002f9e9312a6ef6e7e9441
* Add tests for the UserRightsProxyAlexander Vorwerk2021-08-251-0/+201
| | | | Change-Id: I6e369fe37cecd783b1ed163ccb36cc5d4b5182a4
* Rename where* methods in UserSelectQueryBuilderTChin2021-08-041-5/+5
| | | | | Bug: T278254 Change-Id: I3f6d120b4426d8729b8db0336ce6db2b35163f71
* Merge "Support ActorStore::newSelectQueryBuilder with query flags"jenkins-bot2021-07-271-0/+6
|\
| * Support ActorStore::newSelectQueryBuilder with query flagsPetr Pchelko2021-07-211-0/+6
| | | | | | | | Change-Id: Ia731415f627d72811cf7a354721bb0fb28b128eb
* | 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
* | ActorStore: avoid throwing in case of invalid usernamesAlexander Vorwerk2021-05-191-15/+10
|/ | | | | | | | | When an username cannot be a valid actor, ActorStore::newUserIdentityByName() should return null instead of throwing an Exception. Bug: T283167 Change-Id: Id04978cf2a417f2354d5e336ed1b0b67462603e9
* Merge "ActorStore: Always canonicalize provided user name"jenkins-bot2021-05-031-12/+11
|\
| * ActorStore: Always canonicalize provided user namePetr Pchelko2021-04-291-12/+11
| | | | | | | | | | | | | | | | | | We don't actually know where is the given user name coming from and whether it's been normalized before hitting the storage layer, so always check if it's a valid user name. Bug: T273933 Change-Id: Ie9848188c81c95bedff9d18e6398bd3511c459e4
* | Replace uses of DB_MASTER with DB_PRIMARYJames D. Forrester2021-04-291-1/+1
|/ | | | | | Just an auto-replace from codesniffer for now. Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
* Add ActorStore::deleteActorPetr Pchelko2021-04-291-0/+24
| | | | | | | | | | This is an extremely dangerous method, but it's needed for the temporary users magic in translate extension. At least going via ActorStore we can keep our in-process caches consistent and get rid of some static methods and caching in user object. Change-Id: I8157f7ccee7d72aee405e9b6109dfc1838e1f380
* Keep ActorStore caches consistent on user renamePetr Pchelko2021-04-261-0/+17
| | | | | | | Multi-key in-memory keys for the actors is complicated enough to have it's own small abstraction. Change-Id: Id0e091504b71a44ce52d418c5737d64ac70495e9
* User: use ActorNormalization to insert actorPetr Pchelko2021-04-151-19/+141
| | | | | | | | | | | | | | | | | | | | | | While creating users, we have several interesting corner cases: - When creating a new User, we actually rely on the 'unique' constraint on actor_name. This is important if something calls 'User::createNew' with a name that is already occupied by an existing anon actor with no user. This is quite a weird corner case, but there's a test for that. We could probably assimilate this nicly in actor store by checking whether the user id in the database for the actor we found is the same as user id in the passed in user identity. - Even more interesting use-case is 'subsuming' existing actors with reserved user names. When we call User::newSystemUser, and there is already an actor with the same reserved name, we 'subsume' that actor and take over it's actor_id for our new system user. This can now be done with an upsert. This state of having reserved actor with no user is not easy to cause, but imports or updating from old MW versions seem to be able to produce this state. Archeology revealed that 'subsuming' existing actor was added for installer. Change-Id: I16b2f088217db0283215fc2ef5fb04a3742e1626
* Fix up ActorStoreTest with new UserIdentityValuePetr Pchelko2021-04-141-6/+6
| | | | Change-Id: I60e2dfef9f7c20c98b02f9fed341d4290ee6ca0b
* Merge "Remove $actor field from UsererIdentityValue"jenkins-bot2021-04-144-65/+76
|\
| * Remove $actor field from UsererIdentityValuedaniel2021-04-134-65/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code that needs to store an actor ID in the database to represent a UserIdentity, or needs to construct a UserIdentity based on an actor ID loaded from the database, should use the ActorNormalization service. Note: The getActorId() method is removed from the UserIdentity interface, but all concrete classes continue to support it for now. UsererIdentityValue::getActorId() is hard deprecated and should be removed in 1.37. It always returns 0. User::getActorId() is not deprecated at this point. Bug: T274179 Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237 Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
* | Merge "Rename WatchlistNotificationManager to WatchlistManager"jenkins-bot2021-04-081-93/+0
|\ \
| * | Rename WatchlistNotificationManager to WatchlistManagerCindy Cicalese2021-04-071-93/+0
| |/ | | | | | | Change-Id: Ic9707c6b74180ef111d128f9f00de218d191c175
* / Support User:0 in ActorStorePetr Pchelko2021-04-062-31/+48
|/ | | | | | | | | | | Surprizingly, PHP treats string "0" as false, so user name "0" was unconditionally rejected by ActorStore. Even more surprizingly, we actually have an actor with user name "0" [1], so we need to explicitly check for nulls instead of just checking for falsy. [1] https://en.wikipedia.org/wiki/User:0 Change-Id: I535c2aee3e109c3f535e40b747a1c7e4508171cb
* ActorStore: clean cache if transaction aborted.Petr Pchelko2021-03-221-0/+31
| | | | | | | | | | In case acquireActorId was called as a part of a larger transaction and it gets rolled back, we need to clean in-process caches in case something else would try to acquire actor ID for the same actor again within the same request. Bug: T277795 Change-Id: I912ebb380a1beead3043ac4c5653df947d613b99
* Deprecate UserIdentity::getActorId()daniel2021-03-131-5/+2
| | | | | | | Note: User::getActorId() is not (yet) deprecated. Bug: T274179 Change-Id: Ic2ca6d489db821fc2334e53bf2496c7b0d3ea5b1
* Merge "Convert Language to UserIdentity"jenkins-bot2021-03-111-0/+18
|\
| * Convert Language to UserIdentitydaniel2021-03-111-0/+18
| | | | | | | | | | | | This also introduces minimal instance caching into UserFactory Change-Id: I594c5668c537477516dda4beecd11b8aa840ae62
* | ActorNormalization should require a DB connection.daniel2021-03-101-19/+53
|/ | | | | | | | ActorNormalization should only be used in contexts where a DB connection is already being used, or at least easily available. Bug: T276986 Change-Id: Ie8aadaffa4a30e63fcad0502d45b8ec364fc79ef
* Avoid using UserIdentity::getUserIdVadim Kovalenko2021-03-022-8/+3
| | | | | | | | | Replace UserIdentity::getUserId with ::getId Add $wikiId = self::LOCAL as an optinal parameter to User and UserIdentity Bug: T275482 Change-Id: I44494845c469a14284c3e23cb620e5a7cbf59cd5
* Remove ActorStore::getUserIdentityByAnyId.Petr Pchelko2021-03-011-41/+0
| | | | | | | Adding this method was a mistake, there's no good use for is really. Change-Id: I0b2ecee7420573092f85f4e19da731a6bd56c50b
* ActorStore: introduce findActorIdByNamedaniel2021-03-013-3/+80
| | | | | | | | | | The findActorIdByName method is intended to be used when we need to select by actor ID, but all we have is a user name. We can't use findActorId(), since it requires a UserIdentity, which would needlessly force us to look up a user ID, resulting in two queries. Bug: T274179 Change-Id: I0e65d3258fd3d23ebff793ae04d59e027eb51fba
* Merge "UserQueryBuilder: abstraction for actor table queries."jenkins-bot2021-02-233-82/+324
|\
| * UserQueryBuilder: abstraction for actor table queries.Petr Pchelko2021-02-223-83/+325
| | | | | | | | | | | | | | | | | | | | | | | | This introduces a specialized SelectQueryBuilder for queries related to actor table. So far it's fairly basic, but in future it is intended to grow. This patch only introduces the new abstraction, using it will be separated into separate patches. Bug: T274223 Change-Id: Ibb1c58016e3956a46bfaf1a9f51f265114bb9ace
* | Merge "Add a few tests for ActorStore corner cases"jenkins-bot2021-02-221-1/+37
|\ \ | |/ |/|
| * Add a few tests for ActorStore corner casesPetr Pchelko2021-02-161-1/+37
| | | | | | | | Change-Id: Iba6c5d8fa15952cfef689f8f151f262aaff46417
* | Add caching to ActorStoreCindy Cicalese2021-02-221-0/+49
|/ | | | | | Bug: T273974 Depends-On: I8c18d86fe42056fbb676467a6657fd2f62e9c998 Change-Id: Iff5e3f07ac5b1192dd7a9f7f37589d8eae09a746
* Use static closures where safe to useUmherirrender2021-02-111-16/+16
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Use ActorStore in RevisionStorePetr Pchelko2021-02-101-0/+12
| | | | | Bug: T273290 Change-Id: Iff9b67455d337ea03cb728dd570c4ce760c39e49
* Reorder arguments in ActorStore::newActorFromRowFieldsPetr Pchelko2021-02-091-2/+2
| | | | | | | | | The order $userId, $name, $actorId is more consistent with existing order of arguments in UIV constructor, User::newFromAnyId etc. Even though it's not as logical as placing the primary key argument first, it's more practical. Change-Id: Ic36c0ee451cf6825976e374f0c2f721085c0a507
* Introduce ActorStore, ActorLookup and ActorFactory.Petr Pchelko2021-02-081-0/+574
| | | | | | | | | | | | | | | | | | The ActorNormalization factory methods create UserIdentityValue from the database rows, either via fields of a joined table, or via a row from actor table. They assume that the actor_id exist and throw othervise. ActorNormalization is a storage-layer service providing access to finding and acquiring actor_id. The UserIdentityLookup methods do not instantiate new actor on demand, they just find an appropriate row in the actor table and return the result. Bug: T272689 Depends-On: I74d81f3f0233efb17fc8df5178e4c477cc669c6f Change-Id: Icfa1daca960c696a8cef8adab5eab53985802858
* Add Authority to ContextPetr Pchelko2021-01-201-0/+12
| | | | | Bug: T271460 Change-Id: If1038c94ccf8f3e59b5242f5c33b66f076c60816
* Migrate more User::newFrom* methods to UserFactoryDannyS7122020-10-051-2/+1
| | | | | | Bug: T253432 Depends-On: If5e76f2ae570ef4ae58cb77b5281c4446a1cadff Change-Id: I9286d4a69911a84661cba40c55c0a4e3f1b7f7f3
* Inject dependencies into PasswordReset, and cleanupDannyS7122020-10-031-0/+14
| | | | | | | | | | | | | * Convert everything that is protected to be private, since the class is not stable to extend * Remove PasswordReset::$hookContainer, unneeded Additionally, add missing UserFactory::newFromRow, for now just a wrapper for User::newFromRow Bug: T253432 Change-Id: I1de57a08605ff6e0d2be8e276b7fcb08934fb5da
* UserFactory method for getting anonymous userNikki Nikkhoui2020-07-151-6/+28
| | | | | | | | Create a method in UserFactory to instantiate an anonymous user with an optional IP address. Bug: T257464 Change-Id: I557620f9bcd4b646288b4a76b26c4730fccbc3d8
* UserFactory v.1 - wrapper for User::newFrom* static methodsDannyS7122020-06-101-0/+123
| | | | | | | | | | | Makes it possible to mock static User methods in tests; actually introducing dependency injection to the User class is left for the future. New class has 100% code coverage Bug: T253432 Change-Id: I0b93da09124d95beafd84e932b214909ce920230
* Add new WatchlistNotificationManager serviceDannyS7122020-06-021-0/+93
Replaces watchlist notification methods in Title and User classes: * Title::getNotificationTimestamp -> ::getTitleNotificationTimestamp * User::clearNotification -> ::clearTitleUserNotifications * User::clearAllNotifications -> ::clearAllUserNotifications New service has 67.90% code coverage with pure Unit tests; as well as integration tests for the DeferredUpdates part A follow-up patch will deprecate the replaced methods, as well as document that the `UserClearNewTalkNotification` hook now only provides a UserIdentity (typehint added in T253435 but until now a full User was still provided). Bug: T208777 Change-Id: I6f388c04cb9dc65b20ff028ece607c3dc131dfc5