ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AllowAccessTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAVACL;
4 
5 use Sabre\DAV;
6 
8 
12  protected $server;
13 
14  function setUp() {
15 
16  $nodes = [
17  new DAV\Mock\Collection('testdir', [
18  'file1.txt' => 'contents',
19  ]),
20  ];
21 
22  $this->server = new DAV\Server($nodes);
23  $this->server->addPlugin(
24  new DAV\Auth\Plugin(
25  new DAV\Auth\Backend\Mock()
26  )
27  );
28  // Login
29  $this->server->getPlugin('auth')->beforeMethod(
30  new \Sabre\HTTP\Request(),
31  new \Sabre\HTTP\Response()
32  );
33  $aclPlugin = new Plugin();
34  $this->server->addPlugin($aclPlugin);
35 
36  }
37 
38  function testGet() {
39 
40  $this->server->httpRequest->setMethod('GET');
41  $this->server->httpRequest->setUrl('/testdir');
42 
43  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
44 
45  }
46 
47  function testGetDoesntExist() {
48 
49  $this->server->httpRequest->setMethod('GET');
50  $this->server->httpRequest->setUrl('/foo');
51 
52  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
53 
54  }
55 
56  function testHEAD() {
57 
58  $this->server->httpRequest->setMethod('HEAD');
59  $this->server->httpRequest->setUrl('/testdir');
60 
61  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
62 
63  }
64 
65  function testOPTIONS() {
66 
67  $this->server->httpRequest->setMethod('OPTIONS');
68  $this->server->httpRequest->setUrl('/testdir');
69 
70  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
71 
72  }
73 
74  function testPUT() {
75 
76  $this->server->httpRequest->setMethod('PUT');
77  $this->server->httpRequest->setUrl('/testdir/file1.txt');
78 
79  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
80 
81  }
82 
83  function testPROPPATCH() {
84 
85  $this->server->httpRequest->setMethod('PROPPATCH');
86  $this->server->httpRequest->setUrl('/testdir');
87 
88  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
89 
90  }
91 
92  function testCOPY() {
93 
94  $this->server->httpRequest->setMethod('COPY');
95  $this->server->httpRequest->setUrl('/testdir');
96 
97  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
98 
99  }
100 
101  function testMOVE() {
102 
103  $this->server->httpRequest->setMethod('MOVE');
104  $this->server->httpRequest->setUrl('/testdir');
105 
106  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
107 
108  }
109 
110  function testLOCK() {
111 
112  $this->server->httpRequest->setMethod('LOCK');
113  $this->server->httpRequest->setUrl('/testdir');
114 
115  $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]));
116 
117  }
118 
119  function testBeforeBind() {
120 
121  $this->assertTrue($this->server->emit('beforeBind', ['testdir/file']));
122 
123  }
124 
125 
126  function testBeforeUnbind() {
127 
128  $this->assertTrue($this->server->emit('beforeUnbind', ['testdir']));
129 
130  }
131 
132 }
The Request class represents a single HTTP request.
Definition: Request.php:18
Collection class.
Definition: Collection.php:15
This class represents a single HTTP response.
Definition: Response.php:12
Main DAV server class.
Definition: Server.php:23
SabreDAV ACL Plugin.
Definition: Plugin.php:31
$aclPlugin