作者:msooo
项目:hubzill
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(' ', '', $body);
$vObject = VObject\Reader::read($body);
$this->assertEquals(1, count($vObject->VEVENT));
}
作者:sebbie4
项目:casebo
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());
}
作者:syna
项目:ebic
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();
}
作者:TamirA
项目:hubzill
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);
}
}
作者:Nanoman
项目:pydio-cor
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);
}
作者:TamirA
项目:hubzill
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(' ', '', $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']));
}
作者:JuniperChicag
项目:sabre-katan
/**
* 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.');
}
作者:Radiergumm
项目:anacronis
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());
}
作者:bogolubo
项目:owncollab_talks-
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(' ', '', $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);
}
作者:sebbie4
项目:casebo
function sendPROPFIND($body)
{
$request = new HTTP\Request('PROPFIND', '/', ['Depth' => '0']);
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
}
作者:TamirA
项目:hubzill
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();
}
作者:matte
项目:sabre-da
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);
}
作者:sebbie4
项目:casebo
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());
}
作者:sebbie4
项目:casebo
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']);
}
作者:TamirA
项目:hubzill
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());
}
作者:samj191
项目:rep
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);
}
作者:MetallianFR6
项目:myroundcub
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'));
}
作者:rchicol
项目:owncloud-cor
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);
}
作者:TamirA
项目:hubzill
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'));
}
作者:MetallianFR6
项目:myroundcub
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'));
}