MediaWiki  1.27.4
BotPasswordTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10  protected function setUp() {
11  parent::setUp();
12 
13  $this->setMwGlobals( [
14  'wgEnableBotPasswords' => true,
15  'wgBotPasswordsDatabase' => false,
16  'wgCentralIdLookupProvider' => 'BotPasswordTest OkMock',
17  'wgGrantPermissions' => [
18  'test' => [ 'read' => true ],
19  ],
20  'wgUserrightsInterwikiDelimiter' => '@',
21  ] );
22 
23  $mock1 = $this->getMockForAbstractClass( 'CentralIdLookup' );
24  $mock1->expects( $this->any() )->method( 'isAttached' )
25  ->will( $this->returnValue( true ) );
26  $mock1->expects( $this->any() )->method( 'lookupUserNames' )
27  ->will( $this->returnValue( [ 'UTSysop' => 42, 'UTDummy' => 43, 'UTInvalid' => 0 ] ) );
28  $mock1->expects( $this->never() )->method( 'lookupCentralIds' );
29 
30  $mock2 = $this->getMockForAbstractClass( 'CentralIdLookup' );
31  $mock2->expects( $this->any() )->method( 'isAttached' )
32  ->will( $this->returnValue( false ) );
33  $mock2->expects( $this->any() )->method( 'lookupUserNames' )
34  ->will( $this->returnArgument( 0 ) );
35  $mock2->expects( $this->never() )->method( 'lookupCentralIds' );
36 
37  $this->mergeMwGlobalArrayValue( 'wgCentralIdLookupProviders', [
38  'BotPasswordTest OkMock' => [ 'factory' => function () use ( $mock1 ) {
39  return $mock1;
40  } ],
41  'BotPasswordTest FailMock' => [ 'factory' => function () use ( $mock2 ) {
42  return $mock2;
43  } ],
44  ] );
45 
47  }
48 
49  public function addDBData() {
50  $passwordFactory = new \PasswordFactory();
51  $passwordFactory->init( \RequestContext::getMain()->getConfig() );
52  // A is unsalted MD5 (thus fast) ... we don't care about security here, this is test only
53  $passwordFactory->setDefaultType( 'A' );
54  $pwhash = $passwordFactory->newFromPlaintext( 'foobaz' );
55 
56  $dbw = wfGetDB( DB_MASTER );
57  $dbw->delete(
58  'bot_passwords',
59  [ 'bp_user' => [ 42, 43 ], 'bp_app_id' => 'BotPassword' ],
60  __METHOD__
61  );
62  $dbw->insert(
63  'bot_passwords',
64  [
65  [
66  'bp_user' => 42,
67  'bp_app_id' => 'BotPassword',
68  'bp_password' => $pwhash->toString(),
69  'bp_token' => 'token!',
70  'bp_restrictions' => '{"IPAddresses":["127.0.0.0/8"]}',
71  'bp_grants' => '["test"]',
72  ],
73  [
74  'bp_user' => 43,
75  'bp_app_id' => 'BotPassword',
76  'bp_password' => $pwhash->toString(),
77  'bp_token' => 'token!',
78  'bp_restrictions' => '{"IPAddresses":["127.0.0.0/8"]}',
79  'bp_grants' => '["test"]',
80  ],
81  ],
82  __METHOD__
83  );
84  }
85 
86  public function testBasics() {
87  $user = User::newFromName( 'UTSysop' );
88  $bp = BotPassword::newFromUser( $user, 'BotPassword' );
89  $this->assertInstanceOf( 'BotPassword', $bp );
90  $this->assertTrue( $bp->isSaved() );
91  $this->assertSame( 42, $bp->getUserCentralId() );
92  $this->assertSame( 'BotPassword', $bp->getAppId() );
93  $this->assertSame( 'token!', trim( $bp->getToken(), " \0" ) );
94  $this->assertEquals( '{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson() );
95  $this->assertSame( [ 'test' ], $bp->getGrants() );
96 
97  $this->assertNull( BotPassword::newFromUser( $user, 'DoesNotExist' ) );
98 
99  $this->setMwGlobals( [
100  'wgCentralIdLookupProvider' => 'BotPasswordTest FailMock'
101  ] );
102  $this->assertNull( BotPassword::newFromUser( $user, 'BotPassword' ) );
103 
104  $this->assertSame( '@', BotPassword::getSeparator() );
105  $this->setMwGlobals( [
106  'wgUserrightsInterwikiDelimiter' => '#',
107  ] );
108  $this->assertSame( '#', BotPassword::getSeparator() );
109  }
110 
111  public function testUnsaved() {
112  $user = User::newFromName( 'UTSysop' );
113  $bp = BotPassword::newUnsaved( [
114  'user' => $user,
115  'appId' => 'DoesNotExist'
116  ] );
117  $this->assertInstanceOf( 'BotPassword', $bp );
118  $this->assertFalse( $bp->isSaved() );
119  $this->assertSame( 42, $bp->getUserCentralId() );
120  $this->assertSame( 'DoesNotExist', $bp->getAppId() );
121  $this->assertEquals( MWRestrictions::newDefault(), $bp->getRestrictions() );
122  $this->assertSame( [], $bp->getGrants() );
123 
124  $bp = BotPassword::newUnsaved( [
125  'username' => 'UTDummy',
126  'appId' => 'DoesNotExist2',
127  'restrictions' => MWRestrictions::newFromJson( '{"IPAddresses":["127.0.0.0/8"]}' ),
128  'grants' => [ 'test' ],
129  ] );
130  $this->assertInstanceOf( 'BotPassword', $bp );
131  $this->assertFalse( $bp->isSaved() );
132  $this->assertSame( 43, $bp->getUserCentralId() );
133  $this->assertSame( 'DoesNotExist2', $bp->getAppId() );
134  $this->assertEquals( '{"IPAddresses":["127.0.0.0/8"]}', $bp->getRestrictions()->toJson() );
135  $this->assertSame( [ 'test' ], $bp->getGrants() );
136 
137  $user = User::newFromName( 'UTSysop' );
138  $bp = BotPassword::newUnsaved( [
139  'centralId' => 45,
140  'appId' => 'DoesNotExist'
141  ] );
142  $this->assertInstanceOf( 'BotPassword', $bp );
143  $this->assertFalse( $bp->isSaved() );
144  $this->assertSame( 45, $bp->getUserCentralId() );
145  $this->assertSame( 'DoesNotExist', $bp->getAppId() );
146 
147  $user = User::newFromName( 'UTSysop' );
148  $bp = BotPassword::newUnsaved( [
149  'user' => $user,
150  'appId' => 'BotPassword'
151  ] );
152  $this->assertInstanceOf( 'BotPassword', $bp );
153  $this->assertFalse( $bp->isSaved() );
154 
155  $this->assertNull( BotPassword::newUnsaved( [
156  'user' => $user,
157  'appId' => '',
158  ] ) );
159  $this->assertNull( BotPassword::newUnsaved( [
160  'user' => $user,
161  'appId' => str_repeat( 'X', BotPassword::APPID_MAXLENGTH + 1 ),
162  ] ) );
163  $this->assertNull( BotPassword::newUnsaved( [
164  'user' => 'UTSysop',
165  'appId' => 'Ok',
166  ] ) );
167  $this->assertNull( BotPassword::newUnsaved( [
168  'username' => 'UTInvalid',
169  'appId' => 'Ok',
170  ] ) );
171  $this->assertNull( BotPassword::newUnsaved( [
172  'appId' => 'Ok',
173  ] ) );
174  }
175 
176  public function testGetPassword() {
178 
179  $password = $bp->getPassword();
180  $this->assertInstanceOf( 'Password', $password );
181  $this->assertTrue( $password->equals( 'foobaz' ) );
182 
183  $bp->centralId = 44;
184  $password = $bp->getPassword();
185  $this->assertInstanceOf( 'InvalidPassword', $password );
186 
188  $dbw = wfGetDB( DB_MASTER );
189  $dbw->update(
190  'bot_passwords',
191  [ 'bp_password' => 'garbage' ],
192  [ 'bp_user' => 42, 'bp_app_id' => 'BotPassword' ],
193  __METHOD__
194  );
195  $password = $bp->getPassword();
196  $this->assertInstanceOf( 'InvalidPassword', $password );
197  }
198 
202 
203  $this->assertNotInstanceOf( 'InvalidPassword', $bp1->getPassword(), 'sanity check' );
204  $this->assertNotInstanceOf( 'InvalidPassword', $bp2->getPassword(), 'sanity check' );
206  $this->assertInstanceOf( 'InvalidPassword', $bp1->getPassword() );
207  $this->assertNotInstanceOf( 'InvalidPassword', $bp2->getPassword() );
208 
210  $this->assertInstanceOf( 'InvalidPassword', $bp->getPassword() );
211  }
212 
213  public function testRemoveAllPasswordsForUser() {
214  $this->assertNotNull( BotPassword::newFromCentralId( 42, 'BotPassword' ), 'sanity check' );
215  $this->assertNotNull( BotPassword::newFromCentralId( 43, 'BotPassword' ), 'sanity check' );
216 
218 
219  $this->assertNull( BotPassword::newFromCentralId( 42, 'BotPassword' ) );
220  $this->assertNotNull( BotPassword::newFromCentralId( 43, 'BotPassword' ) );
221  }
222 
226  public function testCanonicalizeLoginData( $username, $password, $expectedResult ) {
228  if ( is_array( $expectedResult ) ) {
229  $this->assertArrayEquals( $expectedResult, $result, true, true );
230  } else {
231  $this->assertSame( $expectedResult, $result );
232  }
233  }
234 
235  public function provideCanonicalizeLoginData() {
236  return [
237  [ 'user', 'pass', false ],
238  [ 'user', 'abc@def', false ],
239  [ 'legacy@user', 'pass', false ],
240  [ 'user@bot', '12345678901234567890123456789012',
241  [ 'user@bot', '12345678901234567890123456789012', true ] ],
242  [ 'user', 'bot@12345678901234567890123456789012',
243  [ 'user@bot', '12345678901234567890123456789012', true ] ],
244  [ 'user', 'bot@12345678901234567890123456789012345',
245  [ 'user@bot', '12345678901234567890123456789012345', true ] ],
246  [ 'user', 'bot@x@12345678901234567890123456789012',
247  [ 'user@bot@x', '12345678901234567890123456789012', true ] ],
248  ];
249  }
250 
251  public function testLogin() {
252  // Test failure when bot passwords aren't enabled
253  $this->setMwGlobals( 'wgEnableBotPasswords', false );
254  $status = BotPassword::login( 'UTSysop@BotPassword', 'foobaz', new FauxRequest );
255  $this->assertEquals( Status::newFatal( 'botpasswords-disabled' ), $status );
256  $this->setMwGlobals( 'wgEnableBotPasswords', true );
257 
258  // Test failure when BotPasswordSessionProvider isn't configured
259  $manager = new SessionManager( [
260  'logger' => new Psr\Log\NullLogger,
261  'store' => new EmptyBagOStuff,
262  ] );
264  $this->assertNull(
265  $manager->getProvider( MediaWiki\Session\BotPasswordSessionProvider::class ),
266  'sanity check'
267  );
268  $status = BotPassword::login( 'UTSysop@BotPassword', 'foobaz', new FauxRequest );
269  $this->assertEquals( Status::newFatal( 'botpasswords-no-provider' ), $status );
270  ScopedCallback::consume( $reset );
271 
272  // Now configure BotPasswordSessionProvider for further tests...
273  $mainConfig = RequestContext::getMain()->getConfig();
274  $config = new HashConfig( [
275  'SessionProviders' => $mainConfig->get( 'SessionProviders' ) + [
278  'args' => [ [ 'priority' => 40 ] ],
279  ]
280  ],
281  ] );
282  $manager = new SessionManager( [
283  'config' => new MultiConfig( [ $config, RequestContext::getMain()->getConfig() ] ),
284  'logger' => new Psr\Log\NullLogger,
285  'store' => new EmptyBagOStuff,
286  ] );
288 
289  // No "@"-thing in the username
290  $status = BotPassword::login( 'UTSysop', 'foobaz', new FauxRequest );
291  $this->assertEquals( Status::newFatal( 'botpasswords-invalid-name', '@' ), $status );
292 
293  // No base user
294  $status = BotPassword::login( 'UTDummy@BotPassword', 'foobaz', new FauxRequest );
295  $this->assertEquals( Status::newFatal( 'nosuchuser', 'UTDummy' ), $status );
296 
297  // No bot password
298  $status = BotPassword::login( 'UTSysop@DoesNotExist', 'foobaz', new FauxRequest );
299  $this->assertEquals(
300  Status::newFatal( 'botpasswords-not-exist', 'UTSysop', 'DoesNotExist' ),
301  $status
302  );
303 
304  // Failed restriction
305  $request = $this->getMock( 'FauxRequest', [ 'getIP' ] );
306  $request->expects( $this->any() )->method( 'getIP' )
307  ->will( $this->returnValue( '10.0.0.1' ) );
308  $status = BotPassword::login( 'UTSysop@BotPassword', 'foobaz', $request );
309  $this->assertEquals( Status::newFatal( 'botpasswords-restriction-failed' ), $status );
310 
311  // Wrong password
312  $status = BotPassword::login( 'UTSysop@BotPassword', 'UTSysopPassword', new FauxRequest );
313  $this->assertEquals( Status::newFatal( 'wrongpassword' ), $status );
314 
315  // Success!
316  $request = new FauxRequest;
317  $this->assertNotInstanceOf(
318  MediaWiki\Session\BotPasswordSessionProvider::class,
319  $request->getSession()->getProvider(),
320  'sanity check'
321  );
322  $status = BotPassword::login( 'UTSysop@BotPassword', 'foobaz', $request );
323  $this->assertInstanceOf( 'Status', $status );
324  $this->assertTrue( $status->isGood() );
325  $session = $status->getValue();
326  $this->assertInstanceOf( MediaWiki\Session\Session::class, $session );
327  $this->assertInstanceOf(
328  MediaWiki\Session\BotPasswordSessionProvider::class, $session->getProvider()
329  );
330  $this->assertSame( $session->getId(), $request->getSession()->getId() );
331 
332  ScopedCallback::consume( $reset );
333  }
334 
339  public function testSave( $password ) {
340  $passwordFactory = new \PasswordFactory();
341  $passwordFactory->init( \RequestContext::getMain()->getConfig() );
342  // A is unsalted MD5 (thus fast) ... we don't care about security here, this is test only
343  $passwordFactory->setDefaultType( 'A' );
344 
345  $bp = BotPassword::newUnsaved( [
346  'centralId' => 42,
347  'appId' => 'TestSave',
348  'restrictions' => MWRestrictions::newFromJson( '{"IPAddresses":["127.0.0.0/8"]}' ),
349  'grants' => [ 'test' ],
350  ] );
351  $this->assertFalse( $bp->isSaved(), 'sanity check' );
352  $this->assertNull(
353  BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST ), 'sanity check'
354  );
355 
356  $pwhash = $password ? $passwordFactory->newFromPlaintext( $password ) : null;
357  $this->assertFalse( $bp->save( 'update', $pwhash ) );
358  $this->assertTrue( $bp->save( 'insert', $pwhash ) );
360  $this->assertInstanceOf( 'BotPassword', $bp2 );
361  $this->assertEquals( $bp->getUserCentralId(), $bp2->getUserCentralId() );
362  $this->assertEquals( $bp->getAppId(), $bp2->getAppId() );
363  $this->assertEquals( $bp->getToken(), $bp2->getToken() );
364  $this->assertEquals( $bp->getRestrictions(), $bp2->getRestrictions() );
365  $this->assertEquals( $bp->getGrants(), $bp2->getGrants() );
366  $pw = TestingAccessWrapper::newFromObject( $bp )->getPassword();
367  if ( $password === null ) {
368  $this->assertInstanceOf( 'InvalidPassword', $pw );
369  } else {
370  $this->assertTrue( $pw->equals( $password ) );
371  }
372 
373  $token = $bp->getToken();
374  $this->assertFalse( $bp->save( 'insert' ) );
375  $this->assertTrue( $bp->save( 'update' ) );
376  $this->assertNotEquals( $token, $bp->getToken() );
378  $this->assertInstanceOf( 'BotPassword', $bp2 );
379  $this->assertEquals( $bp->getToken(), $bp2->getToken() );
380  $pw = TestingAccessWrapper::newFromObject( $bp )->getPassword();
381  if ( $password === null ) {
382  $this->assertInstanceOf( 'InvalidPassword', $pw );
383  } else {
384  $this->assertTrue( $pw->equals( $password ) );
385  }
386 
387  $pwhash = $passwordFactory->newFromPlaintext( 'XXX' );
388  $token = $bp->getToken();
389  $this->assertTrue( $bp->save( 'update', $pwhash ) );
390  $this->assertNotEquals( $token, $bp->getToken() );
391  $pw = TestingAccessWrapper::newFromObject( $bp )->getPassword();
392  $this->assertTrue( $pw->equals( 'XXX' ) );
393 
394  $this->assertTrue( $bp->delete() );
395  $this->assertFalse( $bp->isSaved() );
396  $this->assertNull( BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST ) );
397 
398  $this->assertFalse( $bp->save( 'foobar' ) );
399  }
400 
401  public static function provideSave() {
402  return [
403  [ null ],
404  [ 'foobar' ],
405  ];
406  }
407 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:568
mergeMwGlobalArrayValue($name, $values)
Merges the given values into a MW global array variable.
static getSeparator()
Get the separator for combined user name + app ID.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
const APPID_MAXLENGTH
Definition: BotPassword.php:29
static setSessionManagerSingleton(SessionManager $manager=null)
Override the singleton for unit testing.
Definition: TestUtils.php:17
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
A helper class for throttling authentication attempts.
static newFatal($message)
Factory function for fatal errors.
Definition: Status.php:89
static newUnsaved(array $data, $flags=self::READ_NORMAL)
Create an unsaved BotPassword.
static newFromCentralId($centralId, $appId, $flags=self::READ_NORMAL)
Load a BotPassword from the database.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1800
static removeAllPasswordsForUser($username)
Remove all passwords for a user, by name.
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 just before the function returns a value If you return true
Definition: hooks.txt:1802
static getMain()
Static methods.
static invalidateAllPasswordsForUser($username)
Invalidate all passwords for a user, by name.
A BagOStuff object with no objects in it.
static newFromJson($json)
Provides a fallback sequence for Config objects.
Definition: MultiConfig.php:28
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:246
static newFromUser(User $user, $appId, $flags=self::READ_NORMAL)
Load a BotPassword from the database.
Definition: BotPassword.php:89
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
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:766
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2422
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
static canonicalizeLoginData($username, $password)
There are two ways to login with a bot password: "username@appId", "password" and "username"...
static resetCache()
Reset internal cache for unit testing.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1008
static consume(ScopedCallback &$sc=null)
Trigger a scoped callback and destroy it.
static newDefault()
const DB_MASTER
Definition: Defines.php:48
This serves as the entry point to the MediaWiki session handling system.
static newFromObject($object)
Return the same object, without access restrictions.
static login($username, $password, WebRequest $request)
Try to log the user in.
setMwGlobals($pairs, $value=null)
A Config instance which stores all settings as a member variable.
Definition: HashConfig.php:28
BotPassword Database.
testCanonicalizeLoginData($username, $password, $expectedResult)
provideCanonicalizeLoginData
testSave($password)
provideSave