Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1822031
PluginAdminTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
2 KB
Subscribers
None
PluginAdminTest.php
View Options
<?php
namespace
Sabre\DAVACL
;
use
Sabre\DAV
;
use
Sabre\HTTP
;
require_once
'Sabre/DAVACL/MockACLNode.php'
;
require_once
'Sabre/HTTP/ResponseMock.php'
;
class
PluginAdminTest
extends
\PHPUnit_Framework_TestCase
{
function
testNoAdminAccess
()
{
$principalBackend
=
new
PrincipalBackend\Mock
();
$tree
=
array
(
new
MockACLNode
(
'adminonly'
,
array
()),
new
PrincipalCollection
(
$principalBackend
),
);
$fakeServer
=
new
DAV\Server
(
$tree
);
$fakeServer
->
sapi
=
new
HTTP\SapiMock
();
$plugin
=
new
DAV\Auth\Plugin
(
new
DAV\Auth\Backend\Mock
(),
'realm'
);
$fakeServer
->
addPlugin
(
$plugin
);
$plugin
=
new
Plugin
();
$fakeServer
->
addPlugin
(
$plugin
);
$request
=
HTTP\Sapi
::
createFromServerArray
(
array
(
'REQUEST_METHOD'
=>
'OPTIONS'
,
'HTTP_DEPTH'
=>
1
,
'REQUEST_URI'
=>
'/adminonly'
,
));
$response
=
new
HTTP\ResponseMock
();
$fakeServer
->
httpRequest
=
$request
;
$fakeServer
->
httpResponse
=
$response
;
$fakeServer
->
exec
();
$this
->
assertEquals
(
403
,
$response
->
status
);
}
/**
* @depends testNoAdminAccess
*/
function
testAdminAccess
()
{
$principalBackend
=
new
PrincipalBackend\Mock
();
$tree
=
array
(
new
MockACLNode
(
'adminonly'
,
array
()),
new
PrincipalCollection
(
$principalBackend
),
);
$fakeServer
=
new
DAV\Server
(
$tree
);
$fakeServer
->
sapi
=
new
HTTP\SapiMock
();
$plugin
=
new
DAV\Auth\Plugin
(
new
DAV\Auth\Backend\Mock
(),
'realm'
);
$fakeServer
->
addPlugin
(
$plugin
);
$plugin
=
new
Plugin
();
$plugin
->
adminPrincipals
=
array
(
'principals/admin'
,
);
$fakeServer
->
addPlugin
(
$plugin
);
$request
=
HTTP\Sapi
::
createFromServerArray
(
array
(
'REQUEST_METHOD'
=>
'OPTIONS'
,
'HTTP_DEPTH'
=>
1
,
'REQUEST_URI'
=>
'/adminonly'
,
));
$response
=
new
HTTP\ResponseMock
();
$fakeServer
->
httpRequest
=
$request
;
$fakeServer
->
httpResponse
=
$response
;
$fakeServer
->
exec
();
$this
->
assertEquals
(
200
,
$response
->
status
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Dec 24, 1:12 PM (12 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914199
Default Alt Text
PluginAdminTest.php (2 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment