MediaWiki REL1_33
PasswordDomainAuthenticationRequestTest.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Auth;
4
10
11 protected function getInstance( array $args = [] ) {
12 $ret = new PasswordDomainAuthenticationRequest( [ 'd1', 'd2' ] );
13 $ret->action = $args[0];
14 return $ret;
15 }
16
17 public static function provideGetFieldInfo() {
18 return [
23 ];
24 }
25
26 public function testGetFieldInfo2() {
27 $info = [];
28 foreach ( [
33 ] as $action ) {
34 $req = new PasswordDomainAuthenticationRequest( [ 'd1', 'd2' ] );
35 $req->action = $action;
36 $info[$action] = $req->getFieldInfo();
37 }
38
39 $this->assertSame( [], $info[AuthManager::ACTION_REMOVE], 'No data needed to remove' );
40
41 $this->assertArrayNotHasKey( 'retype', $info[AuthManager::ACTION_LOGIN],
42 'No need to retype password on login' );
43 $this->assertArrayHasKey( 'domain', $info[AuthManager::ACTION_LOGIN],
44 'Domain needed on login' );
45 $this->assertArrayHasKey( 'retype', $info[AuthManager::ACTION_CREATE],
46 'Need to retype when creating new password' );
47 $this->assertArrayHasKey( 'domain', $info[AuthManager::ACTION_CREATE],
48 'Domain needed on account creation' );
49 $this->assertArrayHasKey( 'retype', $info[AuthManager::ACTION_CHANGE],
50 'Need to retype when changing password' );
51 $this->assertArrayNotHasKey( 'domain', $info[AuthManager::ACTION_CHANGE],
52 'Domain not needed on account creation' );
53
54 $this->assertNotEquals(
55 $info[AuthManager::ACTION_LOGIN]['password']['label'],
56 $info[AuthManager::ACTION_CHANGE]['password']['label'],
57 'Password field for change is differentiated from login'
58 );
59 $this->assertNotEquals(
60 $info[AuthManager::ACTION_CREATE]['password']['label'],
61 $info[AuthManager::ACTION_CHANGE]['password']['label'],
62 'Password field for change is differentiated from create'
63 );
64 $this->assertNotEquals(
65 $info[AuthManager::ACTION_CREATE]['retype']['label'],
66 $info[AuthManager::ACTION_CHANGE]['retype']['label'],
67 'Retype field for change is differentiated from create'
68 );
69 }
70
71 public function provideLoadFromSubmission() {
72 $domainList = [ 'domainList' => [ 'd1', 'd2' ] ];
73 return [
74 'Empty request, login' => [
76 [],
77 false,
78 ],
79 'Empty request, change' => [
81 [],
82 false,
83 ],
84 'Empty request, remove' => [
86 [],
87 false,
88 ],
89 'Username + password, login' => [
91 $data = [ 'username' => 'User', 'password' => 'Bar' ],
92 false,
93 ],
94 'Username + password + domain, login' => [
96 $data = [ 'username' => 'User', 'password' => 'Bar', 'domain' => 'd1' ],
97 $data + [ 'action' => AuthManager::ACTION_LOGIN ] + $domainList,
98 ],
99 'Username + password + bad domain, login' => [
101 $data = [ 'username' => 'User', 'password' => 'Bar', 'domain' => 'd5' ],
102 false,
103 ],
104 'Username + password + domain, change' => [
106 [ 'username' => 'User', 'password' => 'Bar', 'domain' => 'd1' ],
107 false,
108 ],
109 'Username + password + domain + retype' => [
111 [ 'username' => 'User', 'password' => 'Bar', 'retype' => 'baz', 'domain' => 'd1' ],
112 [ 'password' => 'Bar', 'retype' => 'baz', 'action' => AuthManager::ACTION_CHANGE ] +
113 $domainList,
114 ],
115 'Username empty, login' => [
117 [ 'username' => '', 'password' => 'Bar', 'domain' => 'd1' ],
118 false,
119 ],
120 'Username empty, change' => [
122 [ 'username' => '', 'password' => 'Bar', 'retype' => 'baz', 'domain' => 'd1' ],
123 [ 'password' => 'Bar', 'retype' => 'baz', 'action' => AuthManager::ACTION_CHANGE ] +
124 $domainList,
125 ],
126 'Password empty, login' => [
128 [ 'username' => 'User', 'password' => '', 'domain' => 'd1' ],
129 false,
130 ],
131 'Password empty, login, with retype' => [
133 [ 'username' => 'User', 'password' => '', 'retype' => 'baz', 'domain' => 'd1' ],
134 false,
135 ],
136 'Retype empty' => [
138 [ 'username' => 'User', 'password' => 'Bar', 'retype' => '', 'domain' => 'd1' ],
139 false,
140 ],
141 ];
142 }
143
144 public function testDescribeCredentials() {
145 $req = new PasswordDomainAuthenticationRequest( [ 'd1', 'd2' ] );
147 $req->username = 'UTSysop';
148 $req->domain = 'd2';
149 $ret = $req->describeCredentials();
150 $this->assertInternalType( 'array', $ret );
151 $this->assertArrayHasKey( 'provider', $ret );
152 $this->assertInstanceOf( \Message::class, $ret['provider'] );
153 $this->assertSame( 'authmanager-provider-password-domain', $ret['provider']->getKey() );
154 $this->assertArrayHasKey( 'account', $ret );
155 $this->assertInstanceOf( \Message::class, $ret['account'] );
156 $this->assertSame( 'authmanager-account-password-domain', $ret['account']->getKey() );
157 $this->assertSame( [ 'UTSysop', 'd2' ], $ret['account']->getParams() );
158 }
159}
if( $line===false) $args
Definition cdb.php:64
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\PasswordDomainAuthenticationRequest.
This is a value object for authentication requests with a username, password, and domain.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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))