Merge "Improve test coverage for ApiLogin.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 23 Mar 2018 17:34:10 +0000 (17:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 23 Mar 2018 17:34:10 +0000 (17:34 +0000)
tests/phpunit/includes/api/ApiLoginTest.php

index ed4d683..d382c83 100644 (file)
@@ -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 );
+       }
 }