Follow-up to I28c31fc4ea. Also improves what policy values are considered disabled, documents how to extend core checks/flags and adds a structure test for it. Bug: T118774 Change-Id: I66bf396e8e8a8c310a47ba337abe9070e7e83ff6
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @coversNothing
|
|
*/
|
|
class PasswordPolicyStructureTest extends MediaWikiTestCase {
|
|
|
|
public function provideChecks() {
|
|
global $wgPasswordPolicy;
|
|
|
|
foreach ( $wgPasswordPolicy['checks'] as $name => $callback ) {
|
|
yield [ $name ];
|
|
}
|
|
}
|
|
|
|
public function provideFlags() {
|
|
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.
|
|
$flags = [ 'forceChange' ];
|
|
foreach ( $wgPasswordPolicy['policies'] as $group => $checks ) {
|
|
foreach ( $checks as $check => $settings ) {
|
|
if ( is_array( $settings ) ) {
|
|
$flags = array_merge( $flags, array_diff( $settings, [ 'value' ] ) );
|
|
}
|
|
}
|
|
}
|
|
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() );
|
|
}
|
|
|
|
}
|