jenkins-bot has submitted this change and it was merged.

Change subject: Remove uses of deprecated TestUser properties
......................................................................


Remove uses of deprecated TestUser properties

Change-Id: Ib44c66492e27516dfe205a5e428ebfd6b0fcdfd9
---
M tests/phpunit/includes/api/ApiLoginTest.php
M tests/phpunit/includes/api/ApiTestCase.php
M tests/phpunit/includes/api/ApiUploadTest.php
M tests/phpunit/includes/user/BotPasswordTest.php
4 files changed, 36 insertions(+), 26 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/includes/api/ApiLoginTest.php 
b/tests/phpunit/includes/api/ApiLoginTest.php
index 2f8ffcc..155a9dd 100644
--- a/tests/phpunit/includes/api/ApiLoginTest.php
+++ b/tests/phpunit/includes/api/ApiLoginTest.php
@@ -19,7 +19,7 @@
                        'wsTokenSecrets' => [ 'login' => 'foobar' ],
                ];
                $data = $this->doApiRequest( [ 'action' => 'login',
-                       'lgname' => '', 'lgpassword' => 
self::$users['sysop']->password,
+                       'lgname' => '', 'lgpassword' => 
self::$users['sysop']->getPassword(),
                        'lgtoken' => (string)( new MediaWiki\Session\Token( 
'foobar', '' ) )
                ], $session );
                $this->assertEquals( $wgDisableAuthManager ? 'NoName' : 
'Failed', $data[0]['login']['result'] );
@@ -29,6 +29,7 @@
                global $wgServer, $wgDisableAuthManager;
 
                $user = self::$users['sysop'];
+               $userName = $user->getUser()->getName();
                $user->getUser()->logout();
 
                if ( !isset( $wgServer ) ) {
@@ -36,7 +37,7 @@
                }
                $ret = $this->doApiRequest( [
                        "action" => "login",
-                       "lgname" => $user->username,
+                       "lgname" => $userName,
                        "lgpassword" => "bad",
                ] );
 
@@ -52,7 +53,7 @@
                        [
                                "action" => "login",
                                "lgtoken" => $token,
-                               "lgname" => $user->username,
+                               "lgname" => $userName,
                                "lgpassword" => "badnowayinhell",
                        ],
                        $ret[2]
@@ -74,12 +75,14 @@
                }
 
                $user = self::$users['sysop'];
+               $userName = $user->getUser()->getName();
+               $password = $user->getPassword();
                $user->getUser()->logout();
 
                $ret = $this->doApiRequest( [
                                "action" => "login",
-                               "lgname" => $user->username,
-                               "lgpassword" => $user->password,
+                               "lgname" => $userName,
+                               "lgpassword" => $password,
                        ]
                );
 
@@ -95,8 +98,8 @@
                        [
                                "action" => "login",
                                "lgtoken" => $token,
-                               "lgname" => $user->username,
-                               "lgpassword" => $user->password,
+                               "lgname" => $userName,
+                               "lgpassword" => $password,
                        ],
                        $ret[2]
                );
@@ -122,12 +125,14 @@
                        $this->markTestIncomplete( 'This test needs $wgServer 
to be set in LocalSettings.php' );
                }
                $user = self::$users['sysop'];
+               $userName = $user->getUser()->getName();
+               $password = $user->getPassword();
 
                $req = MWHttpRequest::factory( self::$apiUrl . 
"?action=login&format=xml",
                        [ "method" => "POST",
                                "postData" => [
-                                       "lgname" => $user->username,
-                                       "lgpassword" => $user->password
+                                       "lgname" => $userName,
+                                       "lgpassword" => $password
                                ]
                        ],
                        __METHOD__
@@ -146,8 +151,8 @@
 
                $req->setData( [
                        "lgtoken" => $token,
-                       "lgname" => $user->username,
-                       "lgpassword" => $user->password ] );
+                       "lgname" => $userName,
+                       "lgpassword" => $password ] );
                $req->execute();
 
                $cj = $req->getCookieJar();
@@ -162,11 +167,14 @@
        }
 
        public function testRunLogin() {
-               $sysopUser = self::$users['sysop'];
+               $user = self::$users['sysop'];
+               $userName = $user->getUser()->getName();
+               $password = $user->getPassword();
+
                $data = $this->doApiRequest( [
                        'action' => 'login',
-                       'lgname' => $sysopUser->username,
-                       'lgpassword' => $sysopUser->password ] );
+                       'lgname' => $userName,
+                       'lgpassword' => $password ] );
 
                $this->assertArrayHasKey( "login", $data[0] );
                $this->assertArrayHasKey( "result", $data[0]['login'] );
@@ -176,8 +184,8 @@
                $data = $this->doApiRequest( [
                        'action' => 'login',
                        "lgtoken" => $token,
-                       "lgname" => $sysopUser->username,
-                       "lgpassword" => $sysopUser->password ], $data[2] );
+                       "lgname" => $userName,
+                       "lgpassword" => $password ], $data[2] );
 
                $this->assertArrayHasKey( "login", $data[0] );
                $this->assertArrayHasKey( "result", $data[0]['login'] );
@@ -244,7 +252,7 @@
                        __METHOD__
                );
 
-               $lgName = $user->username . BotPassword::getSeparator() . 'foo';
+               $lgName = $user->getUser()->getName() . 
BotPassword::getSeparator() . 'foo';
 
                $ret = $this->doApiRequest( [
                        'action' => 'login',
diff --git a/tests/phpunit/includes/api/ApiTestCase.php 
b/tests/phpunit/includes/api/ApiTestCase.php
index e90b46f..31f3daa 100644
--- a/tests/phpunit/includes/api/ApiTestCase.php
+++ b/tests/phpunit/includes/api/ApiTestCase.php
@@ -158,8 +158,8 @@
 
                $data = $this->doApiRequest( [
                        'action' => 'login',
-                       'lgname' => $testUser->username,
-                       'lgpassword' => $testUser->password ] );
+                       'lgname' => $testUser->getUser()->getName(),
+                       'lgpassword' => $testUser->getPassword() ] );
 
                $token = $data[0]['login']['token'];
 
@@ -167,8 +167,8 @@
                        [
                                'action' => 'login',
                                'lgtoken' => $token,
-                               'lgname' => $testUser->username,
-                               'lgpassword' => $testUser->password,
+                               'lgname' => $testUser->getUser()->getName(),
+                               'lgpassword' => $testUser->getPassword(),
                        ],
                        $data[2]
                );
diff --git a/tests/phpunit/includes/api/ApiUploadTest.php 
b/tests/phpunit/includes/api/ApiUploadTest.php
index 873917e..de2b56b 100644
--- a/tests/phpunit/includes/api/ApiUploadTest.php
+++ b/tests/phpunit/includes/api/ApiUploadTest.php
@@ -27,11 +27,13 @@
         */
        public function testLogin() {
                $user = self::$users['uploader'];
+               $userName = $user->getUser()->getName();
+               $password = $user->getPassword();
 
                $params = [
                        'action' => 'login',
-                       'lgname' => $user->username,
-                       'lgpassword' => $user->password
+                       'lgname' => $userName,
+                       'lgpassword' => $password
                ];
                list( $result, , $session ) = $this->doApiRequest( $params );
                $this->assertArrayHasKey( "login", $result );
@@ -42,8 +44,8 @@
                $params = [
                        'action' => 'login',
                        'lgtoken' => $token,
-                       'lgname' => $user->username,
-                       'lgpassword' => $user->password
+                       'lgname' => $userName,
+                       'lgpassword' => $password
                ];
                list( $result, , $session ) = $this->doApiRequest( $params, 
$session );
                $this->assertArrayHasKey( "login", $result );
diff --git a/tests/phpunit/includes/user/BotPasswordTest.php 
b/tests/phpunit/includes/user/BotPasswordTest.php
index 1ef5082..cfd5f78 100644
--- a/tests/phpunit/includes/user/BotPasswordTest.php
+++ b/tests/phpunit/includes/user/BotPasswordTest.php
@@ -290,7 +290,7 @@
 
                // Wrong password
                $status = BotPassword::login(
-                       "{$this->testUserName}@BotPassword", 
$this->testUser->password, new FauxRequest );
+                       "{$this->testUserName}@BotPassword", 
$this->testUser->getPassword(), new FauxRequest );
                $this->assertEquals( Status::newFatal( 'wrongpassword' ), 
$status );
 
                // Success!

-- 
To view, visit https://gerrit.wikimedia.org/r/287228
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib44c66492e27516dfe205a5e428ebfd6b0fcdfd9
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to