public function testMakeCollectionWithInvalidETag()
 {
     $testDest = "/collection/new_collection";
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     // Initialize all property directories
     $req = new ezcWebdavPropFindRequest('');
     $req->allProp = true;
     $req->setHeader('Depth', ezcWebdavRequest::DEPTH_INFINITY);
     $req->validateHeaders();
     $backend->propFind($req);
     $eTag = $backend->getProperty('/collection', 'getetag')->etag;
     $req = new ezcWebdavMakeCollectionRequest($testDest);
     $req->setHeader('If-None-Match', array($eTag));
     $req->validateHeaders();
     $res = $backend->makeCollection($req);
     $this->assertEquals(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_412, '/collection', 'If-None-Match header check failed.'), $res, 'Expected response does not match real response.', 0, 20);
 }
Esempio n. 2
0
 public function testExternalLockMultiple()
 {
     $backendDir = $this->tempDir . 'backend/';
     $backend = new ezcWebdavFileBackend($backendDir);
     $backend->lock(1000, 200000);
     $this->assertFileExists($backendDir . $backend->options->lockFileName, 'Lock file not created');
     $this->assertAttributeEquals(1, 'lockLevel', $backend, 'Lock level not incremented.');
     $backend->lock(1000, 200000);
     $this->assertFileExists($backendDir . $backend->options->lockFileName, 'Lock file not created');
     $this->assertAttributeEquals(2, 'lockLevel', $backend, 'Lock level not incremented.');
     $backend->unlock();
     $this->assertFileExists($backendDir . $backend->options->lockFileName, 'Lock file not created');
     $this->assertAttributeEquals(1, 'lockLevel', $backend, 'Lock level not incremented.');
     $backend->unlock();
     $this->assertFileNotExists($backendDir . $backend->options->lockFileName, 'Lock file not removed.');
     $this->assertAttributeEquals(0, 'lockLevel', $backend, 'Lock level not decremented.');
 }
Esempio n. 3
0
 public function testDeadPropertyRetrieval()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $backend->options->useMimeExts = false;
     $newProperties = new ezcWebdavFlaggedPropertyStorage();
     $newProperties->attach($prop = new ezcWebdavDeadProperty('foo:', 'bar', "<?xml version=\"1.0\"?>\n<bar xmlns=\"foo:\">some content</bar>\n"), ezcWebdavPropPatchRequest::SET);
     $request = new ezcWebdavPropPatchRequest('/resource');
     $request->updates = $newProperties;
     $request->validateHeaders();
     $response = $backend->proppatch($request);
     $this->assertTrue(is_file($this->tempDir . 'backend/.ezc/resource.xml'), 'Expected creation of property storage.');
     $request = new ezcWebdavPropFindRequest('/resource');
     $request->prop = $newProperties;
     $request->validateHeaders();
     $response = $backend->propfind($request);
     $responseProperty = new ezcWebdavBasicPropertyStorage();
     $responseProperty->attach($prop);
     $responseProperty->rewind();
     $expectedResponse = new ezcWebdavMultistatusResponse(new ezcWebdavPropFindResponse(new ezcWebdavResource('/resource'), new ezcWebdavPropStatResponse($responseProperty)));
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
     $this->assertEquals(new ezcWebdavDeadProperty('foo:', 'bar', "<?xml version=\"1.0\"?>\n<bar xmlns=\"foo:\">some content</bar>\n"), $backend->getProperty('/resource', 'bar', 'foo:'));
 }
Esempio n. 4
0
<?php

// Intialize autoload
require_once '/home/kore/devel/ezcomponents/trunk/Base/src/base.php';
function __autoload($class)
{
    ezcBase::autoload($class);
}
// Create log directory for current request
mkdir($logDir = 'log/' . preg_replace('(\\W+)', '_', $_SERVER['HTTP_USER_AGENT']) . '/' . date('Ymd_His_') . substr(microtime(true), 2) . '/', 0777, true);
// Simply use file backend
$backend = new ezcWebdavFileBackend('storage/');
// Read request contents
$GLOBALS['EZC_WEBDAV_REQUEST_BODY'] = '';
$in = fopen('php://input', 'r');
while ($data = fread($in, 1024)) {
    $GLOBALS['EZC_WEBDAV_REQUEST_BODY'] .= $data;
}
// Log request contents
file_put_contents($logDir . 'request_headers.txt', "<?php\n\nreturn " . var_export($_SERVER, true) . "\n?>");
file_put_contents($logDir . 'request_body.xml', $GLOBALS['EZC_WEBDAV_REQUEST_BODY']);
// Mock transport to make important stuff accessible
class mockedTransport extends ezcWebdavMicrosoftCompatibleTransport
{
    protected function retrieveBody()
    {
        return $GLOBALS['EZC_WEBDAV_REQUEST_BODY'];
    }
    protected function sendResponse(ezcWebdavOutputResult $output)
    {
        $GLOBALS['EZC_WEBDAV_RESPONSE'] = $output->status;