Ejemplo n.º 1
0
    function testIssue205()
    {
        $request = new HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:comp-filter name="VALARM">
                    <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
                </C:comp-filter>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: ' . $response->body);
        $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        $this->assertEquals(1, count($vObject->VEVENT));
    }
Ejemplo n.º 2
0
    function testSyncInitialSyncCollection()
    {
        // Making a change
        $this->collection->addChange(['file1.txt'], [], []);
        $request = new HTTP\Request('REPORT', '/coll/', ['Content-Type' => 'application/xml']);
        $body = <<<BLA
<?xml version="1.0" encoding="utf-8" ?>
<D:sync-collection xmlns:D="DAV:">
     <D:sync-token/>
     <D:sync-level>1</D:sync-level>
      <D:prop>
        <D:getcontentlength/>
      </D:prop>
</D:sync-collection>
BLA;
        $request->setBody($body);
        $response = $this->request($request);
        $this->assertEquals(207, $response->status, 'Full response body:' . $response->body);
        $multiStatus = $this->server->xml->parse($response->getBodyAsString());
        // Checking the sync-token
        $this->assertEquals('http://sabre.io/ns/sync/1', $multiStatus->getSyncToken());
        $responses = $multiStatus->getResponses();
        $this->assertEquals(2, count($responses), 'We expected exactly 2 {DAV:}response');
        $response = $responses[0];
        $this->assertNull($response->getHttpStatus());
        $this->assertEquals('/coll/file1.txt', $response->getHref());
        $this->assertEquals([200 => ['{DAV:}getcontentlength' => 3]], $response->getResponseProperties());
        $response = $responses[1];
        $this->assertNull($response->getHttpStatus());
        $this->assertEquals('/coll/file2.txt', $response->getHref());
        $this->assertEquals([200 => ['{DAV:}getcontentlength' => 3]], $response->getResponseProperties());
    }
Ejemplo n.º 3
0
Archivo: HEV.php Proyecto: synap/ebics
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $parameters = json_decode(file_get_contents('parameters.json'));
     $url = $parameters->url;
     $HostID = $parameters->host;
     // Template pour requête HEV
     $xsl = new DOMDocument();
     $xsl->load('xslt/hev.xsl');
     // Configuration du moteur de template
     $proc = new XSLTProcessor();
     $proc->setParameter('', 'HostID', $HostID);
     $proc->importStylesheet($xsl);
     // Récupération du résultat
     $doc = $proc->transformToDoc(new DOMDocument());
     $request = new Request('POST', $url);
     $request->setBody($doc->saveXML());
     $client = new Client();
     $client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
     $response = $client->send($request);
     $dom = new DOMDocument();
     $dom->loadXML($response->getBodyAsString());
     //echo "\nVoici la liste des versions compatibles avec ce serveur:\n\n";
     $result = array();
     foreach ($dom->getElementsByTagName('VersionNumber') as $version) {
         $result[] = array($version->getAttribute('ProtocolVersion'), "EBICS version {$version->nodeValue}");
     }
     $table = new Table($output);
     $table->setHeaders(array('Protocole', 'Description'))->setRows($result);
     $table->render();
 }
    function testCorrect()
    {
        $xml = '<?xml version="1.0"?>
<d:principal-search-property-set xmlns:d="DAV:"/>';
        $serverVars = array('REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals');
        $request = new HTTP\Request($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals('HTTP/1.1 200 OK', $server->httpResponse->status, $server->httpResponse->body);
        $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $server->httpResponse->headers);
        $check = array('/d:principal-search-property-set', '/d:principal-search-property-set/d:principal-search-property' => 2, '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1, '/d:principal-search-property-set/d:principal-search-property/d:description' => 2);
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
        foreach ($check as $v1 => $v2) {
            $xpath = is_int($v1) ? $v2 : $v1;
            $result = $xml->xpath($xpath);
            $count = 1;
            if (!is_int($v1)) {
                $count = $v2;
            }
            $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
        }
    }
Ejemplo n.º 5
0
 public static function parseUserPass(HTTP\Request $httpRequest)
 {
     // Apache and mod_php
     if ($user = $httpRequest->getRawServerValue('PHP_AUTH_USER')) {
         $pass = "";
         if ($passw = $httpRequest->getRawServerValue('PHP_AUTH_PW')) {
             $pass = $passw;
         }
         return array($user, $pass);
     }
     // Most other webservers
     $auth = $httpRequest->getHeader('Authorization');
     // Apache could prefix environment variables with REDIRECT_ when urls
     // are passed through mod_rewrite
     if (!$auth) {
         $auth = $httpRequest->getRawServerValue('REDIRECT_HTTP_AUTHORIZATION');
     }
     if (!$auth) {
         return false;
     }
     if (strpos(strtolower($auth), 'basic') !== 0) {
         return false;
     }
     return explode(':', base64_decode(substr($auth, 6)), 2);
 }
    function testExpand()
    {
        $request = new HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        // We only expect 3 events
        $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: ' . $body);
        // TZID should be gone
        $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID']));
    }
Ejemplo n.º 7
0
 /**
  * Redirect to the installation page of the application.
  * This method does not send the response.
  *
  * @param  Response  $response    HTTP response.
  * @param  Request   $request     HTTP request.
  * @return void
  */
 static function redirectToInstall(Response $response, Request $request)
 {
     list($dirname) = Uri\split($request->getUrl());
     $response->setStatus(307);
     $response->setHeader('Location', $dirname . '/install.php');
     $response->setBody('The application is not installed. ' . 'You are going to be redirected to the installation page.');
 }
Ejemplo n.º 8
0
    function testPrincipalMatchPrincipalProperty()
    {
        $xml = <<<XML
<?xml version="1.0"?>
<principal-match xmlns="DAV:">
    <principal-property>
        <principal-URL />
    </principal-property>
    <prop>
      <resourcetype />
    </prop>
</principal-match>
XML;
        $request = new Request('REPORT', '/principals', ['Content-Type' => 'application/xml']);
        $request->setBody($xml);
        $response = $this->request($request, 207);
        $expected = <<<XML
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
    <d:status>HTTP/1.1 200 OK</d:status>
    <d:href>/principals/user1/</d:href>
    <d:propstat>
        <d:prop>
            <d:resourcetype><d:principal/></d:resourcetype>
        </d:prop>
        <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
</d:multistatus>
XML;
        $this->assertXmlStringEqualsXmlString($expected, $response->getBodyAsString());
    }
    function testQueryTimerange()
    {
        $request = new HTTP\Request('REPORT', '/calendars/user1/calendar1', ['Content-Type' => 'application/xml', 'Depth' => '1']);
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120226T230000Z" end="20120228T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120226T230000Z" end="20120228T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        if (strpos($response->body, 'BEGIN:VCALENDAR') === false) {
            $this->fail('Got no events instead of 1. Output: ' . $response->body);
        }
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        // We expect 1 event
        $this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);
    }
Ejemplo n.º 10
0
 function sendPROPFIND($body)
 {
     $request = new HTTP\Request('PROPFIND', '/', ['Depth' => '0']);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
Ejemplo n.º 11
0
 public function sendPROPFIND($body)
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'PROPFIND', 'HTTP_DEPTH' => '0');
     $request = new HTTP\Request($serverVars);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
Ejemplo n.º 12
0
 function testPostNoSabreAction()
 {
     $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);
     $request->setPostData([]);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(501, $this->response->status);
 }
Ejemplo n.º 13
0
 function testPatchNoEndRange()
 {
     $this->node->put('00000');
     $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
     $request->setBody('111');
     $response = $this->request($request);
     $this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString());
     $this->assertEquals('00111', $this->node->get());
 }
Ejemplo n.º 14
0
 function testCreateFileJson()
 {
     $request = new HTTP\Request('PUT', '/addressbooks/admin/addressbook1/blabla.vcf');
     $request->setBody('[ "vcard" , [ [ "UID" , {}, "text", "foo" ] ] ]');
     $response = $this->request($request);
     $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
     $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf');
     $this->assertEquals("BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", $foo['carddata']);
 }
Ejemplo n.º 15
0
 public function testPatchNoEndRange()
 {
     $this->node->put('00000');
     $request = new HTTP\Request(array('REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/partial', 'HTTP_X_UPDATE_RANGE' => 'bytes=3-', 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', 'HTTP_CONTENT_LENGTH' => 3));
     $request->setBody('111');
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body);
     $this->assertEquals('00111', $this->node->get());
 }
Ejemplo n.º 16
0
 function testCollectionGet()
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET');
     $request = new HTTP\Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8', 'DAV' => '1, 3, extended-mkcol', 'Vary' => 'Brief,Prefer'), $this->response->headers);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body);
 }
Ejemplo n.º 17
0
 function testPutUpdate()
 {
     $request = new HTTP\Request('PUT', '/test.txt');
     $request->setBody('Testing updated file');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('0', $this->response->getHeader('Content-Length'));
     $this->assertEquals(204, $this->response->status);
     $this->assertEquals('', $this->response->body);
     $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt'));
 }
Ejemplo n.º 18
0
 public function testSharing()
 {
     $this->book->expects($this->once())->method('updateShares')->with([['href' => 'principal:principals/admin', 'commonName' => null, 'summary' => null, 'readOnly' => false]], ['mailto:wilfredo@example.com']);
     // setup request
     $request = new Request();
     $request->addHeader('Content-Type', 'application/xml');
     $request->setUrl('addressbook1.vcf');
     $request->setBody('<?xml version="1.0" encoding="utf-8" ?><CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"><CS:set><D:href>principal:principals/admin</D:href><CS:read-write/></CS:set> <CS:remove><D:href>mailto:wilfredo@example.com</D:href></CS:remove></CS:share>');
     $response = new Response();
     $this->plugin->httpPost($request, $response);
 }
Ejemplo n.º 19
0
 function testUpdateFileParsableBody()
 {
     $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo');
     $request = new HTTP\Request(array('REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf'));
     $body = "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n";
     $request->setBody($body);
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
     $expected = array('uri' => 'blabla.vcf', 'carddata' => $body);
     $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf'));
 }
 function testPutFail()
 {
     $serverVars = array('REQUEST_URI' => '/testput.txt', 'REQUEST_METHOD' => 'PUT', 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20');
     $request = new HTTP\Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status);
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $this->response->headers);
     $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));
 }
 protected function sendRequest($body, $path = '/jmap', $headers = [])
 {
     if (!is_string($body)) {
         $body = json_encode($body);
     }
     $request = new HTTP\Request('POST', $path, $headers, $body);
     $request->setHeader('Authorization', 'X-JMAP ' . $this->session->key);
     $this->server->httpRequest = $request;
     $this->server->process();
     return $this->server->httpResponse;
 }
Ejemplo n.º 22
0
 function testGetHttp10()
 {
     $request = new HTTP\Request('GET', '/file1');
     $request->setHttpVersion('1.0');
     $response = $this->request($request);
     $this->assertEquals(200, $response->getStatus());
     // Removing Last-Modified because it keeps changing.
     $response->removeHeader('Last-Modified');
     $this->assertEquals(['X-Sabre-Version' => [Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [3], 'ETag' => ['"' . md5('foo') . '"']], $response->getHeaders());
     $this->assertEquals('1.0', $response->getHttpVersion());
     $this->assertEquals('foo', $response->getBodyAsString());
 }
Ejemplo n.º 23
0
 function testReportPassThrough()
 {
     $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla'));
     $plugin = new Plugin(new Backend\Mock(), 'realm');
     $fakeServer->addPlugin($plugin);
     $request = new HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/'));
     $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
     $fakeServer->httpRequest = $request;
     $fakeServer->httpResponse = new HTTP\ResponseMock();
     $fakeServer->exec();
     $this->assertEquals('HTTP/1.1 403 Forbidden', $fakeServer->httpResponse->status);
 }
Ejemplo n.º 24
0
 function testPutUpdate()
 {
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT');
     $request = new HTTP\Request($serverVars);
     $request->setBody('Testing updated file');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('0', $this->response->headers['Content-Length']);
     $this->assertEquals('HTTP/1.1 204 No Content', $this->response->status);
     $this->assertEquals('', $this->response->body);
     $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt'));
 }
Ejemplo n.º 25
0
 /**
  * Handle JMAP client requests
  */
 public function process(Request $request, Response $response)
 {
     switch ($request->getMethod()) {
         case 'POST':
             $this->processPOST($request, $response);
             break;
         default:
             throw new ProcessorException(405, "Method " . $request->getMethod() . " not allowed");
     }
     if ($response->getStatus() === 401) {
         $response->setHeader('WWW-Authenticate', Auth::SCHEME);
     }
 }
    function testReportDepth1()
    {
        $xml = <<<XML
<?xml version="1.0"?>
<acl-principal-prop-set xmlns="DAV:">
    <principal-URL />
    <displayname />
</acl-principal-prop-set>
XML;
        $request = new Request('REPORT', '/principals/user1', ['Content-Type' => 'application/xml', 'Depth' => 1]);
        $request->setBody($xml);
        $this->request($request, 400);
    }
Ejemplo n.º 27
0
 public function testDigestAuthInt()
 {
     $this->auth->setQOP(Digest::QOP_AUTHINT | Digest::QOP_AUTH);
     list($nonce, $opaque) = $this->getServerTokens(Digest::QOP_AUTHINT | Digest::QOP_AUTH);
     $username = '******';
     $password = 12345;
     $nc = '00003';
     $cnonce = uniqid();
     $digestHash = md5(md5($username . ':' . self::REALM . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . 'auth-int:' . md5('POST' . ':' . '/' . ':' . md5('body')));
     $this->request->setMethod('POST');
     $this->request->setHeader('Authorization', 'Digest username="******", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth-int,nc=' . $nc . ',cnonce="' . $cnonce . '"');
     $this->request->setBody('body');
     $this->auth->init();
     $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)), 'Authentication is deemed invalid through validateA1');
 }
Ejemplo n.º 28
0
 /**
  * @dataProvider data
  */
 public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4)
 {
     $vars = array('REQUEST_METHOD' => 'PATCH', 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', 'HTTP_X_UPDATE_RANGE' => $headerValue, 'REQUEST_URI' => '/foobar.txt');
     if ($contentLength) {
         $vars['HTTP_CONTENT_LENGTH'] = (string) $contentLength;
     }
     $request = new HTTP\Request($vars);
     $request->setBody('----');
     $this->server->httpRequest = $request;
     $this->server->httpResponse = new HTTP\ResponseMock();
     $this->server->exec();
     $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body);
     if (!is_null($endResult)) {
         $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt'));
     }
 }
Ejemplo n.º 29
0
 /**
  * @dataProvider data
  */
 public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4)
 {
     $headers = ['Content-Type' => 'application/x-sabredav-partialupdate', 'X-Update-Range' => $headerValue];
     if ($contentLength) {
         $headers['Content-Length'] = (string) $contentLength;
     }
     $request = new HTTP\Request('PATCH', '/foobar.txt', $headers, '----');
     $request->setBody('----');
     $this->server->httpRequest = $request;
     $this->server->httpResponse = new HTTP\ResponseMock();
     $this->server->sapi = new HTTP\SapiMock();
     $this->server->exec();
     $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body);
     if (!is_null($endResult)) {
         $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt'));
     }
 }
Ejemplo n.º 30
0
    function testIssue203()
    {
        $request = new HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        $this->assertEquals(2, count($vObject->VEVENT));
        $expectedEvents = array(array('DTSTART' => '20120326T135200Z', 'DTEND' => '20120326T145200Z', 'SUMMARY' => 'original summary'), array('DTSTART' => '20120328T135200Z', 'DTEND' => '20120328T145200Z', 'SUMMARY' => 'overwritten summary', 'RECURRENCE-ID' => '20120327T135200Z'));
        // try to match agains $expectedEvents array
        foreach ($expectedEvents as $expectedEvent) {
            $matching = false;
            foreach ($vObject->VEVENT as $vevent) {
                /** @var $vevent Sabre\VObject\Component\VEvent */
                foreach ($vevent->children as $child) {
                    /** @var $child Sabre\VObject\Property */
                    if (isset($expectedEvent[$child->name])) {
                        if ($expectedEvent[$child->name] != $child->getValue()) {
                            continue 2;
                        }
                    }
                }
                $matching = true;
                break;
            }
            $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true));
        }
    }