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

Tests related to the PUT request. More...

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

Public Member Functions

 setUpTree ()
 Sets up the DAV tree. More...
 
 testPut ()
 A successful PUT of a new file. More...
 
 testPutExisting ()
 A successful PUT on an existing file. More...
 
 testPutExistingIfMatchStar ()
 PUT on existing file with If-Match: *. More...
 
 testPutExistingIfMatchCorrect ()
 PUT on existing file with If-Match: with a correct etag. More...
 
 testPutContentRange ()
 PUT with Content-Range should be rejected. More...
 
 testPutIfNoneMatchStar ()
 PUT on non-existing file with If-None-Match: * should work. More...
 
 testPutIfMatchStar ()
 PUT on non-existing file with If-Match: * should fail. More...
 
 testPutExistingIfNoneMatchStar ()
 PUT on existing file with If-None-Match: * should fail. More...
 
 testPutNoParent ()
 PUT thats created in a non-collection should be rejected. More...
 
 testFinderPutSuccess ()
 Finder may sometimes make a request, which gets its content-body stripped. More...
 
 testFinderPutFail ()
 Same as the last one, but in this case we're mimicing a failed request. More...
 
 testPutIntercept ()
 Plugins can intercept PUT. 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)
 

Additional Inherited Members

- 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

Tests related to the PUT request.

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

Definition at line 15 of file HttpPutTest.php.

Member Function Documentation

◆ setUpTree()

Sabre\DAV\HttpPutTest::setUpTree ( )

Sets up the DAV tree.

Returns
void

Definition at line 22 of file HttpPutTest.php.

22  {
23 
24  $this->tree = new Mock\Collection('root', [
25  'file1' => 'foo',
26  ]);
27 
28  }

◆ testFinderPutFail()

Sabre\DAV\HttpPutTest::testFinderPutFail ( )

Same as the last one, but in this case we're mimicing a failed request.

testFinderPutSuccess

Definition at line 307 of file HttpPutTest.php.

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

307  {
308 
309  $request = new HTTP\Request(
310  'PUT',
311  '/file2',
312  ['X-Expected-Entity-Length' => '5'],
313  ''
314  );
315 
316  $response = $this->request($request);
317 
318  $this->assertEquals(403, $response->getStatus());
319 
320  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testFinderPutSuccess()

Sabre\DAV\HttpPutTest::testFinderPutSuccess ( )

Finder may sometimes make a request, which gets its content-body stripped.

We can't always prevent this from happening, but in some cases we can detected this and return an error instead.

testPut

Definition at line 274 of file HttpPutTest.php.

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

274  {
275 
276  $request = new HTTP\Request(
277  'PUT',
278  '/file2',
279  ['X-Expected-Entity-Length' => '5'],
280  'hello'
281  );
282  $response = $this->request($request);
283 
284  $this->assertEquals(201, $response->getStatus());
285 
286  $this->assertEquals(
287  'hello',
288  $this->server->tree->getNodeForPath('file2')->get()
289  );
290 
291  $this->assertEquals(
292  [
293  'X-Sabre-Version' => [Version::VERSION],
294  'Content-Length' => ['0'],
295  'ETag' => ['"' . md5('hello') . '"'],
296  ],
297  $response->getHeaders()
298  );
299 
300  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPut()

Sabre\DAV\HttpPutTest::testPut ( )

A successful PUT of a new file.

Definition at line 33 of file HttpPutTest.php.

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

33  {
34 
35  $request = new HTTP\Request('PUT', '/file2', [], 'hello');
36 
37  $response = $this->request($request);
38 
39  $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:' . $response->getBodyAsString());
40 
41  $this->assertEquals(
42  'hello',
43  $this->server->tree->getNodeForPath('file2')->get()
44  );
45 
46  $this->assertEquals(
47  [
48  'X-Sabre-Version' => [Version::VERSION],
49  'Content-Length' => ['0'],
50  'ETag' => ['"' . md5('hello') . '"']
51  ],
52  $response->getHeaders()
53  );
54 
55  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutContentRange()

Sabre\DAV\HttpPutTest::testPutContentRange ( )

PUT with Content-Range should be rejected.

testPut

Definition at line 159 of file HttpPutTest.php.

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

159  {
160 
161  $request = new HTTP\Request(
162  'PUT',
163  '/file2',
164  ['Content-Range' => 'bytes/100-200'],
165  'hello'
166  );
167 
168  $response = $this->request($request);
169  $this->assertEquals(400, $response->getStatus());
170 
171  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutExisting()

Sabre\DAV\HttpPutTest::testPutExisting ( )

A successful PUT on an existing file.

testPut

Definition at line 62 of file HttpPutTest.php.

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

62  {
63 
64  $request = new HTTP\Request('PUT', '/file1', [], 'bar');
65 
66  $response = $this->request($request);
67 
68  $this->assertEquals(204, $response->getStatus());
69 
70  $this->assertEquals(
71  'bar',
72  $this->server->tree->getNodeForPath('file1')->get()
73  );
74 
75  $this->assertEquals(
76  [
77  'X-Sabre-Version' => [Version::VERSION],
78  'Content-Length' => ['0'],
79  'ETag' => ['"' . md5('bar') . '"']
80  ],
81  $response->getHeaders()
82  );
83 
84  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutExistingIfMatchCorrect()

Sabre\DAV\HttpPutTest::testPutExistingIfMatchCorrect ( )

PUT on existing file with If-Match: with a correct etag.

testPutExisting

Definition at line 125 of file HttpPutTest.php.

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

125  {
126 
127  $request = new HTTP\Request(
128  'PUT',
129  '/file1',
130  ['If-Match' => '"' . md5('foo') . '"'],
131  'hello'
132  );
133 
134  $response = $this->request($request);
135 
136  $this->assertEquals(204, $response->status);
137 
138  $this->assertEquals(
139  'hello',
140  $this->server->tree->getNodeForPath('file1')->get()
141  );
142 
143  $this->assertEquals(
144  [
145  'X-Sabre-Version' => [Version::VERSION],
146  'Content-Length' => ['0'],
147  'ETag' => ['"' . md5('hello') . '"'],
148  ],
149  $response->getHeaders()
150  );
151 
152  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutExistingIfMatchStar()

Sabre\DAV\HttpPutTest::testPutExistingIfMatchStar ( )

PUT on existing file with If-Match: *.

testPutExisting

Definition at line 91 of file HttpPutTest.php.

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

91  {
92 
93  $request = new HTTP\Request(
94  'PUT',
95  '/file1',
96  ['If-Match' => '*'],
97  'hello'
98  );
99 
100  $response = $this->request($request);
101 
102  $this->assertEquals(204, $response->getStatus());
103 
104  $this->assertEquals(
105  'hello',
106  $this->server->tree->getNodeForPath('file1')->get()
107  );
108 
109  $this->assertEquals(
110  [
111  'X-Sabre-Version' => [Version::VERSION],
112  'Content-Length' => ['0'],
113  'ETag' => ['"' . md5('hello') . '"']
114  ],
115  $response->getHeaders()
116  );
117 
118  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutExistingIfNoneMatchStar()

Sabre\DAV\HttpPutTest::testPutExistingIfNoneMatchStar ( )

PUT on existing file with If-None-Match: * should fail.

testPut

Definition at line 232 of file HttpPutTest.php.

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

232  {
233 
234  $request = new HTTP\Request(
235  'PUT',
236  '/file1',
237  ['If-None-Match' => '*'],
238  'hello'
239  );
240  $request->setBody('hello');
241 
242  $response = $this->request($request);
243 
244  $this->assertEquals(412, $response->getStatus());
245 
246  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutIfMatchStar()

Sabre\DAV\HttpPutTest::testPutIfMatchStar ( )

PUT on non-existing file with If-Match: * should fail.

testPut

Definition at line 212 of file HttpPutTest.php.

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

212  {
213 
214  $request = new HTTP\Request(
215  'PUT',
216  '/file2',
217  ['If-Match' => '*'],
218  'hello'
219  );
220 
221  $response = $this->request($request);
222 
223  $this->assertEquals(412, $response->getStatus());
224 
225  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutIfNoneMatchStar()

Sabre\DAV\HttpPutTest::testPutIfNoneMatchStar ( )

PUT on non-existing file with If-None-Match: * should work.

testPut

Definition at line 178 of file HttpPutTest.php.

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

178  {
179 
180  $request = new HTTP\Request(
181  'PUT',
182  '/file2',
183  ['If-None-Match' => '*'],
184  'hello'
185  );
186 
187  $response = $this->request($request);
188 
189  $this->assertEquals(201, $response->getStatus());
190 
191  $this->assertEquals(
192  'hello',
193  $this->server->tree->getNodeForPath('file2')->get()
194  );
195 
196  $this->assertEquals(
197  [
198  'X-Sabre-Version' => [Version::VERSION],
199  'Content-Length' => ['0'],
200  'ETag' => ['"' . md5('hello') . '"']
201  ],
202  $response->getHeaders()
203  );
204 
205  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutIntercept()

Sabre\DAV\HttpPutTest::testPutIntercept ( )

Plugins can intercept PUT.

We need to make sure that works.

testPut

Definition at line 327 of file HttpPutTest.php.

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

327  {
328 
329  $this->server->on('beforeBind', function($uri) {
330  $this->server->httpResponse->setStatus(418);
331  return false;
332  });
333 
334  $request = new HTTP\Request('PUT', '/file2', [], 'hello');
335  $response = $this->request($request);
336 
337  $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: ' . $response->getBodyAsString());
338 
339  $this->assertFalse(
340  $this->server->tree->nodeExists('file2')
341  );
342 
343  $this->assertEquals([
344  'X-Sabre-Version' => [Version::VERSION],
345  ], $response->getHeaders());
346 
347  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

◆ testPutNoParent()

Sabre\DAV\HttpPutTest::testPutNoParent ( )

PUT thats created in a non-collection should be rejected.

testPut

Definition at line 253 of file HttpPutTest.php.

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

253  {
254 
255  $request = new HTTP\Request(
256  'PUT',
257  '/file1/file2',
258  [],
259  'hello'
260  );
261 
262  $response = $this->request($request);
263  $this->assertEquals(409, $response->getStatus());
264 
265  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$response
+ Here is the call graph for this function:

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