Improve test coverage for ApiLogin.php
authorAryeh Gregor <ayg@aryeh.name>
Tue, 20 Mar 2018 15:43:01 +0000 (17:43 +0200)
committerAryeh Gregor <ayg@aryeh.name>
Wed, 21 Mar 2018 17:57:27 +0000 (19:57 +0200)
I only made one small addition, because I don't understand login/session
code well enough to easily do more.

Change-Id: I36c5ea8e31fb00d75da24c38381f74ba8a15f31a

tests/phpunit/includes/api/ApiLoginTest.php

index ed4d683..d382c83 100644 (file)
@@ -282,4 +282,20 @@ class ApiLoginTest extends ApiTestCase {
                $this->assertEquals( 'Success', $a );
        }
 
                $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 );
+       }
 }
 }