예제 #1
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');
 }
    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);
        }
    }
예제 #3
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));
    }
예제 #4
0
 function sendPROPFIND($body)
 {
     $request = new HTTP\Request('PROPFIND', '/', ['Depth' => '0']);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
    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']));
    }
    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);
    }
예제 #7
0
파일: HEV.php 프로젝트: 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();
 }
예제 #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());
    }
예제 #9
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());
    }
예제 #10
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();
 }
예제 #11
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());
 }
예제 #12
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());
 }
예제 #13
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']);
 }
예제 #14
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);
 }
예제 #15
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'));
 }
예제 #16
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);
 }
예제 #17
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'));
 }
예제 #19
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);
 }
예제 #20
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'));
 }
    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);
    }
예제 #22
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'));
     }
 }
예제 #23
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'));
     }
 }
예제 #24
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));
        }
    }
예제 #25
0
파일: INI.php 프로젝트: synap/ebics
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Récupération des paramètres de connexion
     $parameters = json_decode(file_get_contents('parameters.json'));
     // Récupération du certificat X509
     $cert = file_get_contents('test/fixtures/keys/A005/cert.pem');
     $cert_details = openssl_x509_parse($cert);
     $params = array('X509IssuerName' => $cert_details['name'], 'X509SerialNumber' => $cert_details['serialNumber'], 'X509Certificate' => str_replace(array('-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----', "\n"), '', $cert));
     $cert_details = openssl_pkey_get_details(openssl_pkey_get_public($cert));
     $params = array_merge(array('Modulus' => base64_encode($cert_details['rsa']['n']), 'Exponent' => base64_encode($cert_details['rsa']['e'])), $params);
     // Attention, la cohérence entre les différente valeurs n'est pas vérifiée dans
     // la phase d'initialisation. Seule la longueur des valeurs l'est
     // Création de la signature A005
     $xsl = new DOMDocument();
     $xsl->load('xslt/SignaturePubKeyOrderData.xsl');
     $proc = new XSLTProcessor();
     $proc->setParameter('', 'X509IssuerName', $params['X509IssuerName']);
     $proc->setParameter('', 'X509SerialNumber', $params['X509SerialNumber']);
     $proc->setParameter('', 'X509Certificate', $params['X509Certificate']);
     $proc->setParameter('', 'Modulus', $params['Modulus']);
     $proc->setParameter('', 'Exponent', $params['Exponent']);
     $proc->setParameter('', 'PartnerID', $parameters->partner);
     $proc->setParameter('', 'UserID', $parameters->user);
     $proc->setParameter('', 'TimeStamp', date('c'));
     $proc->importStylesheet($xsl);
     $A005 = $proc->transformToXML(new DOMDocument());
     // On compresse et on encode en base64
     $A005 = gzcompress($A005);
     $A005 = base64_encode($A005);
     $xsl = new DOMDocument();
     $xsl->load('xslt/ebicsUnsecuredRequest.xsl');
     $proc->importStylesheet($xsl);
     $proc->setParameter('', 'HostID', $parameters->host);
     $proc->setParameter('', 'OrderData', $A005);
     $xml = $proc->transformToXML(new DOMDocument());
     $request = new Request('POST', $parameters->url);
     $request->setBody($xml);
     $client = new Client();
     $client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
     $response = $client->send($request);
     $dom = new DOMDocument();
     $dom->formatOutput = true;
     $dom->loadXML($response->getBodyAsString());
     echo $dom->saveXML();
 }
    function testDelivery()
    {
        $request = new Request('PUT', '/calendars/user1/default/foo.ics');
        $request->setBody(<<<ICS
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
CREATED:20140109T204404Z
UID:AADC6438-18CF-4B52-8DD2-EF9AD75ADE83
DTEND;TZID=America/Toronto:20140107T110000
TRANSP:OPAQUE
ATTENDEE;CN="Adminstrator";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:user1.sabredav@sabredav.org
ATTENDEE;CN="Roxy Kesh";CUTYPE=INDIVIDUAL;EMAIL="*****@*****.**";
 PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:user2.sabredav@sabredav.org
SUMMARY:Just testing!
DTSTART;TZID=America/Toronto:20140107T100000
DTSTAMP:20140109T204422Z
ORGANIZER;CN="Administrator":mailto:user1.sabredav@sabredav.org
SEQUENCE:4
END:VEVENT
END:VCALENDAR
ICS
);
        $messages = [];
        $this->server->on('schedule', function ($message) use(&$messages) {
            $messages[] = $message;
        });
        $response = $this->request($request);
        $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Response body:' . $response->getBodyAsString());
        $result = $this->request(new Request('GET', '/calendars/user1/default/foo.ics'))->getBody();
        $resultVObj = VObject\Reader::read($result);
        $this->assertEquals('1.2;Message delivered locally', $resultVObj->VEVENT->ATTENDEE[1]['SCHEDULE-STATUS']->getValue());
        $this->assertEquals(1, count($messages));
        $message = $messages[0];
        $this->assertInstanceOf('\\Sabre\\VObject\\ITip\\Message', $message);
        $this->assertEquals('mailto:user2.sabredav@sabredav.org', $message->recipient);
        $this->assertEquals('Roxy Kesh', $message->recipientName);
        $this->assertEquals('mailto:user1.sabredav@sabredav.org', $message->sender);
        $this->assertEquals('Administrator', $message->senderName);
        $this->assertEquals('REQUEST', $message->method);
        $this->assertEquals('REQUEST', $message->message->METHOD->getValue());
    }
예제 #27
0
 function testValidRequest()
 {
     $accessKey = 'accessKey';
     $secretKey = 'secretKey';
     $content = 'thisisthebody';
     $contentMD5 = base64_encode(md5($content, true));
     $date = new \DateTime('now');
     $date->setTimeZone(new \DateTimeZone('GMT'));
     $date = $date->format('D, d M Y H:i:s \\G\\M\\T');
     $sig = base64_encode($this->hmacsha1($secretKey, "POST\n{$contentMD5}\n\n{$date}\nx-amz-date:{$date}\n/evert"));
     $this->request->setUrl('/evert');
     $this->request->setMethod('POST');
     $this->request->setHeaders(['Authorization' => "AWS {$accessKey}:{$sig}", 'Content-MD5' => $contentMD5, 'X-amz-date' => $date]);
     $this->request->setBody($content);
     $this->auth->init();
     $result = $this->auth->validate($secretKey);
     $this->assertTrue($result, 'Signature did not validate, got errorcode ' . $this->auth->errorCode);
     $this->assertEquals($accessKey, $this->auth->getAccessKey());
 }
예제 #28
0
 /**
  * @depends testTreeMove
  * @depends testCopyMoveInfo
  */
 function testEverything()
 {
     // Request object
     $serverVars = array('REQUEST_METHOD' => 'MOVE', 'REQUEST_URI' => '/webdav/bar', 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', 'HTTP_OVERWRITE' => 'F');
     $request = new HTTP\Request($serverVars);
     $request->setBody('');
     $response = new HTTP\ResponseMock();
     // Server setup
     mkdir(SABRE_TEMPDIR . '/issue33');
     $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33');
     $dir->createDirectory('bar');
     $tree = new ObjectTree($dir);
     $server = new Server($tree);
     $server->setBaseUri('/webdav/');
     $server->httpRequest = $request;
     $server->httpResponse = $response;
     $server->exec();
     $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3')));
 }
예제 #29
0
    function testMultiGet()
    {
        $request = new HTTP\Request(array('REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1'));
        $request->setBody('<?xml version="1.0"?>
<c:addressbook-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
    <d:prop>
      <d:getetag />
      <c:address-data />
    </d:prop>
    <d:href>/addressbooks/user1/book1/card1</d:href>
</c:addressbook-multiget>');
        $response = new HTTP\ResponseMock();
        $this->server->httpRequest = $request;
        $this->server->httpResponse = $response;
        $this->server->exec();
        $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
        // using the client for parsing
        $client = new DAV\Client(array('baseUri' => '/'));
        $result = $client->parseMultiStatus($response->body);
        $this->assertEquals(array('/addressbooks/user1/book1/card1' => array(200 => array('{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"))), $result);
    }
    function testExpandRecurringByDayEvent()
    {
        $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="20120210T230000Z" end="20120217T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120210T230000Z" end="20120217T225959Z"/>
            </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));
        // check if DTSTARTs and DTENDs are correct
        foreach ($vObject->VEVENT as $vevent) {
            /** @var $vevent Sabre\VObject\Component\VEvent */
            foreach ($vevent->children as $child) {
                /** @var $child Sabre\VObject\Property */
                if ($child->name == 'DTSTART') {
                    // DTSTART has to be one of two valid values
                    $this->assertContains($child->getValue(), array('20120214T171500Z', '20120216T171500Z'), 'DTSTART is not a valid value: ' . $child->getValue());
                } elseif ($child->name == 'DTEND') {
                    // DTEND has to be one of two valid values
                    $this->assertContains($child->getValue(), array('20120214T181500Z', '20120216T181500Z'), 'DTEND is not a valid value: ' . $child->getValue());
                }
            }
        }
    }