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

Tests related to the HEAD request. More...

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

Public Member Functions

 setUpTree ()
 Sets up the DAV tree. More...
 
 testHEAD ()
 
 testHEADCollection ()
 According to the specs, HEAD should behave identical to GET. More...
 
 testDoubleAuth ()
 HEAD automatically internally maps to GET via a sub-request. 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 HEAD request.

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

Definition at line 15 of file HttpHeadTest.php.

Member Function Documentation

◆ setUpTree()

Sabre\DAV\HttpHeadTest::setUpTree ( )

Sets up the DAV tree.

Returns
void

Reimplemented from Sabre\DAVServerTest.

Definition at line 22 of file HttpHeadTest.php.

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

◆ testDoubleAuth()

Sabre\DAV\HttpHeadTest::testDoubleAuth ( )

HEAD automatically internally maps to GET via a sub-request.

The Auth plugin must not be triggered twice for these, so we'll test for that.

Definition at line 75 of file HttpHeadTest.php.

75 {
76
77 $count = 0;
78
79 $authBackend = new Auth\Backend\BasicCallBack(function($userName, $password) use (&$count) {
80 $count++;
81 return true;
82 });
83 $this->server->addPlugin(
84 new Auth\Plugin(
86 )
87 );
88 $request = new HTTP\Request('HEAD', '/file1', ['Authorization' => 'Basic ' . base64_encode('user:pass')]);
89 $response = $this->request($request);
90
91 $this->assertEquals(200, $response->getStatus());
92
93 $this->assertEquals(1, $count, 'Auth was triggered twice :(');
94
95 }
$authBackend
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
$password
Definition: cron.php:14
$response

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

+ Here is the call graph for this function:

◆ testHEAD()

Sabre\DAV\HttpHeadTest::testHEAD ( )

Definition at line 32 of file HttpHeadTest.php.

32 {
33
34 $request = new HTTP\Request('HEAD', '//file1');
35 $response = $this->request($request);
36
37 $this->assertEquals(200, $response->getStatus());
38
39 // Removing Last-Modified because it keeps changing.
40 $response->removeHeader('Last-Modified');
41
42 $this->assertEquals(
43 [
44 'X-Sabre-Version' => [Version::VERSION],
45 'Content-Type' => ['application/octet-stream'],
46 'Content-Length' => [3],
47 'ETag' => ['"' . md5('foo') . '"'],
48 ],
49 $response->getHeaders()
50 );
51
52 $this->assertEquals('', $response->getBodyAsString());
53
54 }
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:

◆ testHEADCollection()

Sabre\DAV\HttpHeadTest::testHEADCollection ( )

According to the specs, HEAD should behave identical to GET.

But, broken clients needs HEAD requests on collections to respond with a 200, so that's what we do.

Definition at line 61 of file HttpHeadTest.php.

61 {
62
63 $request = new HTTP\Request('HEAD', '/dir');
64 $response = $this->request($request);
65
66 $this->assertEquals(200, $response->getStatus());
67
68 }

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

+ Here is the call graph for this function:

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