mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-23 23:19:28 +00:00
0bc0a09bf4
- application/extensions file system permission now is 775 - application/logs file system permission now is 775 - Added extensions directory in application/: config, controllers, helpers, hooks, libraries, models, views and widgets - Added view views/extensions/manage.php - Added controller controllers/system/extensions/Manager.php - Added library ExtensionsLib to manage extensions - Added model models/system/Extensions_model.php - Moved code related to print out info from MigrationLib to EPrintfLib
84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
<?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);
|
|
$plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
|
|
$fakeServer->addPlugin($plugin);
|
|
$plugin = new Plugin();
|
|
$fakeServer->addPlugin($plugin);
|
|
|
|
$request = new HTTP\Request(array(
|
|
'REQUEST_METHOD' => 'OPTIONS',
|
|
'HTTP_DEPTH' => 1,
|
|
'REQUEST_URI' => '/adminonly',
|
|
));
|
|
|
|
$response = new HTTP\ResponseMock();
|
|
|
|
$fakeServer->httpRequest = $request;
|
|
$fakeServer->httpResponse = $response;
|
|
|
|
$fakeServer->exec();
|
|
|
|
$this->assertEquals('HTTP/1.1 403 Forbidden', $response->status);
|
|
|
|
}
|
|
|
|
/**
|
|
* @depends testNoAdminAccess
|
|
*/
|
|
function testAdminAccess() {
|
|
|
|
$principalBackend = new PrincipalBackend\Mock();
|
|
|
|
$tree = array(
|
|
new MockACLNode('adminonly', array()),
|
|
new PrincipalCollection($principalBackend),
|
|
);
|
|
|
|
$fakeServer = new DAV\Server($tree);
|
|
$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 = new HTTP\Request(array(
|
|
'REQUEST_METHOD' => 'OPTIONS',
|
|
'HTTP_DEPTH' => 1,
|
|
'REQUEST_URI' => '/adminonly',
|
|
));
|
|
|
|
$response = new HTTP\ResponseMock();
|
|
|
|
$fakeServer->httpRequest = $request;
|
|
$fakeServer->httpResponse = $response;
|
|
|
|
$fakeServer->exec();
|
|
|
|
$this->assertEquals('HTTP/1.1 200 OK', $response->status);
|
|
|
|
}
|
|
}
|