Merge "rdbms: cleanup code for read-only propagation for master connections"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / LocalPasswordPrimaryAuthenticationProviderTest.php
index e1b25a1..6d831f6 100644 (file)
@@ -38,11 +38,11 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
                        $this->manager = new AuthManager( new \FauxRequest(), $config );
                }
                $this->validity = \Status::newGood();
-
                $provider = $this->getMockBuilder( LocalPasswordPrimaryAuthenticationProvider::class )
                        ->setMethods( [ 'checkPasswordValidity' ] )
                        ->setConstructorArgs( [ [ 'loginOnly' => $loginOnly ] ] )
                        ->getMock();
+
                $provider->expects( $this->any() )->method( 'checkPasswordValidity' )
                        ->will( $this->returnCallback( function () {
                                return $this->validity;
@@ -167,7 +167,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
 
                $this->manager->removeAuthenticationSessionData( null );
                $row->user_password_expires = null;
-               $status = \Status::newGood();
+               $status = \Status::newGood( [ 'suggestChangeOnLogin' => true ] );
                $status->error( 'testing' );
                $providerPriv->setPasswordResetFlag( $userName, $status, $row );
                $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
@@ -184,6 +184,14 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
                $this->assertNotNull( $ret );
                $this->assertSame( 'resetpass-validity', $ret->msg->getKey() );
                $this->assertTrue( $ret->hard );
+
+               $this->manager->removeAuthenticationSessionData( null );
+               $row->user_password_expires = null;
+               $status = \Status::newGood( [ 'suggestChangeOnLogin' => false, ] );
+               $status->error( 'testing' );
+               $providerPriv->setPasswordResetFlag( $userName, $status, $row );
+               $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
+               $this->assertNull( $ret );
        }
 
        public function testAuthentication() {
@@ -275,6 +283,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
 
                // Successful auth with reset
                $this->manager->removeAuthenticationSessionData( null );
+               $this->validity = \Status::newGood( [ 'suggestChangeOnLogin' => true ] );
                $this->validity->error( 'arbitrary-warning' );
                $this->assertEquals(
                        AuthenticationResponse::newPass( $userName ),
@@ -664,5 +673,4 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiTestCase
                $ret = $provider->beginPrimaryAuthentication( $reqs );
                $this->assertEquals( AuthenticationResponse::PASS, $ret->status, 'new password is set' );
        }
-
 }