ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAVACL\PrincipalPropertySearchTest Class Reference
+ Inheritance diagram for Sabre\DAVACL\PrincipalPropertySearchTest:
+ Collaboration diagram for Sabre\DAVACL\PrincipalPropertySearchTest:

Public Member Functions

 getServer ()
 
 testDepth1 ()
 
 testUnknownSearchField ()
 
 testCorrect ()
 
 testAND ()
 
 testOR ()
 
 testWrongUri ()
 

Detailed Description

Definition at line 10 of file PrincipalPropertySearchTest.php.

Member Function Documentation

◆ getServer()

Sabre\DAVACL\PrincipalPropertySearchTest::getServer ( )

Definition at line 12 of file PrincipalPropertySearchTest.php.

12 {
13
14 $backend = new PrincipalBackend\Mock();
15
16 $dir = new DAV\SimpleCollection('root');
17 $principals = new PrincipalCollection($backend);
18 $dir->addChild($principals);
19
20 $fakeServer = new DAV\Server($dir);
21 $fakeServer->sapi = new HTTP\SapiMock();
22 $fakeServer->httpResponse = new HTTP\ResponseMock();
23 $fakeServer->debugExceptions = true;
24 $plugin = new MockPlugin();
25 $plugin->allowAccessToNodesWithoutACL = true;
26 $plugin->allowUnauthenticatedAccess = false;
27
28 $this->assertTrue($plugin instanceof Plugin);
29 $fakeServer->addPlugin($plugin);
30 $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
31
32 return $fakeServer;
33
34 }

Referenced by Sabre\DAVACL\PrincipalPropertySearchTest\testAND(), Sabre\DAVACL\PrincipalPropertySearchTest\testCorrect(), Sabre\DAVACL\PrincipalPropertySearchTest\testDepth1(), Sabre\DAVACL\PrincipalPropertySearchTest\testOR(), Sabre\DAVACL\PrincipalPropertySearchTest\testUnknownSearchField(), and Sabre\DAVACL\PrincipalPropertySearchTest\testWrongUri().

+ Here is the caller graph for this function:

◆ testAND()

Sabre\DAVACL\PrincipalPropertySearchTest::testAND ( )

Definition at line 181 of file PrincipalPropertySearchTest.php.

181 {
182
183 $xml = '<?xml version="1.0"?>
184<d:principal-property-search xmlns:d="DAV:">
185 <d:apply-to-principal-collection-set />
186 <d:property-search>
187 <d:prop>
188 <d:displayname />
189 </d:prop>
190 <d:match>user</d:match>
191 </d:property-search>
192 <d:property-search>
193 <d:prop>
194 <d:foo />
195 </d:prop>
196 <d:match>bar</d:match>
197 </d:property-search>
198 <d:prop>
199 <d:displayname />
200 <d:getcontentlength />
201 </d:prop>
202</d:principal-property-search>';
203
204 $serverVars = [
205 'REQUEST_METHOD' => 'REPORT',
206 'HTTP_DEPTH' => '0',
207 'REQUEST_URI' => '/',
208 ];
209
211 $request->setBody($xml);
212
213 $server = $this->getServer();
214 $server->httpRequest = $request;
215
216 $server->exec();
217
218 $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body);
219 $this->assertEquals([
220 'X-Sabre-Version' => [DAV\Version::VERSION],
221 'Content-Type' => ['application/xml; charset=utf-8'],
222 'Vary' => ['Brief,Prefer'],
223 ], $server->httpResponse->getHeaders());
224
225
226 $check = [
227 '/d:multistatus',
228 '/d:multistatus/d:response' => 0,
229 '/d:multistatus/d:response/d:href' => 0,
230 '/d:multistatus/d:response/d:propstat' => 0,
231 '/d:multistatus/d:response/d:propstat/d:prop' => 0,
232 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0,
233 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0,
234 '/d:multistatus/d:response/d:propstat/d:status' => 0,
235 ];
236
237 $xml = simplexml_load_string($server->httpResponse->body);
238 $xml->registerXPathNamespace('d', 'DAV:');
239 foreach ($check as $v1 => $v2) {
240
241 $xpath = is_int($v1) ? $v2 : $v1;
242
243 $result = $xml->xpath($xpath);
244
245 $count = 1;
246 if (!is_int($v1)) $count = $v2;
247
248 $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
249
250 }
251
252 }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$server
Definition: sabredav.php:48

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testCorrect()

Sabre\DAVACL\PrincipalPropertySearchTest::testCorrect ( )

Definition at line 114 of file PrincipalPropertySearchTest.php.

114 {
115
116 $xml = '<?xml version="1.0"?>
117<d:principal-property-search xmlns:d="DAV:">
118 <d:apply-to-principal-collection-set />
119 <d:property-search>
120 <d:prop>
121 <d:displayname />
122 </d:prop>
123 <d:match>user</d:match>
124 </d:property-search>
125 <d:prop>
126 <d:displayname />
127 <d:getcontentlength />
128 </d:prop>
129</d:principal-property-search>';
130
131 $serverVars = [
132 'REQUEST_METHOD' => 'REPORT',
133 'HTTP_DEPTH' => '0',
134 'REQUEST_URI' => '/',
135 ];
136
138 $request->setBody($xml);
139
140 $server = $this->getServer();
141 $server->httpRequest = $request;
142
143 $server->exec();
144
145 $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body);
146 $this->assertEquals([
147 'X-Sabre-Version' => [DAV\Version::VERSION],
148 'Content-Type' => ['application/xml; charset=utf-8'],
149 'Vary' => ['Brief,Prefer'],
150 ], $server->httpResponse->getHeaders());
151
152
153 $check = [
154 '/d:multistatus',
155 '/d:multistatus/d:response' => 2,
156 '/d:multistatus/d:response/d:href' => 2,
157 '/d:multistatus/d:response/d:propstat' => 4,
158 '/d:multistatus/d:response/d:propstat/d:prop' => 4,
159 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2,
160 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2,
161 '/d:multistatus/d:response/d:propstat/d:status' => 4,
162 ];
163
164 $xml = simplexml_load_string($server->httpResponse->body);
165 $xml->registerXPathNamespace('d', 'DAV:');
166 foreach ($check as $v1 => $v2) {
167
168 $xpath = is_int($v1) ? $v2 : $v1;
169
170 $result = $xml->xpath($xpath);
171
172 $count = 1;
173 if (!is_int($v1)) $count = $v2;
174
175 $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
176
177 }
178
179 }

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testDepth1()

Sabre\DAVACL\PrincipalPropertySearchTest::testDepth1 ( )

Definition at line 36 of file PrincipalPropertySearchTest.php.

36 {
37
38 $xml = '<?xml version="1.0"?>
39<d:principal-property-search xmlns:d="DAV:">
40 <d:property-search>
41 <d:prop>
42 <d:displayname />
43 </d:prop>
44 <d:match>user</d:match>
45 </d:property-search>
46 <d:prop>
47 <d:displayname />
48 <d:getcontentlength />
49 </d:prop>
50</d:principal-property-search>';
51
52 $serverVars = [
53 'REQUEST_METHOD' => 'REPORT',
54 'HTTP_DEPTH' => '1',
55 'REQUEST_URI' => '/principals',
56 ];
57
59 $request->setBody($xml);
60
61 $server = $this->getServer();
62 $server->httpRequest = $request;
63
64 $server->exec();
65
66 $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString());
67 $this->assertEquals([
68 'X-Sabre-Version' => [DAV\Version::VERSION],
69 'Content-Type' => ['application/xml; charset=utf-8'],
70 ], $server->httpResponse->getHeaders());
71
72 }

References $request, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testOR()

Sabre\DAVACL\PrincipalPropertySearchTest::testOR ( )

Definition at line 253 of file PrincipalPropertySearchTest.php.

253 {
254
255 $xml = '<?xml version="1.0"?>
256<d:principal-property-search xmlns:d="DAV:" test="anyof">
257 <d:apply-to-principal-collection-set />
258 <d:property-search>
259 <d:prop>
260 <d:displayname />
261 </d:prop>
262 <d:match>user</d:match>
263 </d:property-search>
264 <d:property-search>
265 <d:prop>
266 <d:foo />
267 </d:prop>
268 <d:match>bar</d:match>
269 </d:property-search>
270 <d:prop>
271 <d:displayname />
272 <d:getcontentlength />
273 </d:prop>
274</d:principal-property-search>';
275
276 $serverVars = [
277 'REQUEST_METHOD' => 'REPORT',
278 'HTTP_DEPTH' => '0',
279 'REQUEST_URI' => '/',
280 ];
281
283 $request->setBody($xml);
284
285 $server = $this->getServer();
286 $server->httpRequest = $request;
287
288 $server->exec();
289
290 $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body);
291 $this->assertEquals([
292 'X-Sabre-Version' => [DAV\Version::VERSION],
293 'Content-Type' => ['application/xml; charset=utf-8'],
294 'Vary' => ['Brief,Prefer'],
295 ], $server->httpResponse->getHeaders());
296
297
298 $check = [
299 '/d:multistatus',
300 '/d:multistatus/d:response' => 2,
301 '/d:multistatus/d:response/d:href' => 2,
302 '/d:multistatus/d:response/d:propstat' => 4,
303 '/d:multistatus/d:response/d:propstat/d:prop' => 4,
304 '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2,
305 '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2,
306 '/d:multistatus/d:response/d:propstat/d:status' => 4,
307 ];
308
309 $xml = simplexml_load_string($server->httpResponse->body);
310 $xml->registerXPathNamespace('d', 'DAV:');
311 foreach ($check as $v1 => $v2) {
312
313 $xpath = is_int($v1) ? $v2 : $v1;
314
315 $result = $xml->xpath($xpath);
316
317 $count = 1;
318 if (!is_int($v1)) $count = $v2;
319
320 $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
321
322 }
323
324 }

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testUnknownSearchField()

Sabre\DAVACL\PrincipalPropertySearchTest::testUnknownSearchField ( )

Definition at line 75 of file PrincipalPropertySearchTest.php.

75 {
76
77 $xml = '<?xml version="1.0"?>
78<d:principal-property-search xmlns:d="DAV:">
79 <d:property-search>
80 <d:prop>
81 <d:yourmom />
82 </d:prop>
83 <d:match>user</d:match>
84 </d:property-search>
85 <d:prop>
86 <d:displayname />
87 <d:getcontentlength />
88 </d:prop>
89</d:principal-property-search>';
90
91 $serverVars = [
92 'REQUEST_METHOD' => 'REPORT',
93 'HTTP_DEPTH' => '0',
94 'REQUEST_URI' => '/principals',
95 ];
96
98 $request->setBody($xml);
99
100 $server = $this->getServer();
101 $server->httpRequest = $request;
102
103 $server->exec();
104
105 $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString());
106 $this->assertEquals([
107 'X-Sabre-Version' => [DAV\Version::VERSION],
108 'Content-Type' => ['application/xml; charset=utf-8'],
109 'Vary' => ['Brief,Prefer'],
110 ], $server->httpResponse->getHeaders());
111
112 }

References $request, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

◆ testWrongUri()

Sabre\DAVACL\PrincipalPropertySearchTest::testWrongUri ( )

Definition at line 325 of file PrincipalPropertySearchTest.php.

325 {
326
327 $xml = '<?xml version="1.0"?>
328<d:principal-property-search xmlns:d="DAV:">
329 <d:property-search>
330 <d:prop>
331 <d:displayname />
332 </d:prop>
333 <d:match>user</d:match>
334 </d:property-search>
335 <d:prop>
336 <d:displayname />
337 <d:getcontentlength />
338 </d:prop>
339</d:principal-property-search>';
340
341 $serverVars = [
342 'REQUEST_METHOD' => 'REPORT',
343 'HTTP_DEPTH' => '0',
344 'REQUEST_URI' => '/',
345 ];
346
348 $request->setBody($xml);
349
350 $server = $this->getServer();
351 $server->httpRequest = $request;
352
353 $server->exec();
354
355 $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body);
356 $this->assertEquals([
357 'X-Sabre-Version' => [DAV\Version::VERSION],
358 'Content-Type' => ['application/xml; charset=utf-8'],
359 'Vary' => ['Brief,Prefer'],
360 ], $server->httpResponse->getHeaders());
361
362
363 $check = [
364 '/d:multistatus',
365 '/d:multistatus/d:response' => 0,
366 ];
367
368 $xml = simplexml_load_string($server->httpResponse->body);
369 $xml->registerXPathNamespace('d', 'DAV:');
370 foreach ($check as $v1 => $v2) {
371
372 $xpath = is_int($v1) ? $v2 : $v1;
373
374 $result = $xml->xpath($xpath);
375
376 $count = 1;
377 if (!is_int($v1)) $count = $v2;
378
379 $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
380
381 }
382
383 }

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\PrincipalPropertySearchTest\getServer(), and Sabre\DAV\Version\VERSION.

+ Here is the call graph for this function:

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