Commit graph

51 commits

Author SHA1 Message Date
thiemowmde 8662c467d8 Use upstream markTestSkippedIfExtensionNotLoaded in test
Change-Id: I3cf1698e0b6808829d14d5b736237962fce9b945
2024-08-16 15:59:25 +02:00
Fomafix ffce132ec7 Use overrideConfigValue instead of setMwGlobals
Change-Id: I09c1c2c009b5384532b53bae489c9af882091283
2024-07-29 20:55:45 +00:00
Umherirrender 954db277fc Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I3a7b448f3793f6690bb329a2e5255a558048ed5a
2024-06-10 22:05:45 +02:00
Umherirrender 9de38d445a tests: Ensure user exists in TitleBlacklistPreAuthenticationProviderTest
Change-Id: I63c4879baa3c03980f11590f1db729e27ce307e4
2023-12-28 00:53:21 +01:00
Umherirrender c5bee58799 tests: Add group Database to ApiTitleBlacklistTest
Change-Id: I14c964574d9ed6ac8ff6ca3ed5bab452d08d0b67
2023-09-26 21:45:34 +02:00
Umherirrender ffc9986a95 api: Rename php class behind action=titleblacklist
titleblacklist is not part of action=query (since a2f5ccd2 back in 2011)
and should not follow that naming schema.

No class alias as nobody needs to call the class directly

Change-Id: If57e5bd9291a894edf42835fed07d37cd8e8abed
2023-07-04 22:42:50 +02:00
Daimona Eaytoy bf76b5fe55 Remove redundant documentation from test
We generally do not put these instructions in every test. A README file
would be more appropriate, but since there isn't one, I'm not sure if
it's needed, especially because the instructions for running tests
should ideally be the same for all extensions, and those could be
documented in a single place.

In particular, remove reference to soon-to-be-deprecated phpunit.php and
other information that can easily be found in the first 10 lines of
code.

Bug: T90875
Change-Id: I97e6f608f8a3f11febf33c38811fe7692be59e24
2023-07-02 18:31:45 +02:00
Umherirrender d01b9a933c tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I6941b43f599063864de59bd7906beb082278fdea
2023-05-20 14:16:31 +02:00
Umherirrender 7ece0eddd0 tests: Use static provider in TitleBlacklistAuthenticationRequestTest
Shows up a deprecation message

Follow-Up: I5ff35ad0e894f0a27beae00257dc1fc599ad518d
Change-Id: I159d727d92ed1d5ca5721d9a290bff89c5922c8d
2023-05-19 22:27:21 +02:00
Thiemo Kreuz 4d2df71552 Various code style cleanups
E.g. reducing deep indention and code duplication. Removing comments
that literally repeat what the code says.

The goal is to make the code easier to read and to maintain in the
future. I hope this is the case.

Change-Id: I6f23bc61ffb8b6d42ec697fec91bb6c92152561f
2022-12-07 14:37:10 +01:00
Reedy 3113e6bf5f Namespace extension
Change-Id: I7917483168a3534d74b62dd2077026c0baa4cbe0
2022-04-08 14:24:11 +01:00
Amir E. Aharoni 1a9865db5c Rename black and white to allowed and disallowed
According to the discussions at Bug T254649 and Bug T254646
rename the lists to generic "allowed titles" and "disallowed titles"
lists.

The previous change was abandoned, probably because it tried
to say "blocklist", which can be confused for user blocking.
I see there is intention to merge this extension's functionality
into AbuseFilter, but until it happens, it would be nice
to rephrase the user-visible messages at least.

Also make the spelling of "username" and "case-insensitive" consistent
with core MediaWiki, and a few other copy editing fixes,
and fix some tests with these words.

Bug: T254650
Change-Id: I05ccc585325eb1610dd6b257a0b96ab43b0c8c8f
2021-11-06 21:09:27 +00:00
libraryupgrader 8779e481b4 build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: I822a1e9528c542fae3bae7d21d6c6d930b2bc88c
2021-07-24 02:49:35 +00:00
vladshapik 3025d83afc Replace uses of the deprecated setters of AbstractAuthenticationProvider
Since AbstractAuthenticationProvider ::setLogger, ::setManager,
::setConfig, ::setHookContainer methods had been soft deprecated,
so its usages were removed. AuthenticationProviderTestTrait
::initProvider was used in order to initialize
TitleBlacklistPreAuthenticationProvider in the test.
* Also bump required MW version to 1.37.0

Bug: T281994
Change-Id: I15b811a8596addad7a50b13d978851ebd86da9a5
2021-05-25 16:25:07 +00:00
Reedy 94f09be46b Add txt extension to testSource
Change-Id: I6241f4fcb74dde33fd3e17b24382e38f2d601bed
2020-06-07 14:03:14 +01:00
Umherirrender 1243bed54d Use MediaWikiServices::getAuthManager
This required MediaWiki 1.35

Change-Id: I40b1cfd33427cb0c0cc3b484525997f1d2263562
2020-04-12 00:00:28 +00:00
DannyS712 eac758d44a Remove use of ApiTestCase::doLogin
Since no user was passed, it defaults to the test sysop, and no
replacement is needed

Bug: T244039
Change-Id: Idbfcbcded52566218b70ae644f61cf2dcc2c7f11
2020-02-03 06:29:22 +00:00
James D. Forrester 412cea8fef build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I5fe2474773a665b398ed462859bb9d94efea9026
2019-10-11 12:19:14 -07:00
Thiemo Kreuz 8b2dd9cae3 Update unspecific "array" type documentation
Change-Id: Ic1120e726be71f09fa6ebd166d4992ee2c3a3a6b
2019-06-05 18:31:39 +02:00
Umherirrender 0b3b7f67f9 Use ExtensionRegistry rather than class_exists
Change-Id: I6788d31ce53868388c9cf9ddbf432f3397363018
2019-03-03 02:36:14 +01:00
zoranzoki21 3d957b51aa Upgrade TitleBlacklist extension to use newer version of phan
Bug: T216946
Change-Id: I70762433e25706487864c86980daa797d6c60f8d
2019-02-25 20:14:35 +00:00
James D. Forrester 277c88d44d Drop support for operation when wgDisableAuthManager is true
This global from MediaWiki was removed in 854a462 in 2016 but we didn't
clean up after it at the time.

Change-Id: I48f5d104e5350bd2ac170afc155015b8060e2ed5
2019-02-09 12:36:25 -08:00
Umherirrender 8f64795adf Add method scope visibility
Change-Id: Ic56c953e74fc42410d3037417978c46cff910def
2018-11-01 20:27:32 +01:00
Kunal Mehta aa2d12f5d0 Remove unnecessary addition to 'include_path' in tests
Change-Id: I775e6fc9eb39a974cfae507d09b705bf5fceb553
2018-10-11 22:32:16 -07:00
Aryeh Gregor f524ba0af4 Use setGroupPermissions instead of stashMwGlobals
It's shorter, and allows us to take advantage of any future improvements
to setGroupPermissions, such as automatically resetting affected
services.

Change-Id: Ie2d1ea65c0cb334bbde1666d00781474b7ac4dab
2018-10-07 16:09:54 +03:00
Kunal Mehta 928355054d build: Updating mediawiki/mediawiki-phan-config to 0.2.0
Change-Id: I71c824d1ccb8bd448fc7437cd3e760293b1fe097
2018-04-05 17:23:47 -07:00
Kunal Mehta 1bd1b64298 Add @covers tags
Change-Id: Ie8958e3a2d12f22b290ecc27bf078bb053f4c82f
2018-02-16 00:01:34 -08:00
Kunal Mehta ce26a81824 Migrate to mediawiki-phan-config
Change-Id: I8e05d8fafc5638b2b8d4c6dad73955545084d122
2018-02-15 14:37:12 -08:00
Rafid Aslam eac33eeff6 Add phan configuration for static analysis
Bug: T179554
Depends-On: I25beea963444b715bed7b2890475c0c812949520 
Change-Id: I83f9374b2f3236097860f4aecc694326b891905b
2017-12-25 19:31:23 +00:00
Umherirrender 354ea9bb02 build: Updating mediawiki/mediawiki-codesniffer to 0.10.0
Change-Id: I023422fc492220c86c827c45150ab81b734a26e8
2017-07-08 12:41:21 +02:00
Umherirrender 55d068708a Add phpcs and make pass
Change-Id: If5a2ec9700148eb842d6580945e51e1942a2e0ed
2017-06-06 18:18:36 +02:00
Umherirrender 968c6e8cd2 Break long lines
Prepare to make phpcs pass

Change-Id: I08a1b17d1861a7719ff71087fcbb82aae55f4948
2017-06-06 17:52:28 +02:00
Antoine Musso 8e09acc804 TitleBlacklistTest singleton can now be destroyed
The test suite set $wgTitleBlacklistSources with a fixture source of
directories.  Unfortunately when running tests from MediaWiki core the
TitleBlacklist has already been set with empty value and thus setting
the global is a noop.

That later causes a test to fail because the blacklist is emtpy.

Add TitleBlacklistTest::destroySingleton() so a test can reset the
singleton when changing $wgTitleBlacklistSources.

Since that is solely for testing, throw an exception unless we had
MW_PHPUNIT_TEST defined.

Bug: T155980
Change-Id: I99c3185811ed7b2225953fa6960096985e97c4d2
2017-01-23 17:41:03 +01:00
Reedy 1ebec92f0a Remove 'UnitTestList' hook
No longer needed now that extension unittests are autodiscovered.

Bug: T142120
Bug: T142121
Change-Id: Id86f4909e9c74c884ce33434717ad6993cbcc2bd
2016-08-05 17:38:12 +01:00
Brad Jorsch 49e8bf1d44 ApiQueryTitleBlacklistTest needs to restore globals
I guess this only ever worked before because none of the other tests
depended on these globals. Now that AuthManager is enabled by default,
one does.

Change-Id: If335fcc9b844a518b2c56bfa39153159261ae314
2016-05-31 10:57:14 -04:00
Gergő Tisza 17d3a9e313 Update for AuthManager
Bug: T110469
Change-Id: I9690d2fe6b172fcc85e1a8f7f91af21c6422d870
Depends-On: I8b52ec8ddf494f23941807638f149f15b5e46b0c
2016-05-12 00:23:11 +00:00
Alex Monk d372b43a75 Use extension registration, replace constants with some reasonable values, kill i18n shim
Bug: T87982
Change-Id: I9ab045da49179618d7c5558b2b066fba2736ae6e
2015-05-19 17:23:14 +01:00
Kunal Mehta 11841f7d8d spaces --> tabs
Change-Id: I11ba313f35b7d04a6f93c42f83f00a5e403bdf0a
2015-01-06 16:55:42 +00:00
Kunal Mehta 6863a39ed9 Optionally integrate with AntiSpoof
Introduces a new "antispoof" parameter. If set, try to normalize
the title using the AntiSpoof extension.

Bug: 53901
Change-Id: I9b3c5f5f5d9eeda65562fd83e21c9c2ba97e5569
2013-11-13 15:30:04 -08:00
Marius Hoch b6325e875b Fix the use of globals in ApiQueryTitleBlacklistTest
Change-Id: I5461277f06f336142f2de0aaf122a8ea767d74a4
2013-05-15 14:14:43 +02:00
Victor Vasiliev 52bab2daed (bug 36939) Introduce a way to limit username filter to certain sources.
* Name all sources and track them inside the entries. This should be
  fully backwards-compatible with previous configuration format,
  since numbers may be a legitimate source names as well.
* Introduce $wgTitleBlacklistUsernameSources as a variable which allows
  to specify which sources may be used for filtering usernames.

Change-Id: Ia2702370c85f317c763e345c8f92cb38e23e4196
2013-02-20 22:54:25 -08:00
Marius Hoch fc27474834 Fixing several issues with the titleblacklist API
I've fixed four issue with the API of this extension:
1. The extension always assumed the user wants to override the
   blacklist, if he's allowed to do so, but that's not the case.
   Introduced 'tbnooverride' to prevent that.
2. The API used actions not internally supported by
   TitleBlacklistEntry::matches() which made it impossible to check
   whether an account name is ok, if the regexp which would prevent
   this was set to new account only. Therefore I've introduced the
   new action 'new-account'.
3. Same as 2 for the 'upload'
4. The API always returned the 'titleblacklist-forbidden-edit'
   message, even if there was a more suitable one. Fixed that.

Example:
 https://meta.wikimedia.org/w/api.php?action=titleblacklist&tbtitle=User:Steward&tbaction=create
 (this should match the expression .*steward.* <newaccountonly> on
 https://meta.wikimedia.org/wiki/Title_blacklist but it doesn't)

Furthermore I've adjusted the unit tests slightly to test whether
tboverride works and whether <newaccountonly> works.

Change-Id: I2d948c84de39c6ee1c1eea7e6cd7b31506d6cb92
2012-10-27 14:41:15 +02:00
Siebrand Mazeland 16f32456ad Maintenance for TitleBlacklist extension.
* Use Message class.
* Remove trailing whitespace from 'titlewhitelist'.
* stylize.php.
* Update .gitignore.

Change-Id: Ie78fa25816808b0a695cc20630097326fb4cf705
2012-09-18 15:57:57 +02:00
Antoine Musso 506470fd79 tests: switch parameters in assertEquals()
assertEquals has the expect as first parameter.

Change-Id: Ic742aae7c84444817de7855b004695a32195d18a
2012-08-29 15:51:27 +02:00
Antoine Musso 31c466e0f7 tests: split listed/unlisted tests
Factored out common code in setup(), that also fixes the tests on my
local machine.

Change-Id: I4083c27842ccb475e2ce3cfbffb6cd35cbd15cc0
2012-08-29 13:47:38 +00:00
Sam Reed e6975d6152 Fix more comments 2011-10-14 21:30:16 +00:00
Ian Baker 74c1bef009 checking in tests that were missed in r93659 2011-08-01 22:44:54 +00:00
Ian Baker a9b8637fbe Added additional entry for non-automated testing
Added additional return data: raw blacklist line
switched to wfMessage from wfMsg
updated tests
followup to r92805
2011-07-29 17:19:51 +00:00
Ian Baker 039c877658 changed api output for blacklisted entries to be something more correct and informative ("error" is misleading).
followup to r93137
2011-07-28 20:32:48 +00:00
Ian Baker 4e57d6c1e9 Fixed unit test
Removed unnecessary method, re r92807
2011-07-23 00:23:09 +00:00