Commit graph

33 commits

Author SHA1 Message Date
Umherirrender
2909d06a08 Use new namespace for revision related classes
All revision related classes are namespaced MediaWiki\Revision
instead of MediaWiki\Storage since 1.32. The old namespaced
class names are deprecated and only kept for backwards-compatibility.

Bug: T305784
Change-Id: I34e492d84d9fc4bc78481667202716d93b3c43cb
2022-04-14 23:03:43 +02:00
DannyS712
91ac8a717d Add UserNameUtils to DummyServicesTrait, and use it
Allows us to reduce direct mocking in individual tests, or relying
on MediaWikiServices, by having a reusable service instead that
can be used in unit tests.

Make use of it in a few places.

This dummy service is also less coupled to individual tests;
in the rest handler tests, replacing mocks that report that
only a specific string is an ip address with the actual implementation
that accepts other ip address, and in BlockUtilsTest use
an actually invalid user name instead of making the mock
UserNameUtils complain about a perfectly valid name.

Change-Id: Iaa3195002ac4ae7e0c9c58ed57c80c02762d4070
2021-07-27 12:17:06 +00:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
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
2021-04-13 18:18:06 +00:00
Petr Pchelko
ea185c872e Rename Authority::getPerformer() to ::getUser()
We started to call Authority argument $performer everywhere,
and $performer->getPerformer() doesn't look that good.

Change-Id: Id2cf3f27b18340314e4ed1ea9931ad9404b4df6f
2021-03-04 12:45:28 -07:00
Petr Pchelko
375e9f0a68 Rename Authority::getActor to Authority::getPerformer
Bug: T274947
Change-Id: I8f652816af00bf9fa413ba4b1fa7ac4c27290dc2
2021-02-22 14:53:21 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Petr Pchelko
10de1d3472 Introduce MockAuthorityTrait for Authority test helpers
Change-Id: I152f2cbe8a7000eedc237fb46b4e4c6d2f9730d4
2021-01-21 20:19:12 -06:00
Petr Pchelko
3a2e8883b4 Rest: use Authority in all core handlers
Bug: T239753
Change-Id: Idf2229255f49514dd8b68bf63573c5b619b4f2f1
2021-01-21 18:22:33 -06:00
jenkins-bot
e47b3bc655 Merge "Split title mocking methods out of HandlerTestTrait." 2021-01-18 17:08:11 +00:00
Thiemo Kreuz
ac205fa84c Fix incomplete/bogus PHPDoc tags in various tests
Most of these are found by the not yet released I10559d8.

I remove the type MockObject in some cases when the calling
code really does not need to know if he get's a mock or the
real thing. However, I do this only in places that are very
closely related to the fixes.

Change-Id: I26a4c3c5a8ae141bf56161b52b54bce7e68f2e30
2021-01-14 19:02:00 +00:00
Petr Pchelko
7854dd5fc9 Split title mocking methods out of HandlerTestTrait.
The functionality of creating title mocks is generally useful
and this will also allow to make HandlerTestTrait more narrow.

Bug: T264058
Change-Id: I76eca48dfcff65a6203fccde5366912a2d66c495
2021-01-13 12:46:10 -06:00
Umherirrender
3f1c5d0eea Document list of change tags as string[]
Change-Id: I0ce2a8154af82a363fef126033b5819c4ee84842
2020-11-20 14:12:54 +01:00
Nikki Nikkhoui
783258900f UserContribs tags prop as array
Make the tags property in each contribution in
the User Contributions REST endpoint an array of tag
objects (instead of a key/value pair mapping tag names
to tag properties).

Bug: T259716
Change-Id: I8265ded81f05fef5f88d5a565266f91a307dd38c
2020-08-25 22:31:17 +00:00
jenkins-bot
d39861bdc3 Merge "UserContributions endpoint add tags 'display' property" 2020-08-19 13:47:53 +00:00
Nikki Nikkhoui
c26d64fc18 UserContributions endpoint add tags 'display' property
Add a property to the 'tags' object in the /user/{name}/contributions
REST endpoint named 'display' which shows the display
HTML for the tag which is either defined in i18n .json
files or overriden at MediaWiki:tag-$name

Bug: T259716
Depends-On: I57e2a7253944a3fde3f52f52bbf5fe8473c8a415
Change-Id: Id755adcab8b0115e19df2a6046643ebe97881e28
2020-08-19 06:04:50 -07:00
jenkins-bot
51bf53c9e5 Merge "Make array of tags with property 'text'" 2020-08-06 15:38:46 +00:00
Nikki Nikkhoui
c0f4b8a1eb Make array of tags with property 'text'
Change the tag property on each contribution from an
array of strings to an array of objects with property
'text'.

Bug: T252202
Bug: T235073
Change-Id: I9ececd1f351600e3e0fd54be2fb34449898285e1
2020-08-06 07:35:29 -07:00
Nikki Nikkhoui
5c9c1c5d7f Rename "name" to user in UserContributions
Rename path param "name" to user in UserContributions endpoints.
Name is more appropriate as "name" could be username as
well as IP address or range of IP addresses.
It also fits better with the implementation, as the
user parameter gets validated as a User object.

Bug: T259680
Change-Id: I6a146d99d1063c250f2ac460e4576bc287259766
2020-08-05 16:34:39 -07:00
Nikki Nikkhoui
3013ff9bdf Use UserDef in UserContribs endpoints
Change-Id: I9620e45ab1aa28dfa526705fce163ed5a27c4f86
2020-08-05 13:09:35 -07:00
Nikki Nikkhoui
3ba476102d /contributions/user/{user}/count
REST Endpoint for getting the number of contributions for a given
user (not yourself).

Change-Id: Ib3bfedcec0aa1af1983cec0a7bda28fc49ddc673
2020-07-28 18:36:41 +00:00
jenkins-bot
e2c07404df Merge "UserContributionsHandler: use UserFactory::newAnonymous" 2020-07-22 18:51:16 +00:00
daniel
4f5e7c4bfa UserContributionsHandler: use UserFactory::newAnonymous
Change-Id: Ic7d402903b63a5fba6dabd3569d9d6ee18d11b3a
2020-07-22 18:33:16 +02:00
Nikki Nikkhoui
43f2d5440f Rename 'revisions' to 'contributions'
Extensions have the ability to inject their own idea of what
a contribution is into the ContribsPager query resultset (via
the ContribsPager__reallyDoQueryHook). Because of this,
stable chronological ordering of ContribsPager results
becomes virtually impossible

For the purpose of the User Contribution REST endpoints, we will
restrict the resultset to ONLY mediawiki revisions for now.

This patch renames 'revisions' to 'contributions' and adds the
'type' field to future-proof work on adding different kinds of
contributions to the User Contribution REST endpoints.

Bug: T257838
Change-Id: I1e6de1c14a5f47e0310df86325fa6d791833addb
2020-07-22 18:29:29 +02:00
daniel
7717db62e1 REST /user/{name}/contribs
Bug: T235073
Change-Id: Ia262d055185c20142629d0824e4ba14a5e5fa9d3
2020-07-09 12:34:52 -07:00
daniel
2cf5a251b9 me/contributions: filter by tag
Bug: T251803
Change-Id: I5ba4164abe414df4b24858422f2a601e00516d7f
2020-07-02 22:27:21 +02:00
daniel
01b959fb83 UserContributions endpoint: return deltas
Bug: T252202
Change-Id: Ie38c658bddb974ded85a532b2fc556af5706275e
2020-06-26 11:44:57 +02:00
Nikki Nikkhoui
7452d8c067 REST /me/contributions: return change tags
The endpoint for user contributions should include change tags in the
result. Bump the version of npm module api-testing.

Bug: T252202
Change-Id: Iccc0c378bc65d0f34b38557f4c78f424d95a951f
2020-06-25 19:28:02 +02:00
daniel
96aacab20b UserContributions endpoint: filter suppressed revisions
ContributionsLookup needs to have the acting user (the authority) passde
in explicitly, so suppressed user contributions can be filtered according
to the user's permissions.

Bug: T252202
Change-Id: I94098f87ae45cd4e1db4a7168bf6e9478e9e32fc
2020-06-16 08:20:32 -07:00
daniel
5601152836 REST /me/contributions: implement backwards paging
This is part of a chain of patches that implement the user
contributions endpoint. This patch adds the ability to navigate
towards newer newer contributions from a response listign older
contributions.

Bug: T252202
Change-Id: I54c43f3c7bd5d2fa55431eda733291a7067bfc75
2020-06-15 11:41:36 -07:00
Nikki Nikkhoui
fbe321166e REST /me/contributions: allow paging forward
This is part of a chain of patches that implement the
user contributions endpoint.

In this patch, we add the ability to page through changes,
from latest to oldest only.

Bug: T252202
Change-Id: If1e862e419ce86b68606ddf28a78304461d3a6d8
2020-06-12 13:50:16 +02:00
Nikki Nikkhoui
3a6649c27e Fix failing UserContributionsHandlerTest
Some changes to UserContributionsHandlerTest.php were lost and were failing.
To fix, unused mock for ContributionsLookup::getParentRevisionSizes() was
removed. As well as supplying a new, anonymous user in
UserContributionsHandlerTest::testThatAnonymousUserReturns401()

Bug: T254909
Change-Id: I8aeb8a266369725014900487fa4ccbd8a83fb843
2020-06-09 14:23:56 -07:00
daniel
5ac84ffd12 REST /me/contributions: return revisions
This is part of a chain of patches to complete the REST User Contributions
endpoint. This change returns a list of the 2 (hard-coded for now) most
recent revisions for a given user.

Package.json was also updated for new api-testing module (v 1.1.0)

Bug: T252202
Change-Id: I42a5dfc0e1ff7600848e89ac2c4b002e8a3612df
2020-06-09 08:19:45 -07:00
Nikki Nikkhoui
300fcfd00b REST me/contributions: Returns 401 Unauthorized
This is the first in a chain of patches that iteratively create
the me/contributions endpoint that returns a list
of contributions by the currently logged in user.

This patch contains stubs for major classes needed
as well as implementation and test just for returning
a 401 Unauthorized for anonymous users.

Bug:T252202
Change-Id: Ib75711bb015f476e9d486cb3008eb7b06b148d00
2020-06-09 15:00:25 +00:00