jenkins-bot has submitted this change and it was merged. Change subject: Typo fix for AuthPluginPrimaryAuthenticationProvider::providerAllowsAuthenticationDataChange ......................................................................
Typo fix for AuthPluginPrimaryAuthenticationProvider::providerAllowsAuthenticationDataChange Change-Id: I7c05ea91009cdf765b06438e055de891e0edd1f4 (cherry picked from commit 32673970aac21ee7b5fbec71a8c71207f9eba025) --- M includes/auth/AuthPluginPrimaryAuthenticationProvider.php M tests/phpunit/includes/auth/AuthPluginPrimaryAuthenticationProviderTest.php 2 files changed, 25 insertions(+), 6 deletions(-) Approvals: Gergő Tisza: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/auth/AuthPluginPrimaryAuthenticationProvider.php b/includes/auth/AuthPluginPrimaryAuthenticationProvider.php index 9746637..b8e36bc 100644 --- a/includes/auth/AuthPluginPrimaryAuthenticationProvider.php +++ b/includes/auth/AuthPluginPrimaryAuthenticationProvider.php @@ -329,7 +329,7 @@ if ( $req->domain === null ) { return \StatusValue::newGood( 'ignored' ); } - if ( !$this->auth->validDomain( $domain ) ) { + if ( !$this->auth->validDomain( $req->domain ) ) { return \StatusValue::newFatal( 'authmanager-authplugin-setpass-bad-domain' ); } } diff --git a/tests/phpunit/includes/auth/AuthPluginPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/AuthPluginPrimaryAuthenticationProviderTest.php index b676d69..44f2743 100644 --- a/tests/phpunit/includes/auth/AuthPluginPrimaryAuthenticationProviderTest.php +++ b/tests/phpunit/includes/auth/AuthPluginPrimaryAuthenticationProviderTest.php @@ -461,14 +461,19 @@ * @param StatusValue $expect */ public function testProviderAllowsAuthenticationDataChange( $type, $allow, $expect ) { + $domains = $type instanceof PasswordDomainAuthenticationRequest ? [ 'foo', 'bar' ] : []; $plugin = $this->getMock( 'AuthPlugin' ); - $plugin->expects( $this->any() )->method( 'domainList' )->willReturn( [] ); + $plugin->expects( $this->any() )->method( 'domainList' )->willReturn( $domains ); $plugin->expects( $allow === null ? $this->never() : $this->once() ) ->method( 'allowPasswordChange' )->will( $this->returnValue( $allow ) ); + $plugin->expects( $this->any() )->method( 'validDomain' ) + ->willReturnCallback( function ( $d ) use ( $domains ) { + return in_array( $d, $domains, true ); + } ); $provider = new AuthPluginPrimaryAuthenticationProvider( $plugin ); - if ( $type === PasswordAuthenticationRequest::class ) { - $req = new $type(); + if ( is_object( $type ) ) { + $req = $type; } else { $req = $this->getMock( $type ); } @@ -480,14 +485,28 @@ } public static function provideProviderAllowsAuthenticationDataChange() { + $domains = [ 'foo', 'bar' ]; + $reqNoDomain = new PasswordDomainAuthenticationRequest( $domains ); + $reqValidDomain = new PasswordDomainAuthenticationRequest( $domains ); + $reqValidDomain->domain = 'foo'; + $reqInvalidDomain = new PasswordDomainAuthenticationRequest( $domains ); + $reqInvalidDomain->domain = 'invalid'; + return [ [ AuthenticationRequest::class, null, \StatusValue::newGood( 'ignored' ) ], - [ PasswordAuthenticationRequest::class, true, \StatusValue::newGood() ], + [ new PasswordAuthenticationRequest, true, \StatusValue::newGood() ], [ - PasswordAuthenticationRequest::class, + new PasswordAuthenticationRequest, false, \StatusValue::newFatal( 'authmanager-authplugin-setpass-denied' ) ], + [ $reqNoDomain, true, \StatusValue::newGood( 'ignored' ) ], + [ $reqValidDomain, true, \StatusValue::newGood() ], + [ + $reqInvalidDomain, + true, + \StatusValue::newFatal( 'authmanager-authplugin-setpass-bad-domain' ) + ], ]; } -- To view, visit https://gerrit.wikimedia.org/r/291725 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7c05ea91009cdf765b06438e055de891e0edd1f4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_27 Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits