mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
31c59374a4
Also update MathCaptcha so that it works with recent versions of Math (and breaks with old ones). Also fix MathCaptcha API output, which used to send the question in plaintext. Bug: T110302 Change-Id: I0da671a546700110d789b79a3089460abd9cce3b Depends-On: I8b52ec8ddf494f23941807638f149f15b5e46b0c
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Auth\AuthenticationRequestTestCase;
|
|
use MediaWiki\Auth\AuthManager;
|
|
|
|
class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
|
|
public function setUp() {
|
|
parent::setUp();
|
|
$this->setMwGlobals( [
|
|
'wgCaptchaClass' => 'SimpleCaptcha',
|
|
'wgCaptchaStorageClass' => CaptchaHashStore::class,
|
|
] );
|
|
CaptchaStore::get()->clearAll();
|
|
CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
|
|
}
|
|
|
|
protected function getInstance( array $args = [] ) {
|
|
return new CaptchaAuthenticationRequest( $args[0], $args[1] );
|
|
}
|
|
|
|
public static function provideGetFieldInfo() {
|
|
return [
|
|
[ [ '123', [ 'question' => '1+2', 'answer' => '3' ] ] ],
|
|
];
|
|
}
|
|
|
|
public function provideLoadFromSubmission() {
|
|
return [
|
|
'no id' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[],
|
|
false,
|
|
],
|
|
'no answer' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '345' ],
|
|
false,
|
|
],
|
|
'missing' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '234', 'captchaWord' => '5' ],
|
|
false,
|
|
],
|
|
'normal' => [
|
|
[ '123', [ 'question' => '1+2', 'answer' => '3' ] ],
|
|
[ 'captchaId' => '345', 'captchaWord' => '5' ],
|
|
[ 'captchaId' => '345', 'captchaData' => [ 'question' => '2+2', 'answer' => '4' ],
|
|
'captchaWord' => '5' ],
|
|
],
|
|
];
|
|
}
|
|
}
|