From: Aryeh Gregor Date: Tue, 20 Mar 2018 15:43:01 +0000 (+0200) Subject: Improve test coverage for ApiLogin.php X-Git-Tag: 1.31.0-rc.0~298^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=c7778c31d552048711c5683b0784a0fdbc3e70ad Improve test coverage for ApiLogin.php I only made one small addition, because I don't understand login/session code well enough to easily do more. Change-Id: I36c5ea8e31fb00d75da24c38381f74ba8a15f31a --- diff --git a/tests/phpunit/includes/api/ApiLoginTest.php b/tests/phpunit/includes/api/ApiLoginTest.php index ed4d6834bc..d382c83c18 100644 --- a/tests/phpunit/includes/api/ApiLoginTest.php +++ b/tests/phpunit/includes/api/ApiLoginTest.php @@ -282,4 +282,20 @@ class ApiLoginTest extends ApiTestCase { $this->assertEquals( 'Success', $a ); } + public function testLoginWithNoSameOriginSecurity() { + $this->setTemporaryHook( 'RequestHasSameOriginSecurity', + function () { + return false; + } + ); + + $result = $this->doApiRequest( [ + 'action' => 'login', + ] )[0]['login']; + + $this->assertSame( [ + 'result' => 'Aborted', + 'reason' => 'Cannot log in when the same-origin policy is not applied.', + ], $result ); + } }