MediaWiki REL1_30
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 $this->stashMwGlobals( 'wgPasswordPolicy' );
29 $wgPasswordPolicy['policies']['default'] += [
30 'MinimalPasswordLength' => 1,
31 'MinimalPasswordLengthToLogin' => 1,
32 ];
33
36 $this->assertNotSame( '', $ret1->password );
37 $this->assertNotSame( '', $ret2->password );
38 $this->assertNotSame( $ret1->password, $ret2->password );
39 }
40
41 public function testNewInvalid() {
43 $this->assertNull( $ret->password );
44 }
45
46 public function provideLoadFromSubmission() {
47 return [
48 'Empty request' => [
50 [],
51 false,
52 ],
53 'Create, empty request' => [
55 [],
56 false,
57 ],
58 'Create, mailpassword set' => [
60 [ 'mailpassword' => 1 ],
61 [ 'mailpassword' => true, 'action' => AuthManager::ACTION_CREATE ],
62 ],
63 ];
64 }
65
66 public function testDescribeCredentials() {
69 $req->username = 'UTSysop';
70 $ret = $req->describeCredentials();
71 $this->assertInternalType( 'array', $ret );
72 $this->assertArrayHasKey( 'provider', $ret );
73 $this->assertInstanceOf( 'Message', $ret['provider'] );
74 $this->assertSame( 'authmanager-provider-temporarypassword', $ret['provider']->getKey() );
75 $this->assertArrayHasKey( 'account', $ret );
76 $this->assertInstanceOf( 'Message', $ret['account'] );
77 $this->assertSame( [ 'UTSysop' ], $ret['account']->getParams() );
78 }
79}
$wgPasswordPolicy
Password policy for local wiki users.
if( $line===false) $args
Definition cdb.php:63
stashMwGlobals( $globalKeys)
Stashes the global, will 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:988
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:1975