mirror of
https://github.com/Combodo/iTop.git
synced 2026-09-19 07:59:08 +02:00
n°524 - password policy
- The code now uses the standard extension method (using interfaces) - the metamodel can now filter on iModuleExtension in order to leverage extensions modularity (see MetaModel::EnumPlugins second param) - during the setup, there is no pawsord policy control - there is now a default policy - new (more precie) translation reflecting the default policy - fix CI?
This commit is contained in:
@@ -1528,3 +1528,16 @@ class RestUtils
|
||||
return $oObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helpers for modules extensibility, with discover performed by the MetaModel.
|
||||
*
|
||||
*
|
||||
* @api
|
||||
* @package Extensibility
|
||||
*/
|
||||
interface iModuleExtension
|
||||
{
|
||||
public function __construct();
|
||||
}
|
||||
@@ -2794,7 +2794,7 @@ abstract class MetaModel
|
||||
|
||||
// Build the list of available extensions
|
||||
//
|
||||
$aInterfaces = array('iApplicationUIExtension', 'iPreferencesExtension', 'iApplicationObjectExtension', 'iLoginFSMExtension', 'iLoginUIExtension', 'iLogoutExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension', 'iPageUIExtension', 'iPortalUIExtension', 'ModuleHandlerApiInterface', 'iNewsroomProvider');
|
||||
$aInterfaces = array('iApplicationUIExtension', 'iPreferencesExtension', 'iApplicationObjectExtension', 'iLoginFSMExtension', 'iLoginUIExtension', 'iLogoutExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension', 'iPageUIExtension', 'iPortalUIExtension', 'ModuleHandlerApiInterface', 'iNewsroomProvider', 'iModuleExtension');
|
||||
foreach($aInterfaces as $sInterface)
|
||||
{
|
||||
self::$m_aExtensionClasses[$sInterface] = array();
|
||||
@@ -7346,19 +7346,31 @@ abstract class MetaModel
|
||||
|
||||
/**
|
||||
* @param string $sInterface
|
||||
* @param string|null $sFilterInstanceOf [optional] if given, only instance of this string will be returned
|
||||
*
|
||||
* @return array classes=>instance implementing the given interface
|
||||
*/
|
||||
public static function EnumPlugins($sInterface)
|
||||
public static function EnumPlugins($sInterface, $sFilterInstanceOf = null)
|
||||
{
|
||||
if (array_key_exists($sInterface, self::$m_aExtensionClasses))
|
||||
{
|
||||
return self::$m_aExtensionClasses[$sInterface];
|
||||
}
|
||||
else
|
||||
if (!array_key_exists($sInterface, self::$m_aExtensionClasses))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if (is_null($sFilterInstanceOf))
|
||||
{
|
||||
return self::$m_aExtensionClasses[$sInterface];
|
||||
}
|
||||
|
||||
$fFilterCallback = function ($instance) use ($sFilterInstanceOf)
|
||||
{
|
||||
return $instance instanceof $sFilterInstanceOf;
|
||||
};
|
||||
|
||||
return array_filter(
|
||||
self::$m_aExtensionClasses[$sInterface],
|
||||
$fFilterCallback
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<module_parameters>
|
||||
<parameters id="authent-local" _delta="define">
|
||||
<password_validation.pattern>^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,15}$</password_validation.pattern>
|
||||
<password_validation.pattern>^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$</password_validation.pattern>
|
||||
<password_validation.classes></password_validation.classes>
|
||||
</parameters>
|
||||
</module_parameters>
|
||||
|
||||
@@ -41,5 +41,5 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
'Class:UserLocal/Attribute:password' => 'Password',
|
||||
'Class:UserLocal/Attribute:password+' => 'user authentication string',
|
||||
|
||||
'Error:UserLocalPasswordValidator:UserPasswordPolicyRegex/validation_failed' => 'The password does not respect the policy',
|
||||
'Error:UserLocalPasswordValidator:UserPasswordPolicyRegex/validation_failed' => 'Password must be at least 8 characters and include uppercase, lowercase, numeric and special characters.',
|
||||
));
|
||||
|
||||
@@ -25,5 +25,5 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Class:UserLocal/Attribute:password' => 'Mot de passe',
|
||||
'Class:UserLocal/Attribute:password+' => '',
|
||||
|
||||
'Error:UserLocalPasswordValidator:UserPasswordPolicyRegex/validation_failed' => 'Le mot de passe ne respecte pas la politique de mot de passe.',
|
||||
'Error:UserLocalPasswordValidator:UserPasswordPolicyRegex/validation_failed' => 'Le mot de passe doit contenir au moins 8 caractères, avec minuscule, majuscule, nombre et caractère spécial.',
|
||||
));
|
||||
|
||||
@@ -157,60 +157,41 @@ class UserLocal extends UserInternal
|
||||
|
||||
public function IsPasswordValid()
|
||||
{
|
||||
if (ContextTag::Check('Setup'))
|
||||
{
|
||||
// during the setup, the admin account can have whatever password you want ...
|
||||
return true;
|
||||
}
|
||||
|
||||
return (empty($this->m_oPasswordValidity)) || ($this->m_oPasswordValidity->isPasswordValid());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* set the $m_oPasswordValidity
|
||||
* set the $m_oPasswordValidity based on UserLocalPasswordValidator instances vote.
|
||||
*
|
||||
* @param string $proposedValue
|
||||
* @param \Config|null $config
|
||||
* @param Config|null $config internal use (unit tests)
|
||||
* @param null|UserLocalPasswordValidator[] $aValidatorCollection internal use (unit tests)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ValidatePassword($proposedValue, $config = null)
|
||||
public function ValidatePassword($proposedValue, $config = null, $aValidatorCollection = null)
|
||||
{
|
||||
if (null == $config)
|
||||
{
|
||||
$config = MetaModel::GetConfig();
|
||||
}
|
||||
|
||||
$aPasswordValidationClasses = $config->GetModuleSetting('authent-local', 'password_validation.classes');
|
||||
if (empty($aPasswordValidationClasses))
|
||||
if (null == $aValidatorCollection)
|
||||
{
|
||||
$aPasswordValidationClasses = array();
|
||||
$aValidatorCollection = MetaModel::EnumPlugins('iModuleExtension', 'UserLocalPasswordValidator');
|
||||
}
|
||||
|
||||
$sUserPasswordPolicyRegexPattern = $config->GetModuleSetting('authent-local', 'password_validation.pattern');
|
||||
if ($sUserPasswordPolicyRegexPattern)
|
||||
foreach ($aValidatorCollection as $oUserLocalPasswordValidator)
|
||||
{
|
||||
if (array_key_exists('UserPasswordPolicyRegex', $aPasswordValidationClasses))
|
||||
{
|
||||
$this->m_oPasswordValidity = new UserLocalPasswordValidity(
|
||||
false,
|
||||
"Invalid configuration: 'UserPasswordPolicyRegex' was defined twice (once into UserLocal.password_validation_advanced, once into UserLocal.password_validation)."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$aPasswordValidationClasses['UserPasswordPolicyRegex'] = array('pattern' => $sUserPasswordPolicyRegexPattern);
|
||||
}
|
||||
|
||||
foreach ($aPasswordValidationClasses as $sClass => $aOptions)
|
||||
{
|
||||
if (!is_subclass_of($sClass, 'UserLocalPasswordValidator'))
|
||||
{
|
||||
$this->m_oPasswordValidity = new UserLocalPasswordValidity(
|
||||
false,
|
||||
"Invalid configuration: '{$sClass}' must implements ".UserLocalPasswordValidator::class
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \UserLocalPasswordValidator */
|
||||
$oInstance = new $sClass();
|
||||
|
||||
$this->m_oPasswordValidity = $oInstance->ValidatePassword($proposedValue, $aOptions, $this);
|
||||
$this->m_oPasswordValidity = $oUserLocalPasswordValidator->ValidatePassword($proposedValue, $this, $config);
|
||||
|
||||
if (!$this->m_oPasswordValidity->isPasswordValid())
|
||||
{
|
||||
@@ -258,18 +239,16 @@ class UserLocal extends UserInternal
|
||||
|
||||
|
||||
|
||||
interface UserLocalPasswordValidator
|
||||
interface UserLocalPasswordValidator extends iModuleExtension
|
||||
{
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* @param string $proposedValue
|
||||
* @param array $aOptions
|
||||
* @param UserLocal $oUserLocal
|
||||
* @param Config $config
|
||||
*
|
||||
* @return UserLocalPasswordValidity
|
||||
*/
|
||||
public function ValidatePassword($proposedValue, $aOptions, UserLocal $oUserLocal);
|
||||
public function ValidatePassword($proposedValue, UserLocal $oUserLocal, $config);
|
||||
}
|
||||
|
||||
class UserPasswordPolicyRegex implements UserLocalPasswordValidator
|
||||
@@ -280,34 +259,27 @@ class UserPasswordPolicyRegex implements UserLocalPasswordValidator
|
||||
|
||||
/**
|
||||
* @param string $proposedValue
|
||||
* @param array $aOptions
|
||||
* @param UserLocal $oUserLocal
|
||||
* @param Config $config
|
||||
*
|
||||
* @return UserLocalPasswordValidity
|
||||
*/
|
||||
public function ValidatePassword($proposedValue, $aOptions, UserLocal $oUserLocal)
|
||||
public function ValidatePassword($proposedValue, UserLocal $oUserLocal, $config)
|
||||
{
|
||||
$sPattern = $config->GetModuleSetting('authent-local', 'password_validation.pattern');
|
||||
|
||||
if (! array_key_exists('pattern', $aOptions) )
|
||||
{
|
||||
return new UserLocalPasswordValidity(
|
||||
false,
|
||||
"Invalid configuration: key 'pattern' is mandatory"
|
||||
);
|
||||
}
|
||||
|
||||
$sPattern = $aOptions['pattern'];
|
||||
if ('' == $sPattern)
|
||||
{
|
||||
return new UserLocalPasswordValidity(true);
|
||||
}
|
||||
|
||||
$isMatched = preg_match("/{$sPattern}/", $proposedValue);
|
||||
|
||||
if ($isMatched === false)
|
||||
{
|
||||
return new UserLocalPasswordValidity(
|
||||
false,
|
||||
'Unknown error : Failed to check the password, please verify the password\'s Data Model.'
|
||||
'Unknown error : Failed to check the password.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -324,4 +296,3 @@ class UserPasswordPolicyRegex implements UserLocalPasswordValidator
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1921,6 +1921,7 @@ return array(
|
||||
'iLoginUIExtension' => $baseDir . '/application/applicationextension.inc.php',
|
||||
'iLogoutExtension' => $baseDir . '/application/applicationextension.inc.php',
|
||||
'iMetricComputer' => $baseDir . '/core/computing.inc.php',
|
||||
'iModuleExtension' => $baseDir . '/application/applicationextension.inc.php',
|
||||
'iNewsroomProvider' => $baseDir . '/application/newsroomprovider.class.inc.php',
|
||||
'iOnClassInitialization' => $baseDir . '/core/metamodelmodifier.inc.php',
|
||||
'iPageUIExtension' => $baseDir . '/application/applicationextension.inc.php',
|
||||
|
||||
@@ -2153,6 +2153,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'iLoginUIExtension' => __DIR__ . '/../..' . '/application/applicationextension.inc.php',
|
||||
'iLogoutExtension' => __DIR__ . '/../..' . '/application/applicationextension.inc.php',
|
||||
'iMetricComputer' => __DIR__ . '/../..' . '/core/computing.inc.php',
|
||||
'iModuleExtension' => __DIR__ . '/../..' . '/application/applicationextension.inc.php',
|
||||
'iNewsroomProvider' => __DIR__ . '/../..' . '/application/newsroomprovider.class.inc.php',
|
||||
'iOnClassInitialization' => __DIR__ . '/../..' . '/core/metamodelmodifier.inc.php',
|
||||
'iPageUIExtension' => __DIR__ . '/../..' . '/application/applicationextension.inc.php',
|
||||
|
||||
@@ -685,6 +685,7 @@ class ApplicationInstaller
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
$oProductionEnv->InitDataModel($oConfig, true); // load data model only
|
||||
$oContextTag = new ContextTag('Setup');
|
||||
|
||||
// Migrate columns
|
||||
self::MoveColumns($sDBPrefix);
|
||||
@@ -877,6 +878,7 @@ class ApplicationInstaller
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
$oProductionEnv->InitDataModel($oConfig, true); // load data model and connect to the database
|
||||
$oContextTag = new ContextTag('Setup');
|
||||
self::$bMetaModelStarted = true; // No need to reload the final MetaModel in case the installer runs synchronously
|
||||
|
||||
// Perform here additional DB setup... profiles, etc...
|
||||
@@ -943,6 +945,8 @@ class ApplicationInstaller
|
||||
if (!self::$bMetaModelStarted)
|
||||
{
|
||||
$oProductionEnv->InitDataModel($oConfig, false); // load data model and connect to the database
|
||||
$oContextTag = new ContextTag('Setup');
|
||||
|
||||
self::$bMetaModelStarted = true; // No need to reload the final MetaModel in case the installer runs synchronously
|
||||
}
|
||||
|
||||
@@ -1014,6 +1018,8 @@ class ApplicationInstaller
|
||||
// Record which modules are installed...
|
||||
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
|
||||
$oProductionEnv->InitDataModel($oConfig, true); // load data model and connect to the database
|
||||
$oContextTag = new ContextTag('Setup');
|
||||
|
||||
if (!$oProductionEnv->RecordInstallation($oConfig, $sDataModelVersion, $aSelectedModuleCodes, $aSelectedExtensionCodes, $sInstallComment))
|
||||
{
|
||||
throw new Exception("Failed to record the installation information");
|
||||
|
||||
@@ -10,18 +10,23 @@ namespace coreExtensions;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use UserLocal;
|
||||
use UserLocalPasswordPolicyMockNotValid;
|
||||
use UserLocalPasswordPolicyMockNotValidBis;
|
||||
use UserLocalPasswordPolicyMockValid;
|
||||
use UserLocalPasswordPolicyMockValidBis;
|
||||
use UserLocalPasswordValidity;
|
||||
use UserPasswordPolicyRegex;
|
||||
|
||||
class UserLocalTest extends ItopTestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
parent::setUp();
|
||||
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
require_once (APPROOT.'test/coreExtensions/UserLocalTest/UserLocalPasswordPolicyMock.php');
|
||||
require_once (APPROOT.'env-production/authent-local/model.authent-local.php');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,13 +36,13 @@ class UserLocalTest extends ItopTestCase
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
public function testValidatePassword($aValueMap, $sPassword, $bExpectedCheckStatus, $expectedCheckIssues = null)
|
||||
public function testValidatePassword($sPassword, $aValidatorCollection, $aConfigValueMap, $bExpectedCheckStatus, $expectedCheckIssues = null)
|
||||
{
|
||||
$configMock = $this->createMock(\Config::class);
|
||||
|
||||
$configMock
|
||||
->method('GetModuleSetting')
|
||||
->willReturnMap($aValueMap);
|
||||
->willReturnMap($aConfigValueMap);
|
||||
|
||||
/** @var UserLocal $oUserLocal */
|
||||
$oUserLocal = \MetaModel::NewObject('UserLocal', array('login' => 'john'));
|
||||
@@ -48,7 +53,7 @@ class UserLocalTest extends ItopTestCase
|
||||
\MetaModel::NewObject('URP_UserProfile', array('profileid' => 1))
|
||||
);
|
||||
|
||||
$oUserLocal->ValidatePassword($sPassword, $configMock);
|
||||
$oUserLocal->ValidatePassword($sPassword, $configMock, $aValidatorCollection);
|
||||
|
||||
list($bCheckStatus, $aCheckIssues, $aSecurityIssues) = $oUserLocal->CheckToWrite();
|
||||
|
||||
@@ -62,191 +67,107 @@ class UserLocalTest extends ItopTestCase
|
||||
|
||||
public function ProviderValidatePassword()
|
||||
{
|
||||
parent::setUp();
|
||||
require_once (APPROOT.'env-production/authent-local/model.authent-local.php');
|
||||
require_once (APPROOT.'test/coreExtensions/UserLocalTest/UserLocalPasswordPolicyMock.php');
|
||||
|
||||
$oUserPasswordPolicyRegex = new UserPasswordPolicyRegex();
|
||||
|
||||
$oUserLocalPasswordPolicyMockValid = new UserLocalPasswordPolicyMockValid();
|
||||
$oUserLocalPasswordPolicyMockNotValid = new UserLocalPasswordPolicyMockNotValid();
|
||||
$oUserLocalPasswordPolicyMockValidBis = new UserLocalPasswordPolicyMockValidBis();
|
||||
$oUserLocalPasswordPolicyMockNotValidBis = new UserLocalPasswordPolicyMockNotValidBis();
|
||||
|
||||
|
||||
return array(
|
||||
'validPattern' => array(
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserPasswordPolicyRegex,
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{1,10}')
|
||||
),
|
||||
'password' => 'foo',
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'notValidPattern' => array(
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserPasswordPolicyRegex,
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}')
|
||||
),
|
||||
'password' => 'foo',
|
||||
'expectedCheckStatus' => false,
|
||||
),
|
||||
'noPattern' => array(
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserPasswordPolicyRegex,
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '')
|
||||
),
|
||||
'password' => 'foo',
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'validClass' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => true,
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockValid,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'notValidClass' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => false,
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockNotValid,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => false,
|
||||
),
|
||||
|
||||
|
||||
'UserPasswordPolicyRegex_configured_twice' => array(
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.*'),
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserPasswordPolicyRegex' => array(
|
||||
'pattern' => '.*',
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'Invalid configuration: \'UserPasswordPolicyRegex\' was defined twice (once into UserLocal.password_validation_advanced, once into UserLocal.password_validation).',
|
||||
),
|
||||
|
||||
'classNotImplementsUserLocalPasswordValidator' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'StdClass' => array()
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'Invalid configuration: \'StdClass\' must implements UserLocalPasswordValidator',
|
||||
),
|
||||
|
||||
|
||||
'validation_composition_10' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => true,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
),
|
||||
|
||||
'UserLocalPasswordPolicyMockBis' => array(
|
||||
'bCheckStatus' => false,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMockBis',
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockValid,
|
||||
$oUserLocalPasswordPolicyMockNotValid,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockBis',
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
|
||||
|
||||
'validation_composition_01' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => false,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
),
|
||||
|
||||
'UserLocalPasswordPolicyMockBis' => array(
|
||||
'bCheckStatus' => true,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMockBis',
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockNotValid,
|
||||
$oUserLocalPasswordPolicyMockValid,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
|
||||
'validation_composition_11' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => true,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
),
|
||||
|
||||
'UserLocalPasswordPolicyMockBis' => array(
|
||||
'bCheckStatus' => true,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMockBis',
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockValid,
|
||||
$oUserLocalPasswordPolicyMockValidBis,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'validation_composition_00' => array(
|
||||
'valueMap' => array(
|
||||
array(
|
||||
'authent-local',
|
||||
'password_validation.classes',
|
||||
null,
|
||||
array(
|
||||
'UserLocalPasswordPolicyMock' => array(
|
||||
'bCheckStatus' => false,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
),
|
||||
|
||||
'UserLocalPasswordPolicyMockBis' => array(
|
||||
'bCheckStatus' => false,
|
||||
'sCheckIssues' => 'UserLocalPasswordPolicyMockBis',
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
$oUserLocalPasswordPolicyMockNotValid,
|
||||
$oUserLocalPasswordPolicyMockNotValidBis,
|
||||
),
|
||||
'valueMap' => array(),
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMock',
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
class UserLocalPasswordPolicyMock implements \UserLocalPasswordValidator
|
||||
class UserLocalPasswordPolicyMockValid implements \UserLocalPasswordValidator
|
||||
{
|
||||
const CHECK_STATUS = true;
|
||||
const MESSAGE = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -8,21 +10,28 @@ class UserLocalPasswordPolicyMock implements \UserLocalPasswordValidator
|
||||
|
||||
/**
|
||||
* @param string $proposedValue
|
||||
* @param array $aOptions
|
||||
* @param UserLocal $oUserLocal
|
||||
* @param $config
|
||||
*
|
||||
* @return UserLocalPasswordValidity
|
||||
*/
|
||||
public function ValidatePassword($proposedValue, $aOptions, UserLocal $oUserLocal)
|
||||
public function ValidatePassword($proposedValue, UserLocal $oUserLocal, $config)
|
||||
{
|
||||
$message = (isset($aOptions['sCheckIssues'])) ? $aOptions['sCheckIssues'] : 'UserLocalPasswordPolicyMock error message';
|
||||
|
||||
return new UserLocalPasswordValidity($aOptions['bCheckStatus'], $message);
|
||||
return new UserLocalPasswordValidity(static::CHECK_STATUS, static::MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
class UserLocalPasswordPolicyMockBis extends UserLocalPasswordPolicyMock
|
||||
class UserLocalPasswordPolicyMockNotValid extends UserLocalPasswordPolicyMockValid
|
||||
{
|
||||
const CHECK_STATUS = false;
|
||||
const MESSAGE = 'UserLocalPasswordPolicyMockNotValid';
|
||||
}
|
||||
|
||||
class UserLocalPasswordPolicyMockValidBis extends UserLocalPasswordPolicyMockValid
|
||||
{
|
||||
}
|
||||
|
||||
class UserLocalPasswordPolicyMockNotValidBis extends UserLocalPasswordPolicyMockNotValid
|
||||
{
|
||||
const MESSAGE = 'UserLocalPasswordPolicyMockNotValidBis';
|
||||
}
|
||||
Reference in New Issue
Block a user