ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BlockAccessTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAVACL;
4
5use Sabre\DAV;
6
8
12 protected $server;
13 protected $plugin;
14
15 function setUp() {
16
17 $nodes = [
18 new DAV\SimpleCollection('testdir'),
19 ];
20
21 $this->server = new DAV\Server($nodes);
22 $this->plugin = new Plugin();
23 $this->plugin->setDefaultAcl([]);
24 $this->server->addPlugin(
25 new DAV\Auth\Plugin(
26 new DAV\Auth\Backend\Mock()
27 )
28 );
29 // Login
30 $this->server->getPlugin('auth')->beforeMethod(
31 new \Sabre\HTTP\Request(),
32 new \Sabre\HTTP\Response()
33 );
34 $this->server->addPlugin($this->plugin);
35
36 }
37
41 function testGet() {
42
43 $this->server->httpRequest->setMethod('GET');
44 $this->server->httpRequest->setUrl('/testdir');
45
46 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
47
48 }
49
50 function testGetDoesntExist() {
51
52 $this->server->httpRequest->setMethod('GET');
53 $this->server->httpRequest->setUrl('/foo');
54
55 $r = $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
56 $this->assertTrue($r);
57
58 }
59
63 function testHEAD() {
64
65 $this->server->httpRequest->setMethod('HEAD');
66 $this->server->httpRequest->setUrl('/testdir');
67
68 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
69
70 }
71
75 function testOPTIONS() {
76
77 $this->server->httpRequest->setMethod('OPTIONS');
78 $this->server->httpRequest->setUrl('/testdir');
79
80 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
81
82 }
83
87 function testPUT() {
88
89 $this->server->httpRequest->setMethod('PUT');
90 $this->server->httpRequest->setUrl('/testdir');
91
92 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
93
94 }
95
99 function testPROPPATCH() {
100
101 $this->server->httpRequest->setMethod('PROPPATCH');
102 $this->server->httpRequest->setUrl('/testdir');
103
104 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
105
106 }
107
111 function testCOPY() {
112
113 $this->server->httpRequest->setMethod('COPY');
114 $this->server->httpRequest->setUrl('/testdir');
115
116 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
117
118 }
119
123 function testMOVE() {
124
125 $this->server->httpRequest->setMethod('MOVE');
126 $this->server->httpRequest->setUrl('/testdir');
127
128 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
129
130 }
131
135 function testACL() {
136
137 $this->server->httpRequest->setMethod('ACL');
138 $this->server->httpRequest->setUrl('/testdir');
139
140 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
141
142 }
143
147 function testLOCK() {
148
149 $this->server->httpRequest->setMethod('LOCK');
150 $this->server->httpRequest->setUrl('/testdir');
151
152 $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]);
153
154 }
155
159 function testBeforeBind() {
160
161 $this->server->emit('beforeBind', ['testdir/file']);
162
163 }
164
168 function testBeforeUnbind() {
169
170 $this->server->emit('beforeUnbind', ['testdir']);
171
172 }
173
174 function testPropFind() {
175
176 $propFind = new DAV\PropFind('testdir', [
177 '{DAV:}displayname',
178 '{DAV:}getcontentlength',
179 '{DAV:}bar',
180 '{DAV:}owner',
181 ]);
182
183 $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]);
184 $this->assertTrue($r);
185
186 $expected = [
187 200 => [],
188 404 => [],
189 403 => [
190 '{DAV:}displayname' => null,
191 '{DAV:}getcontentlength' => null,
192 '{DAV:}bar' => null,
193 '{DAV:}owner' => null,
194 ],
195 ];
196
197 $this->assertEquals($expected, $propFind->getResultForMultiStatus());
198
199 }
200
202
203 $this->plugin->hideNodesFromListings = true;
204 $propFind = new DAV\PropFind('testdir', [
205 '{DAV:}displayname',
206 '{DAV:}getcontentlength',
207 '{DAV:}bar',
208 '{DAV:}owner',
209 ]);
210
211 $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]);
212 $this->assertFalse($r);
213
214 }
215}
An exception for terminatinating execution or to throw for unit testing.
testCOPY()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testLOCK()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testHEAD()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testPROPPATCH()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testPUT()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testGet()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testOPTIONS()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testACL()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testBeforeUnbind()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testMOVE()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
testBeforeBind()
@expectedException Sabre\DAVACL\Exception\NeedPrivileges
SabreDAV ACL Plugin.
Definition: Plugin.php:31
This class holds all the information about a PROPFIND request.
Definition: PropFind.php:11
Main DAV server class.
Definition: Server.php:23
The Request class represents a single HTTP request.
Definition: Request.php:18
This class represents a single HTTP response.
Definition: Response.php:12
$r
Definition: example_031.php:79