ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PluginAdminTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAVACL;
4 
5 use Sabre\DAV;
6 use Sabre\HTTP;
7 
8 require_once 'Sabre/DAVACL/MockACLNode.php';
9 require_once 'Sabre/HTTP/ResponseMock.php';
10 
12 
13  public $server;
14 
15  function setUp() {
16 
17  $principalBackend = new PrincipalBackend\Mock();
18 
19  $tree = [
20  new MockACLNode('adminonly', []),
22  ];
23 
24  $this->server = new DAV\Server($tree);
25  $this->server->sapi = new HTTP\SapiMock();
26  $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
27  $this->server->addPlugin($plugin);
28  }
29 
30  function testNoAdminAccess() {
31 
32  $plugin = new Plugin();
33  $this->server->addPlugin($plugin);
34 
36  'REQUEST_METHOD' => 'OPTIONS',
37  'HTTP_DEPTH' => 1,
38  'REQUEST_URI' => '/adminonly',
39  ]);
40 
41  $response = new HTTP\ResponseMock();
42 
43  $this->server->httpRequest = $request;
44  $this->server->httpResponse = $response;
45 
46  $this->server->exec();
47 
48  $this->assertEquals(403, $response->status);
49 
50  }
51 
55  function testAdminAccess() {
56 
57  $plugin = new Plugin();
58  $plugin->adminPrincipals = [
59  'principals/admin',
60  ];
61  $this->server->addPlugin($plugin);
62 
64  'REQUEST_METHOD' => 'OPTIONS',
65  'HTTP_DEPTH' => 1,
66  'REQUEST_URI' => '/adminonly',
67  ]);
68 
69  $response = new HTTP\ResponseMock();
70 
71  $this->server->httpRequest = $request;
72  $this->server->httpResponse = $response;
73 
74  $this->server->exec();
75 
76  $this->assertEquals(200, $response->status);
77 
78  }
79 }
This plugin provides Authentication for a WebDAV server.
Definition: Plugin.php:25
foreach($paths as $path) $request
Definition: asyncclient.php:32
testAdminAccess()
testNoAdminAccess
Main DAV server class.
Definition: Server.php:23
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
SabreDAV ACL Plugin.
Definition: Plugin.php:31
$principalBackend