The exception serves no purpose, and can only really be triggered via
a test. The API prevents no file extension at all, as does UW js.
This function (for whatever reason, probably a seperate bug) cannot
get the extension from a stashed stl file (seems to work fine for
other types).
With what/how it's actually used, it doens't really matter if
we can't get the extension, we get it by more robust methods later
on.
This partially reverts 0a82600a27. Before the changes in that commit,
the exception was unreachable.
Bug: T254078
Change-Id: I0a7bd13fe8e08c7d4a75b4a3709661dbbf53d6cb
77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Database
|
|
*
|
|
* @covers UploadStash
|
|
*/
|
|
class UploadStashTest extends MediaWikiTestCase {
|
|
/**
|
|
* @var TestUser[] Array of UploadStashTestUser
|
|
*/
|
|
public static $users;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $tmpFile;
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
|
|
$this->tmpFile = $this->getNewTempFile();
|
|
file_put_contents( $this->tmpFile, "\x00" );
|
|
|
|
self::$users = [
|
|
'sysop' => new TestUser(
|
|
'Uploadstashtestsysop',
|
|
'Upload Stash Test Sysop',
|
|
'upload_stash_test_sysop@example.com',
|
|
[ 'sysop' ]
|
|
),
|
|
'uploader' => new TestUser(
|
|
'Uploadstashtestuser',
|
|
'Upload Stash Test User',
|
|
'upload_stash_test_user@example.com',
|
|
[]
|
|
)
|
|
];
|
|
}
|
|
|
|
public static function provideInvalidRequests() {
|
|
return [
|
|
'Check failure on bad wpFileKey' =>
|
|
[ new FauxRequest( [ 'wpFileKey' => 'foo' ] ) ],
|
|
'Check failure on bad wpSessionKey' =>
|
|
[ new FauxRequest( [ 'wpSessionKey' => 'foo' ] ) ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideInvalidRequests
|
|
*/
|
|
public function testValidRequestWithInvalidRequests( $request ) {
|
|
$this->assertFalse( UploadFromStash::isValidRequest( $request ) );
|
|
}
|
|
|
|
public static function provideValidRequests() {
|
|
return [
|
|
'Check good wpFileKey' =>
|
|
[ new FauxRequest( [ 'wpFileKey' => 'testkey-test.test' ] ) ],
|
|
'Check good wpSessionKey' =>
|
|
[ new FauxRequest( [ 'wpFileKey' => 'testkey-test.test' ] ) ],
|
|
'Check key precedence' =>
|
|
[ new FauxRequest( [
|
|
'wpFileKey' => 'testkey-test.test',
|
|
'wpSessionKey' => 'foo'
|
|
] ) ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideValidRequests
|
|
*/
|
|
public function testValidRequestWithValidRequests( $request ) {
|
|
$this->assertTrue( UploadFromStash::isValidRequest( $request ) );
|
|
}
|
|
}
|