MediaWiki REL1_33
TemporaryPasswordAuthenticationRequestTest.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Auth;
4
10
11 protected function getInstance( array $args = [] ) {
13 $ret->action = $args[0];
14 return $ret;
15 }
16
17 public static function provideGetFieldInfo() {
18 return [
22 ];
23 }
24
25 public function testNewRandom() {
26 global $wgPasswordPolicy;
27
28 $policy = $wgPasswordPolicy;
29 unset( $policy['policies'] );
30 $policy['policies']['default'] = [
31 'MinimalPasswordLength' => 1,
32 'MinimumPasswordLengthToLogin' => 1,
33 ];
34
35 $this->setMwGlobals( [
36 'wgMinimalPasswordLength' => 10,
37 'wgPasswordPolicy' => $policy,
38 ] );
39
42 $this->assertEquals( 10, strlen( $ret1->password ) );
43 $this->assertEquals( 10, strlen( $ret2->password ) );
44 $this->assertNotSame( $ret1->password, $ret2->password );
45
46 $policy['policies']['default']['MinimalPasswordLength'] = 15;
47 $this->setMwGlobals( 'wgPasswordPolicy', $policy );
49 $this->assertEquals( 15, strlen( $ret->password ) );
50
51 $policy['policies']['default']['MinimalPasswordLength'] = [ 'value' => 20 ];
52 $this->setMwGlobals( 'wgPasswordPolicy', $policy );
54 $this->assertEquals( 20, strlen( $ret->password ) );
55 }
56
57 public function testNewInvalid() {
59 $this->assertNull( $ret->password );
60 }
61
62 public function provideLoadFromSubmission() {
63 return [
64 'Empty request' => [
66 [],
67 false,
68 ],
69 'Create, empty request' => [
71 [],
72 false,
73 ],
74 'Create, mailpassword set' => [
76 [ 'mailpassword' => 1 ],
77 [ 'mailpassword' => true, 'action' => AuthManager::ACTION_CREATE ],
78 ],
79 ];
80 }
81
82 public function testDescribeCredentials() {
85 $req->username = 'UTSysop';
87 $this->assertInternalType( 'array', $ret );
88 $this->assertArrayHasKey( 'provider', $ret );
89 $this->assertInstanceOf( \Message::class, $ret['provider'] );
90 $this->assertSame( 'authmanager-provider-temporarypassword', $ret['provider']->getKey() );
91 $this->assertArrayHasKey( 'account', $ret );
92 $this->assertInstanceOf( \Message::class, $ret['account'] );
93 $this->assertSame( [ 'UTSysop' ], $ret['account']->getParams() );
94 }
95}
$wgPasswordPolicy
Password policy for the wiki.
if( $line===false) $args
Definition cdb.php:64
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
const ACTION_CHANGE
Change a user's credentials.
const ACTION_REMOVE
Remove a user's credentials.
const ACTION_LOGIN
Log in with an existing (not necessarily local) user.
const ACTION_CREATE
Create a new user.
AuthManager \MediaWiki\Auth\TemporaryPasswordAuthenticationRequest.
This represents the intention to set a temporary password for the user.
static newRandom()
Return an instance with a new, random password.
describeCredentials()
Describe the credentials represented by this request.
static newInvalid()
Return an instance with an invalid password.
this hook is for auditing only $req
Definition hooks.txt:979
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2003
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))