aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/preferences/SignatureValidatorTest.php
Commit message (Collapse)AuthorAgeFilesLines
* tests: Streamline a few overcomplicated if-else in test codethiemowmde2025-03-111-9/+5
| | | | | | | | I believe the code is quite a bit more readable like this. There is less indirection and less duplication. The tests still do the same as before. Change-Id: I501ccee89b37e2338bc07af3024a75f0e45e05b3
* Re-apply "Drop all 49 remaining class_aliases from MediaWiki 1.40"Daimona Eaytoy2025-03-051-0/+1
| | | | | | | | | This reverts commit 1695950bccb1ca7eba98952753708ae7c4b76d8d and re-applies commit I8f3c2ea021d0f6e. Reason for revert: the remaining usages have been updated in Ida665f486eff384. Bug: T166010 Change-Id: I43f06e6872b264e43aef7fa7c2ac47159926a694
* Revert "Drop all 49 remaining class_aliases from MediaWiki 1.40"Ahmon Dancy2025-03-041-1/+0
| | | | | | | | | This reverts commit db47e7f7154a2121bce6d3d9e93a74486bf765f3. Reason for revert: Broke scap sync-world in beta, and possibly caused T387938 Bug: T166010 Change-Id: If608c3e27081bb36b284ad16a5b912dd51b3557e
* Drop all 49 remaining class_aliases from MediaWiki 1.40James D. Forrester2025-03-041-0/+1
| | | | | | | Bug: T166010 Depends-On: Iba93dd9749656e641c427e01790d7a14cd1a2dc2 Depends-On: I97ccc2c49ce09ca96192bf6ffdc833c1765c3faa Change-Id: I8f3c2ea021d0f6e574dde901f0bfd4a0408f5455
* Use namespaced Title classUmherirrender2025-03-021-0/+1
| | | | Change-Id: Ic5f178b202574b937169a47faf1566bd62bf6ad3
* Revision: make RevisionRecord::getPage() return a value objectdaniel2025-01-081-0/+21
| | | | | | | | | | | | | | | | | | | | RevisionRecord::getPage() returns a PageIdentity, which may be a Title or a WikiPage. In the context of an ongoing page deletion, the state of these objects may change and the page ID may get set to 0. To provide a reliable stable interface that can be used e.g. in a deferred update or job, we need to return an immutable value object instead. NOTE: this may break callers of getPage() that downcast to Title, or that rely on the page ID contained in the returned PageIdentity to be updated dynamically during page creation or deletion. This is a modified version of I7440f8f30b05949. It reverts I4ed5406a8b3aa9, which reverted the original patch. The main difference to the original patch is the additional check in the constructor of the RevisionRecord base class and the regression test in SignatureValidatorTest. Bug: T380536 Change-Id: I0ea915983b6187090f46ad23c9b582196b4be85f
* tests: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | | Changes to the use statements and some additions are done automatically via script This also updates @covers tag for the namespaced classes Change-Id: I859ba6d05018c99710b744e2becab432410d3bca
* tests: Add missing documentation to class propertiesUmherirrender2024-09-181-0/+1
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: Ifc27750207edc09e94af030d882b6f1a5369cf98
* Add MediaWiki\Registration namespace to registration classesEbrahim Byagowi2024-08-101-0/+1
| | | | | Bug: T353458 Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
* Extract LintErrorChecker out of SignatureValidatorKunal Mehta2024-07-291-28/+0
| | | | | | | | | | | | This code was partially copied into MassMessage and will hopefully enable more places that accept arbitrary wikitext to check lint errors. It also hides the internal details of checking with the Linter extension's configuration in one place until it can be refactored into something more acceptable (T360809). Bug: T368690 Change-Id: Iaeb3ccbd61a2a8cb0d8b3dc8b06a3a10bc8fa653
* Re-enable test after parsoid vendor bumpArlo Breault2024-04-081-2/+1
| | | | | | Bug: T361858 Follows-Up: I0983aebfd435ab76191c232ecb543a9f0e42d778 Change-Id: If6812e77fd1e689aa3d11901f666a56b753f43eb
* Temporarily ignore test for parsoid vendor patch mergeIsabelle Hurbain-Palatin2024-04-081-0/+2
| | | | | | | | | | Ie09865d333cbc8df52edb46e7f00743fe94a6174 modifies the linter such that null values are not dropped anymore. This patch temporarily ignores a test whose behaviour is modified so that we can merge vendor patch and then reactivate the (modified) test. Bug: T361858 Change-Id: I0983aebfd435ab76191c232ecb543a9f0e42d778
* SignatureValidator: Don't fail signature validation on hidden lintsC. Scott Ananian2024-03-291-1/+93
| | | | | | Bug: T360809 Bug: T360796 Change-Id: Ia3512b5e7bb6eae6bfa9b9ae67611a9f977e6bb3
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-4/+4
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* SignatureValidator: Call Parsoid directly instead of via REST APIBartosz Dziewoński2023-08-091-0/+28
| | | | | | | | | I wrote this code before it was feasible to call Parsoid directly from MediaWiki code, but now it is, so let's get rid of all this indirection. This lets us add tests for this without mocking the whole world. Change-Id: I32fea6d0e309ca6f06b3a249fba6e9a311057ce4
* Fix more non-database tests accessing the databaseDaimona Eaytoy2023-08-061-0/+1
| | | | | | | | Mock the needed services, or set fixed values to avoid DB lookups, when possible. Add the test to the Database group otherwise, e.g. for things like Skin and Parser that use global state all over the place. Change-Id: I8d87013d89accaf04d0ac19cb4b7216290383eb5
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-3/+3
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Fix visibility of setUp methods in testsThiemo Kreuz2022-05-171-1/+1
| | | | Change-Id: Iefc05b4f4a9c258a385a22fc8d87b29648900e44
* preferences: Introduce SignatureValidatorFactory serviceDerick Alangi2021-12-141-5/+4
| | | | Change-Id: Ib8df0e76b81c8f3ad592f1caa3be86ac3597a0cf
* 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
* Check for line breaks in user signaturesBartosz Dziewoński2021-04-231-0/+18
| | | | | Bug: T272322 Change-Id: Ieac8be8839915a1ec4d547c2fc15d5fa9b27aca9
* Add missing @param and @return to documentation in testsUmherirrender2021-01-221-0/+1
| | | | Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
* preferences: Signature validation (lint errors, user links, nested subst)Bartosz Dziewoński2020-06-241-0/+104
Three new checks are now applied to user signatures in preferences: * Disallow invalid HTML and lint errors (T140606) Since 15e0e9bb4b we can rely on Parsoid to check the signature for lint errors. (The old PHP Parser doesn't have this capability.) Most importantly, this will disallow unclosed HTML tags. Unclosed formatting tags like `<i>` (and also wikitext markup like `''`) could affect the entire page with the bad markup. New configuration variable $wgSignatureAllowedLintErrors is added to allow ignoring some errors. The default value ignores the 'obsolete-tag' error (caused by HTML tags like `<font>` and `<tt>`.) * Require a link to user page, talk page or contributions (T237700) Various tools don't work correctly when such a link is missing. For example, Echo notifications are not sent, DiscussionTools will not allow replying to these comments, English Wikipedia's SineBot treats these comments as unsigned. Such requirement has been present for a long time in many Wikimedia wikis' policies, but it was not enforced by software. * Disallow "nested" substitution in signature (T230652) Clever abuse of "subst" markup and tildes allows users to save edits containing wikitext in which substitution occurs again when the page is next saved. Disallow this in signatures, at least. New configuration variable $wgSignatureValidation is added to control what we do about the result of the validation described above. The options are: * 'warning': Only displays a warning near the field on Special:Preferences if the current signature is invalid. Signatures can still be changed regardless of validity and will be used when signing comments. * 'new': In addition to the above, if a user tries to change their signature, the new one must be valid. Existing invalid signatures are still used when signing comments. * 'disallow': In addition to the above, existing invalid signatures are no longer used when signing comments. Bug: T140606 Bug: T237700 Bug: T230652 Change-Id: I07c575c2d9d2afe7a89c4847d16ac044417297bf