X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Ffilebackend%2FSwiftFileBackendTest.php;h=35eca28f7e001da578461a25797a3475ace34569;hb=08b2cf66387856c623ff99bca4a83db2b7d8c9e6;hp=9cd2b100cd989b3701590f7b8b989bd54d9a716d;hpb=16a9c7076f5eb5279d6eb1384751a08a4e33f532;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php b/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php index 9cd2b100cd..35eca28f7e 100644 --- a/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php +++ b/tests/phpunit/includes/filebackend/SwiftFileBackendTest.php @@ -22,7 +22,7 @@ class SwiftFileBackendTest extends MediaWikiTestCase { $this->backend = TestingAccessWrapper::newFromObject( new SwiftFileBackend( [ 'name' => 'local-swift-testing', - 'class' => 'SwiftFileBackend', + 'class' => SwiftFileBackend::class, 'wikiId' => 'unit-testing', 'lockManager' => LockManagerGroup::singleton()->get( 'fsLockManager' ), 'swiftAuthUrl' => 'http://127.0.0.1:8080/auth', // unused @@ -33,6 +33,68 @@ class SwiftFileBackendTest extends MediaWikiTestCase { ); } + /** + * @dataProvider provider_testSanitizeHdrsStrict + */ + public function testSanitizeHdrsStrict( $raw, $sanitized ) { + $hdrs = $this->backend->sanitizeHdrsStrict( [ 'headers' => $raw ] ); + + $this->assertEquals( $hdrs, $sanitized, 'sanitizeHdrsStrict() has expected result' ); + } + + public static function provider_testSanitizeHdrsStrict() { + return [ + [ + [ + 'content-length' => 345, + 'content-type' => 'image+bitmap/jpeg', + 'content-disposition' => 'inline', + 'content-duration' => 35.6363, + 'content-Custom' => 'hello', + 'x-content-custom' => 'hello' + ], + [ + 'content-disposition' => 'inline', + 'content-duration' => 35.6363, + 'content-custom' => 'hello', + 'x-content-custom' => 'hello' + ] + ], + [ + [ + 'content-length' => 345, + 'content-type' => 'image+bitmap/jpeg', + 'content-Disposition' => 'inline; filename=xxx; ' . str_repeat( 'o', 1024 ), + 'content-duration' => 35.6363, + 'content-custom' => 'hello', + 'x-content-custom' => 'hello' + ], + [ + 'content-disposition' => 'inline;filename=xxx', + 'content-duration' => 35.6363, + 'content-custom' => 'hello', + 'x-content-custom' => 'hello' + ] + ], + [ + [ + 'content-length' => 345, + 'content-type' => 'image+bitmap/jpeg', + 'content-disposition' => 'filename=' . str_repeat( 'o', 1024 ) . ';inline', + 'content-duration' => 35.6363, + 'content-custom' => 'hello', + 'x-content-custom' => 'hello' + ], + [ + 'content-disposition' => '', + 'content-duration' => 35.6363, + 'content-custom' => 'hello', + 'x-content-custom' => 'hello' + ] + ] + ]; + } + /** * @dataProvider provider_testSanitizeHdrs */ @@ -54,6 +116,7 @@ class SwiftFileBackendTest extends MediaWikiTestCase { 'x-content-custom' => 'hello' ], [ + 'content-type' => 'image+bitmap/jpeg', 'content-disposition' => 'inline', 'content-duration' => 35.6363, 'content-custom' => 'hello', @@ -70,6 +133,7 @@ class SwiftFileBackendTest extends MediaWikiTestCase { 'x-content-custom' => 'hello' ], [ + 'content-type' => 'image+bitmap/jpeg', 'content-disposition' => 'inline;filename=xxx', 'content-duration' => 35.6363, 'content-custom' => 'hello', @@ -86,6 +150,7 @@ class SwiftFileBackendTest extends MediaWikiTestCase { 'x-content-custom' => 'hello' ], [ + 'content-type' => 'image+bitmap/jpeg', 'content-disposition' => '', 'content-duration' => 35.6363, 'content-custom' => 'hello',