9 $pf->
register(
'foo', [
'class' => InvalidPassword::class ] );
10 $this->assertArrayHasKey(
'foo', $pf->getTypes() );
15 $pf->
register(
'1', [
'class' => InvalidPassword::class ] );
16 $pf->register(
'2', [
'class' => InvalidPassword::class ] );
17 $pf->setDefaultType(
'1' );
18 $this->assertSame(
'1', $pf->getDefaultType() );
19 $pf->setDefaultType(
'2' );
20 $this->assertSame(
'2', $pf->getDefaultType() );
34 'foo' => [
'class' => InvalidPassword::class ],
36 'PasswordDefault' =>
'foo'
40 $this->assertSame(
'foo', $pf->getDefaultType() );
41 $this->assertArrayHasKey(
'foo', $pf->getTypes() );
46 $pf->
register(
'B', [
'class' => MWSaltedPassword::class ] );
47 $pw = $pf->newFromCiphertext(
':B:salt:d529e941509eb9e9b9cfaeae1fe7ca23' );
48 $this->assertInstanceOf( MWSaltedPassword::class, $pw );
52 return [ [
'blah' ], [
':blah:' ] ];
61 $pf->
register(
'B', [
'class' => MWSaltedPassword::class ] );
62 $pf->newFromCiphertext( $hash );
67 $pf->
register(
'B', [
'class' => MWSaltedPassword::class ] );
68 $pw = $pf->newFromType(
'B' );
69 $this->assertInstanceOf( MWSaltedPassword::class, $pw );
77 $pf->
register(
'B', [
'class' => MWSaltedPassword::class ] );
78 $pf->newFromType(
'bogus' );
83 $pf->
register(
'A', [
'class' => MWOldPassword::class ] );
84 $pf->register(
'B', [
'class' => MWSaltedPassword::class ] );
85 $pf->setDefaultType(
'A' );
87 $this->assertInstanceOf( InvalidPassword::class, $pf->newFromPlaintext(
null ) );
88 $this->assertInstanceOf( MWOldPassword::class, $pf->newFromPlaintext(
'password' ) );
89 $this->assertInstanceOf( MWSaltedPassword::class,
90 $pf->newFromPlaintext(
'password', $pf->newFromType(
'B' ) ) );
95 $pf->
register(
'A', [
'class' => MWOldPassword::class ] );
96 $pf->register(
'B', [
'class' => MWSaltedPassword::class ] );
97 $pf->setDefaultType(
'A' );
99 $this->assertFalse( $pf->needsUpdate( $pf->newFromType(
'A' ) ) );
100 $this->assertTrue( $pf->needsUpdate( $pf->newFromType(
'B' ) ) );
104 $this->assertSame( 13, strlen( PasswordFactory::generateRandomPasswordString( 13 ) ) );
108 $this->assertInstanceOf( InvalidPassword::class, PasswordFactory::newInvalidPassword() );
A Config instance which stores all settings as a member variable.
testNewFromCiphertextErrors( $hash)
provideNewFromCiphertextErrors PasswordError
testNewFromTypeError()
PasswordError.
testSetDefaultTypeError()
Exception.
provideNewFromCiphertextErrors()
testGenerateRandomPasswordString()
Factory class for creating and checking Password objects.
register( $type, array $config)
Register a new type of password hash.
setDefaultType( $type)
Set the default password type.
init(Config $config)
Initialize the internal static variables using the global variables.