public function setUp() { $_SERVER['REQUEST_METHOD'] = 'UNKNOWN'; $this->obj = DAV_Request::inst(); DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); }
public function setUp() { $_SERVER['REQUEST_METHOD'] = 'REPORT'; DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); DAV_Multistatus::reset(); }
public function setUp() { $_SERVER['REQUEST_METHOD'] = 'PROPPATCH'; DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); DAV::$LOCKPROVIDER = null; DAV_Multistatus::reset(); }
/** * Because we can't be sure we're using PHP 5.4 or higher, we can't use traits. * Instead, we use this global function to do the general setup for tests * * @return void */ function setUp() { reset_SERVER(); \DAV::$REGISTRY = new \BeeHub_Registry(); \DAV::$LOCKPROVIDER = new \BeeHub_Lock_Provider(); \DAV::$ACLPROVIDER = new \BeeHub_ACL_Provider(); \BeeHub::setAuth(new BeeHub_Auth(new \SimpleSAML_Auth_Simple('BeeHub'))); }
public function setUp() { $_SERVER['REQUEST_METHOD'] = 'MKCOL'; $this->obj = DAV_Request::inst(); DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAV_Resource'); DAV::$LOCKPROVIDER = null; }
public function setUp() { DAV::$LOCKPROVIDER = new DAV_Test_Lock_Provider(); DAV::$LOCKPROVIDER->returnLock(true); $_SERVER['REQUEST_METHOD'] = 'UNLOCK'; $_SERVER['HTTP_LOCK_TOKEN'] = '<' . DAV::$LOCKPROVIDER->setlock(null, null, null, null) . '>'; DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); $this->obj = DAV_Request::inst(); }
public function setUp() { $_SERVER['REQUEST_METHOD'] = 'DELETE'; $_SERVER['HTTP_DEPTH'] = 'infinity'; $_SERVER['REQUEST_URI'] = '/path/to/resource'; DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); dav::$LOCKPROVIDER = new DAV_Test_Lock_Provider(); $this->obj = DAV_Request::inst(); }
public function setUp() { $_SERVER['REQUEST_METHOD'] = 'HEAD'; $headers = array(); $headers['Content-Length'] = 100; $headers['Content-Type'] = 'text/plain'; $headers['ETag'] = 'an ETag'; $headers['Last-Modified'] = '11-12-13 14:15'; $headers['Content-Language'] = 'nl'; $headers['Accept-Ranges'] = 'bytes'; $resource = $this->getMock('DAVACL_Test_Resource', array('method_HEAD'), array($_SERVER['REQUEST_URI'])); $resource->expects($this->once())->method('method_HEAD')->will($this->returnValue($headers)); DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass($resource); $this->obj = DAV_Request::inst(); }
public function testHandleToUnexisting() { // Unable to COPY to unexisting destination collection // Make a return map so the registry will return null when de collection of the destination is requested $returnMap = array(); $returnMap[] = array($_SERVER['REQUEST_URI'], new DAVACL_Test_Resource($_SERVER['REQUEST_URI'])); $returnMap[] = array(dirname($_SERVER['REQUEST_URI']), null); $tempRegistry = DAV::$REGISTRY; DAV::$REGISTRY = $this->getMock('DAV_Registry'); DAV::$REGISTRY->expects($this->any())->method('resource')->will($this->returnValueMap($returnMap)); $this->expectOutputString(<<<EOS Content-Type: text/plain; charset="UTF-8" HTTP/1.1 409 Conflict HTTP/1.1 409 Conflict Unable to COPY to unexisting destination collection EOS ); $this->obj->handleRequest(); DAV::$REGISTRY = $tempRegistry; }
defined('ENT_HTML5') || define('ENT_HTML5', 0); // Set the include path, so BeeHub* classes are automatically loaded set_include_path(realpath(dirname(dirname(__FILE__))) . PATH_SEPARATOR . dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; DAV::bootstrap(); set_exception_handler(array('BeeHub', 'exception_handler')); // We need SimpleSamlPHP require_once BeeHub::$CONFIG['environment']['simplesamlphp'] . 'lib' . DIRECTORY_SEPARATOR . '_autoload.php'; if (isset($_SERVER['HTTP_ORIGIN']) && !empty($_SERVER['HTTP_ORIGIN']) && parse_url($_SERVER['HTTP_ORIGIN'], PHP_URL_HOST) != $_SERVER['SERVER_NAME']) { die('Cross Origin Resourc Sharing prohibited!'); } DAV::$PROTECTED_PROPERTIES[DAV::PROP_GROUP_MEMBER_SET] = true; DAV::$ACL_PROPERTIES[BeeHub::PROP_SPONSOR] = 'sponsor'; DAV::addSupported_Properties(BeeHub::PROP_SPONSOR, 'sponsor'); BeeHub::handle_method_spoofing(); DAV::$REGISTRY = BeeHub_Registry::inst(); DAV::$LOCKPROVIDER = BeeHub_Lock_Provider::inst(); DAV::$ACLPROVIDER = BeeHub_ACL_Provider::inst(); DAV::$UNAUTHORIZED = array(BeeHub::getAuth(), 'unauthorized'); // In case of POST requests, we can already check the POST authentication code if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!BeeHub::getAuth()->checkPostAuthCode()) { throw new DAV_Status(DAV::HTTP_FORBIDDEN, 'POST authentication code (POST_auth_code) was incorrect. The correct code can be obtained with a GET request to /system/?POST_auth_code'); } } // Prepare test environments if needed if (APPLICATION_ENV === BeeHub::ENVIRONMENT_TEST && isset($_GET['test'])) { if (substr($_SERVER['REQUEST_URI'], 0, 19) !== '/foo/client_tests/?') { header('Location: /foo/client_tests/?' . $_SERVER['QUERY_STRING']); die; }
public function testUser() { $user = $this->getMock('BeeHub_User', array('init_props'), array('/system/users/test_user')); $user->expects($this->any())->method('init_props'); $registryMock = $this->getMock('BeeHub_Registry', array('resource')); $registryMock->expects($this->once())->method('resource')->will($this->returnValue($user)); \DAV::$REGISTRY = $registryMock; $this->assertSame($user, \BeeHub::user('/system/users/test_user'), 'BeeHub::user() should return a user if the path is correct'); $registryMockNull = $this->getMock('BeeHub_Registry', array('resource')); $registryMockNull->expects($this->once())->method('resource')->will($this->returnValue(null)); \DAV::$REGISTRY = $registryMockNull; $this->setExpectedException('DAV_Status'); \BeeHub::group('/system/users/test_user', null, \DAV::HTTP_FORBIDDEN); }
/** * @depends testConstructorExclusiveLock * @param DAV_Test_Request_LOCK $obj */ public function testCreateLockUnexisting($obj) { $new_resource = new DAVACL_Test_Resource($_SERVER['REQUEST_URI']); $collection = $this->getMock('DAVACL_Test_Collection', array('create_member'), array(dirname($_SERVER['REQUEST_URI']))); $collection->expects($this->once())->method('create_member')->with($this->equalTo(basename($_SERVER['REQUEST_URI'])))->will($this->returnValue($new_resource)); $map = array(array($_SERVER['REQUEST_URI'], null), array(dirname($_SERVER['REQUEST_URI']), $collection)); DAV::$REGISTRY = $this->getMock('DAV_Test_Registry', array('resource')); DAV::$REGISTRY->expects($this->any())->method('resource')->will($this->returnValueMap($map)); $this->expectOutputString(<<<EOS Content-Type: application/xml; charset="utf-8" Location: http://example.org/path/to/resource Lock-Token: <urn:uuid:e71d4fae-5dec-22d6-fea5-00a0c91e6be4> HTTP/1.1 201 Created <?xml version="1.0" encoding="utf-8"?> <D:prop xmlns:D="DAV:"><D:lockdiscovery><D:activelock> <D:lockscope><D:exclusive/></D:lockscope> <D:locktype><D:write/></D:locktype> <D:depth>0</D:depth> <D:owner>somebody</D:owner> <D:timeout>Second-0</D:timeout> <D:lockroot><D:href>/path/to/resource</D:href></D:lockroot> </D:activelock></D:lockdiscovery></D:prop> EOS ); $obj->handleRequest(); }
public function testHandleWithRange() { // Check with range $map = array(array('/collection/new_resource', new DAVACL_Test_Resource('/collection/new_resource')), array('/collection', new DAVACL_Test_Collection('/collection'))); DAV::$REGISTRY = $this->getMock('DAV_Test_Registry', array('resource')); DAV::$REGISTRY->expects($this->any())->method('resource')->will($this->returnValueMap($map)); $this->expectOutputString(<<<EOS DAVACL_Test_Resource::method_PUT_range() called for /collection/new_resource HTTP/1.1 204 No Content EOS ); $_SERVER['HTTP_CONTENT_RANGE'] = 'bytes 500-999/1234'; $this->obj = DAV_Request::inst(); $this->obj->handleRequest(); }
case 1: $this->resourceClass = $this->resourceClass[0]; $resourceClass = $this->resourceClass; break; default: $resourceClass = array_shift($this->resourceClass); break; } } else { $resourceClass = $this->resourceClass; } if (is_null($resourceClass)) { return null; } elseif ($resourceClass instanceof DAV_Resource) { return $resourceClass; } return new $resourceClass($path); } public function forget($path) { } public function shallowLock($write_paths, $read_paths) { } public function shallowUnlock() { } } // DAV_Test_Registry DAV::$REGISTRY = new DAV_Test_Registry(); // End of file
public function setUp() { DAV::$REGISTRY = new DAV_Test_Registry(); DAV::$REGISTRY->setResourceClass('DAVACL_Test_Resource'); DAV::$LOCKPROVIDER = null; }