3 use Wikimedia\TestingAccessWrapper
;
10 * @covers SwiftFileBackend
11 * @covers SwiftFileBackendDirList
12 * @covers SwiftFileBackendFileList
13 * @covers SwiftFileBackendList
15 class SwiftFileBackendTest
extends MediaWikiTestCase
{
16 /** @var TestingAccessWrapper|SwiftFileBackend */
19 protected function setUp() {
22 $this->backend
= TestingAccessWrapper
::newFromObject(
23 new SwiftFileBackend( [
24 'name' => 'local-swift-testing',
25 'class' => SwiftFileBackend
::class,
26 'wikiId' => 'unit-testing',
27 'lockManager' => LockManagerGroup
::singleton()->get( 'fsLockManager' ),
28 'swiftAuthUrl' => 'http://127.0.0.1:8080/auth', // unused
29 'swiftUser' => 'test:tester',
30 'swiftKey' => 'testing',
31 'swiftTempUrlKey' => 'b3968d0207b54ece87cccc06515a89d4' // unused
37 * @covers SwiftFileBackend::extractMutableContentHeaders
38 * @dataProvider provider_testExtractPostableContentHeaders
40 public function testExtractPostableContentHeaders( $raw, $sanitized ) {
41 $hdrs = $this->backend
->extractMutableContentHeaders( $raw );
43 $this->assertEquals( $hdrs, $sanitized, 'Correct extractPostableContentHeaders() result' );
46 public static function provider_testExtractPostableContentHeaders() {
50 'content-length' => 345,
51 'content-type' => 'image+bitmap/jpeg',
52 'content-disposition' => 'inline',
53 'content-duration' => 35.6363,
54 'content-Custom' => 'hello',
55 'x-content-custom' => 'hello'
58 'content-type' => 'image+bitmap/jpeg',
59 'content-disposition' => 'inline',
60 'content-duration' => 35.6363,
61 'content-custom' => 'hello',
62 'x-content-custom' => 'hello'
67 'content-length' => 345,
68 'content-type' => 'image+bitmap/jpeg',
69 'content-Disposition' => 'inline; filename=xxx; ' . str_repeat( 'o', 1024 ),
70 'content-duration' => 35.6363,
71 'content-custom' => 'hello',
72 'x-content-custom' => 'hello'
75 'content-type' => 'image+bitmap/jpeg',
76 'content-disposition' => 'inline;filename=xxx',
77 'content-duration' => 35.6363,
78 'content-custom' => 'hello',
79 'x-content-custom' => 'hello'
84 'content-length' => 345,
85 'content-type' => 'image+bitmap/jpeg',
86 'content-disposition' => 'filename=' . str_repeat( 'o', 1024 ) . ';inline',
87 'content-duration' => 35.6363,
88 'content-custom' => 'hello',
89 'x-content-custom' => 'hello'
92 'content-type' => 'image+bitmap/jpeg',
93 'content-disposition' => '',
94 'content-duration' => 35.6363,
95 'content-custom' => 'hello',
96 'x-content-custom' => 'hello'
103 * @covers SwiftFileBackend::extractMetadataHeaders
104 * @dataProvider provider_testGetMetadataHeaders
106 public function testGetMetadataHeaders( $raw, $sanitized ) {
107 $hdrs = $this->backend
->extractMetadataHeaders( $raw );
109 $this->assertEquals( $hdrs, $sanitized, 'getMetadataHeaders() has expected result' );
112 public static function provider_testGetMetadataHeaders() {
116 'content-length' => 345,
117 'content-custom' => 'hello',
118 'x-content-custom' => 'hello',
119 'x-object-meta-custom' => 5,
120 'x-object-meta-sha1Base36' => 'a3deadfg...',
123 'x-object-meta-custom' => 5,
124 'x-object-meta-sha1base36' => 'a3deadfg...',
131 * @covers SwiftFileBackend::getMetadataFromHeaders
132 * @dataProvider provider_testGetMetadata
134 public function testGetMetadata( $raw, $sanitized ) {
135 $hdrs = $this->backend
->getMetadataFromHeaders( $raw );
137 $this->assertEquals( $hdrs, $sanitized, 'getMetadata() has expected result' );
140 public static function provider_testGetMetadata() {
144 'content-length' => 345,
145 'content-custom' => 'hello',
146 'x-content-custom' => 'hello',
147 'x-object-meta-custom' => 5,
148 'x-object-meta-sha1Base36' => 'a3deadfg...',
152 'sha1base36' => 'a3deadfg...',