Commit graph

8 commits

Author SHA1 Message Date
Alexander Vorwerk
872970a21c Drop some pre-7.4 php compat code
Change-Id: Ie92e4b2722692c64f38557bfcd3687168d245e8e
(cherry picked from commit eec198b245901d9a5dbe52a426e909ffbff32ac0)
2022-09-29 14:40:13 +00:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Kevin Israel
8408d4de47 Always encode spaces in cookie values as "%20"
I think the backward incompatible change to PHP (to no longer decode
plus signs in cookie values as spaces) was not properly justified, since
the cited RFC does not specify how a server should decode the value of a
cookie. Nevertheless, the change happened, so we work around it:

- Update setCookieEmulated() to match PHP 7.4.3, by using rawurlencode()
  instead of urlencode(). While tildes are no longer encoded as "%7E",
  that difference does not break backward compatibility.
- setCookieEmulated() is only called under PHP 7.2, and only if the
  SameSite attribute is set. Keep it that way by using an alternative
  workaround when possible: pass the return value of rawurlencode() to
  setrawcookie().
- This change only fixes the bug with respect to newly set or updated
  cookies. To fix the bug with respect to existing cookies, I wrote a
  backward compatible cookie parser and intend to commit it separately.

Bug: T291127
Change-Id: I7920ff4bbc7f8516d76daa2b39c585d02706cacd
2021-10-15 04:40:53 -04:00
Kunal Mehta
e5b85ae8f9 tests: Fix invalid @covers tags
And use the MediaWikiCoversValidator trait to ensure we don't regress.

Change-Id: I60a75eaf7b6b2606355e1f549050f7b0b8a990b9
2021-01-22 12:45:24 -08:00
Tim Starling
f8a7a1ace8 Support SameSite=None cookies
* Add $wgCookieSameSite, which controls the SameSite attribute for login
  cookies. This will need to be set to "None" on WMF and other wikis
  with a CentralAuth installation spanning multiple registrable domains.
* Add $wgUseSameSiteLegacyCookies, which causes a "legacy" cookie to be
  sent without a SameSite attribute whenever a SameSite=None cookie is
  sent. I used the prefix "ss0" since it's like SameSite version 0, and
  that's shorter than "legacy". It's a prefix instead of a suffix to
  avoid the need to update the VCL config which identifies cookie types
  by their name suffix.
* Simplify WebRequest::getCookie() removing the unnecessary unicode
  normalization. This was added by analogy with GET/POST, I don't
  believe it was ever necessary for cookies.
* Add WebRequest::getCrossSiteCookie(), which implements the read side
  of the legacy SameSite cookie support.
* Fix Doxygen formatting of the parameter list in
  WebResponse::setCookie().
* To work around the lack of SameSite cookie support in PHP 7.2, emulate
  setcookie() with header() where necessary.

Bug: T252236
Change-Id: I141ea114fea007a72a4f24bfc34dd81100854d68
2020-07-07 02:18:45 +01:00
Max Semenik
5bf93709f4 Move a lot of libs tests to the unit test directory
Change-Id: Ie7eb1016cd735f07b00524815598581e0d485f2a
2019-11-11 17:53:56 -08:00
Legoktm
4e35134f7a Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.

Reason for revert: Broke postgres tests.

Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
2019-06-13 23:00:08 +00:00
Máté Szabó
0a2b996278 Separate MediaWiki unit and integration tests
This changeset implements T89432 and related tickets and is based on exploration
done at the Prague Hackathon. The goal is to identify tests in MediaWiki core
that can be run without having to install & configure MediaWiki and its dependencies,
and provide a way to execute these tests via the standard phpunit entry point,
allowing for faster development and integration with existing tooling like IDEs.

The initial set of tests that met these criteria were identified using the work Amir did in
I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory
under phpunit/ and organized into a separate test suite. The environment for this suite
is set up via a PHPUnit bootstrap file without a custom entry point.

You can execute these tests by running:
$ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml

Bug: T89432
Bug: T87781
Bug: T84948
Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d
2019-06-13 22:56:31 +02:00