MediaWiki REL1_32
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 $policy['policies']['default'] += [
30 'MinimalPasswordLength' => 1,
31 'MinimalPasswordLengthToLogin' => 1,
32 ];
33
34 $this->setMwGlobals( 'wgPasswordPolicy', $policy );
35
38 $this->assertNotSame( '', $ret1->password );
39 $this->assertNotSame( '', $ret2->password );
40 $this->assertNotSame( $ret1->password, $ret2->password );
41 }
42
43 public function testNewInvalid() {
45 $this->assertNull( $ret->password );
46 }
47
48 public function provideLoadFromSubmission() {
49 return [
50 'Empty request' => [
52 [],
53 false,
54 ],
55 'Create, empty request' => [
57 [],
58 false,
59 ],
60 'Create, mailpassword set' => [
62 [ 'mailpassword' => 1 ],
63 [ 'mailpassword' => true, 'action' => AuthManager::ACTION_CREATE ],
64 ],
65 ];
66 }
67
68 public function testDescribeCredentials() {
71 $req->username = 'UTSysop';
72 $ret = $req->describeCredentials();
73 $this->assertInternalType( 'array', $ret );
74 $this->assertArrayHasKey( 'provider', $ret );
75 $this->assertInstanceOf( \Message::class, $ret['provider'] );
76 $this->assertSame( 'authmanager-provider-temporarypassword', $ret['provider']->getKey() );
77 $this->assertArrayHasKey( 'account', $ret );
78 $this->assertInstanceOf( \Message::class, $ret['account'] );
79 $this->assertSame( [ 'UTSysop' ], $ret['account']->getParams() );
80 }
81}
$wgPasswordPolicy
Password policy for local wiki users.
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.
static newInvalid()
Return an instance with an invalid password.
this hook is for auditing only $req
Definition hooks.txt:1018
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:2054
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))