Commit graph

24 commits

Author SHA1 Message Date
Umherirrender 1cfba87b23 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I60968f9b735b27eaef20e5d42af322a8c2ecd257
2024-10-19 23:34:41 +02:00
jenkins-bot 31c26eaa77 Merge "Fix confusing usages of TestingAccessWrapper" 2024-09-17 23:27:24 +00:00
jenkins-bot bac39ab8fe Merge "Use more trivial HashConfig in CaptchaTest" 2024-09-17 11:13:21 +00:00
thiemowmde 8180e6450d Fix confusing usages of TestingAccessWrapper
Some of this is not necessary at all because all properties are
public anyway.

In other cases only one property needs to use the wrapper, the rest
is public and can be accessed normally.

In other cases we just missed the @var annotation to make the IDE
aware of what's actually going on.

Change-Id: I29b526ee3aad9f0c9671fb133c625b9f14309db9
2024-09-17 08:53:41 +00:00
thiemowmde 7913547820 Use more trivial HashConfig in CaptchaTest
HashConfig is a rather trivial value class with not much behavior.
The complexity of an actual moc is not needed here, it seems.

Change-Id: I80025e67f248889ffff4d7237793e7d83dd269d5
2024-09-17 06:58:43 +00:00
thiemowmde 9639f30ed5 Merge trivial @dataProviders in CaptchaTest
These providers don't really do anything but provide the two possible
booleans. That's it. Why not make the code say that?

Change-Id: I0cbca6222e8130d504494ae86b1a963a92430a61
2024-09-13 13:02:24 +02:00
Fomafix 07646e4a65 Replace setMwGlobals by overrideConfigValue/overrideConfigValues
Change-Id: If63e84d8101f2169f684c4db822f7df907d2deec
2024-07-22 13:33:09 +00:00
Kosta Harlan 3b195090fe SimpleCaptcha: Allow invoking CAPTCHA display from other extensions
Why:

- In the production WMF deployment of AbuseFilter and ConfirmEdit, we
  load ConfirmEdit first, then AbuseFilter. That means that
  ConfirmEdit's onEditFilterMergedContent hook fires before
  AbuseFilter's. The problem is that AbuseFilter uses
  onEditFilterMergedContent to evaluate its rules and consequences, so
  an AbuseFilter rule that defines a "showcaptcha" consequence becomes a
  no-op, as it fires after ConfirmEdit has already decided to show or
  not show a CAPTCHA to a user.
 - All of that is to say: we need a way to tell ConfirmEdit to show a
   CAPTCHA at the time that AbuseFilter's consequences are invoked,
   which could be before or after ConfirmEdit's EditFilterMergedContent
   hook invocation, depending on how the wiki has decided to load the
   extensions

What:

- Define a flag for "shouldForceShowCaptcha", that other extensions can
  set on the SimpleCaptcha base class to indicate that ConfirmEdit must
  show a CAPTCHA (users with "skipcaptcha" right are still exempt)
- Check the isCaptchaSolved() and shouldForShowCaptcha() flags in
  ::triggersCaptcha, and also check if ConfirmEdit's
  EditFilterMergedContent hook already ran
- In CaptchaConsequence, set the forceShowCaptcha property on the
  SimpleCaptcha base class
- [misc] Add getter/setter for the captchaSolved property and the other
  new class properties

Depends-On: I7dd3a7c41606dcf5123518c2d3d0f4355f5edfd3
Bug: T20110
Change-Id: Idc47bdae8007da938f31e1c0f33e9be4813f41d7
2024-06-26 16:07:44 +00:00
Umherirrender 81d0c7bcd4 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I325f5bab163cddf76dbf8d5a6eca35a7ed7b6df7
2024-06-08 23:46:45 +02:00
Umherirrender 92bc1f3d2f Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: Id44f211320e56bc83e4c8f243369dc4eb562cf37
2023-12-11 00:07:55 +01:00
gerritbot 4bc5e7ed8f Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I639a03a5f828d7036e29a11a8a45d8d1e8923590
2023-08-19 04:14:21 +00:00
Umherirrender 1a440848fa tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I74e62a477cb8657da93180cd71432a95e70fff4b
2023-05-20 11:59:50 +02:00
Reedy 30cd1d8a23 Namespace base classes
Change-Id: I3fa9747e0ea970c5de39e2da8603e1bba9388a69
2022-07-30 18:13:03 +00:00
daniel 5770d44639 tests: Remove access to private ExtensionProcessor::globalSettings variable
It's internal, extensions should not rely on it. And now it is being removed.

Needed-By: I85324d04ecde38aad5f827c7aa33d989089e6d33
Change-Id: Id981f5f110789c5b7daa64185ec8ad952914ab48
2022-03-11 21:50:21 +00:00
Alexander Vorwerk 9ee7caa78e MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: Iba498b9107753233b4fbb1f8d435663199635507
2021-11-29 19:54:25 +00:00
libraryupgrader 81a524e2e9 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.0 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I57837ebf8054a2e968d207fecb3f12397c18e2a2
2021-07-22 14:24:25 +00:00
Umherirrender 91ecfa4ddd Remove incomplete @param from test function
the @dataProvider should be a enough here

Change-Id: Id9396e8baf734a028eda5dde5caeb8ac98cf1606
2021-01-23 01:36:10 +01:00
Daimona Eaytoy f85f9f14f8 Remove PPHUnit 4 bc stuff
Bug: T192167
Change-Id: I825b694550c11942cd9aa352f370894133b12c7b
2019-10-13 11:34:12 +02:00
James D. Forrester 86246f0172 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I12c3660e74e42937f6cfb31ec4771a67d8651f42
2019-10-09 15:45:51 -07:00
Aryeh Gregor 4228dbd2b7 Do not reset extension registry in tests
This breaks later tests, e.g.:

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/450433
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/465423

The only reason this didn't cause test failures until now is because the
namespace data was getting (incorrectly) cached in between tests.  As
soon as we start resetting namespaces for each test, namespaces set by
the extension registry get wiped out by these tests.

Change-Id: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d
2019-04-09 20:29:49 +03:00
Kunal Mehta 9fc9337fca Use new ExtensionRegistry::setAttributeForTest() in tests
So we don't need to hackily deal with ExtensionRegistry internals.

Depends-On: I9e62a02ed2044c847e9ab2dcdfab094001f88986
Change-Id: Id6ca6eb49db789dbb3f227533c4442506cc61bc4
2019-01-14 10:34:22 -08:00
Eddie Greiner-Petter 2848a699db Move "can user skip captchas" check to own function
As a direct effect
- sending emails and creating accounts now respects $wgAllowConfirmedEmail
- log messages get a bit less verbose for mail sending and creating
  accounts (but should be clear from the context what action was
  performed)
- less code duplication \o/

Indirectly, this should make solving the attached bug easy(tm), because it
just needs to add a hook to the canSkipCaptcha function.

Bug: T176589
Change-Id: Id27b0eadbab7300b9e6969d406fa6f00ef0888bf
2018-05-19 13:27:04 +00:00
Kunal Mehta e1f45829d4 Add @covers tags
Change-Id: I1e99261acb13c86e96c1b2dd1cb61918ebc660c2
2018-01-23 15:59:08 -08:00
Florian Schmidt 50bc57a200 Allow other extensions to setup triggers using attributes
Instead of misusing the config section of extension.json to declare
captcha triggers in the ConfirmEdits CaptchaTriggers config variable,
other extensions can now use the CaptchaTriggers attribute for the
exact same thing. E.g., to declare a new trigger, the following
addition to the own extension.json will register the trigger in
ConfirmEdit:

  "CaptchaTriggers": {
    "wikiforum": true
  }

This also removes the CaptchaClass config from the main extension.json
config section, and automatically sets the SimpleCaptcha module in the
getInstance() method of ConfirmEditHooks, which is a pre-requirement for
the mediawiki/core change Ieeb26011e42c741041d2c3252238ca0823b99eb4.

Bug: T152929
Change-Id: I4c5eaf87657f5dc07787480a2f1a56a1db8c714f
2017-09-02 17:45:26 +02:00