Merge "tests: Avoid dynamic properties in auth tests"
This commit is contained in:
commit
dd4461c17d
4 changed files with 72 additions and 74 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Auth;
|
||||
|
||||
use DynamicPropertyTestHelper;
|
||||
use Exception;
|
||||
use Language;
|
||||
use MediaWiki\Auth\Hook\AuthManagerLoginAuthenticateAuditHook;
|
||||
|
|
@ -1028,9 +1029,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
// Set up lots of mocks...
|
||||
$req = new RememberMeAuthenticationRequest;
|
||||
$req->rememberMe = (bool)rand( 0, 1 );
|
||||
$req->pre = $preResponse;
|
||||
$req->primary = $primaryResponses;
|
||||
$req->secondary = $secondaryResponses;
|
||||
$mocks = [];
|
||||
foreach ( [ 'pre', 'primary', 'secondary' ] as $key ) {
|
||||
$class = ucfirst( $key ) . 'AuthenticationProvider';
|
||||
|
|
@ -1052,15 +1050,15 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
$mocks['pre']->expects( $this->once() )->method( 'testForAuthentication' )
|
||||
->willReturnCallback( function ( $reqs ) use ( $req ) {
|
||||
->willReturnCallback( function ( $reqs ) use ( $req, $preResponse ) {
|
||||
$this->assertContains( $req, $reqs );
|
||||
return $req->pre;
|
||||
return $preResponse;
|
||||
} );
|
||||
|
||||
$ct = count( $req->primary );
|
||||
$callback = $this->returnCallback( function ( $reqs ) use ( $req ) {
|
||||
$ct = count( $primaryResponses );
|
||||
$callback = $this->returnCallback( function ( $reqs ) use ( $req, &$primaryResponses ) {
|
||||
$this->assertContains( $req, $reqs );
|
||||
return array_shift( $req->primary );
|
||||
return array_shift( $primaryResponses );
|
||||
} );
|
||||
$mocks['primary']->expects( $this->exactly( min( 1, $ct ) ) )
|
||||
->method( 'beginPrimaryAuthentication' )
|
||||
|
|
@ -1073,12 +1071,12 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->willReturn( PrimaryAuthenticationProvider::TYPE_LINK );
|
||||
}
|
||||
|
||||
$ct = count( $req->secondary );
|
||||
$callback = $this->returnCallback( function ( $user, $reqs ) use ( $id, $name, $req ) {
|
||||
$ct = count( $secondaryResponses );
|
||||
$callback = $this->returnCallback( function ( $user, $reqs ) use ( $id, $name, $req, &$secondaryResponses ) {
|
||||
$this->assertSame( $id, $user->getId() );
|
||||
$this->assertSame( $name, $user->getName() );
|
||||
$this->assertContains( $req, $reqs );
|
||||
return array_shift( $req->secondary );
|
||||
return array_shift( $secondaryResponses );
|
||||
} );
|
||||
$mocks['secondary']->expects( $this->exactly( min( 1, $ct ) ) )
|
||||
->method( 'beginSecondaryAuthentication' )
|
||||
|
|
@ -1123,7 +1121,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
}
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$p->postCalled = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', false );
|
||||
$p->expects( $this->atMost( 1 ) )->method( 'postAuthentication' )
|
||||
->willReturnCallback( function ( $userArg, $response ) use ( $user, $constraint, $p ) {
|
||||
if ( $userArg !== null ) {
|
||||
|
|
@ -1132,7 +1130,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
}
|
||||
$this->assertInstanceOf( AuthenticationResponse::class, $response );
|
||||
$this->assertThat( $response->status, $constraint );
|
||||
$p->postCalled = $response->status;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', $response->status );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
@ -1203,7 +1201,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->assertNull( $session->getSecret( AuthManager::AUTHN_STATE ),
|
||||
"Response $i, session state" );
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertSame( $response->status, $p->postCalled,
|
||||
$this->assertSame( $response->status, DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ),
|
||||
"Response $i, post-auth callback called" );
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1219,7 +1217,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
"Response $i, continuation check"
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertFalse( $p->postCalled, "Response $i, post-auth callback not called" );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ), "Response $i, post-auth callback not called" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2117,11 +2115,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
// Set up lots of mocks...
|
||||
$req = $this->getMockForAbstractClass( AuthenticationRequest::class );
|
||||
$req->preTest = $preTest;
|
||||
$req->primaryTest = $primaryTest;
|
||||
$req->secondaryTest = $secondaryTest;
|
||||
$req->primary = $primaryResponses;
|
||||
$req->secondary = $secondaryResponses;
|
||||
$mocks = [];
|
||||
foreach ( [ 'pre', 'primary', 'secondary' ] as $key ) {
|
||||
$class = ucfirst( $key ) . 'AuthenticationProvider';
|
||||
|
|
@ -2135,7 +2128,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$mocks[$key]->method( 'testForAccountCreation' )
|
||||
->willReturnCallback(
|
||||
function ( $user, $creatorIn, $reqs )
|
||||
use ( $username, $creator, $req, $key )
|
||||
use ( $username, $creator, $req, $key, $preTest, $primaryTest, $secondaryTest )
|
||||
{
|
||||
$this->assertSame( $username, $user->getName() );
|
||||
$this->assertSame( $creator->getId(), $creatorIn->getId() );
|
||||
|
|
@ -2146,8 +2139,13 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$foundReq = $foundReq || get_class( $r ) === get_class( $req );
|
||||
}
|
||||
$this->assertTrue( $foundReq, '$reqs contains $req' );
|
||||
$k = $key . 'Test';
|
||||
return $req->$k;
|
||||
if ( $key === 'pre' ) {
|
||||
return $preTest;
|
||||
}
|
||||
if ( $key === 'primary' ) {
|
||||
return $primaryTest;
|
||||
}
|
||||
return $secondaryTest;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -2166,8 +2164,8 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->willReturn( PrimaryAuthenticationProvider::TYPE_CREATE );
|
||||
$mocks['primary']->method( 'testUserExists' )
|
||||
->willReturn( false );
|
||||
$ct = count( $req->primary );
|
||||
$callback = $this->returnCallback( function ( $user, $creatorArg, $reqs ) use ( $creator, $username, $req ) {
|
||||
$ct = count( $primaryResponses );
|
||||
$callback = $this->returnCallback( function ( $user, $creatorArg, $reqs ) use ( $creator, $username, $req, &$primaryResponses ) {
|
||||
$this->assertSame( $username, $user->getName() );
|
||||
$this->assertSame( $creator->getName(), $creatorArg->getName() );
|
||||
$foundReq = false;
|
||||
|
|
@ -2176,7 +2174,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$foundReq = $foundReq || get_class( $r ) === get_class( $req );
|
||||
}
|
||||
$this->assertTrue( $foundReq, '$reqs contains $req' );
|
||||
return array_shift( $req->primary );
|
||||
return array_shift( $primaryResponses );
|
||||
} );
|
||||
$mocks['primary']->expects( $this->exactly( min( 1, $ct ) ) )
|
||||
->method( 'beginPrimaryAccountCreation' )
|
||||
|
|
@ -2185,8 +2183,8 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->method( 'continuePrimaryAccountCreation' )
|
||||
->will( $callback );
|
||||
|
||||
$ct = count( $req->secondary );
|
||||
$callback = $this->returnCallback( function ( $user, $creatorArg, $reqs ) use ( $creator, $username, $req ) {
|
||||
$ct = count( $secondaryResponses );
|
||||
$callback = $this->returnCallback( function ( $user, $creatorArg, $reqs ) use ( $creator, $username, $req, &$secondaryResponses ) {
|
||||
$this->assertSame( $username, $user->getName() );
|
||||
$this->assertSame( $creator->getName(), $creatorArg->getName() );
|
||||
$foundReq = false;
|
||||
|
|
@ -2195,7 +2193,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$foundReq = $foundReq || get_class( $r ) === get_class( $req );
|
||||
}
|
||||
$this->assertTrue( $foundReq, '$reqs contains $req' );
|
||||
return array_shift( $req->secondary );
|
||||
return array_shift( $secondaryResponses );
|
||||
} );
|
||||
$mocks['secondary']->expects( $this->exactly( min( 1, $ct ) ) )
|
||||
->method( 'beginSecondaryAccountCreation' )
|
||||
|
|
@ -2247,7 +2245,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->preauthMocks, $this->primaryauthMocks, $this->secondaryauthMocks
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$p->postCalled = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', false );
|
||||
$p->expects( $this->atMost( 1 ) )->method( 'postAccountCreation' )
|
||||
->willReturnCallback( function ( $user, $creatorArg, $response )
|
||||
use ( $creator, $constraint, $p, $username )
|
||||
|
|
@ -2257,7 +2255,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( $creator->getName(), $creatorArg->getName() );
|
||||
$this->assertInstanceOf( AuthenticationResponse::class, $response );
|
||||
$this->assertThat( $response->status, $constraint );
|
||||
$p->postCalled = $response->status;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', $response->status );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
@ -2347,7 +2345,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
"Response $i, session state"
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertSame( $response->status, $p->postCalled,
|
||||
$this->assertSame( $response->status, DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ),
|
||||
"Response $i, post-auth callback called" );
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2365,7 +2363,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
"Response $i, continuation check"
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertFalse( $p->postCalled, "Response $i, post-auth callback not called" );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ), "Response $i, post-auth callback not called" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3165,13 +3163,12 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$req->method( 'getUniqueId' )
|
||||
->willReturn( $key );
|
||||
$req->action = $action === AuthManager::ACTION_UNLINK ? AuthManager::ACTION_REMOVE : $action;
|
||||
$req->key = $key;
|
||||
return $req;
|
||||
};
|
||||
$cmpReqs = static function ( $a, $b ) {
|
||||
$ret = strcmp( get_class( $a ), get_class( $b ) );
|
||||
if ( !$ret ) {
|
||||
$ret = strcmp( $a->key, $b->key );
|
||||
$ret = strcmp( $a->getUniqueId(), $b->getUniqueId() );
|
||||
}
|
||||
return $ret;
|
||||
};
|
||||
|
|
@ -3228,7 +3225,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
->willReturn( [] );
|
||||
$mocks['primary2']->method( 'providerAllowsAuthenticationDataChange' )
|
||||
->willReturnCallback( static function ( $req ) use ( $good ) {
|
||||
return $req->key === 'generic' ? StatusValue::newFatal( 'no' ) : $good;
|
||||
return $req->getUniqueId() === 'generic' ? StatusValue::newFatal( 'no' ) : $good;
|
||||
} );
|
||||
$this->primaryauthMocks[] = $mocks['primary2'];
|
||||
|
||||
|
|
@ -3367,14 +3364,13 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$req->method( 'getUniqueId' )
|
||||
->willReturn( $key );
|
||||
$req->action = AuthManager::ACTION_LOGIN;
|
||||
$req->key = $key;
|
||||
$req->required = $required;
|
||||
return $req;
|
||||
};
|
||||
$cmpReqs = static function ( $a, $b ) {
|
||||
$ret = strcmp( get_class( $a ), get_class( $b ) );
|
||||
if ( !$ret ) {
|
||||
$ret = strcmp( $a->key, $b->key );
|
||||
$ret = strcmp( $a->getUniqueId(), $b->getUniqueId() );
|
||||
}
|
||||
return $ret;
|
||||
};
|
||||
|
|
@ -3716,7 +3712,6 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
// Set up lots of mocks...
|
||||
$req = $this->getMockForAbstractClass( AuthenticationRequest::class );
|
||||
$req->primary = $primaryResponses;
|
||||
$mocks = [];
|
||||
|
||||
foreach ( [ 'pre', 'primary' ] as $key ) {
|
||||
|
|
@ -3752,8 +3747,8 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
$mocks['primary']->method( 'accountCreationType' )
|
||||
->willReturn( PrimaryAuthenticationProvider::TYPE_LINK );
|
||||
$ct = count( $req->primary );
|
||||
$callback = $this->returnCallback( function ( $u, $reqs ) use ( $user, $req ) {
|
||||
$ct = count( $primaryResponses );
|
||||
$callback = $this->returnCallback( function ( $u, $reqs ) use ( $user, $req, &$primaryResponses ) {
|
||||
$this->assertSame( $user->getId(), $u->getId() );
|
||||
$this->assertSame( $user->getName(), $u->getName() );
|
||||
$foundReq = false;
|
||||
|
|
@ -3762,7 +3757,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$foundReq = $foundReq || get_class( $r ) === get_class( $req );
|
||||
}
|
||||
$this->assertTrue( $foundReq, '$reqs contains $req' );
|
||||
return array_shift( $req->primary );
|
||||
return array_shift( $primaryResponses );
|
||||
} );
|
||||
$mocks['primary']->expects( $this->exactly( min( 1, $ct ) ) )
|
||||
->method( 'beginPrimaryAccountLink' )
|
||||
|
|
@ -3795,14 +3790,14 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
);
|
||||
$providers = array_merge( $this->preauthMocks, $this->primaryauthMocks );
|
||||
foreach ( $providers as $p ) {
|
||||
$p->postCalled = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', false );
|
||||
$p->expects( $this->atMost( 1 ) )->method( 'postAccountLink' )
|
||||
->willReturnCallback( function ( $userArg, $response ) use ( $user, $constraint, $p ) {
|
||||
$this->assertInstanceOf( User::class, $userArg );
|
||||
$this->assertSame( $user->getName(), $userArg->getName() );
|
||||
$this->assertInstanceOf( AuthenticationResponse::class, $response );
|
||||
$this->assertThat( $response->status, $constraint );
|
||||
$p->postCalled = $response->status;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $p, 'postCalled', $response->status );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
@ -3844,7 +3839,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
$this->assertNull( $this->request->getSession()->getSecret( AuthManager::ACCOUNT_LINK_STATE ),
|
||||
"Response $i, session state" );
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertSame( $response->status, $p->postCalled,
|
||||
$this->assertSame( $response->status, DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ),
|
||||
"Response $i, post-auth callback called" );
|
||||
}
|
||||
} else {
|
||||
|
|
@ -3862,7 +3857,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
|
|||
"Response $i, continuation check"
|
||||
);
|
||||
foreach ( $providers as $p ) {
|
||||
$this->assertFalse( $p->postCalled, "Response $i, post-auth callback not called" );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $p, 'postCalled' ), "Response $i, post-auth callback not called" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,6 +396,8 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
$user = $usernameGetter( $this->getTestSysop()->getUserIdentity()->getName() );
|
||||
if ( $type === PasswordAuthenticationRequest::class ) {
|
||||
$req = new $type();
|
||||
$req->password = 'NewPassword';
|
||||
$req->retype = 'NewPassword';
|
||||
} elseif ( $type === PasswordDomainAuthenticationRequest::class ) {
|
||||
$req = new $type( [] );
|
||||
} else {
|
||||
|
|
@ -403,15 +405,15 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
}
|
||||
$req->action = AuthManager::ACTION_CHANGE;
|
||||
$req->username = $user;
|
||||
$req->password = 'NewPassword';
|
||||
$req->retype = 'NewPassword';
|
||||
|
||||
$provider = $this->getProvider();
|
||||
$this->validity = $validity;
|
||||
$this->assertEquals( $expect1, $provider->providerAllowsAuthenticationDataChange( $req, false ) );
|
||||
$this->assertEquals( $expect2, $provider->providerAllowsAuthenticationDataChange( $req, true ) );
|
||||
|
||||
$req->retype = 'BadRetype';
|
||||
if ( $req instanceof PasswordAuthenticationRequest ) {
|
||||
$req->retype = 'BadRetype';
|
||||
}
|
||||
$this->assertEquals(
|
||||
$expect1,
|
||||
$provider->providerAllowsAuthenticationDataChange( $req, false )
|
||||
|
|
@ -531,12 +533,12 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
|
|||
|
||||
if ( $type === PasswordAuthenticationRequest::class ) {
|
||||
$changeReq = new $type();
|
||||
$changeReq->password = $newpass;
|
||||
} else {
|
||||
$changeReq = $this->createMock( $type );
|
||||
}
|
||||
$changeReq->action = AuthManager::ACTION_CHANGE;
|
||||
$changeReq->username = $user;
|
||||
$changeReq->password = $newpass;
|
||||
$provider->providerChangeAuthenticationData( $changeReq );
|
||||
|
||||
if ( $loginOnly && $changed ) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Auth;
|
||||
|
||||
use DynamicPropertyTestHelper;
|
||||
use MediaWiki\Config\HashConfig;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\Tests\Unit\Auth\AuthenticationProviderTestTrait;
|
||||
|
|
@ -78,12 +79,12 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$provider->method( 'providerAllowsAuthenticationDataChange' )
|
||||
->willReturnCallback( function ( $req ) use ( $username ) {
|
||||
$this->assertSame( $username, $req->username );
|
||||
return $req->allow;
|
||||
return DynamicPropertyTestHelper::getDynamicProperty( $req, 'allow' );
|
||||
} );
|
||||
$provider->method( 'providerChangeAuthenticationData' )
|
||||
->willReturnCallback( function ( $req ) use ( $username ) {
|
||||
$this->assertSame( $username, $req->username );
|
||||
$req->done = true;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $req, 'done', true );
|
||||
} );
|
||||
$config = new HashConfig( [
|
||||
MainConfigNames::AuthManagerConfig => [
|
||||
|
|
@ -127,8 +128,8 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$passReq->action = AuthManager::ACTION_CHANGE;
|
||||
$passReq->password = 'Foo';
|
||||
$passReq->retype = 'Bar';
|
||||
$passReq->allow = \StatusValue::newGood();
|
||||
$passReq->done = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq, 'allow', \StatusValue::newGood() );
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq, 'done', false );
|
||||
|
||||
$passReq2 = $this->getMockBuilder( PasswordAuthenticationRequest::class )
|
||||
->enableProxyingToOriginalMethods()
|
||||
|
|
@ -136,15 +137,15 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$passReq2->action = AuthManager::ACTION_CHANGE;
|
||||
$passReq2->password = 'Foo';
|
||||
$passReq2->retype = 'Foo';
|
||||
$passReq2->allow = \StatusValue::newGood();
|
||||
$passReq2->done = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq2, 'allow', \StatusValue::newGood() );
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq2, 'done', false );
|
||||
|
||||
$passReq3 = new PasswordAuthenticationRequest();
|
||||
$passReq3->action = AuthManager::ACTION_LOGIN;
|
||||
$passReq3->password = 'Foo';
|
||||
$passReq3->retype = 'Foo';
|
||||
$passReq3->allow = \StatusValue::newGood();
|
||||
$passReq3->done = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq3, 'allow', \StatusValue::newGood() );
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq3, 'done', false );
|
||||
|
||||
$this->assertEquals(
|
||||
AuthenticationResponse::newAbstain(),
|
||||
|
|
@ -225,7 +226,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res->neededRequests[0]
|
||||
);
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
'msg' => $msg,
|
||||
|
|
@ -242,7 +243,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$this->assertEquals( $expectedPassReq, $res->neededRequests[0] );
|
||||
$this->assertEquals( $skipReq, $res->neededRequests[1] );
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$passReq->retype = 'Bad';
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
|
|
@ -253,7 +254,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res = $provider->tryReset( $user, [ $skipReq, $passReq ] );
|
||||
$this->assertEquals( AuthenticationResponse::newPass(), $res );
|
||||
$this->assertNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$passReq->retype = 'Bad';
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
|
|
@ -269,7 +270,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res->neededRequests[0]
|
||||
);
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
'msg' => $msg,
|
||||
|
|
@ -284,10 +285,10 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res->neededRequests[0]
|
||||
);
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$passReq->retype = $passReq->password;
|
||||
$passReq->allow = \StatusValue::newFatal( 'arbitrary-fail' );
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq, 'allow', \StatusValue::newFatal( 'arbitrary-fail' ) );
|
||||
$res = $provider->tryReset( $user, [ $skipReq, $passReq ] );
|
||||
$this->assertSame( AuthenticationResponse::UI, $res->status );
|
||||
$this->assertSame( 'arbitrary-fail', $res->message->getKey() );
|
||||
|
|
@ -297,13 +298,13 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res->neededRequests[0]
|
||||
);
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$passReq->allow = \StatusValue::newGood();
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq, 'allow', \StatusValue::newGood() );
|
||||
$res = $provider->tryReset( $user, [ $skipReq, $passReq ] );
|
||||
$this->assertEquals( AuthenticationResponse::newPass(), $res );
|
||||
$this->assertNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertTrue( $passReq->done );
|
||||
$this->assertTrue( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
'msg' => $msg,
|
||||
|
|
@ -313,10 +314,10 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$res = $provider->tryReset( $user, [ $passReq2 ] );
|
||||
$this->assertEquals( AuthenticationResponse::newPass(), $res );
|
||||
$this->assertNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertTrue( $passReq2->done );
|
||||
$this->assertTrue( DynamicPropertyTestHelper::getDynamicProperty( $passReq2, 'done' ) );
|
||||
|
||||
$passReq->done = false;
|
||||
$passReq2->done = false;
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq, 'done', false );
|
||||
DynamicPropertyTestHelper::setDynamicProperty( $passReq2, 'done', false );
|
||||
$manager->setAuthenticationSessionData( 'reset-pass', [
|
||||
'msg' => $msg,
|
||||
'hard' => false,
|
||||
|
|
@ -332,7 +333,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
|
|||
$this->assertEquals( $expectedPassReq, $res->neededRequests[0] );
|
||||
$this->assertEquals( $skipReq, $res->neededRequests[1] );
|
||||
$this->assertNotNull( $manager->getAuthenticationSessionData( 'reset-pass' ) );
|
||||
$this->assertFalse( $passReq->done );
|
||||
$this->assertFalse( $passReq2->done );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq, 'done' ) );
|
||||
$this->assertFalse( DynamicPropertyTestHelper::getDynamicProperty( $passReq2, 'done' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,12 +409,12 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
|
|||
$type === TemporaryPasswordAuthenticationRequest::class
|
||||
) {
|
||||
$req = new $type();
|
||||
$req->password = 'NewPassword';
|
||||
} else {
|
||||
$req = $this->createMock( $type );
|
||||
}
|
||||
$req->action = AuthManager::ACTION_CHANGE;
|
||||
$req->username = $user;
|
||||
$req->password = 'NewPassword';
|
||||
|
||||
$provider = $this->getProvider();
|
||||
$this->validity = $validity;
|
||||
|
|
@ -533,12 +533,12 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
|
|||
$type === TemporaryPasswordAuthenticationRequest::class
|
||||
) {
|
||||
$changeReq = new $type();
|
||||
$changeReq->password = $newpass;
|
||||
} else {
|
||||
$changeReq = $this->createMock( $type );
|
||||
}
|
||||
$changeReq->action = AuthManager::ACTION_CHANGE;
|
||||
$changeReq->username = $user;
|
||||
$changeReq->password = $newpass;
|
||||
$resetMailer = $this->hookMailer();
|
||||
$provider->providerChangeAuthenticationData( $changeReq );
|
||||
ScopedCallback::consume( $resetMailer );
|
||||
|
|
|
|||
Loading…
Reference in a new issue