Commit graph

7 commits

Author SHA1 Message Date
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
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
2023-03-24 02:53:57 +00:00
daniel
2f8736f1d3 REST: introduce getPrivateRouteUrl
We need a way to determine the URL of routes that are not public,
and should be using $wgInternalServer rather than $wgCanonicalServer.

This patch also refactors some test code to make changes to the
constructor of the Router class less painful.

Bug: T311867
Change-Id: If1878365d019434bb862c643c2350b63479c9844
2022-07-14 13:12:35 +00:00
Bill Pirkle
7295100773 Allow REST API handlers to require csrf-safe session providers
Bug: T305043
Depends-On: Ic7c1b19b86e8a151e2d42aaec00ef0e89db77f08
Change-Id: Ic6bd48b400ecd839ef99b518ef955781470cd05c
2022-05-20 16:52:54 +00:00
Alexander Vorwerk
9b09bf3112 Use updated ObjectFactory namespace
Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324
Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9
Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5
Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
2022-03-09 23:04:51 +00:00
daniel
13acba25a0 REST: gracefully handle all exceptions.
ResponseFactory::createFromException already had support for arbitrary
exceptions, but Router was so far only using it for HttpExceptions,
leaving other kinds of exceptions uncaught.

In addition to catching all exceptions and generating an appropriate
JSON response for them, this patch introduces the ErrorReporter
interface, with an MWErrorReporter implementation which calls
MWExceptionHandler::rollbackMasterChangesAndLog(). This is how uncaught
errors are handled for requests coming in via api.php, so it seems
appropriate to use the same approach for requests coming in via
rest.php.

Bug: T285984
Change-Id: I0605a7693821ef58fac80ab67f51a742556a37fd
2021-11-02 20:33:13 +01:00
DannyS712
12ffb90aa8 Convert MWBasicRequestAuthorizerTest to a unit test
Already essentially a unit test, does not use any integration

Change-Id: I705c9e5fb04103f305e26b7cd677cf68fc7b73b5
2021-04-23 23:35:09 +00:00
Petr Pchelko
c1d5cbe561 Introduce CompoundAuthorizer to pass multiple authorizers
Change-Id: Icacad6fe95400e1ec9817fae0f9aa6edfe717b43
2020-09-22 00:25:38 +00:00