$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;
$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' );
$this->assertNotNull( $ret );
$this->assertSame( 'resetpass-validity-soft', $ret->msg->getKey() );
$this->assertFalse( $ret->hard );
+
+ $this->manager->removeAuthenticationSessionData( null );
+ $row->user_password_expires = null;
+ $status = \Status::newGood( [ 'forceChange' => true ] );
+ $status->error( 'testing' );
+ $providerPriv->setPasswordResetFlag( $userName, $status, $row );
+ $ret = $this->manager->getAuthenticationSessionData( 'reset-pass' );
+ $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() {
// Successful auth with reset
$this->manager->removeAuthenticationSessionData( null );
+ $this->validity = \Status::newGood( [ 'suggestChangeOnLogin' => true ] );
$this->validity->error( 'arbitrary-warning' );
$this->assertEquals(
AuthenticationResponse::newPass( $userName ),
);
// Correct handling of really old password hashes
- $this->config->set( 'PasswordSalt', false );
- $password = md5( 'FooBar' );
- $dbw->update( 'user', [ 'user_password' => $password ], [ 'user_name' => $userName ] );
- $req->password = 'FooBar';
- $this->assertEquals(
- AuthenticationResponse::newPass( $userName ),
- $provider->beginPrimaryAuthentication( $reqs )
- );
-
$this->config->set( 'PasswordSalt', true );
$password = md5( "$id-" . md5( 'FooBar' ) );
$dbw->update( 'user', [ 'user_password' => $password ], [ 'user_name' => $userName ] );
$ret = $provider->beginPrimaryAuthentication( $reqs );
$this->assertEquals( AuthenticationResponse::PASS, $ret->status, 'new password is set' );
}
-
}