From c26dede97f626b52b7bf8962ed55d1dbda86abe8 Mon Sep 17 00:00:00 2001 From: Hilmar R Date: Sun, 28 Feb 2021 21:06:16 +0100 Subject: get dev --- .../dav/tests/Sabre/CardDAV/AbstractPluginTest.php | 43 --- .../tests/Sabre/CardDAV/AddressBookQueryTest.php | 351 --------------------- .../tests/Sabre/CardDAV/AddressBookRootTest.php | 31 -- .../dav/tests/Sabre/CardDAV/AddressBookTest.php | 171 ---------- .../Sabre/CardDAV/Backend/AbstractPDOTest.php | 351 --------------------- .../sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php | 257 --------------- .../tests/Sabre/CardDAV/Backend/PDOMySQLTest.php | 10 - .../tests/Sabre/CardDAV/Backend/PDOSqliteTest.php | 10 - vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php | 194 ------------ .../dav/tests/Sabre/CardDAV/IDirectoryTest.php | 28 -- .../sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php | 99 ------ .../sabre/dav/tests/Sabre/CardDAV/PluginTest.php | 101 ------ .../Sabre/CardDAV/SogoStripContentTypeTest.php | 67 ---- .../dav/tests/Sabre/CardDAV/VCFExportTest.php | 130 -------- .../dav/tests/Sabre/CardDAV/ValidateFilterTest.php | 204 ------------ .../dav/tests/Sabre/CardDAV/ValidateVCardTest.php | 293 ----------------- 16 files changed, 2340 deletions(-) delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php delete mode 100644 vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV') diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php deleted file mode 100644 index 6565fc459..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php +++ /dev/null @@ -1,43 +0,0 @@ -backend = new Backend\Mock(); - $principalBackend = new DAVACL\PrincipalBackend\Mock(); - - $tree = [ - new AddressBookRoot($principalBackend, $this->backend), - new DAVACL\PrincipalCollection($principalBackend), - ]; - - $this->plugin = new Plugin(); - $this->plugin->directories = ['directory']; - $this->server = new DAV\Server($tree); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->addPlugin($this->plugin); - $this->server->debugExceptions = true; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php deleted file mode 100644 index a86d85144..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php +++ /dev/null @@ -1,351 +0,0 @@ - '1'] - ); - - $request->setBody( -' - - - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - ], - ], - '/addressbooks/user1/book1/card2' => [ - 404 => [ - '{DAV:}getetag' => null, - ], - ], - ], $result); - } - - public function testQueryDepth0() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book1/card1', - ['Depth' => '0'] - ); - - $request->setBody( -' - - - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - ], - ], - ], $result); - } - - public function testQueryNoMatch() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book1', - ['Depth' => '1'] - ); - - $request->setBody( -' - - - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([], $result); - } - - public function testQueryLimit() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', - ]); - - $request->setBody( -' - - - - - - - - 1 -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - ], - ], - ], $result); - } - - public function testJson() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book1/card1', - ['Depth' => '0'] - ); - - $request->setBody( -' - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $vobjVersion = \Sabre\VObject\Version::VERSION; - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject '.$vobjVersion.'\/\/EN"],["uid",{},"text","12345"]]]', - ], - ], - ], $result); - } - - public function testVCard4() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book1/card1', - ['Depth' => '0'] - ); - - $request->setBody( -' - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $vobjVersion = \Sabre\VObject\Version::VERSION; - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject $vobjVersion//EN\r\nUID:12345\r\nEND:VCARD\r\n", - ], - ], - ], $result); - } - - public function testAddressBookDepth0() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book1', - ['Depth' => '0'] - ); - - $request->setBody( - ' - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:'.$response->getBodyAsString()); - } - - public function testAddressBookProperties() - { - $request = new HTTP\Request( - 'REPORT', - '/addressbooks/user1/book3', - ['Depth' => '1'] - ); - - $request->setBody( - ' - - - - - - - - -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([ - '/addressbooks/user1/book3/card3' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD").'"', - '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:12345\r\nFN:Test-Card\r\nEND:VCARD\r\n", - ], - ], - ], $result); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php deleted file mode 100644 index c4aff2712..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertEquals('addressbooks', $root->getName()); - } - - public function testGetChildForPrincipal() - { - $pBackend = new DAVACL\PrincipalBackend\Mock(); - $cBackend = new Backend\Mock(); - $root = new AddressBookRoot($pBackend, $cBackend); - - $children = $root->getChildren(); - $this->assertEquals(3, count($children)); - - $this->assertInstanceOf('Sabre\\CardDAV\\AddressBookHome', $children[0]); - $this->assertEquals('user1', $children[0]->getName()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php deleted file mode 100644 index e985c54ff..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php +++ /dev/null @@ -1,171 +0,0 @@ -backend = new Backend\Mock(); - $this->ab = new AddressBook( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - '{DAV:}displayname' => 'd-name', - 'principaluri' => 'principals/user1', - ] - ); - } - - public function testGetName() - { - $this->assertEquals('book1', $this->ab->getName()); - } - - public function testGetChild() - { - $card = $this->ab->getChild('card1'); - $this->assertInstanceOf('Sabre\\CardDAV\\Card', $card); - $this->assertEquals('card1', $card->getName()); - } - - public function testGetChildNotFound() - { - $this->expectException('Sabre\DAV\Exception\NotFound'); - $card = $this->ab->getChild('card3'); - } - - public function testGetChildren() - { - $cards = $this->ab->getChildren(); - $this->assertEquals(2, count($cards)); - - $this->assertEquals('card1', $cards[0]->getName()); - $this->assertEquals('card2', $cards[1]->getName()); - } - - public function testCreateDirectory() - { - $this->expectException('Sabre\DAV\Exception\MethodNotAllowed'); - $this->ab->createDirectory('name'); - } - - public function testCreateFile() - { - $file = fopen('php://memory', 'r+'); - fwrite($file, 'foo'); - rewind($file); - $this->ab->createFile('card2', $file); - - $this->assertEquals('foo', $this->backend->cards['foo']['card2']); - } - - public function testDelete() - { - $this->ab->delete(); - $this->assertEquals(1, count($this->backend->addressBooks)); - } - - public function testSetName() - { - $this->expectException('Sabre\DAV\Exception\MethodNotAllowed'); - $this->ab->setName('foo'); - } - - public function testGetLastModified() - { - $this->assertNull($this->ab->getLastModified()); - } - - public function testUpdateProperties() - { - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'barrr', - ]); - $this->ab->propPatch($propPatch); - $this->assertTrue($propPatch->commit()); - - $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']); - } - - public function testGetProperties() - { - $props = $this->ab->getProperties(['{DAV:}displayname']); - $this->assertEquals([ - '{DAV:}displayname' => 'd-name', - ], $props); - } - - public function testACLMethods() - { - $this->assertEquals('principals/user1', $this->ab->getOwner()); - $this->assertNull($this->ab->getGroup()); - $this->assertEquals([ - [ - 'privilege' => '{DAV:}all', - 'principal' => '{DAV:}owner', - 'protected' => true, - ], - ], $this->ab->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $this->ab->setACL([]); - } - - public function testGetSupportedPrivilegeSet() - { - $this->assertNull( - $this->ab->getSupportedPrivilegeSet() - ); - } - - public function testGetSyncTokenNoSyncSupport() - { - $this->assertNull($this->ab->getSyncToken()); - } - - public function testGetChangesNoSyncSupport() - { - $this->assertNull($this->ab->getChanges(1, null)); - } - - public function testGetSyncToken() - { - $this->driver = 'sqlite'; - $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); - $this->createSchema('addressbooks'); - $backend = new Backend\PDO( - $this->getPDO() - ); - $ab = new AddressBook($backend, ['id' => 1, '{DAV:}sync-token' => 2]); - $this->assertEquals(2, $ab->getSyncToken()); - } - - public function testGetSyncToken2() - { - $this->driver = 'sqlite'; - $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); - $this->createSchema('addressbooks'); - $backend = new Backend\PDO( - $this->getPDO() - ); - $ab = new AddressBook($backend, ['id' => 1, '{http://sabredav.org/ns}sync-token' => 2]); - $this->assertEquals(2, $ab->getSyncToken()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php deleted file mode 100644 index bac3b2b22..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php +++ /dev/null @@ -1,351 +0,0 @@ -dropTables([ - 'addressbooks', - 'cards', - 'addressbookchanges', - ]); - $this->createSchema('addressbooks'); - $pdo = $this->getPDO(); - - $this->backend = new PDO($pdo); - $pdo->exec("INSERT INTO addressbooks (principaluri, displayname, uri, description, synctoken) VALUES ('principals/user1', 'book1', 'book1', 'addressbook 1', 1)"); - $pdo->exec("INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '".md5('card1')."', 5)"); - } - - public function testGetAddressBooksForUser() - { - $result = $this->backend->getAddressBooksForUser('principals/user1'); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ], - ]; - - $this->assertEquals($expected, $result); - } - - public function testUpdateAddressBookInvalidProp() - { - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', - '{DAV:}foo' => 'bar', - ]); - - $this->backend->updateAddressBook(1, $propPatch); - $result = $propPatch->commit(); - - $this->assertFalse($result); - - $result = $this->backend->getAddressBooksForUser('principals/user1'); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ], - ]; - - $this->assertEquals($expected, $result); - } - - public function testUpdateAddressBookNoProps() - { - $propPatch = new PropPatch([ - ]); - - $this->backend->updateAddressBook(1, $propPatch); - $result = $propPatch->commit(); - $this->assertTrue($result); - - $result = $this->backend->getAddressBooksForUser('principals/user1'); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ], - ]; - - $this->assertEquals($expected, $result); - } - - public function testUpdateAddressBookSuccess() - { - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', - ]); - - $this->backend->updateAddressBook(1, $propPatch); - $result = $propPatch->commit(); - - $this->assertTrue($result); - - $result = $this->backend->getAddressBooksForUser('principals/user1'); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'updated', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', - '{http://calendarserver.org/ns/}getctag' => 2, - '{http://sabredav.org/ns}sync-token' => 2, - ], - ]; - - $this->assertEquals($expected, $result); - } - - public function testDeleteAddressBook() - { - $this->backend->deleteAddressBook(1); - - $this->assertEquals([], $this->backend->getAddressBooksForUser('principals/user1')); - } - - public function testCreateAddressBookUnsupportedProp() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - $this->backend->createAddressBook('principals/user1', 'book2', [ - '{DAV:}foo' => 'bar', - ]); - } - - public function testCreateAddressBookSuccess() - { - $this->backend->createAddressBook('principals/user1', 'book2', [ - '{DAV:}displayname' => 'book2', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', - ]); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ], - [ - 'id' => 2, - 'uri' => 'book2', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book2', - '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ], - ]; - $result = $this->backend->getAddressBooksForUser('principals/user1'); - $this->assertEquals($expected, $result); - } - - public function testGetCards() - { - $result = $this->backend->getCards(1); - - $expected = [ - [ - 'id' => 1, - 'uri' => 'card1', - 'lastmodified' => 0, - 'etag' => '"'.md5('card1').'"', - 'size' => 5, - ], - ]; - - $this->assertEquals($expected, $result); - } - - public function testGetCard() - { - $result = $this->backend->getCard(1, 'card1'); - - $expected = [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', - 'lastmodified' => 0, - 'etag' => '"'.md5('card1').'"', - 'size' => 5, - ]; - - if (is_resource($result['carddata'])) { - $result['carddata'] = stream_get_contents($result['carddata']); - } - - $this->assertEquals($expected, $result); - } - - /** - * @depends testGetCard - */ - public function testCreateCard() - { - $result = $this->backend->createCard(1, 'card2', 'data2'); - $this->assertEquals('"'.md5('data2').'"', $result); - $result = $this->backend->getCard(1, 'card2'); - $this->assertEquals(2, $result['id']); - $this->assertEquals('card2', $result['uri']); - if (is_resource($result['carddata'])) { - $result['carddata'] = stream_get_contents($result['carddata']); - } - $this->assertEquals('data2', $result['carddata']); - } - - /** - * @depends testCreateCard - */ - public function testGetMultiple() - { - $result = $this->backend->createCard(1, 'card2', 'data2'); - $result = $this->backend->createCard(1, 'card3', 'data3'); - $check = [ - [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', - 'lastmodified' => 0, - ], - [ - 'id' => 2, - 'uri' => 'card2', - 'carddata' => 'data2', - 'lastmodified' => time(), - ], - [ - 'id' => 3, - 'uri' => 'card3', - 'carddata' => 'data3', - 'lastmodified' => time(), - ], - ]; - - $result = $this->backend->getMultipleCards(1, ['card1', 'card2', 'card3']); - - foreach ($check as $index => $node) { - foreach ($node as $k => $v) { - $expected = $v; - $actual = $result[$index][$k]; - - switch ($k) { - case 'lastmodified': - $this->assertIsInt($actual); - break; - case 'carddata': - if (is_resource($actual)) { - $actual = stream_get_contents($actual); - } - // no break intended. - default: - $this->assertEquals($expected, $actual); - break; - } - } - } - } - - /** - * @depends testGetCard - */ - public function testUpdateCard() - { - $result = $this->backend->updateCard(1, 'card1', 'newdata'); - $this->assertEquals('"'.md5('newdata').'"', $result); - - $result = $this->backend->getCard(1, 'card1'); - $this->assertEquals(1, $result['id']); - if (is_resource($result['carddata'])) { - $result['carddata'] = stream_get_contents($result['carddata']); - } - $this->assertEquals('newdata', $result['carddata']); - } - - /** - * @depends testGetCard - */ - public function testDeleteCard() - { - $this->backend->deleteCard(1, 'card1'); - $result = $this->backend->getCard(1, 'card1'); - $this->assertFalse($result); - } - - public function testGetChanges() - { - $backend = $this->backend; - $id = $backend->createAddressBook( - 'principals/user1', - 'bla', - [] - ); - $result = $backend->getChangesForAddressBook($id, null, 1); - - $this->assertEquals([ - 'syncToken' => 1, - 'added' => [], - 'modified' => [], - 'deleted' => [], - ], $result); - - $currentToken = $result['syncToken']; - - $dummyCard = "BEGIN:VCARD\r\nEND:VCARD\r\n"; - - $backend->createCard($id, 'card1.ics', $dummyCard); - $backend->createCard($id, 'card2.ics', $dummyCard); - $backend->createCard($id, 'card3.ics', $dummyCard); - $backend->updateCard($id, 'card1.ics', $dummyCard); - $backend->deleteCard($id, 'card2.ics'); - - $result = $backend->getChangesForAddressBook($id, $currentToken, 1); - - $this->assertEquals([ - 'syncToken' => 6, - 'modified' => ['card1.ics'], - 'deleted' => ['card2.ics'], - 'added' => ['card3.ics'], - ], $result); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php deleted file mode 100644 index 630465cc8..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php +++ /dev/null @@ -1,257 +0,0 @@ -addressBooks = $addressBooks; - $this->cards = $cards; - - if (is_null($this->addressBooks)) { - $this->addressBooks = [ - [ - 'id' => 'foo', - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'd-name', - ], - [ - 'id' => 'bar', - 'uri' => 'book3', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'd-name', - ], - ]; - - $card2 = fopen('php://memory', 'r+'); - fwrite($card2, "BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD"); - rewind($card2); - $this->cards = [ - 'foo' => [ - 'card1' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", - 'card2' => $card2, - ], - 'bar' => [ - 'card3' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD", - ], - ]; - } - } - - public function getAddressBooksForUser($principalUri) - { - $books = []; - foreach ($this->addressBooks as $book) { - if ($book['principaluri'] === $principalUri) { - $books[] = $book; - } - } - - return $books; - } - - /** - * Updates properties for an address book. - * - * The list of mutations is stored in a Sabre\DAV\PropPatch object. - * To do the actual updates, you must tell this object which properties - * you're going to process with the handle() method. - * - * Calling the handle method is like telling the PropPatch object "I - * promise I can handle updating this property". - * - * Read the PropPatch documentation for more info and examples. - * - * @param string $addressBookId - */ - public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) - { - foreach ($this->addressBooks as &$book) { - if ($book['id'] !== $addressBookId) { - continue; - } - - $propPatch->handleRemaining(function ($mutations) use (&$book) { - foreach ($mutations as $key => $value) { - $book[$key] = $value; - } - - return true; - }); - } - } - - public function createAddressBook($principalUri, $url, array $properties) - { - $this->addressBooks[] = array_merge($properties, [ - 'id' => $url, - 'uri' => $url, - 'principaluri' => $principalUri, - ]); - } - - public function deleteAddressBook($addressBookId) - { - foreach ($this->addressBooks as $key => $value) { - if ($value['id'] === $addressBookId) { - unset($this->addressBooks[$key]); - } - } - unset($this->cards[$addressBookId]); - } - - /** - * Returns all cards for a specific addressbook id. - * - * This method should return the following properties for each card: - * * carddata - raw vcard data - * * uri - Some unique url - * * lastmodified - A unix timestamp - * - * It's recommended to also return the following properties: - * * etag - A unique etag. This must change every time the card changes. - * * size - The size of the card in bytes. - * - * If these last two properties are provided, less time will be spent - * calculating them. If they are specified, you can also ommit carddata. - * This may speed up certain requests, especially with large cards. - * - * @param mixed $addressBookId - * - * @return array - */ - public function getCards($addressBookId) - { - $cards = []; - foreach ($this->cards[$addressBookId] as $uri => $data) { - if (is_resource($data)) { - $cards[] = [ - 'uri' => $uri, - 'carddata' => $data, - ]; - } else { - $cards[] = [ - 'uri' => $uri, - 'carddata' => $data, - 'etag' => '"'.md5($data).'"', - 'size' => strlen($data), - ]; - } - } - - return $cards; - } - - /** - * Returns a specfic card. - * - * The same set of properties must be returned as with getCards. The only - * exception is that 'carddata' is absolutely required. - * - * If the card does not exist, you must return false. - * - * @param mixed $addressBookId - * @param string $cardUri - * - * @return array - */ - public function getCard($addressBookId, $cardUri) - { - if (!isset($this->cards[$addressBookId][$cardUri])) { - return false; - } - - $data = $this->cards[$addressBookId][$cardUri]; - - return [ - 'uri' => $cardUri, - 'carddata' => $data, - 'etag' => '"'.md5($data).'"', - 'size' => strlen($data), - ]; - } - - /** - * Creates a new card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressBooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag is for the - * newly created resource, and must be enclosed with double quotes (that - * is, the string itself must contain the double quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param mixed $addressBookId - * @param string $cardUri - * @param string $cardData - * - * @return string|null - */ - public function createCard($addressBookId, $cardUri, $cardData) - { - if (is_resource($cardData)) { - $cardData = stream_get_contents($cardData); - } - $this->cards[$addressBookId][$cardUri] = $cardData; - - return '"'.md5($cardData).'"'; - } - - /** - * Updates a card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressBooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag should - * match that of the updated resource, and must be enclosed with double - * quotes (that is: the string itself must contain the actual quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param mixed $addressBookId - * @param string $cardUri - * @param string $cardData - * - * @return string|null - */ - public function updateCard($addressBookId, $cardUri, $cardData) - { - if (is_resource($cardData)) { - $cardData = stream_get_contents($cardData); - } - $this->cards[$addressBookId][$cardUri] = $cardData; - - return '"'.md5($cardData).'"'; - } - - public function deleteCard($addressBookId, $cardUri) - { - unset($this->cards[$addressBookId][$cardUri]); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php deleted file mode 100644 index 718eec6be..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php +++ /dev/null @@ -1,10 +0,0 @@ -backend = new Backend\Mock(); - $this->card = new Card( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - 'principaluri' => 'principals/user1', - ], - [ - 'uri' => 'card1', - 'addressbookid' => 'foo', - 'carddata' => 'card', - ] - ); - } - - public function testGet() - { - $result = $this->card->get(); - $this->assertEquals('card', $result); - } - - public function testGet2() - { - $this->card = new Card( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - 'principaluri' => 'principals/user1', - ], - [ - 'uri' => 'card1', - 'addressbookid' => 'foo', - ] - ); - $result = $this->card->get(); - $this->assertEquals("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", $result); - } - - /** - * @depends testGet - */ - public function testPut() - { - $file = fopen('php://memory', 'r+'); - fwrite($file, 'newdata'); - rewind($file); - $this->card->put($file); - $result = $this->card->get(); - $this->assertEquals('newdata', $result); - } - - public function testDelete() - { - $this->card->delete(); - $this->assertEquals(1, count($this->backend->cards['foo'])); - } - - public function testGetContentType() - { - $this->assertEquals('text/vcard; charset=utf-8', $this->card->getContentType()); - } - - public function testGetETag() - { - $this->assertEquals('"'.md5('card').'"', $this->card->getETag()); - } - - public function testGetETag2() - { - $card = new Card( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - 'principaluri' => 'principals/user1', - ], - [ - 'uri' => 'card1', - 'addressbookid' => 'foo', - 'carddata' => 'card', - 'etag' => '"blabla"', - ] - ); - $this->assertEquals('"blabla"', $card->getETag()); - } - - public function testGetLastModified() - { - $this->assertEquals(null, $this->card->getLastModified()); - } - - public function testGetSize() - { - $this->assertEquals(4, $this->card->getSize()); - $this->assertEquals(4, $this->card->getSize()); - } - - public function testGetSize2() - { - $card = new Card( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - 'principaluri' => 'principals/user1', - ], - [ - 'uri' => 'card1', - 'addressbookid' => 'foo', - 'etag' => '"blabla"', - 'size' => 4, - ] - ); - $this->assertEquals(4, $card->getSize()); - } - - public function testACLMethods() - { - $this->assertEquals('principals/user1', $this->card->getOwner()); - $this->assertNull($this->card->getGroup()); - $this->assertEquals([ - [ - 'privilege' => '{DAV:}all', - 'principal' => 'principals/user1', - 'protected' => true, - ], - ], $this->card->getACL()); - } - - public function testOverrideACL() - { - $card = new Card( - $this->backend, - [ - 'uri' => 'book1', - 'id' => 'foo', - 'principaluri' => 'principals/user1', - ], - [ - 'uri' => 'card1', - 'addressbookid' => 'foo', - 'carddata' => 'card', - 'acl' => [ - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ], - ], - ] - ); - $this->assertEquals([ - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ], - ], $card->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $this->card->setACL([]); - } - - public function testGetSupportedPrivilegeSet() - { - $this->assertNull( - $this->card->getSupportedPrivilegeSet() - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php deleted file mode 100644 index 760749f6c..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php +++ /dev/null @@ -1,28 +0,0 @@ -addPlugin($plugin); - - $props = $server->getProperties('directory', ['{DAV:}resourcetype']); - $this->assertTrue($props['{DAV:}resourcetype']->is('{'.Plugin::NS_CARDDAV.'}directory')); - } -} - -class DirectoryMock extends DAV\SimpleCollection implements IDirectory -{ -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php deleted file mode 100644 index ac0cd5e91..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php +++ /dev/null @@ -1,99 +0,0 @@ - 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - ]); - - $request->setBody( -' - - - - - - /addressbooks/user1/book1/card1 -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{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); - } - - public function testMultiGetVCard4() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - ]); - - $request->setBody( -' - - - - - - /addressbooks/user1/book1/card1 -' - ); - - $response = new HTTP\ResponseMock(); - - $this->server->httpRequest = $request; - $this->server->httpResponse = $response; - - $this->server->exec(); - - $bodyAsString = $response->getBodyAsString(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$bodyAsString); - - // using the client for parsing - $client = new DAV\Client(['baseUri' => '/']); - - $result = $client->parseMultiStatus($bodyAsString); - - $prodId = 'PRODID:-//Sabre//Sabre VObject '.\Sabre\VObject\Version::VERSION.'//EN'; - - $this->assertEquals([ - '/addressbooks/user1/book1/card1' => [ - 200 => [ - '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', - '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\n$prodId\r\nUID:12345\r\nEND:VCARD\r\n", - ], - ], - ], $result); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php deleted file mode 100644 index b5a68dc48..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php +++ /dev/null @@ -1,101 +0,0 @@ -assertEquals('{'.Plugin::NS_CARDDAV.'}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']); - - $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures())); - $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']); - } - - public function testSupportedReportSet() - { - $this->assertEquals([ - '{'.Plugin::NS_CARDDAV.'}addressbook-multiget', - '{'.Plugin::NS_CARDDAV.'}addressbook-query', - ], $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); - } - - public function testSupportedReportSetEmpty() - { - $this->assertEquals([ - ], $this->plugin->getSupportedReportSet('')); - } - - public function testAddressBookHomeSet() - { - $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']); - - $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set'])); - $this->assertEquals('addressbooks/user1/', $result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']->getHref()); - } - - public function testDirectoryGateway() - { - $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}directory-gateway']); - - $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}directory-gateway'])); - $this->assertEquals(['directory'], $result['{'.Plugin::NS_CARDDAV.'}directory-gateway']->getHrefs()); - } - - public function testReportPassThrough() - { - $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument(), '')); - } - - public function testHTMLActionsPanel() - { - $output = ''; - $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]); - $this->assertFalse($r); - - $this->assertTrue((bool) strpos($output, 'Display name')); - } - - public function testAddressbookPluginProperties() - { - $ns = '{'.Plugin::NS_CARDDAV.'}'; - $propFind = new DAV\PropFind('addressbooks/user1/book1', [ - $ns.'supported-address-data', - $ns.'supported-collation-set', - ]); - $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1'); - $this->plugin->propFindEarly($propFind, $node); - - $this->assertInstanceOf( - 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData', - $propFind->get($ns.'supported-address-data') - ); - $this->assertInstanceOf( - 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet', - $propFind->get($ns.'supported-collation-set') - ); - } - - public function testGetTransform() - { - $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept' => 'application/vcard+json']); - $response = new \Sabre\HTTP\ResponseMock(); - $this->server->invokeMethod($request, $response); - - $this->assertEquals(200, $response->getStatus()); - } - - public function testGetWithoutContentType() - { - $request = new \Sabre\HTTP\Request('GET', '/'); - $response = new \Sabre\HTTP\ResponseMock(); - $this->plugin->httpAfterGet($request, $response); - $this->assertTrue(true); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php deleted file mode 100644 index 8d045569c..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php +++ /dev/null @@ -1,67 +0,0 @@ - 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - ], - ]; - protected $carddavCards = [ - 1 => [ - 'card1.vcf' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", - ], - ]; - - public function testDontStrip() - { - $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); - $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8', - ], $result); - } - - public function testStrip() - { - $this->server->httpRequest = new HTTP\Request('GET', '/', [ - 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', - ]); - $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); - $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/x-vcard', - ], $result); - } - - public function testDontTouchOtherMimeTypes() - { - $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ - 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', - ]); - - $propFind = new PropFind('hello', ['{DAV:}getcontenttype']); - $propFind->set('{DAV:}getcontenttype', 'text/plain'); - $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); - $this->assertEquals('text/plain', $propFind->get('{DAV:}getcontenttype')); - } - - public function testStripWithoutGetContentType() - { - $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ - 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', - ]); - - $propFind = new PropFind('hello', ['{DAV:}getcontenttype']); - $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); - $this->assertEquals(null, $propFind->get('{DAV:}getcontenttype')); // Property not present - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php deleted file mode 100644 index 546a4ccfb..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php +++ /dev/null @@ -1,130 +0,0 @@ - 'book1', - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - ], - ]; - protected $carddavCards = [ - 'book1' => [ - 'card1' => "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n", - 'card2' => "BEGIN:VCARD\r\nFN:Person2\r\nEND:VCARD", - 'card3' => "BEGIN:VCARD\r\nFN:Person3\r\nEND:VCARD\r\n", - 'card4' => "BEGIN:VCARD\nFN:Person4\nEND:VCARD\n", - ], - ]; - - public function setup(): void - { - parent::setUp(); - $plugin = new VCFExportPlugin(); - $this->server->addPlugin( - $plugin - ); - } - - public function testSimple() - { - $plugin = $this->server->getPlugin('vcf-export'); - $this->assertInstanceOf('Sabre\\CardDAV\\VCFExportPlugin', $plugin); - - $this->assertEquals( - 'vcf-export', - $plugin->getPluginInfo()['name'] - ); - } - - public function testExport() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/addressbooks/user1/book1?export', - 'QUERY_STRING' => 'export', - 'REQUEST_METHOD' => 'GET', - ]); - - $response = $this->request($request); - $this->assertEquals(200, $response->status, $response->getBodyAsString()); - - $expected = 'BEGIN:VCARD -FN:Person1 -END:VCARD -BEGIN:VCARD -FN:Person2 -END:VCARD -BEGIN:VCARD -FN:Person3 -END:VCARD -BEGIN:VCARD -FN:Person4 -END:VCARD -'; - // We actually expected windows line endings - $expected = str_replace("\n", "\r\n", $expected); - - $this->assertEquals($expected, $response->getBodyAsString()); - } - - public function testBrowserIntegration() - { - $plugin = $this->server->getPlugin('vcf-export'); - $actions = ''; - $addressbook = new AddressBook($this->carddavBackend, []); - $this->server->emit('browserButtonActions', ['/foo', $addressbook, &$actions]); - $this->assertStringContainsString('/foo?export', $actions); - } - - public function testContentDisposition() - { - $request = new HTTP\Request( - 'GET', - '/addressbooks/user1/book1?export' - ); - - $response = $this->request($request, 200); - $this->assertEquals('text/directory', $response->getHeader('Content-Type')); - $this->assertEquals( - 'attachment; filename="book1-'.date('Y-m-d').'.vcf"', - $response->getHeader('Content-Disposition') - ); - } - - public function testContentDispositionBadChars() - { - $this->carddavBackend->createAddressBook( - 'principals/user1', - 'book-b_ad"(ch)ars', - [] - ); - $this->carddavBackend->createCard( - 'book-b_ad"(ch)ars', - 'card1', - "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n" - ); - - $request = new HTTP\Request( - 'GET', - '/addressbooks/user1/book-b_ad"(ch)ars?export' - ); - - $response = $this->request($request, 200); - $this->assertEquals('text/directory', $response->getHeader('Content-Type')); - $this->assertEquals( - 'attachment; filename="book-b_adchars-'.date('Y-m-d').'.vcf"', - $response->getHeader('Content-Disposition') - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php deleted file mode 100644 index de7de19cd..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php +++ /dev/null @@ -1,204 +0,0 @@ -assertTrue($this->plugin->validateFilters($input, $filters, $test), $message); - } else { - $this->assertFalse($this->plugin->validateFilters($input, $filters, $test), $message); - } - } - - public function data() - { - $body1 = << 'title', 'is-not-defined' => false, 'param-filters' => [], 'text-matches' => []]; - - // Check if FOO is defined - $filter2 = - ['name' => 'foo', 'is-not-defined' => false, 'param-filters' => [], 'text-matches' => []]; - - // Check if TITLE is not defined - $filter3 = - ['name' => 'title', 'is-not-defined' => true, 'param-filters' => [], 'text-matches' => []]; - - // Check if FOO is not defined - $filter4 = - ['name' => 'foo', 'is-not-defined' => true, 'param-filters' => [], 'text-matches' => []]; - - // Check if TEL[TYPE] is defined - $filter5 = - [ - 'name' => 'tel', - 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [ - [ - 'name' => 'type', - 'is-not-defined' => false, - 'text-match' => null, - ], - ], - 'text-matches' => [], - ]; - - // Check if TEL[FOO] is defined - $filter6 = $filter5; - $filter6['param-filters'][0]['name'] = 'FOO'; - - // Check if TEL[TYPE] is not defined - $filter7 = $filter5; - $filter7['param-filters'][0]['is-not-defined'] = true; - - // Check if TEL[FOO] is not defined - $filter8 = $filter5; - $filter8['param-filters'][0]['name'] = 'FOO'; - $filter8['param-filters'][0]['is-not-defined'] = true; - - // Combining property filters - $filter9 = $filter5; - $filter9['param-filters'][] = $filter6['param-filters'][0]; - - $filter10 = $filter5; - $filter10['param-filters'][] = $filter6['param-filters'][0]; - $filter10['test'] = 'allof'; - - // Check if URL contains 'google' - $filter11 = - [ - 'name' => 'url', - 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [], - 'text-matches' => [ - [ - 'match-type' => 'contains', - 'value' => 'google', - 'negate-condition' => false, - 'collation' => 'i;octet', - ], - ], - ]; - - // Check if URL contains 'bing' - $filter12 = $filter11; - $filter12['text-matches'][0]['value'] = 'bing'; - - // Check if URL does not contain 'google' - $filter13 = $filter11; - $filter13['text-matches'][0]['negate-condition'] = true; - - // Check if URL does not contain 'bing' - $filter14 = $filter11; - $filter14['text-matches'][0]['value'] = 'bing'; - $filter14['text-matches'][0]['negate-condition'] = true; - - // Param filter with text - $filter15 = $filter5; - $filter15['param-filters'][0]['text-match'] = [ - 'match-type' => 'contains', - 'value' => 'WORK', - 'collation' => 'i;octet', - 'negate-condition' => false, - ]; - $filter16 = $filter15; - $filter16['param-filters'][0]['text-match']['negate-condition'] = true; - - // Param filter + text filter - $filter17 = $filter5; - $filter17['test'] = 'anyof'; - $filter17['text-matches'][] = [ - 'match-type' => 'contains', - 'value' => '444', - 'collation' => 'i;octet', - 'negate-condition' => false, - ]; - - $filter18 = $filter17; - $filter18['text-matches'][0]['negate-condition'] = true; - - $filter18['test'] = 'allof'; - - return [ - // Basic filters - [$body1, [$filter1], 'anyof', true], - [$body1, [$filter2], 'anyof', false], - [$body1, [$filter3], 'anyof', false], - [$body1, [$filter4], 'anyof', true], - - // Combinations - [$body1, [$filter1, $filter2], 'anyof', true], - [$body1, [$filter1, $filter2], 'allof', false], - [$body1, [$filter1, $filter4], 'anyof', true], - [$body1, [$filter1, $filter4], 'allof', true], - [$body1, [$filter2, $filter3], 'anyof', false], - [$body1, [$filter2, $filter3], 'allof', false], - - // Basic parameters - [$body1, [$filter5], 'anyof', true, 'TEL;TYPE is defined, so this should return true'], - [$body1, [$filter6], 'anyof', false, 'TEL;FOO is not defined, so this should return false'], - - [$body1, [$filter7], 'anyof', false, 'TEL;TYPE is defined, so this should return false'], - [$body1, [$filter8], 'anyof', true, 'TEL;TYPE is not defined, so this should return true'], - - // Combined parameters - [$body1, [$filter9], 'anyof', true], - [$body1, [$filter10], 'anyof', false], - - // Text-filters - [$body1, [$filter11], 'anyof', true], - [$body1, [$filter12], 'anyof', false], - [$body1, [$filter13], 'anyof', false], - [$body1, [$filter14], 'anyof', true], - - // Param filter with text-match - [$body1, [$filter15], 'anyof', true], - [$body1, [$filter16], 'anyof', false], - - // Param filter + text filter - [$body1, [$filter17], 'anyof', true], - [$body1, [$filter18], 'anyof', false], - [$body1, [$filter18], 'anyof', false], - ]; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php deleted file mode 100644 index 571cce3f0..000000000 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php +++ /dev/null @@ -1,293 +0,0 @@ - 'addressbook1', - 'principaluri' => 'principals/admin', - 'uri' => 'addressbook1', - ], - ]; - - $this->cardBackend = new Backend\Mock($addressbooks, []); - $principalBackend = new DAVACL\PrincipalBackend\Mock(); - - $tree = [ - new AddressBookRoot($principalBackend, $this->cardBackend), - ]; - - $this->server = new DAV\Server($tree); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->debugExceptions = true; - - $plugin = new Plugin(); - $this->server->addPlugin($plugin); - - $response = new HTTP\ResponseMock(); - $this->server->httpResponse = $response; - } - - public function request(HTTP\Request $request, $expectedStatus = null) - { - $this->server->httpRequest = $request; - $this->server->exec(); - - if ($expectedStatus) { - $realStatus = $this->server->httpResponse->getStatus(); - - $msg = ''; - if ($realStatus !== $expectedStatus) { - $msg = 'Response body: '.$this->server->httpResponse->getBodyAsString(); - } - $this->assertEquals( - $expectedStatus, - $realStatus, - $msg - ); - } - - return $this->server->httpResponse; - } - - public function testCreateFile() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - ]); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status); - } - - public function testCreateFileValid() - { - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - - $vcard = <<setBody($vcard); - - $response = $this->request($request, 201); - - // The custom Ew header should not be set - $this->assertNull( - $response->getHeader('X-Sabre-Ew-Gross') - ); - // Valid, non-auto-fixed responses should contain an ETag. - $this->assertTrue( - null !== $response->getHeader('ETag'), - 'We did not receive an etag' - ); - - $expected = [ - 'uri' => 'blabla.vcf', - 'carddata' => $vcard, - 'size' => strlen($vcard), - 'etag' => '"'.md5($vcard).'"', - ]; - - $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } - - /** - * This test creates an intentionally broken vCard that vobject is able - * to automatically repair. - * - * @depends testCreateFileValid - */ - public function testCreateVCardAutoFix() - { - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - - // The error in this vcard is that there's not enough semi-colons in N - $vcard = <<setBody($vcard); - - $response = $this->request($request, 201); - - // Auto-fixed vcards should NOT return an etag - $this->assertNull( - $response->getHeader('ETag') - ); - - // We should have gotten an Ew header - $this->assertNotNull( - $response->getHeader('X-Sabre-Ew-Gross') - ); - - $expectedVCard = << 'blabla.vcf', - 'carddata' => $expectedVCard, - 'size' => strlen($expectedVCard), - 'etag' => '"'.md5($expectedVCard).'"', - ]; - - $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } - - /** - * This test creates an intentionally broken vCard that vobject is able - * to automatically repair. - * - * However, we're supplying a heading asking the server to treat the - * request as strict, so the server should still let the request fail. - * - * @depends testCreateFileValid - */ - public function testCreateVCardStrictFail() - { - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf', - [ - 'Prefer' => 'handling=strict', - ] - ); - - // The error in this vcard is that there's not enough semi-colons in N - $vcard = <<setBody($vcard); - $this->request($request, 415); - } - - public function testCreateFileNoUID() - { - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - $vcard = <<setBody($vcard); - - $response = $this->request($request, 201); - - $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); - $this->assertTrue( - false !== strpos($foo['carddata'], 'UID'), - print_r($foo, true) - ); - } - - public function testCreateFileJson() - { - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - $request->setBody('[ "vcard" , [ [ "VERSION", {}, "text", "4.0"], [ "UID" , {}, "text", "foo" ], [ "FN", {}, "text", "FirstName LastName"] ] ]'); - - $response = $this->request($request); - - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - - $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); - $this->assertEquals("BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n", $foo['carddata']); - } - - public function testCreateFileVCalendar() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testUpdateFile() - { - $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - - $response = $this->request($request, 415); - } - - public function testUpdateFileParsableBody() - { - $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); - $request = new HTTP\Request( - 'PUT', - '/addressbooks/admin/addressbook1/blabla.vcf' - ); - - $body = "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n"; - $request->setBody($body); - - $response = $this->request($request, 204); - - $expected = [ - 'uri' => 'blabla.vcf', - 'carddata' => $body, - 'size' => strlen($body), - 'etag' => '"'.md5($body).'"', - ]; - - $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } -} -- cgit v1.2.3