MediaWiki  1.30.0
TemporaryPasswordAuthenticationRequestTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace 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() {
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 }
MediaWikiTestCase\stashMwGlobals
stashMwGlobals( $globalKeys)
Stashes the global, will be restored in tearDown()
Definition: MediaWikiTestCase.php:724
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\provideGetFieldInfo
static provideGetFieldInfo()
Definition: TemporaryPasswordAuthenticationRequestTest.php:17
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\testNewRandom
testNewRandom()
Definition: TemporaryPasswordAuthenticationRequestTest.php:25
$req
this hook is for auditing only $req
Definition: hooks.txt:988
php
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:35
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\provideLoadFromSubmission
provideLoadFromSubmission()
Definition: TemporaryPasswordAuthenticationRequestTest.php:46
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newInvalid
static newInvalid()
Return an instance with an invalid password.
Definition: TemporaryPasswordAuthenticationRequest.php:89
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\testDescribeCredentials
testDescribeCredentials()
Definition: TemporaryPasswordAuthenticationRequestTest.php:66
MediaWiki\Auth\AuthManager\ACTION_CREATE
const ACTION_CREATE
Create a new user.
Definition: AuthManager.php:89
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\getInstance
getInstance(array $args=[])
Definition: TemporaryPasswordAuthenticationRequestTest.php:11
MediaWiki\Auth\AuthManager\ACTION_CHANGE
const ACTION_CHANGE
Change a user's credentials.
Definition: AuthManager.php:99
$ret
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:1965
MediaWiki\Auth\AuthManager\ACTION_REMOVE
const ACTION_REMOVE
Remove a user's credentials.
Definition: AuthManager.php:101
$args
if( $line===false) $args
Definition: cdb.php:63
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest
This represents the intention to set a temporary password for the user.
Definition: TemporaryPasswordAuthenticationRequest.php:31
MediaWiki\Auth\AuthManager\ACTION_LOGIN
const ACTION_LOGIN
Log in with an existing (not necessarily local) user.
Definition: AuthManager.php:84
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest\testNewInvalid
testNewInvalid()
Definition: TemporaryPasswordAuthenticationRequestTest.php:41
MediaWiki\Auth\AuthenticationRequestTestCase
AuthManager.
Definition: AuthenticationRequestTestCase.php:8
$wgPasswordPolicy
$wgPasswordPolicy
Password policy for local wiki users.
Definition: DefaultSettings.php:4516
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom
static newRandom()
Return an instance with a new, random password.
Definition: TemporaryPasswordAuthenticationRequest.php:65
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
array
the array() calling protocol came about after MediaWiki 1.4rc1.
MediaWiki\Auth\TemporaryPasswordAuthenticationRequestTest
AuthManager MediaWiki\Auth\TemporaryPasswordAuthenticationRequest.
Definition: TemporaryPasswordAuthenticationRequestTest.php:9