ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\ServerRangeTest Class Reference

This file tests HTTP requests that use the Range: header. More...

+ Inheritance diagram for Sabre\DAV\ServerRangeTest:
+ Collaboration diagram for Sabre\DAV\ServerRangeTest:

Public Member Functions

 setUp ()
 
 testRange ()
 
 testStartRange ()
 @depends testRange More...
 
 testEndRange ()
 @depends testRange More...
 
 testTooHighRange ()
 @depends testRange More...
 
 testCrazyRange ()
 @depends testRange More...
 
 testNonSeekableStream ()
 
 testIfRangeEtag ()
 @depends testRange More...
 
 testIfRangeEtagIncorrect ()
 @depends testIfRangeEtag More...
 
 testIfRangeModificationDate ()
 @depends testIfRangeEtag More...
 
 testIfRangeModificationDateModified ()
 @depends testIfRangeModificationDate More...
 
- Public Member Functions inherited from Sabre\DAVServerTest
 setUp ()
 
 initializeEverything ()
 
 request ($request, $expectedStatus=null)
 Makes a request, and returns a response object. More...
 
 autoLogin ($userName)
 This function takes a username and sets the server in a state where this user is logged in, and no longer requires an authentication check. More...
 
 setUpTree ()
 Override this to provide your own Tree for your test-case. More...
 
 setUpBackends ()
 
 assertHttpStatus ($expectedStatus, HTTP\Request $req)
 

Protected Attributes

 $setupFiles = true
 
 $lastModified
 We need this string a lot. More...
 
- Protected Attributes inherited from Sabre\DAVServerTest
 $setupCalDAV = false
 
 $setupCardDAV = false
 
 $setupACL = false
 
 $setupCalDAVSharing = false
 
 $setupCalDAVScheduling = false
 
 $setupCalDAVSubscriptions = false
 
 $setupCalDAVICSExport = false
 
 $setupLocks = false
 
 $setupFiles = false
 
 $setupSharing = false
 
 $setupPropertyStorage = false
 
 $caldavCalendars = []
 An array with calendars. More...
 
 $caldavCalendarObjects = []
 
 $carddavAddressBooks = []
 
 $carddavCards = []
 
 $server
 
 $tree = []
 
 $caldavBackend
 
 $carddavBackend
 
 $principalBackend
 
 $locksBackend
 
 $propertyStorageBackend
 
 $caldavPlugin
 
 $carddavPlugin
 
 $aclPlugin
 
 $caldavSharingPlugin
 
 $caldavSchedulePlugin
 
 $authPlugin
 
 $locksPlugin
 
 $sharingPlugin
 
 $propertyStoragePlugin
 
 $autoLogin = null
 If this string is set, we will automatically log in the user with this name. More...
 

Detailed Description

This file tests HTTP requests that use the Range: header.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 15 of file ServerRangeTest.php.

Member Function Documentation

◆ setUp()

Sabre\DAV\ServerRangeTest::setUp ( )

Reimplemented from Sabre\DAVServerTest.

Definition at line 24 of file ServerRangeTest.php.

24 {
25
26 parent::setUp();
27 $this->server->createFile('files/test.txt', 'Test contents');
28
29 $this->lastModified = HTTP\Util::toHTTPDate(
30 new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified())
31 );
32
33 $stream = popen('echo "Test contents"', 'r');
34 $streamingFile = new Mock\StreamingFile(
35 'no-seeking.txt',
37 );
38 $streamingFile->setSize(12);
39 $this->server->tree->getNodeForPath('files')->addNode($streamingFile);
40
41 }
static toHTTPDate(\DateTime $dateTime)
Transforms a DateTime object to HTTP's most common date format.
Definition: Util.php:69
$stream
PHP stream implementation.

References GuzzleHttp\Psr7\$stream, and Sabre\HTTP\Util\toHTTPDate().

+ Here is the call graph for this function:

◆ testCrazyRange()

Sabre\DAV\ServerRangeTest::testCrazyRange ( )

@depends testRange

Definition at line 126 of file ServerRangeTest.php.

126 {
127
128 $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=8-4']);
129 $response = $this->request($request);
130
131 $this->assertEquals(416, $response->getStatus());
132
133 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response

References $request, $response, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testEndRange()

Sabre\DAV\ServerRangeTest::testEndRange ( )

@depends testRange

Definition at line 90 of file ServerRangeTest.php.

90 {
91
92 $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=-8']);
93 $response = $this->request($request);
94
95 $this->assertEquals([
96 'X-Sabre-Version' => [Version::VERSION],
97 'Content-Type' => ['application/octet-stream'],
98 'Content-Length' => [8],
99 'Content-Range' => ['bytes 5-12/13'],
100 'ETag' => ['"' . md5('Test contents') . '"'],
101 'Last-Modified' => [$this->lastModified],
102 ],
103 $response->getHeaders()
104 );
105
106 $this->assertEquals(206, $response->getStatus());
107 $this->assertEquals('contents', $response->getBodyAsString());
108
109 }
const VERSION
Full version number.
Definition: Version.php:17

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testIfRangeEtag()

Sabre\DAV\ServerRangeTest::testIfRangeEtag ( )

@depends testRange

Definition at line 159 of file ServerRangeTest.php.

159 {
160
161 $request = new HTTP\Request('GET', '/files/test.txt', [
162 'Range' => 'bytes=2-5',
163 'If-Range' => '"' . md5('Test contents') . '"',
164 ]);
165 $response = $this->request($request);
166
167 $this->assertEquals([
168 'X-Sabre-Version' => [Version::VERSION],
169 'Content-Type' => ['application/octet-stream'],
170 'Content-Length' => [4],
171 'Content-Range' => ['bytes 2-5/13'],
172 'ETag' => ['"' . md5('Test contents') . '"'],
173 'Last-Modified' => [$this->lastModified],
174 ],
175 $response->getHeaders()
176 );
177
178 $this->assertEquals(206, $response->getStatus());
179 $this->assertEquals('st c', $response->getBodyAsString());
180
181 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testIfRangeEtagIncorrect()

Sabre\DAV\ServerRangeTest::testIfRangeEtagIncorrect ( )

@depends testIfRangeEtag

Definition at line 186 of file ServerRangeTest.php.

186 {
187
188 $request = new HTTP\Request('GET', '/files/test.txt', [
189 'Range' => 'bytes=2-5',
190 'If-Range' => '"foobar"',
191 ]);
192 $response = $this->request($request);
193
194 $this->assertEquals([
195 'X-Sabre-Version' => [Version::VERSION],
196 'Content-Type' => ['application/octet-stream'],
197 'Content-Length' => [13],
198 'ETag' => ['"' . md5('Test contents') . '"'],
199 'Last-Modified' => [$this->lastModified],
200 ],
201 $response->getHeaders()
202 );
203
204 $this->assertEquals(200, $response->getStatus());
205 $this->assertEquals('Test contents', $response->getBodyAsString());
206
207 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testIfRangeModificationDate()

Sabre\DAV\ServerRangeTest::testIfRangeModificationDate ( )

@depends testIfRangeEtag

Definition at line 212 of file ServerRangeTest.php.

212 {
213
214 $request = new HTTP\Request('GET', '/files/test.txt', [
215 'Range' => 'bytes=2-5',
216 'If-Range' => 'tomorrow',
217 ]);
218 $response = $this->request($request);
219
220 $this->assertEquals([
221 'X-Sabre-Version' => [Version::VERSION],
222 'Content-Type' => ['application/octet-stream'],
223 'Content-Length' => [4],
224 'Content-Range' => ['bytes 2-5/13'],
225 'ETag' => ['"' . md5('Test contents') . '"'],
226 'Last-Modified' => [$this->lastModified],
227 ],
228 $response->getHeaders()
229 );
230
231 $this->assertEquals(206, $response->getStatus());
232 $this->assertEquals('st c', $response->getBodyAsString());
233
234 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testIfRangeModificationDateModified()

Sabre\DAV\ServerRangeTest::testIfRangeModificationDateModified ( )

@depends testIfRangeModificationDate

Definition at line 239 of file ServerRangeTest.php.

239 {
240
241 $request = new HTTP\Request('GET', '/files/test.txt', [
242 'Range' => 'bytes=2-5',
243 'If-Range' => '-2 years',
244 ]);
245 $response = $this->request($request);
246
247 $this->assertEquals([
248 'X-Sabre-Version' => [Version::VERSION],
249 'Content-Type' => ['application/octet-stream'],
250 'Content-Length' => [13],
251 'ETag' => ['"' . md5('Test contents') . '"'],
252 'Last-Modified' => [$this->lastModified],
253 ],
254 $response->getHeaders()
255 );
256
257 $this->assertEquals(200, $response->getStatus());
258 $this->assertEquals('Test contents', $response->getBodyAsString());
259
260 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testNonSeekableStream()

Sabre\DAV\ServerRangeTest::testNonSeekableStream ( )

Definition at line 135 of file ServerRangeTest.php.

135 {
136
137 $request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']);
138 $response = $this->request($request);
139
140 $this->assertEquals(206, $response->getStatus(), $response);
141 $this->assertEquals([
142 'X-Sabre-Version' => [Version::VERSION],
143 'Content-Type' => ['application/octet-stream'],
144 'Content-Length' => [4],
145 'Content-Range' => ['bytes 2-5/12'],
146 // 'ETag' => ['"' . md5('Test contents') . '"'],
147 'Last-Modified' => [$this->lastModified],
148 ],
149 $response->getHeaders()
150 );
151
152 $this->assertEquals('st c', $response->getBodyAsString());
153
154 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testRange()

Sabre\DAV\ServerRangeTest::testRange ( )

Definition at line 43 of file ServerRangeTest.php.

43 {
44
45 $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-5']);
46 $response = $this->request($request);
47
48 $this->assertEquals([
49 'X-Sabre-Version' => [Version::VERSION],
50 'Content-Type' => ['application/octet-stream'],
51 'Content-Length' => [4],
52 'Content-Range' => ['bytes 2-5/13'],
53 'ETag' => ['"' . md5('Test contents') . '"'],
54 'Last-Modified' => [$this->lastModified],
55 ],
56 $response->getHeaders()
57 );
58 $this->assertEquals(206, $response->getStatus());
59 $this->assertEquals('st c', $response->getBodyAsString());
60
61 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testStartRange()

Sabre\DAV\ServerRangeTest::testStartRange ( )

@depends testRange

Definition at line 66 of file ServerRangeTest.php.

66 {
67
68 $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-']);
69 $response = $this->request($request);
70
71 $this->assertEquals([
72 'X-Sabre-Version' => [Version::VERSION],
73 'Content-Type' => ['application/octet-stream'],
74 'Content-Length' => [11],
75 'Content-Range' => ['bytes 2-12/13'],
76 'ETag' => ['"' . md5('Test contents') . '"'],
77 'Last-Modified' => [$this->lastModified],
78 ],
79 $response->getHeaders()
80 );
81
82 $this->assertEquals(206, $response->getStatus());
83 $this->assertEquals('st contents', $response->getBodyAsString());
84
85 }

References $request, $response, Sabre\DAVServerTest\request(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testTooHighRange()

Sabre\DAV\ServerRangeTest::testTooHighRange ( )

@depends testRange

Definition at line 114 of file ServerRangeTest.php.

114 {
115
116 $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=100-200']);
117 $response = $this->request($request);
118
119 $this->assertEquals(416, $response->getStatus());
120
121 }

References $request, $response, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

Field Documentation

◆ $lastModified

Sabre\DAV\ServerRangeTest::$lastModified
protected

We need this string a lot.

Definition at line 22 of file ServerRangeTest.php.

◆ $setupFiles

Sabre\DAV\ServerRangeTest::$setupFiles = true
protected

Definition at line 17 of file ServerRangeTest.php.


The documentation for this class was generated from the following file: