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

Change subject: Revert "Add global password policies"
......................................................................


Revert "Add global password policies"

This reverts commit 35add6da8f14b758762ef69ed99979a75f7c24f1.

Bug: T104615
Change-Id: I06dd171382cb7652eb0388158ab74ccb1e7f97cc
---
M CentralAuth.php
M includes/CentralAuthHooks.php
M includes/CentralAuthUser.php
D tests/CentralAuthHooksTest.php
M tests/phpunit/CentralAuthUserTest.php
5 files changed, 0 insertions(+), 221 deletions(-)

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



diff --git a/CentralAuth.php b/CentralAuth.php
index 921a2c9..141885d 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -268,13 +268,6 @@
 $wgCentralAuthCheckSULMigration = false;
 
 /**
- * Global Password Policies. These are applied like local password policies,
- * the strongest policy applicable to a user is used.
- * @var array
- */
-$wgCentralAuthGlobalPasswordPolicies = array();
-
-/**
  * Initialization of the autoloaders, and special extension pages.
  */
 $caBase = __DIR__;
@@ -395,7 +388,6 @@
 $wgHooks['UnitTestsList'][] = 'CentralAuthHooks::onUnitTestsList';
 $wgHooks['SpecialContributionsBeforeMainOutput'][] = 
'CentralAuthHooks::onSpecialContributionsBeforeMainOutput';
 $wgHooks['SpecialPage_initList'][] = 
'CentralAuthHooks::onSpecialPage_initList';
-$wgHooks['PasswordPoliciesForUser'][] = 
'CentralAuthHooks::onPasswordPoliciesForUser';
 
 // For interaction with the Special:Renameuser extension
 $wgHooks['RenameUserWarning'][] = 'CentralAuthHooks::onRenameUserWarning';
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index 8f5d307..0ff63e8 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -2061,28 +2061,4 @@
                        );
                }
        }
-
-       /**
-        * Apply global password policies when calculating the effective policy 
for
-        * a user.
-        * @param User $user
-        * @param array $effectivePolicy
-        */
-       public static function onPasswordPoliciesForUser( User $user, array 
&$effectivePolicy ) {
-               global $wgCentralAuthGlobalPasswordPolicies;
-               $central = CentralAuthUser::getInstance( $user );
-               if ( $central->exists() ) {
-                       $localPolicyGroups = array_intersect(
-                               array_keys( 
$wgCentralAuthGlobalPasswordPolicies ),
-                               $central->getLocalGroups()
-                       );
-
-                       $effectivePolicy = 
UserPasswordPolicy::getPoliciesForGroups(
-                               $wgCentralAuthGlobalPasswordPolicies,
-                               array_merge( $central->getGlobalGroups(), 
$localPolicyGroups ),
-                               $effectivePolicy
-                       );
-               }
-               return true;
-       }
 }
diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index 91b3954..5dd3c64 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -2014,24 +2014,6 @@
        }
 
        /**
-        * Returns a list of all groups where the user is a member of the group 
on at
-        * least one wiki where their account is attached.
-        * @return array of group names where the user is a member on at least 
one wiki
-        */
-       public function getLocalGroups() {
-               $localgroups = array();
-               array_map(
-                       function ( $local ) use ( &$localgroups ) {
-                               $localgroups = array_unique( array_merge(
-                                       $localgroups, $local['groups']
-                               ) );
-                       },
-                       $this->queryAttached()
-               );
-               return $localgroups;
-       }
-
-       /**
         * Get information about each local user attached to this account
         *
         * @return array Map of database name to property table with members:
diff --git a/tests/CentralAuthHooksTest.php b/tests/CentralAuthHooksTest.php
deleted file mode 100644
index 3b666e8..0000000
--- a/tests/CentralAuthHooksTest.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-/**
- * Tests for CentralAuthHooks. Only tests that do not
- * require the database to be set up.
- *
- * @group CentralAuth
- */
-class CentralAuthHooksTest extends MediaWikiTestCase {
-
-       /**
-        * @covers CentralAuthHooks::onPasswordPoliciesForUser
-        * @dataProvider provideOnPasswordPoliciesForUser
-        */
-       public function testOnPasswordPoliciesForUser( $localgroups, 
$globalgroups, $expected ) {
-               $this->setMwGlobals( array(
-                       'wgCentralAuthGlobalPasswordPolicies' => array(
-                               'bureaucrat' => array(
-                                       'MinimalPasswordLength' => 10,
-                                       'MinimumPasswordLengthToLogin' => 1,
-                                       'PasswordCannotMatchUsername' => true,
-                               ),
-                               'sysop' => array(
-                                       'MinimalPasswordLength' => 9,
-                                       'MinimumPasswordLengthToLogin' => 1,
-                                       'PasswordCannotMatchUsername' => true,
-                               ),
-                               'bot' => array(
-                                       'MinimalPasswordLength' => 8,
-                                       'MinimumPasswordLengthToLogin' => 1,
-                                       'PasswordCannotMatchUsername' => true,
-                               ),
-                               'steward' => array(
-                                       'MinimalPasswordLength' => 9,
-                                       'MinimumPasswordLengthToLogin' => 4,
-                                       'PasswordCannotMatchUsername' => true,
-                               ),
-                       ),
-               ) );
-
-               /** @var 
PHPUnit_Framework_MockObject_MockObject|CentralAuthUser $ca */
-               $ca = $this->getMockBuilder( 'CentralAuthUser' )
-                       ->disableOriginalConstructor()
-                       ->setMethods( array( 'getLocalGroups', 
'getGlobalGroups', 'exists' ) )
-                       ->getMock();
-               $ca->expects( $this->any() )->method( 'exists' )->will( 
$this->returnValue( true ) );
-               $ca->expects( $this->any() )->method( 'getGlobalGroups' 
)->will( $this->returnValue( $globalgroups ) );
-               $ca->expects( $this->any() )->method( 'getLocalGroups' )->will( 
$this->returnValue( $localgroups ) );
-               $user = User::newFromName( 'MockedCentralAuthUser' );
-               $user->centralAuthObj = $ca;
-               $policy = array();
-               CentralAuthHooks::onPasswordPoliciesForUser( $user, $policy );
-               $this->assertEquals( $expected, $policy );
-       }
-
-       public function provideOnPasswordPoliciesForUser() {
-               return array(
-                       array(
-                               array(),
-                               array(),
-                               array()
-                       ),
-                       array(
-                               array( 'bot' ),
-                               array(),
-                               array(
-                                       'MinimalPasswordLength' => 8,
-                                       'MinimumPasswordLengthToLogin' => 1,
-                                       'PasswordCannotMatchUsername' => true,
-                               )
-                       ),
-                       array(
-                               array( 'bot', 'sysop' ),
-                               array(),
-                               array(
-                                       'MinimalPasswordLength' => 9,
-                                       'MinimumPasswordLengthToLogin' => 1,
-                                       'PasswordCannotMatchUsername' => true,
-                               )
-                       ),
-                       array(
-                               array( 'bureaucrat' ),
-                               array( 'steward' ),
-                               array(
-                                       'MinimalPasswordLength' => 10,
-                                       'MinimumPasswordLengthToLogin' => 4,
-                                       'PasswordCannotMatchUsername' => true,
-                               )
-                       ),
-
-               );
-       }
-}
diff --git a/tests/phpunit/CentralAuthUserTest.php 
b/tests/phpunit/CentralAuthUserTest.php
index 817cf95..f706c09 100644
--- a/tests/phpunit/CentralAuthUserTest.php
+++ b/tests/phpunit/CentralAuthUserTest.php
@@ -180,83 +180,4 @@
                        ),
                );
        }
-
-       /**
-        * @covers CentralAuthUser::getLocalGroups
-        * @dataProvider provideOnPasswordPoliciesForUser
-        */
-       public function testGetLocalGroups( $attached, $expected ) {
-
-               /** @var 
PHPUnit_Framework_MockObject_MockObject|CentralAuthUser $ca */
-               $ca = $this->getMockBuilder( 'CentralAuthUser' )
-                       ->disableOriginalConstructor()
-                       ->setMethods( array( 'queryAttached' ) )
-                       ->getMock();
-               $ca->expects( $this->any() )->method( 'queryAttached' )->will( 
$this->returnValue( $attached ) );
-
-               $this->assertEquals( $expected, $ca->getLocalGroups() );
-       }
-
-       public function provideOnPasswordPoliciesForUser() {
-               return array(
-                       array(
-                               array(
-                                       'enwiki' => array(
-                                               'wiki' => 'enwiki',
-                                               'attachedTimestamp' => 
'20130627183725',
-                                               'attachedMethod' => 'login',
-                                               'id' => '1234',
-                                               'groups' => array(),
-                                       ),
-                                       'commonswiki' => array(
-                                               'wiki' => 'commonswiki',
-                                               'attachedTimestamp' => 
'20130627183726',
-                                               'attachedMethod' => 'login',
-                                               'id' => '4321',
-                                               'groups' => array(),
-                                       ),
-                               ),
-                               array()
-                       ),
-                       array(
-                               array(
-                                       'enwiki' => array(
-                                               'wiki' => 'enwiki',
-                                               'attachedTimestamp' => 
'20130627183727',
-                                               'attachedMethod' => 'login',
-                                               'id' => '12345',
-                                               'groups' => array( 'sysop' ),
-                                       ),
-                                       'commonswiki' => array(
-                                               'wiki' => 'commonswiki',
-                                               'attachedTimestamp' => 
'20130627183728',
-                                               'attachedMethod' => 'login',
-                                               'id' => '54321',
-                                               'groups' => array( 'sysop' ),
-                                       ),
-                               ),
-                               array( 'sysop' )
-                       ),
-                       array(
-                               array(
-                                       'enwiki' => array(
-                                               'wiki' => 'enwiki',
-                                               'attachedTimestamp' => 
'20130627183729',
-                                               'attachedMethod' => 'login',
-                                               'id' => '123456',
-                                               'groups' => array( 'bureaucrat' 
),
-                                       ),
-                                       'commonswiki' => array(
-                                               'wiki' => 'commonswiki',
-                                               'attachedTimestamp' => 
'20130627183720',
-                                               'attachedMethod' => 'login',
-                                               'id' => '654321',
-                                               'groups' => array(),
-                                       ),
-                               ),
-                               array( 'bureaucrat' )
-                       ),
-               );
-       }
-
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I06dd171382cb7652eb0388158ab74ccb1e7f97cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.26wmf12
Gerrit-Owner: CSteipp <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to