Commit graph

13 commits

Author SHA1 Message Date
Kosta Harlan
6efd008f33 TempAccounts: Rate limit acquisition of temp account names
Why:

- We don't want to allow unlimited acquisition of temp account names.
  These should be rate limited in similar way to how we limit the
  creation of temp accounts

What:

- Provide a TempAccountNameAcquisitionThrottle, and use it in the
  acquireName() method
- Set a default that is 10 times the limit of
  TempAccountNameCreationThrottle

Depends-On: If660aad1d0f04f366414084aff3f88484a19d416
Bug: T343101
Change-Id: I99d5973498a89ac227847de5837c0a8e895c28fb
2024-04-23 13:33:57 +00:00
Dreamy Jazz
2e3bd68bec Add 'temp' flag to ApiQueryUserInfo API
Why:
* The ApiQueryUserInfo API returns 'anon' as true when the user
  making the request is an IP user.
* This API should return 'temp' if the user making the request is
  a temporary account, as described by T358683.

What:
* Return 'temp' with the value true from the ApiQueryUserInfo API
  when the user making the API request is a temporary user.
* Test that the temp user flag is added when the user making the
  request is a temporary user and that the flag is not added when
  the user is logged-out.

Bug: T358683
Change-Id: I5f165576a12a2218d89ab3623d7df45e2c9049fa
2024-02-28 17:21:30 +00:00
Reedy
75640200fb tests: Namespace api tests
Bug: T357823
Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
2024-02-18 15:47:04 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Amir Sarabadani
15a278189f Reorg: Move MWTimestamp to MediaWiki\Utils
Bug: T321882
Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
2023-08-19 05:53:40 +02:00
Daimona Eaytoy
4d5cd3a84f Replace deprecated MWException
Bug: T328220
Change-Id: I66be7a6dd752d6b9c254beb65f4eb5ace3c89776
2023-06-09 17:21:12 +02:00
Gergő Tisza
0024c71954 Add cancreateaccount property to userinfo API
Add a new action=query&meta=userinfo&uiprop=cancreateaccount
API property that checks whether the current user is allowed to
create accounts. This replaces the functionality removed from
list=users&usprop=cancreate in Ie94d61640301192b287275311f345,
and makes more sense - list=users is supposed to be about the
username (and re-called every time the username in the
registration form is changed), while meta=userinfo is about the
current user. It's also more accurate: it checks for all things
integrated with the permission system.

Change-Id: I0006500245a7c2bc3be0310ce9860b5771637a29
2022-08-31 11:51:18 +00:00
Umherirrender
ef0623ec06 tests/api: Add TestUser::getAuthority and use it
Change-Id: Icfb66f9927c8e67582010a208538b0b5e0ba353f
2022-08-06 23:15:27 +02:00
daniel
e239b02a5e Add convenience methods for asserting status.
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.

Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
2022-03-16 22:44:25 +01:00
DannyS712
cd58ec2a36 Tests: remove unneeded tearDown functions
No need to manually reset MWTimestamp fake time,
MediaWikiTestCaseTrait::fakeTimestampTearDown() does
that after all tests anyway.

Change-Id: Ie45e837c693d7f21b6c7e25471cdaad6f60a3de9
2021-07-27 13:15:40 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
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
2021-02-11 00:13:52 +00:00
Cindy Cicalese
f8e1fcacbb Use UserEditTracker in ApiQueryUserInfo::getLatestContributionTime()
Bug: T273788
Change-Id: I5d53fbe84dc3904f042a0f183d8d92b4f9695036
2021-02-07 15:52:58 -05:00
Cindy Cicalese
089e014e9f Add test to ApiQueryUserInfo for latestcontrib timestamp
Bug: T273788
Change-Id: I188402feee3a6ad6cb3198aedbabb5b3ca4d7fb8
2021-02-07 01:42:15 -05:00