2019-01-20 02:16:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-10-07 00:45:44 +00:00
|
|
|
/**
|
|
|
|
|
* @coversNothing
|
|
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class PasswordPolicyStructureTest extends MediaWikiIntegrationTestCase {
|
2019-01-20 02:16:51 +00:00
|
|
|
|
2023-03-23 11:36:19 +00:00
|
|
|
public static function provideChecks() {
|
2019-01-20 02:16:51 +00:00
|
|
|
global $wgPasswordPolicy;
|
|
|
|
|
|
|
|
|
|
foreach ( $wgPasswordPolicy['checks'] as $name => $callback ) {
|
|
|
|
|
yield [ $name ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:36:19 +00:00
|
|
|
public static function provideFlags() {
|
2019-01-20 02:16:51 +00:00
|
|
|
global $wgPasswordPolicy;
|
|
|
|
|
|
|
|
|
|
// This won't actually find all flags, just the ones in use. Can't really be helped,
|
|
|
|
|
// other than adding the core flags here.
|
2019-02-20 06:02:33 +00:00
|
|
|
$flags = [ 'forceChange', 'suggestChangeOnLogin' ];
|
2019-01-20 02:16:51 +00:00
|
|
|
foreach ( $wgPasswordPolicy['policies'] as $group => $checks ) {
|
|
|
|
|
foreach ( $checks as $check => $settings ) {
|
|
|
|
|
if ( is_array( $settings ) ) {
|
2019-02-20 06:02:33 +00:00
|
|
|
$flags = array_unique(
|
|
|
|
|
array_merge( $flags, array_diff( array_keys( $settings ), [ 'value' ] ) )
|
|
|
|
|
);
|
2019-01-20 02:16:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-20 06:02:33 +00:00
|
|
|
|
2019-01-20 02:16:51 +00:00
|
|
|
foreach ( $flags as $flag ) {
|
|
|
|
|
yield [ $flag ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @dataProvider provideChecks */
|
|
|
|
|
public function testCheckMessage( $check ) {
|
|
|
|
|
$msg = wfMessage( 'passwordpolicies-policy-' . strtolower( $check ) );
|
|
|
|
|
$this->assertTrue( $msg->exists() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @dataProvider provideFlags */
|
|
|
|
|
public function testFlagMessage( $flag ) {
|
|
|
|
|
$msg = wfMessage( 'passwordpolicies-policyflag-' . strtolower( $flag ) );
|
|
|
|
|
$this->assertTrue( $msg->exists() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|