Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1842461
BlockAccessTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
5 KB
Subscribers
None
BlockAccessTest.php
View Options
<?php
namespace
Sabre\DAVACL
;
use
Sabre\DAV
;
use
Sabre\HTTP
;
class
BlockAccessTest
extends
\PHPUnit_Framework_TestCase
{
/**
* @var DAV\Server
*/
protected
$server
;
protected
$plugin
;
function
setUp
()
{
$nodes
=
[
new
DAV\SimpleCollection
(
'testdir'
),
];
$this
->
server
=
new
DAV\Server
(
$nodes
);
$this
->
plugin
=
new
Plugin
();
$this
->
plugin
->
allowAccessToNodesWithoutACL
=
false
;
$this
->
server
->
addPlugin
(
$this
->
plugin
);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testGet
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'GET'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
function
testGetDoesntExist
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'GET'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/foo'
);
$r
=
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
$this
->
assertTrue
(
$r
);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testHEAD
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'HEAD'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testOPTIONS
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'OPTIONS'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testPUT
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'PUT'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testPROPPATCH
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'PROPPATCH'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testCOPY
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'COPY'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testMOVE
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'MOVE'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testACL
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'ACL'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testLOCK
()
{
$this
->
server
->
httpRequest
->
setMethod
(
'LOCK'
);
$this
->
server
->
httpRequest
->
setUrl
(
'/testdir'
);
$this
->
server
->
emit
(
'beforeMethod'
,
[
$this
->
server
->
httpRequest
,
$this
->
server
->
httpResponse
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testBeforeBind
()
{
$this
->
server
->
emit
(
'beforeBind'
,
[
'testdir/file'
]);
}
/**
* @expectedException Sabre\DAVACL\Exception\NeedPrivileges
*/
function
testBeforeUnbind
()
{
$this
->
server
->
emit
(
'beforeUnbind'
,
[
'testdir'
]);
}
function
testPropFind
()
{
$propFind
=
new
DAV\PropFind
(
'testdir'
,
[
'{DAV:}displayname'
,
'{DAV:}getcontentlength'
,
'{DAV:}bar'
,
'{DAV:}owner'
,
]);
$r
=
$this
->
server
->
emit
(
'propFind'
,
[
$propFind
,
new
DAV\SimpleCollection
(
'testdir'
)]);
$this
->
assertTrue
(
$r
);
$expected
=
[
200
=>
[],
404
=>
[],
403
=>
[
'{DAV:}displayname'
=>
null
,
'{DAV:}getcontentlength'
=>
null
,
'{DAV:}bar'
=>
null
,
'{DAV:}owner'
=>
null
,
],
];
$this
->
assertEquals
(
$expected
,
$propFind
->
getResultForMultiStatus
());
}
function
testBeforeGetPropertiesNoListing
()
{
$this
->
plugin
->
hideNodesFromListings
=
true
;
$propFind
=
new
DAV\PropFind
(
'testdir'
,
[
'{DAV:}displayname'
,
'{DAV:}getcontentlength'
,
'{DAV:}bar'
,
'{DAV:}owner'
,
]);
$r
=
$this
->
server
->
emit
(
'propFind'
,
[
$propFind
,
new
DAV\SimpleCollection
(
'testdir'
)]);
$this
->
assertFalse
(
$r
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jan 8, 6:42 AM (2 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914498
Default Alt Text
BlockAccessTest.php (5 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment