8 * @covers SwiftFileBackend
9 * @covers SwiftFileBackendDirList
10 * @covers SwiftFileBackendFileList
11 * @covers SwiftFileBackendList
13 class SwiftFileBackendTest
extends MediaWikiTestCase
{
14 /** @var TestingAccessWrapper Proxy to SwiftFileBackend */
17 protected function setUp() {
20 $this->backend
= TestingAccessWrapper
::newFromObject(
21 new SwiftFileBackend( [
22 'name' => 'local-swift-testing',
23 'class' => 'SwiftFileBackend',
24 'wikiId' => 'unit-testing',
25 'lockManager' => LockManagerGroup
::singleton()->get( 'fsLockManager' ),
26 'swiftAuthUrl' => 'http://127.0.0.1:8080/auth', // unused
27 'swiftUser' => 'test:tester',
28 'swiftKey' => 'testing',
29 'swiftTempUrlKey' => 'b3968d0207b54ece87cccc06515a89d4' // unused
35 * @dataProvider provider_testSanitizeHdrs
37 public function testSanitizeHdrs( $raw, $sanitized ) {
38 $hdrs = $this->backend
->sanitizeHdrs( [ 'headers' => $raw ] );
40 $this->assertEquals( $hdrs, $sanitized, 'sanitizeHdrs() has expected result' );
43 public static function provider_testSanitizeHdrs() {
47 'content-length' => 345,
48 'content-type' => 'image+bitmap/jpeg',
49 'content-disposition' => 'inline',
50 'content-duration' => 35.6363,
51 'content-Custom' => 'hello',
52 'x-content-custom' => 'hello'
55 'content-disposition' => 'inline',
56 'content-duration' => 35.6363,
57 'content-custom' => 'hello',
58 'x-content-custom' => 'hello'
63 'content-length' => 345,
64 'content-type' => 'image+bitmap/jpeg',
65 'content-Disposition' => 'inline; filename=xxx; ' . str_repeat( 'o', 1024 ),
66 'content-duration' => 35.6363,
67 'content-custom' => 'hello',
68 'x-content-custom' => 'hello'
71 'content-disposition' => 'inline;filename=xxx',
72 'content-duration' => 35.6363,
73 'content-custom' => 'hello',
74 'x-content-custom' => 'hello'
79 'content-length' => 345,
80 'content-type' => 'image+bitmap/jpeg',
81 'content-disposition' => 'filename=' . str_repeat( 'o', 1024 ) . ';inline',
82 'content-duration' => 35.6363,
83 'content-custom' => 'hello',
84 'x-content-custom' => 'hello'
87 'content-disposition' => '',
88 'content-duration' => 35.6363,
89 'content-custom' => 'hello',
90 'x-content-custom' => 'hello'
97 * @dataProvider provider_testGetMetadataHeaders
99 public function testGetMetadataHeaders( $raw, $sanitized ) {
100 $hdrs = $this->backend
->getMetadataHeaders( $raw );
102 $this->assertEquals( $hdrs, $sanitized, 'getMetadataHeaders() has expected result' );
105 public static function provider_testGetMetadataHeaders() {
109 'content-length' => 345,
110 'content-custom' => 'hello',
111 'x-content-custom' => 'hello',
112 'x-object-meta-custom' => 5,
113 'x-object-meta-sha1Base36' => 'a3deadfg...',
116 'x-object-meta-custom' => 5,
117 'x-object-meta-sha1base36' => 'a3deadfg...',
124 * @dataProvider provider_testGetMetadata
126 public function testGetMetadata( $raw, $sanitized ) {
127 $hdrs = $this->backend
->getMetadata( $raw );
129 $this->assertEquals( $hdrs, $sanitized, 'getMetadata() has expected result' );
132 public static function provider_testGetMetadata() {
136 'content-length' => 345,
137 'content-custom' => 'hello',
138 'x-content-custom' => 'hello',
139 'x-object-meta-custom' => 5,
140 'x-object-meta-sha1Base36' => 'a3deadfg...',
144 'sha1base36' => 'a3deadfg...',