diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-05-28 17:46:24 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-05-28 17:46:24 +0200 |
commit | 66effbfe0827fc61fff6d248797a894213ad20d6 (patch) | |
tree | 0fbb5ca644e1140e5b3b44b1adc874043790c388 /vendor/sabre | |
parent | ac4688eac087854bf8cb0c893d7a79052ad63a20 (diff) | |
download | volse-hubzilla-66effbfe0827fc61fff6d248797a894213ad20d6.tar.gz volse-hubzilla-66effbfe0827fc61fff6d248797a894213ad20d6.tar.bz2 volse-hubzilla-66effbfe0827fc61fff6d248797a894213ad20d6.zip |
upgrade to sabre32
Diffstat (limited to 'vendor/sabre')
206 files changed, 8950 insertions, 8432 deletions
diff --git a/vendor/sabre/dav/.travis.yml b/vendor/sabre/dav/.travis.yml index 48c88b169..a9189c981 100644 --- a/vendor/sabre/dav/.travis.yml +++ b/vendor/sabre/dav/.travis.yml @@ -3,12 +3,6 @@ php: - 5.5 - 5.6 - 7 - - hhvm - -matrix: - fast_finish: true - allow_failures: - - php: hhvm env: matrix: @@ -17,17 +11,25 @@ env: services: - mysql + - postgresql sudo: false -cache: vendor - before_script: - - mysql -e 'create database sabredav' + - mysql -e 'create database sabredav_test' + - psql -c "create database sabredav_test" -U postgres + - psql -c "create user sabredav with PASSWORD 'sabredav';GRANT ALL PRIVILEGES ON DATABASE sabredav_test TO sabredav" -U postgres + - phpenv config-rm xdebug.ini; true # - composer self-update - - composer update --prefer-source $LOWEST_DEPS + - composer update --prefer-dist $LOWEST_DEPS + +# addons: +# postgresql: "9.5" script: - - ./bin/phpunit --configuration tests/phpunit.xml $TEST_DEPS + - ./bin/phpunit --configuration tests/phpunit.xml.dist $TEST_DEPS - ./bin/sabre-cs-fixer fix lib/ --dry-run --diff +cache: + directories: + - $HOME/.composer/cache diff --git a/vendor/sabre/dav/CHANGELOG.md b/vendor/sabre/dav/CHANGELOG.md deleted file mode 100644 index f719c8e1a..000000000 --- a/vendor/sabre/dav/CHANGELOG.md +++ /dev/null @@ -1,2242 +0,0 @@ -ChangeLog -========= - -3.1.3 (2016-04-06) ------------------- - -* Set minimum libxml version to 2.7.0 in `composer.json`. -* #805: It wasn't possible to create calendars that hold events, journals and - todos using MySQL, because the `components` column was 1 byte too small. -* The zip release ships with [sabre/vobject 4.1.0][vobj], - [sabre/http 4.2.1][http], [sabre/event 3.0.0][evnt], - [sabre/uri 1.1.0][uri] and [sabre/xml 1.4.1][xml]. - - -3.1.2 (2016-03-12) ------------------- - -* #784: Sync logs for address books were not correctly cleaned up after - deleting them. -* #787: Cannot use non-seekable stream-wrappers with range requests. -* Faster XML parsing and generating due to sabre/xml update. -* #793: The Sqlite schema is now more strict and more similar to the MySQL - schema. This solves a problem within Baikal. -* The zip release ships with [sabre/vobject 4.0.3][vobj], - [sabre/http 4.2.1][http], [sabre/event 3.0.0][evnt], - [sabre/uri 1.1.0][uri] and [sabre/xml 1.4.1][xml]. - - -3.1.1 (2016-01-25) ------------------- - -* #755: The brower plugin and some operations would break when scheduling and - delegation would both be enabled. -* #757: A bunch of unittest improvements (@jakobsack). -* The zip release ships with [sabre/vobject 4.0.2][vobj], - [sabre/http 4.2.1][http], [sabre/event 3.0.0][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.3.0][xml]. - - -3.1.0 (2016-01-06) ------------------- - -* Better error message when the browser plugin is not enabled. -* Added a super minimal server example. -* #730: Switched all mysql tables to `utf8mb4` character set, allowing you to - use emoji in some tables where you couldn't before. -* #710: Provide an Auth backend that acts as a helper for people implementing - OAuth2 Bearer token. (@fkooman). -* #729: Not all calls to `Sabre\DAV\Tree::getChildren()` were properly cached. -* #727: Added another workaround to make CalDAV work for Windows 10 clients. -* #742: Fixes to make sure that vobject 4 is correctly supported. -* #726: Better error reporting in `Client::propPatch`. We're now throwing - exceptions. -* #608: When a HTTP error is triggered during `Client:propFind`, we're now - throwing `Sabre\HTTP\ClientHttpException` instead of `Sabre\DAV\Exception`. - This new exception contains a LOT more information about the problem. -* #721: Events are now handled in the correct order for `COPY` requests. - Before this subtle bugs could appear that could cause data-loss. -* #747: Now throwing exceptions and setting the HTTP status to 500 in subtle - cases where no other plugin set a correct HTTP status. -* #686: Corrected PDO principal backend's findByURI for email addresses that - don't match the exact capitalization. -* #512: The client now has it's own `User-Agent`. -* #720: Some browser improvements. -* The zip release ships with [sabre/vobject 4.0.1][vobj], - [sabre/http 4.2.1][http], [sabre/event 3.0.0][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.3.0][xml]. - - -3.1.0-alpha2 (2015-09-05) -------------------------- - -* Massive calendars and addressbooks should see a big drop in peak memory - usage. -* Fixed a privilege bug in the availability system. -* #697: Added a "tableName" member to the PropertyStorage PDO backend. (@Frzk). -* #699: PostgreSQL fix for the Locks PDO backend. (@TCKnet) -* Removed the `simplefsserver.php` example file. It's not simple enough. -* #703: PropPatch in client is not correctly encoded. -* #709: Throw exception when running into empty - `supported-calendar-component-set`. -* #711: Don't trigger deserializers for empty elements in `{DAV:}prop`. This - fixes issues when using sabre/dav as a client. -* The zip release ships with [sabre/vobject 4.0.0-alpha2][vobj], - [sabre/http 4.1.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.2.0][xml]. - - -3.1.0-alpha1 (2015-07-19) -------------------------- - -* Now requires PHP 5.5 -* Upgraded to vobject 4, which is a lot faster. -* Support for PHP 7. -* #690: Support for `calendar-availability`, draft 05. - [reference][calendar-availability]. -* #691: Workaround for broken Windows Phone client. -* The zip release ships with [sabre/vobject 4.0.0-alpha1][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.1.0][xml]. - - -3.0.9 (2016-04-06) ------------------- - -* Set minimum libxml version to 2.7.0 in `composer.json`. -* #727: Added another workaround to make CalDAV work for Windows 10 clients. -* #805: It wasn't possible to create calendars that hold events, journals and - todos using MySQL, because the `components` column was 1 byte too small. -* The zip release ships with [sabre/vobject 3.5.1][vobj], - [sabre/http 4.2.1][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.1.0][uri] and [sabre/xml 1.4.1][xml]. - - -3.0.8 (2016-03-12) ------------------- - -* #784: Sync logs for address books were not correctly cleaned up after - deleting them. -* #787: Cannot use non-seekable stream-wrappers with range requests. -* Faster XML parsing and generating due to sabre/xml update. -* The zip release ships with [sabre/vobject 3.5.0][vobj], - [sabre/http 4.2.1][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.1.0][uri] and [sabre/xml 1.4.1][xml]. - - -3.0.7 (2016-01-12) ------------------- - -* #752: PHP 7 support for 3.0 branch. (@DeepDiver1975) -* The zip release ships with [sabre/vobject 3.5.0][vobj], - [sabre/http 4.2.1][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.3.0][xml]. - - -3.0.6 (2016-01-04) ------------------- - -* #730: Switched all mysql tables to `utf8mb4` character set, allowing you to - use emoji in some tables where you couldn't before. -* #729: Not all calls to `Sabre\DAV\Tree::getChildren()` were properly cached. -* #734: Return `418 I'm a Teapot` when generating a multistatus response that - has resources with no returned properties. -* #740: Bugs in `migrate20.php` script. -* The zip release ships with [sabre/vobject 3.4.8][vobj], - [sabre/http 4.1.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.3.0][xml]. - - -3.0.5 (2015-09-15) ------------------- - -* #704: Fixed broken uri encoding in multistatus responses. This affected - at least CyberDuck, but probably also others. -* The zip release ships with [sabre/vobject 3.4.7][vobj], -* The zip release ships with [sabre/vobject 3.4.7][vobj], - [sabre/http 4.1.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.2.0][xml]. - - -3.0.4 (2015-09-06) ------------------- - -* #703: PropPatch in client is not correctly encoded. -* #709: Throw exception when running into empty - `supported-calendar-component-set`. -* #711: Don't trigger deserializers for empty elements in `{DAV:}prop`. This - fixes issues when using sabre/dav as a client. -* #705: A `MOVE` request that gets prevented from deleting the source resource - will still remove the target resource. Now all events are triggered before - any destructive operations. -* The zip release ships with [sabre/vobject 3.4.7][vobj], - [sabre/http 4.1.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.2.0][xml]. - - -3.0.3 (2015-08-06) ------------------- - -* #700: Digest Auth fails on `HEAD` requests. -* Fixed example files to no longer use now-deprecated realm argument. -* The zip release ships with [sabre/vobject 3.4.6][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.1.0][xml]. - - -3.0.2 (2015-07-21) ------------------- - -* #657: Migration script would break when coming a cross an iCalendar object - with no UID. -* #691: Workaround for broken Windows Phone client. -* Fixed a whole bunch of incorrect php docblocks. -* The zip release ships with [sabre/vobject 3.4.5][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.1.0][xml]. - - -3.0.1 (2015-07-02) ------------------- - -* #674: Postgres sql file fixes. (@davesouthey) -* #677: Resources with the name '0' would not get retrieved when using - `Depth: infinity` in a `PROPFIND` request. -* #680: Fix 'autoprefixing' of dead `{DAV:}href` properties. -* #675: NTLM support in DAV\Client. (@k42b3) -* The zip release ships with [sabre/vobject 3.4.5][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.1.0][xml]. - - -3.0.0 (2015-06-02) ------------------- - -* No changes since last beta. -* The zip release ships with [sabre/vobject 3.4.5][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.0.0][xml]. - - -3.0.0-beta3 (2015-05-29) ------------------------- - -* Fixed deserializing href properties with no value. -* Fixed deserializing `{DAV:}propstat` without a `{DAV:}prop`. -* #668: More information about vcf-export-plugin in browser plugin. -* #669: Add export button to browser plugin for address books. (@mgee) -* #670: multiget report hrefs were not decoded. -* The zip release ships with [sabre/vobject 3.4.4][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.0.0][xml]. - - -3.0.0-beta2 (2015-05-27) ------------------------- - -* A node's properties should not overwrite properties that were already set. -* Some uris were not correctly encoded in notifications. -* The zip release ships with [sabre/vobject 3.4.4][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.0.0][xml]. - - -3.0.0-beta1 (2015-05-25) ------------------------- - -* `migrate22.php` is now called `migrate30.php`. -* Using php-cs-fixer for automated coding standards enforcement and fixing. -* #660: principals could break html output. -* #662: Fixed several bugs in the `share` request parser. -* #665: Fix a bug in serialization of complex properties in the proppatch - request in the client. -* #666: expand-property report did not correctly prepend the base uri when - generating uris, this caused delegation to break. -* #659: Don't throw errors when when etag-related checks are done on - collections. -* Fully supporting the updated `Prefer` header syntax, as defined in - [rfc7240][rfc7240]. -* The zip release ships with [sabre/vobject 3.4.3][vobj], - [sabre/http 4.0.0][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 1.0.0][xml]. - - -3.0.0-alpha1 (2015-05-19) -------------------------- - -* It's now possible to get all property information from files using the - browser plugin. -* Browser plugin will now show a 'calendar export' button when the - ics-export plugin is enabled. -* Some nodes that by default showed the current time as their last - modification time, now no longer has a last modification time. -* CardDAV namespace was missing from default namespaceMap. -* #646: Properties can now control their own HTML output in the browser plugin. -* #646: Nicer HTML output for the `{DAV:}acl` property. -* Browser plugin no longer shows a few properties that take up a lot of space, - but are likely not really interesting for most users. -* #654: Added a collection, `Sabre\DAVACL\FS\HomeCollection` for automatically - creating a private home collection per-user. -* Changed all MySQL columns from `VARCHAR` to `VARBINARY` where possible. -* Improved older migration scripts a bit to allow easier testing. -* The zip release ships with [sabre/vobject 3.4.3][vobj], - [sabre/http 4.0.0-alpha3][http], [sabre/event 2.0.2][evnt], - [sabre/uri 1.0.1][uri] and [sabre/xml 0.4.3][xml]. - - -2.2.0-alpha4 (2015-04-13) -------------------------- - -* Complete rewrite of the XML system. We now use our own [sabre/xml][xml], - which has a much smarter XML Reader and Writer. -* BC Break: It's no longer possible to instantiate the Locks plugin without - a locks backend. I'm not sure why this ever made sense. -* Simplified the Locking system and fixed a bug related to if tokens checking - locks unrelated to the current request. -* `FSExt` Directory and File no longer do custom property storage. This - functionality is already covered pretty well by the `PropertyStorage` plugin, - so please switch. -* Renamed `Sabre\CardDAV\UserAddressBooks` to `Sabre\CardDAV\AddressBookHome` - to be more consistent with `CalendarHome` as well as the CardDAV - specification. -* `Sabre\DAV\IExtendedCollection` now receives a `Sabre\DAV\MkCol` object as - its second argument, and no longer receives seperate properties and - resourcetype arguments. -* `MKCOL` now integrates better with propertystorage plugins. -* #623: Remove need of temporary files when working with Range requests. - (@dratini0) -* The zip release ships with [sabre/vobject 3.4.2][vobj], - [sabre/http 4.0.0-alpha1][http], [sabre/event 2.0.1][evnt], - [sabre/uri 1.0.0][uri] and [sabre/xml 0.4.3][xml]. - - -2.2.0-alpha3 (2015-02-25) -------------------------- - -* Contains all the changes introduced between 2.1.2 and 2.1.3. -* The zip release ships with [sabre/vobject 3.4.2][vobj], - [sabre/http 4.0.0-alpha1][http], [sabre/event 2.0.1][evnt] and - [sabre/uri 1.0.0][uri]. - - -2.2.0-alpha2 (2015-01-09) -------------------------- - -* Renamed `Sabre\DAV\Auth\Backend\BackendInterface::requireAuth` to - `challenge`, which is a more correct and better sounding name. -* The zip release ships with [sabre/vobject 3.3.5][vobj], - [sabre/http 3.0.4][http], [sabre/event 2.0.1][evnt]. - - -2.2.0-alpha1 (2014-12-10) -------------------------- - -* The browser plugin now has a new page with information about your sabredav - server, and shows information about every plugin that's loaded in the - system. -* #191: The Authentication system can now support multiple authentication - backends. -* Removed: all `$tableName` arguments from every PDO backend. This was already - deprecated, but has now been fully removed. All of these have been replaced - with public properties. -* Deleted several classes that were already deprecated much earlier: - * `Sabre\CalDAV\CalendarRootNode` - * `Sabre\CalDAV\UserCalendars` - * `Sabre\DAV\Exception\FileNotFound` - * `Sabre\DAV\Locks\Backend\FS` - * `Sabre\DAV\PartialUpdate\IFile` - * `Sabre\DAV\URLUtil` -* Removed: `Sabre\DAV\Client::addTrustedCertificates` and - `Sabre\DAV\Client::setVerifyPeer`. -* Removed: `Sabre\DAV\Plugin::getPlugin()` can now no longer return plugins - based on its class name. -* Removed: `Sabre\DAVACL\Plugin::getPrincipalByEmail()`. -* #560: GuessContentType plugin will now set content-type to - `application/octet-stream` if a better content-type could not be determined. -* #568: Added a `componentType` argument to `ICSExportPlugin`, allowing you to - specifically fetch `VEVENT`, `VTODO` or `VJOURNAL`. -* #582: Authentication backend interface changed to be stateless. If you - implemented your own authentication backend, make sure you upgrade your class - to the latest API! -* #582: `Sabre\DAV\Auth\Plugin::getCurrentUser()` is now deprecated. Use - `Sabre\DAV\Auth\Plugin::getCurrentPrincipal()` instead. -* #193: Fix `Sabre\DAV\FSExt\Directory::getQuotaInfo()` on windows. - - -2.1.11 (2016-??-??) -------------------- - -* #805: It wasn't possible to create calendars that hold events, journals and - todos using MySQL, because the `components` column was 1 byte too small. - - -2.1.10 (2016-03-10) -------------------- - -* #784: Sync logs for address books were not correctly cleaned up after - deleting them. - - -2.1.9 (2016-01-25) ------------------- - -* #674: PHP7 support (@DeepDiver1975). -* The zip release ships with [sabre/vobject 3.5.0][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.8 (2016-01-04) ------------------- - -* #729: Fixed a caching problem in the Tree object. -* #740: Bugs in `migrate20.php` script. -* The zip release ships with [sabre/vobject 3.4.8][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.7 (2015-09-05) ------------------- - -* #705: A `MOVE` request that gets prevented from deleting the source resource - will still remove the target resource. Now all events are triggered before - any destructive operations. -* The zip release ships with [sabre/vobject 3.4.7][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.6 (2015-07-21) ------------------- - -* #657: Migration script would break when coming a cross an iCalendar object - with no UID. -* #691: Workaround for broken Windows Phone client. -* The zip release ships with [sabre/vobject 3.4.5][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.5 (2015-07-11) ------------------- - -* #677: Resources with the name '0' would not get retrieved when using - `Depth: infinity` in a `PROPFIND` request. -* The zip release ships with [sabre/vobject 3.4.5][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.4 (2015-05-25) ------------------- - -* #651: Double-encoded path in the browser plugin. Should fix a few broken - links in some setups. -* #650: Correctly cleaning up change info after deleting calendars (@ErrOrnAmE). -* #658: Updating `schedule-calendar-default-URL` does not work well, so we're - disabling it until there's a better fix. -* The zip release ships with [sabre/vobject 3.4.3][vobj], - [sabre/http 3.0.5][http], and [sabre/event 2.0.2][evnt]. - - -2.1.3 (2015-02-25) ------------------- - -* #586: `SCHEDULE-STATUS` should not contain a reason-phrase. -* #539: Fixed a bug related to scheduling in shared calendars. -* #595: Support for calendar-timezone in iCalendar exports. -* #581: findByUri would send empty prefixes to the principal backend (@soydeedo) -* #611: Escaping a bit more HTML output in the browser plugin. (@LukasReschke) -* #610: Don't allow discovery of arbitrary files using `..` in the browser - plugin (@LukasReschke). -* Browser plugin now shows quota properties. -* #612: PropertyStorage didn't delete properties from nodes when a node's - parents get deleted. -* #581: Fixed problems related to finding attendee information during - scheduling. -* The zip release ships with [sabre/vobject 3.4.2][vobj], - [sabre/http 3.0.4][http], and [sabre/event 2.0.1][evnt]. - - -2.1.2 (2014-12-10) ------------------- - -* #566: Another issue related to the migration script, which would cause - scheduling to not work well for events that were already added before the - migration. -* #567: Doing freebusy requests on accounts that had 0 calendars would throw - a `E_NOTICE`. -* #572: `HEAD` requests trigger a PHP warning. -* #579: Browser plugin can throw exception for a few resourcetypes that didn't - have an icon defined. -* The zip release ships with [sabre/vobject 3.3.4][vobj], - [sabre/http 3.0.4][http], and [sabre/event 2.0.1][evnt]. - - -2.1.1 (2014-11-22) ------------------- - -* #561: IMip Plugin didn't strip mailto: from email addresses. -* #566: Migration process had 2 problems related to adding the `uid` field - to the `calendarobjects` table. -* The zip release ships with [sabre/vobject 3.3.4][vobj], - [sabre/http 3.0.2][http], and [sabre/event 2.0.1][evnt]. - - -2.1.0 (2014-11-19) ------------------- - -* #541: CalDAV PDO backend didn't respect overridden PDO table names. -* #550: Scheduling invites are no longer delivered into shared calendars. -* #554: `calendar-multiget` `REPORT` did not work on inbox items. -* #555: The `calendar-timezone` property is now respected for floating times - and all-day events in the `calendar-query`, `calendar-multiget` and - `free-busy-query` REPORTs. -* #555: The `calendar-timezone` property is also respected for scheduling - free-busy requests. -* #547: CalDAV system too aggressively 'corrects' incoming iCalendar data, and - as a result doesn't return an etag for common cases. -* The zip release ships with [sabre/vobject 3.3.4][vobj], - [sabre/http 3.0.2][http], and [sabre/event 2.0.1][evnt]. - - -2.1.0-alpha2 (2014-10-23) -------------------------- - -* Added: calendar-user-address-set to default principal search properties - list. This should fix iOS attendee autocomplete support. -* Changed: Moved all 'notifications' functionality from `Sabre\CalDAV\Plugin` - to a new plugin: `Sabre\CalDAV\Notifications\Plugin`. If you want to use - notifications-related functionality, just add this plugin. -* Changed: Accessing the caldav inbox, outbox or notification collection no - longer triggers getCalendarsForUser() on backends. -* #533: New invites are no longer delivered to taks-only calendars. -* #538: Added `calendarObjectChange` event. -* Scheduling speedups. -* #539: added `afterResponse` event. (@joserobleda) -* Deprecated: All the "tableName" constructor arguments for all the PDO - backends are now deprecated. They still work, but will be removed in the - next major sabredav version. Every argument that is now deprecated can now - be accessed as a public property on the respective backends. -* #529: Added getCalendarObjectByUID to PDO backend, speeding up scheduling - operations on large calendars. -* The zip release ships with [sabre/vobject 3.3.3][vobj], - [sabre/http 3.0.2][http], and [sabre/event 2.0.1][evnt]. - - -2.1.0-alpha1 (2014-09-23) -------------------------- - -* Added: Support for [rfc6638][rfc6638], also known as CalDAV Scheduling. -* Added: Automatically converting between vCard 3, 4 and jCard using the - `Accept:` header, in CardDAV reports, and automatically converting from - jCard to vCard upon `PUT`. It's important to note that your backends _may_ - now recieve both vCard 3.0 and 4.0. -* Added: #444. Collections can now opt-in to support high-speed `MOVE`. -* Changed: PropertyStorage backends now have a `move` method. -* Added: `beforeMove`, and `afterMove` events. -* Changed: A few database changes for the CalDAV PDO backend. Make sure you - run `bin/migrate21.php` to upgrade your database schema. -* Changed: CalDAV backends have a new method: `getCalendarObjectByUID`. This - method MUST be implemented by all backends, but the `AbstractBackend` has a - simple default implementation for this. -* Changed: `Sabre\CalDAV\UserCalendars` has been renamed to - `Sabre\CalDAV\CalendarHome`. -* Changed: `Sabre\CalDAV\CalendarRootNode` has been renamed to - `Sabre\CalDAV\CalendarRoot`. -* Changed: The IMipHandler has been completely removed. With CalDAV scheduling - support, it is no longer needed. It's functionality has been replaced by - `Sabre\CalDAV\Schedule\IMipPlugin`, which can now send emails for clients - other than iCal. -* Removed: `Sabre\DAV\ObjectTree` and `Sabre\DAV\Tree\FileSystem`. All this - functionality has been merged into `Sabre\DAV\Tree`. -* Changed: PrincipalBackend now has a findByUri method. -* Changed: `PrincipalBackend::searchPrincipals` has a new optional `test` - argument. -* Added: Support for the `{http://calendarserver.org/ns/}email-address-set` - property. -* #460: PropertyStorage must move properties during `MOVE` requests. -* Changed: Restructured the zip distribution to be a little bit more lean - and consistent. -* #524: Full support for the `test="anyof"` attribute in principal-search - `REPORT`. -* #472: Always returning lock tokens in the lockdiscovery property. -* Directory entries in the Browser plugin are sorted by type and name. - (@aklomp) -* #486: It's now possible to return additional properties when an 'allprop' - PROPFIND request is being done. (@aklomp) -* Changed: Now return HTTP errors when an addressbook-query REPORT is done - on a uri that's not a vcard. This should help with debugging this common - mistake. -* Changed: `PUT` requests with a `Content-Range` header now emit a 400 status - instead of 501, as per RFC7231. -* Added: Browser plugin can now display the contents of the - `{DAV:}supported-privilege-set` property. -* Added: Now reporting `CALDAV:max-resource-size`, but we're not actively - restricting it yet. -* Changed: CalDAV plugin is now responsible for reporting - `CALDAV:supported-collation-set` and `CALDAV:supported-calendar-data` - properties. -* Added: Now reporting `CARDDAV:max-resource-size`, but we're not actively - restricting it yet. -* Added: Support for `CARDDAV:supported-collation-set`. -* Changed: CardDAV plugin is now responsible for reporting - `CARDDAV:supported-address-data`. This functionality has been removed from - the CardDAV PDO backend. -* When a REPORT is not supported, we now emit HTTP error 415, instead of 403. -* #348: `HEAD` requests now work wherever `GET` also works. -* Changed: Lower priority for the iMip plugins `schedule` event listener. -* Added: #523 Custom CalDAV backends can now mark any calendar as read-only. -* The zip release ships with [sabre/vobject 3.3.3][vobj], - [sabre/http 3.0.0][http], and [sabre/event 2.0.0][evnt]. - - -2.0.9 (2015-09-04) ------------------- - -* #705: A `MOVE` request that gets prevented from deleting the source resource - will still remove the target resource. Now all events are triggered before - any destructive operations. -* The zip release ships with [sabre/vobject 3.4.6][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - - -2.0.8 (2015-07-11) ------------------- - -* #677: Resources with the name '0' would not get retrieved when using - `Depth: infinity` in a `PROPFIND` request. -* The zip release ships with [sabre/vobject 3.3.5][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.7 (2015-05-25) ------------------- - -* #650: Correctly cleaning up change info after deleting calendars (@ErrOrnAmE). -* The zip release ships with [sabre/vobject 3.3.4][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.6 (2014-12-10) ------------------- - -* Added `Sabre\CalDAV\CalendarRoot` as an alias for - `Sabre\CalDAV\CalendarRootNode`. The latter is going to be deprecated in 2.1, - so this makes it slightly easier to write code that works in both branches. -* #497: Making sure we're initializing the sync-token field with a value after - migration. -* The zip release ships with [sabre/vobject 3.3.4][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.5 (2014-10-14) ------------------- - -* #514: CalDAV PDO backend didn't work when overriding the 'calendar changes' - database table name. -* #515: 304 status code was not being sent when checking preconditions. -* The zip release ships with [sabre/vobject 3.3.3][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.4 (2014-08-27) ------------------- - -* #483: typo in calendars creation for PostgreSQL. -* #487: Locks are now automatically removed after a node has been deleted. -* #496: Improve CalDAV and CardDAV sync when there is no webdav-sync support. -* Added: Automatically mapping internal sync-tokens to getctag. -* The zip release ships with [sabre/vobject 3.3.1][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.3 (2014-07-14) ------------------- - -* #474: Fixed PropertyStorage `pathFilter()`. -* #476: CSP policy incorrect, causing stylesheets to not load in the browser - plugin. -* #475: Href properties in the browser plugin sometimes included a backslash. -* #478: `TooMuchMatches` exception never worked. This was fixed, and we also - took this opportunity to rename it to `TooManyMatches`. -* The zip release ships with [sabre/vobject 3.2.4][vobj], - [sabre/http 2.0.4][http], and [sabre/event 1.0.1][evnt]. - - -2.0.2 (2014-06-12) ------------------- - -* #470: Fixed compatibility with PHP < 5.4.14. -* #467: Fixed a problem in `examples/calendarserver.php`. -* #466: All the postgresql sample files have been updated. -* Fixed: An error would be thrown if a client did a propfind on a node the - user didn't have access to. -* Removed: Old and broken example code from the `examples/` directory. -* The zip release ships with [sabre/vobject 3.2.3][vobj], - [sabre/http 2.0.3][http], and [sabre/event 1.0.1][evnt]. - - -2.0.1 (2014-05-28) ------------------- - -* #459: PROPFIND requests on Files with no Depth header would return a fatal - error. -* #464: A PROPFIND allprops request should not return properties with status - 404. -* The zip release ships with [sabre/vobject 3.2.2][vobj], - [sabre/http 2.0.3][http], and [sabre/event 1.0.0][evnt]. - - -2.0.0 (2014-05-22) ------------------- - -* The zip release ships with [sabre/vobject 3.2.2][vobj], - [sabre/http 2.0.3][http], and [sabre/event 1.0.0][evnt]. -* Fixed: #456: Issue in sqlite migration script. -* Updated: MySQL database schema optimized by using more efficient column types. -* Cleaned up browser design. - - -2.0.0-beta1 (2014-05-15) -------------------------- - -* The zip release ships with [sabre/vobject 3.2.2][vobj], - [sabre/http 2.0.3][http], and [sabre/event 1.0.0][evnt]. -* BC Break: Property updating and fetching got refactored. Read the [migration - document][mi20] for more information. This allows for creation of a generic - property storage, and other property-related functionality that was not - possible before. -* BC Break: Removed `propertyUpdate`, `beforeGetProperties` and - `afterGetProperties` events. -* Fixed: #413: Memory optimizations for the CardDAV PDO backend. -* Updated: Brand new browser plugin with more debugging features and a design - that is slightly less painful. -* Added: Support for the `{DAV:}supported-method-set` property server-wide. -* Making it easier for implementors to override how the CardDAV addressbook - home is located. -* Fixed: Issue #422 Preconditions were not being set on PUT on non-existant - files. Not really a chance for data-loss, but incorrect nevertheless. -* Fixed: Issue #428: Etag check with `If:` fails if the target is a collection. -* Fixed: Issues #430, #431, #433: Locks plugin didn't not properly release - filesystem based locks. -* Fixed: #443. Support for creating new calendar subscriptions for OS X 10.9.2 - and up. -* Removed: `Sabre\DAV\Server::NODE_*` constants. -* Moved all precondition checking into a central place, instead of having to - think about it on a per-method basis. -* jCal transformation for calendar-query REPORT now works again. -* Switched to PSR-4 -* Fixed: #175. Returning ETag header upon a failed `If-Match` or - `If-None-Match` check. -* Removed: `lib/Sabre/autoload.php`. Use `vendor/autoload.php` instead. -* Removed: all the rfc documentation from the sabre/dav source. This made the - package needlessly larger. -* Updated: Issue #439. Lots of updates in PATCH support. The - Sabre_DAV_PartialUpdate_IFile interface is now deprecated and will be - removed in a future version. -* Added: `Sabre\DAV\Exception\LengthRequired`. - -1.9.0-alpha2 (2014-01-14) -------------------------- - -* The zip release ships with sabre/vobject 3.1.3, sabre/http 2.0.1, and - sabre/event 1.0.0. -* Added: Browser can now inspect any node, if ?sabreaction=browser is appended. -* Fixed: Issue #178. Support for multiple items in the Timeout header. -* Fixed: Issue #382. Stricter checking if calendar-query is allowed to run. -* Added: Depth: Infinity support for PROPFIND request. Thanks Thomas Müller and - Markus Goetz. - - -1.9.0-alpha1 (2013-11-07) -------------------------- - -* The zip release ships with sabre/vobject 3.1.3, sabre/http 2.0.0alpha5, and - sabre/event 1.0.0. -* BC Break: The CardDAV and CalDAV BackendInterface each have a new method: - getMultipleCards and getMultipleCalendarObjects. The Abstract and PDO backends - have default implementations, but if you implement that interface directly, - this method is now required. -* BC Break: XML property classes now receive an extra argument in their - unserialize method ($propertyMap). This allows for recursively parsing - properties, if needed. -* BC Break: Now using sabre/event for event emitting/subscription. For plugin - authors this means Server::subscribeEvent is now Server::on, and - Server::broadcastEvent is now Server::emit. -* BC Break: Almost all core functionality moved into a CorePlugin. -* BC Break: Most events triggered by the server got an overhaul. -* Changed: Sabre\HTTP now moved into a dedicated sabre/http package. -* Added: Support for WebDAV-sync (rfc6578). -* Added: Support for caldav-subscriptions, which is an easy way for caldav - clients to manage a list of subscriptions on the server. -* Added: Support for emitting and receiving jCal instead of iCalendar for - CalDAV. -* Added: BasicCallback authenticaton backend, for creating simple authentication - systems without having to define any classes. -* Added: A $transactionType property on the server class. This can be used for - logging and performance measuring purposes. -* Fixed: If event handlers modify the request body from a PUT request, an ETag - is no longer sent back. -* Added: Sabre\DAV\IMultiGet to optimize requests that retrieve information - about lists of resources. -* Added: MultiGet support to default CalDAV and CardDAV backends, speeding up - the multiget and sync reports quite a bit! -* Added: ICSExportPlugin can now generate jCal, filter on time-ranges and expand - recurrences. -* Fixed: Read-only access to calendars still allows the sharee to modify basic - calendar properties, such as the displayname and color. -* Changed: The default supportedPrivilegeSet has changed. Most privileges are no - longer marked as abstract. -* Changed: More elegant ACL management for CalendarObject and Card nodes. -* Added: Browser plugin now marks a carddav directory as type Directory, and a - shared calendar as 'Shared'. -* Added: When debugExceptions is turned on, all previous exceptions are also - traversed. -* Removed: Got rid of the Version classes for CalDAV, CardDAV, HTTP, and DAVACL. - Now that there's no separate packages anymore, this makes a bit more sense. -* Added: Generalized the multistatus response parser a bit more, for better - re-use. -* Added: Sabre\DAV\Client now has support for complex properties for PROPPATCH. - (Issue #299). -* Added: Sabre\DAV\Client has support for gzip and deflate encoding. -* Added: Sabre\DAV\Client now has support for sending objects as streams. -* Added: Deserializer for {DAV:}current-user-privilege-set. -* Added: Addressbooks or backends can now specify custom acl rules when creating - cards. -* Added: The ability for plugins to validate custom tokens in If: headers. -* Changed: Completely refactored the Lock plugin to deal with the new If: header - system. -* Added: Checking preconditions for MOVE, COPY, DELETE and PROPPATCH methods. -* Added: has() method on DAV\Property\SupportedReportSet. -* Added: If header now gets checked (with ETag) all the time. Before the dealing - with the If-header was a responsibility of the Locking plugin. -* Fixed: Outbox access for delegates. -* Added: Issue 333: It's now possible to override the calendar-home in the - CalDAV plugin. -* Added: A negotiateContentType to HTTP\Request. A convenience method. -* Fixed: Issue 349: Denying copying or moving a resource into it's own subtree. -* Fixed: SabreDAV catches every exception again. -* Added: Issue #358, adding a component=vevent parameter to the content-types - for calendar objects, if the caldav backend provides this info. - - -1.8.12-stable (2015-01-21) --------------------------- - -* The zip release ships with sabre/vobject 2.1.7. -* #568: Support empty usernames and passwords in basic auth. - - -1.8.11 (2014-12-10) -------------------- - -* The zip release ships with sabre/vobject 2.1.6. -* Updated: MySQL database schema optimized by using more efficient column types. -* #516: The DAV client will now only redirect to HTTP and HTTPS urls. - - -1.8.10 (2014-05-15) -------------------- - -* The zip release ships with sabre/vobject 2.1.4. -* includes changes from version 1.7.12. - - -1.8.9 (2014-02-26) ------------------- - -* The zip release ships with sabre/vobject 2.1.3. -* includes changes from version 1.7.11. - - -1.8.8 (2014-02-09) ------------------- - -* includes changes from version 1.7.10. -* The zip release ships with sabre/vobject 2.1.3. - -1.8.7 (2013-10-02) ------------------- - -* the zip release ships with sabre/vobject 2.1.3. -* includes changes from version 1.7.9. - - -1.8.6 (2013-06-18) ------------------- - -* The zip release ships with sabre/vobject 2.1.0. -* Includes changes from version 1.7.8. - - -1.8.5 (2013-04-11) ------------------- - -* The zip release ships with sabre/vobject 2.0.7. -* Includes changes from version 1.7.7. - - -1.8.4 (2013-04-08) ------------------- - -* The zip release ships with sabre/vobject 2.0.7. -* Includes changes from version 1.7.6. - - -1.8.3 (2013-03-01) ------------------- - -* The zip release ships with sabre/vobject 2.0.6. -* Includes changes from version 1.7.5. -* Fixed: organizer email-address for shared calendars is now prefixed with - mailto:, as it should. - - -1.8.2 (2013-01-19) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* Includes changes from version 1.7.4. - - -1.8.1 (2012-12-01) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* Includes changes from version 1.7.3. -* Fixed: Typo in 1.7 migration script caused it to fail. - - -1.8.0 (2012-11-08) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* BC Break: Moved the entire codebase to PHP namespaces. -* BC Break: Every backend package (CalDAV, CardDAV, Auth, Locks, Principals) now - has consistent naming conventions. There's a BackendInterface, and an - AbstractBackend class. -* BC Break: Changed a bunch of constructor signatures in the CalDAV package, to - reduce dependencies on the ACL package. -* BC Break: Sabre_CalDAV_ISharedCalendar now also has a getShares method, so - sharees can figure out who is also on a shared calendar. -* Added: Sabre_DAVACL_IPrincipalCollection interface, to advertise support for - principal-property-search on any node. -* Added: Simple console script to fire up a fileserver in the current directory - using PHP 5.4's built-in webserver. -* Added: Sharee's can now also read out the list of invites for a shared - calendar. -* Added: The Proxy principal classes now both implement an interface, for - greater flexiblity. - - -1.7.13 (2014-07-28) -------------------- - -* The zip release ships with sabre/vobject 2.1.4. -* Changed: Removed phing and went with a custom build script for now. - - -1.7.12 (2014-05-15) -------------------- - -* The zip release ships with sabre/vobject 2.1.4. -* Updated: Issue #439. Lots of updates in PATCH support. The - Sabre_DAV_PartialUpdate_IFile interface is now deprecated and will be removed - in a future version. -* Fixed: Restoring old setting after changing libxml_disable_entity_loader. -* Fixed: Issue #422: Preconditions were not being set on PUT on non-existant - files. Not really a chance for data-loss, but incorrect nevertheless. -* Fixed: Issue #427: Now checking preconditions on DELETE requests. -* Fixed: Issue #428: Etag check with If: fails if the target is a collection. -* Fixed: Issue #393: PATCH request with missing end-range was handled - incorrectly. -* Added: Sabre_DAV_Exception_LengthRequired to omit 411 errors. - - -1.7.11 (2014-02-26) -------------------- - -* The zip release ships with sabre/vobject 2.1.3. -* Fixed: Issue #407: large downloads failed. -* Fixed: Issue #414: XXE security problem on older PHP versions. - - -1.7.10 (2014-02-09) -------------------- - -* Fixed: Issue #374: Don't urlescape colon (:) when it's not required. -* Fixed: Potential security vulnerability in the http client. - - -1.7.9 (2013-10-02) ------------------- - -* The zip release ships with sabre/vobject 2.1.3. -* Fixed: Issue #365. Incorrect output when principal urls have spaces in them. -* Added: Issue #367: Automatically adding a UID to vcards that don't have them. - - -1.7.8 (2013-06-17) ------------------- - -* The zip release ships with sabre/vobject 2.1.0. -* Changed: Sabre\DAV\Client::verifyPeer is now a protected property (instead of - private). -* Fixed: Text was incorrectly escaped in the Href and HrefList properties, - disallowing urls with ampersands (&) in them. -* Added: deserializer for Sabre\DAVACL\Property\CurrentUserPrivilegeSet. -* Fixed: Issue 335: Client only deserializes properties with status 200. -* Fixed: Issue 341: Escaping xml in 423 Locked error responses. -* Added: Issue 339: beforeGetPropertiesForPath event. - - -1.7.7 (2013-04-11) ------------------- - -* The zip release ships with sabre/vobject 2.0.7. -* Fixed: Assets in the browser plugins were not being served on windows - machines. - - -1.7.6 (2013-04-08) ------------------- - -* The zip release ships with sabre/vobject 2.0.7. -* Fixed: vcardurl in database schema can now hold 255 characters instead of 80 - (which is often way to small). -* Fixed: The browser plugin potentially allowed people to open any arbitrary - file on windows servers (CVE-2013-1939). - - -1.7.5 (2013-03-01) ------------------- - -* The zip release ships with sabre/vobject 2.0.6. -* Change: No longer advertising support for 4.0 vcards. iOS and OS X address - book don't handle this well, and just advertising 3.0 support seems like the - most logical course of action. -* Added: ->setVerifyPeers to Sabre_DAV_Client (greatly resisting against it, - don't use this..). - - -1.7.4 (2013-01-19) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* Changed: To be compatibile with MS Office 2011 for Mac, a workaround was - removed that was added to support old versions of Windows XP (pre-SP3). - Indeed! We needed a crazy workaround to work with one MS product in the past, - and we can't keep that workaround to be compatible with another MS product. -* Fixed: expand-properties REPORT had incorrect values for the href element. -* Fixed: Range requests now work for non-seekable streams. (Thanks Alfred - Klomp). -* Fixed: Changed serialization of {DAV:}getlastmodified and {DAV:}supportedlock - to improve compatiblity with MS Office 2011 for Mac. -* Changed: reverted the automatic translation of 'DAV:' xml namespaces to - 'urn:DAV' when parsing files. Issues were reported with libxml 2.6.32, on a - relatively recent debian release, so we'll wait till 2015 to take this one out - again. -* Added: Sabre_DAV_Exception_ServiceUnavailable, for emitting 503's. - - -1.7.3 (2012-12-01) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* Fixed: Removing double slashes from getPropertiesForPath. -* Change: Marked a few more properties in the CardDAV as protected, instead of - private. -* Fixed: SharingPlugin now plays nicer with other plugins with similar - functionality. -* Fixed: Issue 174. Sending back HTTP/1.0 for requests with this version. - - -1.7.2 (2012-11-08) ------------------- - -* The zip release ships with sabre/vobject 2.0.5. -* Added: ACL plugin advertises support for 'calendarserver-principal- - property-search'. -* Fixed: [#153] Allowing for relative http principals in iMip requests. -* Added: Support for cs:first-name and cs:last-name properties in sharing - invites. -* Fixed: Made a bunch of properties protected, where they were private before. -* Added: Some non-standard properties for sharing to improve compatibility. -* Fixed: some bugfixes in postgres sql script. -* Fixed: When requesting some properties using PROPFIND, they could show up as - both '200 Ok' and '403 Forbidden'. -* Fixed: calendar-proxy principals were not checked for deeper principal - membership than 1 level. -* Fixed: setGroupMemberSet argument now correctly receives relative principal - urls, instead of the absolute ones. -* Fixed: Server class will filter out any bonus properties if any extra were - returned. This means the implementor of the IProperty class can be a bit - lazier when implementing. Note: bug numbers after this line refer to Google - Code tickets. We're using github now. - - -1.7.1 (2012-10-07) ------------------- - -* Fixed: include path problem in the migration script. - - -1.7.0 (2012-10-06) ------------------- - -* BC Break: The calendarobjects database table has a bunch of new fields, and a - migration script is required to ensure everything will keep working. Read the - wiki for more details. -* BC Break: The ICalendar interface now has a new method: calendarQuery. -* BC Break: In this version a number of classes have been deleted, that have - been previously deprecated. Namely: - Sabre_DAV_Directory (now: - Sabre_DAV_Collection) - Sabre_DAV_SimpleDirectory (now: - Sabre_DAV_SimpleCollection) -* BC Break: Sabre_CalDAV_Schedule_IMip::sendMessage now has an extra argument. - If you extended this class, you should fix this method. It's only used for - informational purposes. -* BC Break: The DAV: namespace is no longer converted to urn:DAV. This was a - workaround for a bug in older PHP versions (pre-5.3). -* Removed: Sabre.includes.php was deprecated, and is now removed. -* Removed: Sabre_CalDAV_Server was deprecated, and is now removed. Please use - Sabre_DAV_Server and check the examples in the examples/ directory. -* Changed: The Sabre_VObject library now spawned into it's own project! The - VObject library is still included in the SabreDAV zip package. -* Added: Experimental interfaces to allow implementation of caldav-sharing. Note - that no implementation is provided yet, just the api hooks. -* Added: Free-busy reporting compliant with the caldav-scheduling standard. This - allows iCal and other clients to fetch other users' free-busy data. -* Added: Experimental NotificationSupport interface to add caldav notifications. -* Added: VCF Export plugin. If enabled, it can generate an export of an entire - addressbook. -* Added: Support for PATCH using a SabreDAV format, to live-patch files. -* Added: Support for Prefer: return-minimal and Brief: t headers for PROPFIND - and PROPPATCH requests. -* Changed: Responsibility for dealing with the calendar-query is now moved from - the CalDAV plugin to the CalDAV backends. This allows for heavy optimizations. -* Changed: The CalDAV PDO backend is now a lot faster for common calendar - queries. -* Changed: We are now using the composer autoloader. -* Changed: The CalDAV backend now all implement an interface. -* Changed: Instead of Sabre_DAV_Property, Sabre_DAV_PropertyInterface is now the - basis of every property class. -* Update: Caching results for principal lookups. This should cut down queries - and performance for a number of heavy requests. -* Update: ObjectTree caches lookups much more aggresively, which will help - especially speeding up a bunch of REPORT queries. -* Added: Support for the schedule-calendar-transp property. -* Fixed: Marking both the text/calendar and text/x-vcard as UTF-8 encoded. -* Fixed: Workaround for the SOGO connector, as it doesn't understand receiving - "text/x-vcard; charset=utf-8" for a contenttype. -* Added: Sabre_DAV_Client now throws more specific exceptions in cases where we - already has an exception class. -* Added: Sabre_DAV_PartialUpdate. This plugin allows you to use the PATCH method - to update parts of a file. -* Added: Tons of timezone name mappings for Microsoft Exchange. -* Added: Support for an 'exception' event in the server class. -* Fixed: Uploaded VCards without a UID are now rejected. (thanks Dominik!) -* Fixed: Rejecting calendar objects if they are not in the - supported-calendar-component list. (thanks Armin!) -* Fixed: Issue 219: serialize() now reorders correctly. -* Fixed: Sabre_DAV_XMLUtil no longer returns empty $dom->childNodes if there is - whitespace in $dom. -* Fixed: Returning 409 Conflict instead of 500 when an attempt is made to create - a file as a child of something that's not a collection. -* Fixed: Issue 237: xml-encoding values in SabreDAV error responses. -* Fixed: Returning 403, instead of 501 when an unknown REPORT is requested. -* Fixed: Postfixing slash on {DAV:}owner properties. -* Fixed: Several embarrassing spelling mistakes in docblocks. - - -1.6.10 (2013-06-17) -------------------- - -* Fixed: Text was incorrectly escaped in the Href and HrefList properties, - disallowing urls with ampersands (&) in them. -* Fixed: Issue 341: Escaping xml in 423 Locked error responses. - - -1.6.9 (2013-04-11) ------------------- - -* Fixed: Assets in the browser plugins were not being served on windows - machines. - - -1.6.8 (2013-04-08) ------------------- - -* Fixed: vcardurl in database schema can now hold 255 characters instead of 80 - (which is often way to small). -* Fixed: The browser plugin potentially allowed people to open any arbitrary - file on windows servers. (CVE-2013-1939). - - -1.6.7 (2013-03-01) ------------------- - -* Change: No longer advertising support for 4.0 vcards. iOS and OS X address - book don't handle this well, and just advertising 3.0 support seems like the - most logical course of action. -* Added: ->setVerifyPeers to Sabre_DAV_Client (greatly resisting against it, - don't use this..). - - -1.6.6 (2013-01-19) ------------------- - -* Fixed: Backported a fix for broken XML serialization in error responses. - (Thanks @DeepDiver1975!) - - -1.6.5 (2012-10-04) ------------------- - -* Fixed: Workaround for line-ending bug OS X 10.8 addressbook has. -* Added: Ability to allow users to set SSL certificates for the Client class. - (Thanks schiesbn!). -* Fixed: Directory indexes with lots of nodes should be a lot faster. -* Fixed: Issue 235: E_NOTICE thrown when doing a propfind request with - Sabre_DAV_Client, and no valid properties are returned. -* Fixed: Issue with filtering on alarms in tasks. - - -1.6.4 (2012-08-02) ------------------- - -* Fixed: Issue 220: Calendar-query filters may fail when filtering on alarms, if - an overridden event has it's alarm removed. -* Fixed: Compatibility for OS/X 10.8 iCal in the IMipHandler. -* Fixed: Issue 222: beforeWriteContent shouldn't be called for lock requests. -* Fixed: Problem with POST requests to the outbox if mailto: was not lower - cased. -* Fixed: Yearly recurrence rule expansion on leap-days no behaves correctly. -* Fixed: Correctly checking if recurring, all-day events with no dtstart fall in - a timerange if the start of the time-range exceeds the start of the instance - of an event, but not the end. -* Fixed: All-day recurring events wouldn't match if an occurence ended exactly - on the start of a time-range. -* Fixed: HTTP basic auth did not correctly deal with passwords containing colons - on some servers. -* Fixed: Issue 228: DTEND is now non-inclusive for all-day events in the - calendar-query REPORT and free-busy calculations. - - -1.6.3 (2012-06-12) ------------------- - -* Added: It's now possible to specify in Sabre_DAV_Client which type of - authentication is to be used. -* Fixed: Issue 206: Sabre_DAV_Client PUT requests are fixed. -* Fixed: Issue 205: Parsing an iCalendar 0-second date interval. -* Fixed: Issue 112: Stronger validation of iCalendar objects. Now making sure - every iCalendar object only contains 1 component, and disallowing vcards, - forcing every component to have a UID. -* Fixed: Basic validation for vcards in the CardDAV plugin. -* Fixed: Issue 213: Workaround for an Evolution bug, that prevented it from - updating events. -* Fixed: Issue 211: A time-limit query on a non-relative alarm trigger in a - recurring event could result in an endless loop. -* Fixed: All uri fields are now a maximum of 200 characters. The Bynari outlook - plugin used much longer strings so this should improve compatibility. -* Fixed: Added a workaround for a bug in KDE 4.8.2 contact syncing. See - https://bugs.kde.org/show_bug.cgi?id=300047 -* Fixed: Issue 217: Sabre_DAV_Tree_FileSystem was pretty broken. - - -1.6.2 (2012-04-16) ------------------- - -* Fixed: Sabre_VObject_Node::$parent should have been public. -* Fixed: Recurrence rules of events are now taken into consideration when doing - time-range queries on alarms. -* Fixed: Added a workaround for the fact that php's DateInterval cannot parse - weeks and days at the same time. -* Added: Sabre_DAV_Server::$exposeVersion, allowing you to hide SabreDAV's - version number from various outputs. -* Fixed: DTSTART values would be incorrect when expanding events. -* Fixed: DTSTART and DTEND would be incorrect for expansion of WEEKLY BYDAY - recurrences. -* Fixed: Issue 203: A problem with overridden events hitting the exact date and - time of a subsequent event in the recurrence set. -* Fixed: There was a problem with recurrence rules, for example the 5th tuesday - of the month, if this day did not exist. -* Added: New HTTP status codes from draft-nottingham-http-new-status-04. - - -1.6.1 (2012-03-05) ------------------- - -* Added: createFile and put() can now return an ETag. -* Added: Sending back an ETag on for operations on CardDAV backends. This should - help with OS X 10.6 Addressbook compatibility. -* Fixed: Fixed a bug where an infinite loop could occur in the recurrence - iterator if the recurrence was YEARLY, with a BYMONTH rule, and either BYDAY - or BYMONTHDAY match the first day of the month. -* Fixed: Events that are excluded using EXDATE are still counted in the COUNT= - parameter in the RRULE property. -* Added: Support for time-range filters on VALARM components. -* Fixed: Correctly filtering all-day events. -* Fixed: Sending back correct mimetypes from the browser plugin (thanks - Jürgen). -* Fixed: Issue 195: Sabre_CardDAV pear package had an incorrect dependency. -* Fixed: Calendardata would be destroyed when performing a MOVE request. - - -1.6.0 (2012-02-22) ------------------- - -* BC Break: Now requires PHP 5.3 -* BC Break: Any node that implemented Sabre_DAVACL_IACL must now also implement - the getSupportedPrivilegeSet method. See website for details. -* BC Break: Moved functions from Sabre_CalDAV_XMLUtil to - Sabre_VObject_DateTimeParser. -* BC Break: The Sabre_DAVACL_IPrincipalCollection now has two new methods: - 'searchPrincipals' and 'updatePrincipal'. -* BC Break: Sabre_DAV_ILockable is removed and all related per-node locking - functionality. -* BC Break: Sabre_DAV_Exception_FileNotFound is now deprecated in favor of - Sabre_DAV_Exception_NotFound. The former will be removed in a later version. -* BC Break: Removed Sabre_CalDAV_ICalendarUtil, use Sabre_VObject instead. -* BC Break: Sabre_CalDAV_Server is now deprecated, check out the documentation - on how to setup a caldav server with just Sabre_DAV_Server. -* BC Break: Default Principals PDO backend now needs a new field in the - 'principals' table. See the website for details. -* Added: Ability to create new calendars and addressbooks from within the - browser plugin. -* Added: Browser plugin: icons for various nodes. -* Added: Support for FREEBUSY reports! -* Added: Support for creating principals with admin-level privileges. -* Added: Possibility to let server send out invitation emails on behalf of - CalDAV client, using Sabre_CalDAV_Schedule_IMip. -* Changed: beforeCreateFile event now passes data argument by reference. -* Changed: The 'propertyMap' property from Sabre_VObject_Reader, must now be - specified in Sabre_VObject_Property::$classMap. -* Added: Ability for plugins to tell the ACL plugin which principal plugins are - searchable. -* Added: [DAVACL] Per-node overriding of supported privileges. This allows for - custom privileges where needed. -* Added: [DAVACL] Public 'principalSearch' method on the DAVACL plugin, which - allows for easy searching for principals, based on their properties. -* Added: Sabre_VObject_Component::getComponents() to return a list of only - components and not properties. -* Added: An includes.php file in every sub-package (CalDAV, CardDAV, DAV, - DAVACL, HTTP, VObject) as an alternative to the autoloader. This often works - much faster. -* Added: Support for the 'Me card', which allows Addressbook.app users specify - which vcard is their own. -* Added: Support for updating principal properties in the DAVACL principal - backends. -* Changed: Major refactoring in the calendar-query REPORT code. Should make - things more flexible and correct. -* Changed: The calendar-proxy-[read|write] principals will now only appear in - the tree, if they actually exist in the Principal backend. This should reduce - some problems people have been having with this. -* Changed: Sabre_VObject_Element_* classes are now renamed to - Sabre_VObject_Property. Old classes are retained for backwards compatibility, - but this will be removed in the future. -* Added: Sabre_VObject_FreeBusyGenerator to generate free-busy reports based on - lists of events. -* Added: Sabre_VObject_RecurrenceIterator to find all the dates and times for - recurring events. -* Fixed: Issue 97: Correctly handling RRULE for the calendar-query REPORT. -* Fixed: Issue 154: Encoding of VObject parameters with no value was incorrect. -* Added: Support for {DAV:}acl-restrictions property from RFC3744. -* Added: The contentlength for calendar objects can now be supplied by a CalDAV - backend, allowing for more optimizations. -* Fixed: Much faster implementation of Sabre_DAV_URLUtil::encodePath. -* Fixed: {DAV:}getcontentlength may now be not specified. -* Fixed: Issue 66: Using rawurldecode instead of urldecode to decode paths from - clients. This means that + will now be treated as a literal rather than a - space, and this should improve compatibility with the Windows built-in client. -* Added: Sabre_DAV_Exception_PaymentRequired exception, to emit HTTP 402 status - codes. -* Added: Some mysql unique constraints to example files. -* Fixed: Correctly formatting HTTP dates. -* Fixed: Issue 94: Sending back Last-Modified header for 304 responses. -* Added: Sabre_VObject_Component_VEvent, Sabre_VObject_Component_VJournal, - Sabre_VObject_Component_VTodo and Sabre_VObject_Component_VCalendar. -* Changed: Properties are now also automatically mapped to their appropriate - classes, if they are created using the add() or __set() methods. -* Changed: Cloning VObject objects now clones the entire tree, rather than just - the default shallow copy. -* Added: Support for recurrence expansion in the CALDAV:calendar-multiget and - CALDAV:calendar-query REPORTS. -* Changed: CalDAV PDO backend now sorts calendars based on the internal - 'calendarorder' field. -* Added: Issue 181: Carddav backends may no optionally not supply the carddata - in getCards, if etag and size are specified. This may speed up certain - requests. -* Added: More arguments to beforeWriteContent and beforeCreateFile (see - WritingPlugins wiki document). -* Added: Hook for iCalendar validation. This allows us to validate iCalendar - objects when they're uploaded. At the moment we're just validating syntax. -* Added: VObject now support Windows Timezone names correctly (thanks mrpace2). -* Added: If a timezonename could not be detected, we fall back on the default - PHP timezone. -* Added: Now a Composer package (thanks willdurand). -* Fixed: Support for \N as a newline character in the VObject reader. -* Added: afterWriteContent, afterCreateFile and afterUnbind events. -* Added: Postgresql example files. Not part of the unittests though, so use at - your own risk. -* Fixed: Issue 182: Removed backticks from sql queries, so it will work with - Postgres. - - -1.5.9 (2012-04-16) ------------------- - -* Fixed: Issue with parsing timezone identifiers that were surrounded by quotes. - (Fixes emClient compatibility). - - -1.5.8 (2012-02-22) ------------------- - -* Fixed: Issue 95: Another timezone parsing issue, this time in calendar-query. - - -1.5.7 (2012-02-19) ------------------- - -* Fixed: VObject properties are now always encoded before components. -* Fixed: Sabre_DAVACL had issues with multiple levels of privilege aggregration. -* Changed: Added 'GuessContentType' plugin to fileserver.php example. -* Fixed: The Browser plugin will now trigger the correct events when creating - files. -* Fixed: The ICSExportPlugin now considers ACL's. -* Added: Made it optional to supply carddata from an Addressbook backend when - requesting getCards. This can make some operations much faster, and could - result in much lower memory use. -* Fixed: Issue 187: Sabre_DAV_UUIDUtil was missing from includes file. -* Fixed: Issue 191: beforeUnlock was triggered twice. - - -1.5.6 (2012-01-07) ------------------- - -* Fixed: Issue 174: VObject could break UTF-8 characters. -* Fixed: pear package installation issues. - - -1.5.5 (2011-12-16) ------------------- - -* Fixed: CalDAV time-range filter workaround for recurring events. -* Fixed: Bug in Sabre_DAV_Locks_Backend_File that didn't allow multiple files to - be locked at the same time. - - -1.5.4 (2011-10-28) ------------------- - -* Fixed: GuessContentType plugin now supports mixed case file extensions. -* Fixed: DATE-TIME encoding was wrong in VObject. (we used 'DATETIME'). -* Changed: Sending back HTTP 204 after a PUT request on an existing resource - instead of HTTP 200. This should fix Evolution CardDAV client compatibility. -* Fixed: Issue 95: Parsing X-LIC-LOCATION if it's available. -* Added: All VObject elements now have a reference to their parent node. - - -1.5.3 (2011-09-28) ------------------- - -* Fixed: Sabre_DAV_Collection was missing from the includes file. -* Fixed: Issue 152. iOS 1.4.2 apparantly requires HTTP/1.1 200 OK to be in - uppercase. -* Fixed: Issue 153: Support for files with mixed newline styles in - Sabre_VObject. -* Fixed: Issue 159: Automatically converting any vcard and icalendardata to - UTF-8. -* Added: Sabre_DAV_SimpleFile class for easy static file creation. -* Added: Issue 158: Support for the CARDDAV:supported-address-data property. - - -1.5.2 (2011-09-21) ------------------- - -* Fixed: carddata and calendardata MySQL fields are now of type 'mediumblob'. - 'TEXT' was too small sometimes to hold all the data. -* Fixed: {DAV:}supported-report-set is now correctly reporting the reports for - IAddressBook. -* Added: Sabre_VObject_Property::add() to add duplicate parameters to - properties. -* Added: Issue 151: Sabre_CalDAV_ICalendar and Sabre_CalDAV_ICalendarObject - interfaces. -* Fixed: Issue 140: Not returning 201 Created if an event cancelled the creation - of a file. -* Fixed: Issue 150: Faster URLUtil::encodePath() implementation. -* Fixed: Issue 144: Browser plugin could interfere with - TemporaryFileFilterPlugin if it was loaded first. -* Added: It's not possible to specify more 'alternate uris' in principal - backends. - - -1.5.1 (2011-08-24) ------------------- - -* Fixed: Issue 137. Hiding action interface in HTML browser for non-collections. -* Fixed: addressbook-query is now correctly returned from the - {DAV:}supported-report-set property. -* Fixed: Issue 142: Bugs in groupwareserver.php example. -* Fixed: Issue 139: Rejecting PUT requests with Content-Range. - - -1.5.0 (2011-08-12) ------------------- - -* Added: CardDAV support. -* Added: An experimental WebDAV client. -* Added: MIME-Directory grouping support in the VObject library. This is very - useful for people attempting to parse vcards. -* BC Break: Adding parameters with the VObject libraries now overwrites the - previous parameter, rather than just add it. This makes more sense for 99% of - the cases. -* BC Break: lib/Sabre.autoload.php is now removed in favor of - lib/Sabre/autoload.php. -* Deprecated: Sabre_DAV_Directory is now deprecated and will be removed in a - future version. Use Sabre_DAV_Collection instead. -* Deprecated: Sabre_DAV_SimpleDirectory is now deprecated and will be removed in - a future version. Use Sabre_DAV_SimpleCollection instead. -* Fixed: Problem with overriding tablenames for the CalDAV backend. -* Added: Clark-notation parser to XML utility. -* Added: unset() support to VObject components. -* Fixed: Refactored CalDAV property fetching to be faster and simpler. -* Added: Central string-matcher for CalDAV and CardDAV plugins. -* Added: i;unicode-casemap support -* Fixed: VObject bug: wouldn't parse parameters if they weren't specified in - uppercase. -* Fixed: VObject bug: Parameters now behave more like Properties. -* Fixed: VObject bug: Parameters with no value are now correctly parsed. -* Changed: If calendars don't specify which components they allow, 'all' - components are assumed (e.g.: VEVENT, VTODO, VJOURNAL). -* Changed: Browser plugin now uses POST variable 'sabreAction' instead of - 'action' to reduce the chance of collisions. - - -1.4.4 (2011-07-07) ------------------- - -* Fixed: Issue 131: Custom CalDAV backends could break in certain cases. -* Added: The option to override the default tablename all PDO backends use. - (Issue 60). -* Fixed: Issue 124: 'File' authentication backend now takes realm into - consideration. -* Fixed: Sabre_DAV_Property_HrefList now properly deserializes. This allows - users to update the {DAV:}group-member-set property. -* Added: Helper functions for DateTime-values in Sabre_VObject package. -* Added: VObject library can now automatically map iCalendar properties to - custom classes. - - -1.4.3 (2011-04-25) ------------------- - -* Fixed: Issue 123: Added workaround for Windows 7 UNLOCK bug. -* Fixed: datatype of lastmodified field in mysql.calendars.sql. Please change - the DATETIME field to an INT to ensure this field will work correctly. -* Change: Sabre_DAV_Property_Principal is now renamed to - Sabre_DAVACL_Property_Principal. -* Added: API level support for ACL HTTP method. -* Fixed: Bug in serializing {DAV:}acl property. -* Added: deserializer for {DAV:}resourcetype property. -* Added: deserializer for {DAV:}acl property. -* Added: deserializer for {DAV:}principal property. - - -1.4.2-beta (2011-04-01) ------------------------ - -* Added: It's not possible to disable listing of nodes that are denied read - access by ACL. -* Fixed: Changed a few properties in CalDAV classes from private to protected. -* Fixed: Issue 119: Terrible things could happen when relying on guessBaseUri, - the server was running on the root of the domain and a user tried to access a - file ending in .php. This is a slight BC break. -* Fixed: Issue 118: Lock tokens in If headers without a uri should be treated as - the request uri, not 'all relevant uri's. -* Fixed: Issue 120: PDO backend was incorrectly fetching too much locks in cases - where there were similar named locked files in a directory. - - -1.4.1-beta (2011-02-26) ------------------------ - -* Fixed: Sabre_DAV_Locks_Backend_PDO returned too many locks. -* Fixed: Sabre_HTTP_Request::getHeader didn't return Content-Type when running - on apache, so a few workarounds were added. -* Change: Slightly changed CalDAV Backend API's, to allow for heavy - optimizations. This is non-bc breaking. - - -1.4.0-beta (2011-02-12) ------------------------ - -* Added: Partly RFC3744 ACL support. -* Added: Calendar-delegation (caldav-proxy) support. -* BC break: In order to fix Issue 99, a new argument had to be added to - Sabre_DAV_Locks_Backend_*::getLocks classes. Consult the classes for details. -* Deprecated: Sabre_DAV_Locks_Backend_FS is now deprecated and will be removed - in a later version. Use PDO or the new File class instead. -* Deprecated: The Sabre_CalDAV_ICalendarUtil class is now marked deprecated, and - will be removed in a future version. Please use Sabre_VObject instead. -* Removed: All principal-related functionality has been removed from the - Sabre_DAV_Auth_Plugin, and moved to the Sabre_DAVACL_Plugin. -* Added: VObject library, for easy vcard/icalendar parsing using a natural - interface. -* Added: Ability to automatically generate full .ics feeds off calendars. To - use: Add the Sabre_CalDAV_ICSExportPlugin, and add ?export to your calendar - url. -* Added: Plugins can now specify a pluginname, for easy access using - Sabre_DAV_Server::getPlugin(). -* Added: beforeGetProperties event. -* Added: updateProperties event. -* Added: Principal listings and calendar-access can now be done privately, - disallowing users from accessing or modifying other users' data. -* Added: You can now pass arrays to the Sabre_DAV_Server constructor. If it's an - array with node-objects, a Root collection will automatically be created, and - the nodes are used as top-level children. -* Added: The principal base uri is now customizable. It used to be hardcoded to - 'principals/[user]'. -* Added: getSupportedReportSet method in ServerPlugin class. This allows you to - easily specify which reports you're implementing. -* Added: A '..' link to the HTML browser. -* Fixed: Issue 99: Locks on child elements were ignored when their parent nodes - were deleted. -* Fixed: Issue 90: lockdiscovery property and LOCK response now include a - {DAV}lockroot element. -* Fixed: Issue 96: support for 'default' collation in CalDAV text-match filters. -* Fixed: Issue 102: Ensuring that copy and move with identical source and - destination uri's fails. -* Fixed: Issue 105: Supporting MKCALENDAR with no body. -* Fixed: Issue 109: Small fixes in Sabre_HTTP_Util. -* Fixed: Issue 111: Properly catching the ownername in a lock (if it's a string) -* Fixed: Sabre_DAV_ObjectTree::nodeExist always returned false for the root - node. -* Added: Global way to easily supply new resourcetypes for certain node classes. -* Fixed: Issue 59: Allowing the user to override the authentication realm in - Sabre_CalDAV_Server. -* Update: Issue 97: Looser time-range checking if there's a recurrence rule in - an event. This fixes 'missing recurring events'. - - -1.3.0 (2010-10-14) ------------------- - -* Added: childExists method to Sabre_DAV_ICollection. This is an api break, so - if you implement Sabre_DAV_ICollection directly, add the method. -* Changed: Almost all HTTP method implementations now take a uri argument, - including events. This allows for internal rerouting of certain calls. If you - have custom plugins, make sure they use this argument. If they don't, they - will likely still work, but it might get in the way of future changes. -* Changed: All getETag methods MUST now surround the etag with double-quotes. - This was a mistake made in all previous SabreDAV versions. If you don't do - this, any If-Match, If-None-Match and If: headers using Etags will work - incorrectly. (Issue 85). -* Added: Sabre_DAV_Auth_Backend_AbstractBasic class, which can be used to easily - implement basic authentication. -* Removed: Sabre_DAV_PermissionDenied class. Use Sabre_DAV_Forbidden instead. -* Removed: Sabre_DAV_IDirectory interface, use Sabre_DAV_ICollection instead. -* Added: Browser plugin now uses {DAV:}displayname if this property is - available. -* Added: Cache layer in the ObjectTree. -* Added: Tree classes now have a delete and getChildren method. -* Fixed: If-Modified-Since and If-Unmodified-Since would be incorrect if the - date is an exact match. -* Fixed: Support for multiple ETags in If-Match and If-None-Match headers. -* Fixed: Improved baseUrl handling. -* Fixed: Issue 67: Non-seekable stream support in ::put()/::get(). -* Fixed: Issue 65: Invalid dates are now ignored. -* Updated: Refactoring in Sabre_CalDAV to make everything a bit more ledgable. -* Fixed: Issue 88, Issue 89: Fixed compatibility for running SabreDAV on - Windows. -* Fixed: Issue 86: Fixed Content-Range top-boundary from 'file size' to 'file - size'-1. - - -1.2.5 (2010-08-18) ------------------- - -* Fixed: Issue 73: guessBaseUrl fails for some servers. -* Fixed: Issue 67: SabreDAV works better with non-seekable streams. -* Fixed: If-Modified-Since and If-Unmodified-Since would be incorrect if - the date is an exact match. - - -1.2.4 (2010-07-13) ------------------- - -* Fixed: Issue 62: Guessing baseUrl fails when url contains a query-string. -* Added: Apache configuration sample for CGI/FastCGI setups. -* Fixed: Issue 64: Only returning calendar-data when it was actually requested. - - -1.2.3 (2010-06-26) ------------------- - -* Fixed: Issue 57: Supporting quotes around etags in If-Match and If-None-Match - - -1.2.2 (2010-06-21) ------------------- - -* Updated: SabreDAV now attempts to guess the BaseURI if it's not set. -* Updated: Better compatibility with BitKinex -* Fixed: Issue 56: Incorrect behaviour for If-None-Match headers and GET - requests. -* Fixed: Issue with certain encoded paths in Browser Plugin. - - -1.2.1 (2010-06-07) ------------------- - -* Fixed: Issue 50, patch by Mattijs Hoitink. -* Fixed: Issue 51, Adding windows 7 lockfiles to TemporaryFileFilter. -* Fixed: Issue 38, Allowing custom filters to be added to TemporaryFileFilter. -* Fixed: Issue 53, ETags in the If: header were always failing. This behaviour - is now corrected. -* Added: Apache Authentication backend, in case authentication through .htaccess - is desired. -* Updated: Small improvements to example files. - - -1.2.0 (2010-05-24) ------------------- - -* Fixed: Browser plugin now displays international characters. -* Changed: More properties in CalDAV classes are now protected instead of - private. - - -1.2.0beta3 (2010-05-14) ------------------------ - -* Fixed: Custom properties were not properly sent back for allprops requests. -* Fixed: Issue 49, incorrect parsing of PROPPATCH, affecting Office 2007. -* Changed: Removed CalDAV items from includes.php, and added a few missing ones. - - -1.2.0beta2 (2010-05-04) ------------------------ - -* Fixed: Issue 46: Fatal error for some non-existent nodes. -* Updated: some example sql to include email address. -* Added: 208 and 508 statuscodes from RFC5842. -* Added: Apache2 configuration examples - - -1.2.0beta1 (2010-04-28) ------------------------ - -* Fixed: redundant namespace declaration in resourcetypes. -* Fixed: 2 locking bugs triggered by litmus when no Sabre_DAV_ILockable - interface is used. -* Changed: using http://sabredav.org/ns for all custom xml properties. -* Added: email address property to principals. -* Updated: CalendarObject validation. - - -1.2.0alpha4 (2010-04-24) ------------------------- - -* Added: Support for If-Range, If-Match, If-None-Match, If-Modified-Since, - If-Unmodified-Since. -* Changed: Brand new build system. Functionality is split up between Sabre, - Sabre_HTTP, Sabre_DAV and Sabre_CalDAV packages. In addition to that a new - non-pear package will be created with all this functionality combined. -* Changed: Autoloader moved to Sabre/autoload.php. -* Changed: The Allow: header is now more accurate, with appropriate HTTP methods - per uri. -* Changed: Now throwing back Sabre_DAV_Exception_MethodNotAllowed on a few - places where Sabre_DAV_Exception_NotImplemented was used. - - -1.2.0alpha3 (2010-04-20) ------------------------- - -* Update: Complete rewrite of property updating. Now easier to use and atomic. -* Fixed: Issue 16, automatically adding trailing / to baseUri. -* Added: text/plain is used for .txt files in GuessContentType plugin. -* Added: support for principal-property-search and principal-search-property-set - reports. -* Added: Issue 31: Hiding exception information by default. Can be turned on - with the Sabre_DAV_Server::$debugExceptions property. - - -1.2.0alpha2 (2010-04-08) ------------------------- - -* Added: Calendars are now private and can only be read by the owner. -* Fixed: double namespace declaration in multistatus responses. -* Added: MySQL database dumps. MySQL is now also supported next to SQLite. -* Added: expand-properties REPORT from RFC 3253. -* Added: Sabre_DAV_Property_IHref interface for properties exposing urls. -* Added: Issue 25: Throwing error on broken Finder behaviour. -* Changed: Authentication backend is now aware of current user. - - -1.2.0alpha1 (2010-03-31) ------------------------- - -* Fixed: Issue 26: Workaround for broken GVFS behaviour with encoded special - characters. -* Fixed: Issue 34: Incorrect Lock-Token response header for LOCK. Fixes Office - 2010 compatibility. -* Added: Issue 35: SabreDAV version to header to OPTIONS response to ease - debugging. -* Fixed: Issue 36: Incorrect variable name, throwing error in some requests. -* Fixed: Issue 37: Incorrect smultron regex in temporary filefilter. -* Fixed: Issue 33: Converting ISO-8859-1 characters to UTF-8. -* Fixed: Issue 39 & Issue 40: Basename fails on non-utf-8 locales. -* Added: More unittests. -* Added: SabreDAV version to all error responses. -* Added: URLUtil class for decoding urls. -* Changed: Now using pear.sabredav.org pear channel. -* Changed: Sabre_DAV_Server::getCopyAndMoveInfo is now a public method. - - -1.1.2-alpha (2010-03-18) ------------------------- - -* Added: RFC5397 - current-user-principal support. -* Fixed: Issue 27: encoding entities in property responses. -* Added: naturalselection script now allows the user to specify a 'minimum - number of bytes' for deletion. This should reduce load due to less crawling -* Added: Full support for the calendar-query report. -* Added: More unittests. -* Added: Support for complex property deserialization through the static - ::unserialize() method. -* Added: Support for modifying calendar-component-set -* Fixed: Issue 29: Added TIMEOUT_INFINITE constant - - -1.1.1-alpha (2010-03-11) ------------------------- - -* Added: RFC5689 - Extended MKCOL support. -* Fixed: Evolution support for CalDAV. -* Fixed: PDO-locks backend was pretty much completely broken. This is 100% - unittested now. -* Added: support for ctags. -* Fixed: Comma's between HTTP methods in 'Allow' method. -* Changed: default argument for Sabre_DAV_Locks_Backend_FS. This means a - datadirectory must always be specified from now on. -* Changed: Moved Sabre_DAV_Server::parseProps to - Sabre_DAV_XMLUtil::parseProperties. -* Changed: Sabre_DAV_IDirectory is now Sabre_DAV_ICollection. -* Changed: Sabre_DAV_Exception_PermissionDenied is now - Sabre_DAV_Exception_Forbidden. -* Changed: Sabre_CalDAV_ICalendarCollection is removed. -* Added: Sabre_DAV_IExtendedCollection. -* Added: Many more unittests. -* Added: support for calendar-timezone property. - - -1.1.0-alpha (2010-03-01) ------------------------- - -* Note: This version is forked from version 1.0.5, so release dates may be out - of order. -* Added: CalDAV - RFC 4791 -* Removed: Sabre_PHP_Exception. PHP has a built-in ErrorException for this. -* Added: PDO authentication backend. -* Added: Example sql for auth, caldav, locks for sqlite. -* Added: Sabre_DAV_Browser_GuessContentType plugin -* Changed: Authentication plugin refactored, making it possible to implement - non-digest authentication. -* Fixed: Better error display in browser plugin. -* Added: Support for {DAV:}supported-report-set -* Added: XML utility class with helper functions for the WebDAV protocol. -* Added: Tons of unittests -* Added: PrincipalCollection and Principal classes -* Added: Sabre_DAV_Server::getProperties for easy property retrieval -* Changed: {DAV:}resourceType defaults to 0 -* Changed: Any non-null resourceType now gets a / appended to the href value. - Before this was just for {DAV:}collection's, but this is now also the case for - for example {DAV:}principal. -* Changed: The Href property class can now optionally create non-relative uri's. -* Changed: Sabre_HTTP_Response now returns false if headers are already sent and - header-methods are called. -* Fixed: Issue 19: HEAD requests on Collections -* Fixed: Issue 21: Typo in Sabre_DAV_Property_Response -* Fixed: Issue 18: Doesn't work with Evolution Contacts - - -1.0.15 (2010-05-28) -------------------- - -* Added: Issue 31: Hiding exception information by default. Can be turned on - with the Sabre_DAV_Server::$debugExceptions property. -* Added: Moved autoload from lib/ to lib/Sabre/autoload.php. This is also the - case in the upcoming 1.2.0, so it will improve future compatibility. - - -1.0.14 (2010-04-15) -------------------- - -* Fixed: double namespace declaration in multistatus responses. - - -1.0.13 (2010-03-30) -------------------- - -* Fixed: Issue 40: Last references to basename/dirname - - -1.0.12 (2010-03-30) -------------------- - -* Fixed: Issue 37: Incorrect smultron regex in temporary filefilter. -* Fixed: Issue 26: Workaround for broken GVFS behaviour with encoded special - characters. -* Fixed: Issue 33: Converting ISO-8859-1 characters to UTF-8. -* Fixed: Issue 39: Basename fails on non-utf-8 locales. -* Added: More unittests. -* Added: SabreDAV version to all error responses. -* Added: URLUtil class for decoding urls. -* Updated: Now using pear.sabredav.org pear channel. - - -1.0.11 (2010-03-23) -------------------- - -* Non-public release. This release is identical to 1.0.10, but it is used to - test releasing packages to pear.sabredav.org. - - -1.0.10 (2010-03-22) -------------------- - -* Fixed: Issue 34: Invalid Lock-Token header response. -* Added: Issue 35: Addign SabreDAV version to HTTP OPTIONS responses. - - -1.0.9 (2010-03-19) ------------------- - -* Fixed: Issue 27: Entities not being encoded in PROPFIND responses. -* Fixed: Issue 29: Added missing TIMEOUT_INFINITE constant. - - -1.0.8 (2010-03-03) ------------------- - -* Fixed: Issue 21: typos causing errors -* Fixed: Issue 23: Comma's between methods in Allow header. -* Added: Sabre_DAV_ICollection interface, to aid in future compatibility. -* Added: Sabre_DAV_Exception_Forbidden exception. This will replace - Sabre_DAV_Exception_PermissionDenied in the future, and can already be used to - ensure future compatibility. - - -1.0.7 (2010-02-24) ------------------- - -* Fixed: Issue 19 regression for MS Office - - -1.0.6 (2010-02-23) ------------------- - -* Fixed: Issue 19: HEAD requests on Collections - - -1.0.5 (2010-01-22) ------------------- - -* Fixed: Fatal error when a malformed url was used for unlocking, in conjuction - with Sabre.autoload.php due to a incorrect filename. -* Fixed: Improved unittests and build system - - -1.0.4 (2010-01-11) ------------------- - -* Fixed: needed 2 different releases. One for googlecode and one for pearfarm. - This is to retain the old method to install SabreDAV until pearfarm becomes - the standard installation method. - - -1.0.3 (2010-01-11) ------------------- - -* Added: RFC4709 support (davmount) -* Added: 6 unittests -* Added: naturalselection. A tool to keep cache directories below a specified - theshold. -* Changed: Now using pearfarm.org channel server. - - -1.0.1 (2009-12-22) ------------------- - -* Fixed: Issue 15: typos in examples -* Fixed: Minor pear installation issues - - -1.0.0 (2009-11-02) ------------------- - -* Added: SimpleDirectory class. This class allows creating static directory - structures with ease. -* Changed: Custom complex properties and exceptions now get an instance of - Sabre_DAV_Server as their first argument in serialize() -* Changed: Href complex property now prepends server's baseUri -* Changed: delete before an overwriting copy/move is now handles by server class - instead of tree classes -* Changed: events must now explicitly return false to stop execution. Before, - execution would be stopped by anything loosely evaluating to false. -* Changed: the getPropertiesForPath method now takes a different set of - arguments, and returns a different response. This allows plugin developers to - return statuses for properties other than 200 and 404. The hrefs are now also - always calculated relative to the baseUri, and not the uri of the request. -* Changed: generatePropFindResponse is renamed to generateMultiStatus, and now - takes a list of properties similar to the response of getPropertiesForPath. - This was also needed to improve flexibility for plugin development. -* Changed: Auth plugins are no longer included. They were not yet stable - quality, so they will probably be reintroduced in a later version. -* Changed: PROPPATCH also used generateMultiStatus now. -* Removed: unknownProperties event. This is replaced by the afterGetProperties - event, which should provide more flexibility. -* Fixed: Only calling getSize() on IFile instances in httpHead() -* Added: beforeBind event. This is invoked upon file or directory creation -* Added: beforeWriteContent event, this is invoked by PUT and LOCK on an - existing resource. -* Added: beforeUnbind event. This is invoked right before deletion of any - resource. -* Added: afterGetProperties event. This event can be used to make modifications - to property responses. -* Added: beforeLock and beforeUnlock events. -* Added: afterBind event. -* Fixed: Copy and Move could fail in the root directory. This is now fixed. -* Added: Plugins can now be retrieved by their classname. This is useful for - inter-plugin communication. -* Added: The Auth backend can now return usernames and user-id's. -* Added: The Auth backend got a getUsers method -* Added: Sabre_DAV_FSExt_Directory now returns quota info - - -0.12.1-beta (2009-09-11) ------------------------- - -* Fixed: UNLOCK bug. Unlock didn't work at all - - -0.12-beta (2009-09-10) ----------------------- - -* Updated: Browser plugin now shows multiple {DAV:}resourcetype values if - available. -* Added: Experimental PDO backend for Locks Manager -* Fixed: Sending Content-Length: 0 for every empty response. This improves NGinx - compatibility. -* Fixed: Last modification time is reported in UTC timezone. This improves - Finder compatibility. - - -0.11-beta (2009-08-11) ----------------------- - -* Updated: Now in Beta -* Updated: Pear package no longer includes docs/ directory. These just contained - rfc's, which are publicly available. This reduces the package from ~800k to - ~60k -* Added: generatePropfindResponse now takes a baseUri argument -* Added: ResourceType property can now contain multiple resourcetypes. -* Fixed: Issue 13. - - -0.10-alpha (2009-08-03) ------------------------ - -* Added: Plugin to automatically map GET requests to non-files to PROPFIND - (Sabre_DAV_Browser_MapGetToPropFind). This should allow easier debugging of - complicated WebDAV setups. -* Added: Sabre_DAV_Property_Href class. For future use. -* Added: Ability to choose to use auth-int, auth or both for HTTP Digest - authentication. (Issue 11) -* Changed: Made more methods in Sabre_DAV_Server public. -* Fixed: TemporaryFileFilter plugin now intercepts HTTP LOCK requests to - non-existent files. (Issue 12) -* Added: Central list of defined xml namespace prefixes. This can reduce - Bandwidth and legibility for xml bodies with user-defined namespaces. -* Added: now a PEAR-compatible package again, thanks to Michael Gauthier -* Changed: moved default copy and move logic from ObjectTree to Tree class - -0.9a-alpha (2009-07-21) ----------------------- - -* Fixed: Broken release - -0.9-alpha (2009-07-21) ----------------------- - -* Changed: Major refactoring, removed most of the logic from the Tree objects. - The Server class now directly works with the INode, IFile and IDirectory - objects. If you created your own Tree objects, this will most likely break in - this release. -* Changed: Moved all the Locking logic from the Tree and Server classes into a - separate plugin. -* Changed: TemporaryFileFilter is now a plugin. -* Added: Comes with an autoloader script. This can be used instead of the - includer script, and is preferred by some people. -* Added: AWS Authentication class. -* Added: simpleserversetup.py script. This will quickly get a fileserver up and - running. -* Added: When subscribing to events, it is now possible to supply a priority. - This is for example needed to ensure that the Authentication Plugin is used - before any other Plugin. -* Added: 22 new tests. -* Added: Users-manager plugin for .htdigest files. Experimental and subject to - change. -* Added: RFC 2324 HTTP 418 status code -* Fixed: Exclusive locks could in some cases be picked up as shared locks -* Fixed: Digest auth for non-apache servers had a bug (still not actually tested - this well). - - -0.8-alpha (2009-05-30) ----------------------- - -* Changed: Renamed all exceptions! This is a compatibility break. Every - Exception now follows Sabre_DAV_Exception_FileNotFound convention instead of - Sabre_DAV_FileNotFoundException. -* Added: Browser plugin now allows uploading and creating directories straight - from the browser. -* Added: 12 more unittests -* Fixed: Locking bug, which became prevalent on Windows Vista. -* Fixed: Netdrive support -* Fixed: TemporaryFileFilter filtered out too many files. Fixed some of the - regexes. -* Fixed: Added README and ChangeLog to package - - -0.7-alpha (2009-03-29) ----------------------- - -* Added: System to return complex properties from PROPFIND. -* Added: support for {DAV:}supportedlock. -* Added: support for {DAV:}lockdiscovery. -* Added: 6 new tests. -* Added: New plugin system. -* Added: Simple HTML directory plugin, for browser access. -* Added: Server class now sends back standard pre-condition error xml bodies. - This was new since RFC4918. -* Added: Sabre_DAV_Tree_Aggregrate, which can 'host' multiple Tree objects into - one. -* Added: simple basis for HTTP REPORT method. This method is not used yet, but - can be used by plugins to add reports. -* Changed: ->getSize is only called for files, no longer for collections. r303 -* Changed: Sabre_DAV_FilterTree is now Sabre_DAV_Tree_Filter -* Changed: Sabre_DAV_TemporaryFileFilter is now called - Sabre_DAV_Tree_TemporaryFileFilter. -* Changed: removed functions (get(/set)HTTPRequest(/Response)) from Server - class, and using a public property instead. -* Fixed: bug related to parsing proppatch and propfind requests. Didn't show up - in most clients, but it needed fixing regardless. (r255) -* Fixed: auth-int is now properly supported within HTTP Digest. -* Fixed: Using application/xml for a mimetype vs. text/xml as per RFC4918 sec - 8.2. -* Fixed: TemporaryFileFilter now lets through GET's if they actually exist on - the backend. (r274) -* FIxed: Some methods didn't get passed through in the FilterTree (r283). -* Fixed: LockManager is now slightly more complex, Tree classes slightly less. - (r287) - - -0.6-alpha (2009-02-16) ----------------------- - -* Added: Now uses streams for files, instead of strings. This means it won't - require to hold entire files in memory, which can be an issue if you're - dealing with big files. Note that this breaks compatibility for put() and - createFile methods. -* Added: HTTP Digest Authentication helper class. -* Added: Support for HTTP Range header -* Added: Support for ETags within If: headers -* Added: The API can now return ETags and override the default Content-Type -* Added: starting with basic framework for unittesting, using PHPUnit. -* Added: 49 unittests. -* Added: Abstraction for the HTTP request. -* Updated: Using Clark Notation for tags in properties. This means tags are - serialized as {namespace}tagName instead of namespace#tagName -* Fixed: HTTP_BasicAuth class now works as expected. -* Fixed: DAV_Server uses / for a default baseUrl. -* Fixed: Last modification date is no longer ignored in PROPFIND. -* Fixed: PROPFIND now sends back information about the requestUri even when - "Depth: 1" is specified. - - -0.5-alpha (2009-01-14) ----------------------- - -* Added: Added a very simple example for implementing a mapping to PHP file - streams. This should allow easy implementation of for example a WebDAV to FTP - proxy. -* Added: HTTP Basic Authentication helper class. -* Added: Sabre_HTTP_Response class. This centralizes HTTP operations and will be - a start towards the creating of a testing framework. -* Updated: Backwards compatibility break: all require_once() statements are - removed from all the files. It is now recommended to use autoloading of - classes, or just including lib/Sabre.includes.php. This fix was made to allow - easier integration into applications not using this standard inclusion model. -* Updated: Better in-file documentation. -* Updated: Sabre_DAV_Tree can now work with Sabre_DAV_LockManager. -* Updated: Fixes a shared-lock bug. -* Updated: Removed ?> from the bottom of each php file. -* Updated: Split up some operations from Sabre_DAV_Server to - Sabre_HTTP_Response. -* Fixed: examples are now actually included in the pear package. - - -0.4-alpha (2008-11-05) ----------------------- - -* Passes all litmus tests! -* Added: more examples -* Added: Custom property support -* Added: Shared lock support -* Added: Depth support to locks -* Added: Locking on unmapped urls (non-existent nodes) -* Fixed: Advertising as WebDAV class 3 support - - -0.3-alpha (2008-06-29) ----------------------- - -* Fully working in MS Windows clients. -* Added: temporary file filter: support for smultron files. -* Added: Phing build scripts -* Added: PEAR package -* Fixed: MOVE bug identified using finder. -* Fixed: Using gzuncompress instead of gzdecode in the temporary file filter. - This seems more common. - - -0.2-alpha (2008-05-27) ----------------------- - -* Somewhat working in Windows clients -* Added: Working PROPPATCH method (doesn't support custom properties yet) -* Added: Temporary filename handling system -* Added: Sabre_DAV_IQuota to return quota information -* Added: PROPFIND now reads the request body and only supplies the requested - properties - - -0.1-alpha (2008-04-04) ----------------------- - -* First release! -* Passes litmus: basic, http and copymove test. -* Fully working in Finder and DavFS2. - -Project started: 2007-12-13 - -[vobj]: http://sabre.io/vobject/ -[evnt]: http://sabre.io/event/ -[http]: http://sabre.io/http/ -[uri]: http://sabre.io/uri/ -[xml]: http://sabre.io/xml/ -[mi20]: http://sabre.io/dav/upgrade/1.8-to-2.0/ -[rfc6638]: http://tools.ietf.org/html/rfc6638 "CalDAV Scheduling" -[rfc7240]: http://tools.ietf.org/html/rfc7240 -[calendar-availability]: https://tools.ietf.org/html/draft-daboo-calendar-availability-05 diff --git a/vendor/sabre/dav/LICENSE b/vendor/sabre/dav/LICENSE deleted file mode 100644 index fd3539e33..000000000 --- a/vendor/sabre/dav/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (C) 2007-2016 fruux GmbH (https://fruux.com/). - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of SabreDAV nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/sabre/dav/README.md b/vendor/sabre/dav/README.md deleted file mode 100644 index 278187b55..000000000 --- a/vendor/sabre/dav/README.md +++ /dev/null @@ -1,29 +0,0 @@ -![sabre's logo](http://sabre.io/img/logo.png) SabreDAV -====================================================== - -Introduction ------------- - -SabreDAV is the most popular WebDAV framework for PHP. Use it to create WebDAV, CalDAV and CardDAV servers. - -Full documentation can be found on the website: - -http://sabre.io/ - -Build status ------------- - -| branch | status | minimum PHP version | -| ------------ | ------ | ------------------- | -| master | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=master)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.5 | -| 3.0 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=3.0)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 2.1 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=2.1)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 2.0 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=2.0)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.4 | -| 1.8 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.8)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | -| 1.7 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.7)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | -| 1.6 | [![Build Status](https://travis-ci.org/fruux/sabre-dav.svg?branch=1.6)](https://travis-ci.org/fruux/sabre-dav) | PHP 5.3 | - -Made at fruux -------------- - -SabreDAV is being developed by [fruux](https://fruux.com/). Drop us a line for commercial services or enterprise support. diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php index 82b1e7530..c4ba20941 100755 --- a/vendor/sabre/dav/bin/build.php +++ b/vendor/sabre/dav/bin/build.php @@ -110,7 +110,7 @@ function test() { echo " Running all unittests.\n"; echo " This may take a while.\n\n"; - system(__DIR__ . '/phpunit --configuration ' . $baseDir . '/tests/phpunit.xml --stop-on-failure', $code); + system(__DIR__ . '/phpunit --configuration ' . $baseDir . '/tests/phpunit.xml.dist --stop-on-failure', $code); if ($code != 0) { echo "PHPUnit reported error code $code\n"; die(1); diff --git a/vendor/sabre/dav/bin/migrateto17.php b/vendor/sabre/dav/bin/migrateto17.php index a1173c584..3ccf0a380 100755 --- a/vendor/sabre/dav/bin/migrateto17.php +++ b/vendor/sabre/dav/bin/migrateto17.php @@ -3,7 +3,7 @@ echo "SabreDAV migrate script for version 1.7\n"; -if ($argc < 2) { +if ($argc<2) { echo <<<HELLO @@ -35,12 +35,12 @@ HELLO; // There's a bunch of places where the autoloader could be, so we'll try all of // them. -$paths = [ +$paths = array( __DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php', -]; +); -foreach ($paths as $path) { +foreach($paths as $path) { if (file_exists($path)) { include $path; break; @@ -48,8 +48,8 @@ foreach ($paths as $path) { } $dsn = $argv[1]; -$user = isset($argv[2]) ? $argv[2] : null; -$pass = isset($argv[3]) ? $argv[3] : null; +$user = isset($argv[2])?$argv[2]:null; +$pass = isset($argv[3])?$argv[3]:null; echo "Connecting to database: " . $dsn . "\n"; @@ -67,32 +67,32 @@ if (!$row) { exit(-1); } -$requiredFields = [ +$requiredFields = array( 'id', 'calendardata', 'uri', 'calendarid', 'lastmodified', -]; +); -foreach ($requiredFields as $requiredField) { - if (!array_key_exists($requiredField, $row)) { +foreach($requiredFields as $requiredField) { + if (!array_key_exists($requiredField,$row)) { echo "Error: The current 'calendarobjects' table was missing a field we expected to exist.\n"; echo "For safety reasons, this process is stopped.\n"; exit(-1); } } -$fields17 = [ +$fields17 = array( 'etag', 'size', 'componenttype', 'firstoccurence', 'lastoccurence', -]; +); $found = 0; -foreach ($fields17 as $field) { +foreach($fields17 as $field) { if (array_key_exists($field, $row)) { $found++; } @@ -102,7 +102,7 @@ if ($found === 0) { echo "The database had the 1.6 schema. Table will now be altered.\n"; echo "This may take some time for large tables\n"; - switch ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : @@ -150,7 +150,7 @@ $stmt = $pdo->prepare('UPDATE calendarobjects SET etag = ?, size = ?, componentt echo "Total records found: " . $result->rowCount() . "\n"; $done = 0; $total = $result->rowCount(); -while ($row = $result->fetch()) { +while($row = $result->fetch()) { try { $newData = getDenormalizedData($row['calendardata']); @@ -161,14 +161,14 @@ while ($row = $result->fetch()) { echo "This record is ignored, you should inspect it to see if there's anything wrong.\n===\n"; continue; } - $stmt->execute([ + $stmt->execute(array( $newData['etag'], $newData['size'], $newData['componentType'], $newData['firstOccurence'], $newData['lastOccurence'], $row['id'], - ]); + )); $done++; if ($done % 500 === 0) { @@ -188,7 +188,7 @@ if (array_key_exists('transparent', $row)) { echo "Adding the 'transparent' field to the calendars table\n"; - switch ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : $pdo->exec("ALTER TABLE calendars ADD transparent TINYINT(1) NOT NULL DEFAULT '0'"); @@ -229,8 +229,8 @@ function getDenormalizedData($calendarData) { $component = null; $firstOccurence = null; $lastOccurence = null; - foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + foreach($vObject->getComponents() as $component) { + if ($component->name!=='VTIMEZONE') { $componentType = $component->name; break; } @@ -262,7 +262,7 @@ function getDenormalizedData($calendarData) { $lastOccurence = $maxDate->getTimeStamp(); } else { $end = $it->getDtEnd(); - while ($it->valid() && $end < $maxDate) { + while($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); @@ -273,12 +273,12 @@ function getDenormalizedData($calendarData) { } } - return [ - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, + return array( + 'etag' => md5($calendarData), + 'size' => strlen($calendarData), + 'componentType' => $componentType, 'firstOccurence' => $firstOccurence, 'lastOccurence' => $lastOccurence, - ]; + ); } diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php index f42c4cf88..c81ee5cca 100755 --- a/vendor/sabre/dav/bin/migrateto21.php +++ b/vendor/sabre/dav/bin/migrateto21.php @@ -169,10 +169,6 @@ switch ($driver) { ) '); break; - $pdo->exec(' - CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri); - '); - break; } echo "Done.\n"; diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php new file mode 100755 index 000000000..59732b511 --- /dev/null +++ b/vendor/sabre/dav/bin/migrateto32.php @@ -0,0 +1,268 @@ +#!/usr/bin/env php +<?php + +echo "SabreDAV migrate script for version 3.2\n"; + +if ($argc < 2) { + + echo <<<HELLO + +This script help you migrate from a 3.1 database to 3.2 and later + +Changes: +* Created a new calendarinstances table to support calendar sharing. +* Remove a lot of columns from calendars. + +Keep in mind that ALTER TABLE commands will be executed. If you have a large +dataset this may mean that this process takes a while. + +Make a back-up first. This script has been tested, but the amount of +potential variants are extremely high, so it's impossible to deal with every +possible situation. + +In the worst case, you will lose all your data. This is not an overstatement. + +Lastly, if you are upgrading from an older version than 3.1, make sure you run +the earlier migration script first. Migration scripts must be ran in order. + +Usage: + +php {$argv[0]} [pdo-dsn] [username] [password] + +For example: + +php {$argv[0]} "mysql:host=localhost;dbname=sabredav" root password +php {$argv[0]} sqlite:data/sabredav.db + +HELLO; + + exit(); + +} + +// There's a bunch of places where the autoloader could be, so we'll try all of +// them. +$paths = [ + __DIR__ . '/../vendor/autoload.php', + __DIR__ . '/../../../autoload.php', +]; + +foreach ($paths as $path) { + if (file_exists($path)) { + include $path; + break; + } +} + +$dsn = $argv[1]; +$user = isset($argv[2]) ? $argv[2] : null; +$pass = isset($argv[3]) ? $argv[3] : null; + +$backupPostfix = time(); + +echo "Connecting to database: " . $dsn . "\n"; + +$pdo = new PDO($dsn, $user, $pass); +$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + +$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); + +switch ($driver) { + + case 'mysql' : + echo "Detected MySQL.\n"; + break; + case 'sqlite' : + echo "Detected SQLite.\n"; + break; + default : + echo "Error: unsupported driver: " . $driver . "\n"; + die(-1); +} + +echo "Creating 'calendarinstances'\n"; +$addValueType = false; +try { + $result = $pdo->query('SELECT * FROM calendarinstances LIMIT 1'); + $result->fetch(\PDO::FETCH_ASSOC); + echo "calendarinstances exists. Assuming this part of the migration has already been done.\n"; +} catch (Exception $e) { + echo "calendarinstances does not yet exist. Creating table and migrating data.\n"; + + switch ($driver) { + case 'mysql' : + $pdo->exec(<<<SQL +CREATE TABLE calendarinstances ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + calendarid INTEGER UNSIGNED NOT NULL, + principaluri VARBINARY(100), + access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite', + displayname VARCHAR(100), + uri VARBINARY(200), + description TEXT, + calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', + calendarcolor VARBINARY(10), + timezone TEXT, + transparent TINYINT(1) NOT NULL DEFAULT '0', + share_href VARBINARY(100), + share_displayname VARCHAR(100), + share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid', + UNIQUE(principaluri, uri), + UNIQUE(calendarid, principaluri), + UNIQUE(calendarid, share_href) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +SQL + ); + $pdo->exec(" +INSERT INTO calendarinstances + ( + calendarid, + principaluri, + access, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent + ) +SELECT + id, + principaluri, + 1, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent +FROM calendars +"); + break; + case 'sqlite' : + $pdo->exec(<<<SQL +CREATE TABLE calendarinstances ( + id integer primary key asc NOT NULL, + calendarid integer, + principaluri text, + access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1', + displayname text, + uri text NOT NULL, + description text, + calendarorder integer, + calendarcolor text, + timezone text, + transparent bool, + share_href text, + share_displayname text, + share_invitestatus integer DEFAULT '2', + UNIQUE (principaluri, uri), + UNIQUE (calendarid, principaluri), + UNIQUE (calendarid, share_href) +); +SQL + ); + $pdo->exec(" +INSERT INTO calendarinstances + ( + calendarid, + principaluri, + access, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent + ) +SELECT + id, + principaluri, + 1, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent +FROM calendars +"); + break; + } + +} +try { + $result = $pdo->query('SELECT * FROM calendars LIMIT 1'); + $row = $result->fetch(\PDO::FETCH_ASSOC); + + if (!$row) { + echo "Source table is empty.\n"; + $migrateCalendars = true; + } + + $columnCount = count($row); + if ($columnCount === 3) { + echo "The calendars table has 3 columns already. Assuming this part of the migration was already done.\n"; + $migrateCalendars = false; + } else { + echo "The calendars table has " . $columnCount . " columns.\n"; + $migrateCalendars = true; + } + +} catch (Exception $e) { + echo "calendars table does not exist. This is a major problem. Exiting.\n"; + exit(-1); +} + +if ($migrateCalendars) { + + $calendarBackup = 'calendars_3_1_' . $backupPostfix; + echo "Backing up 'calendars' to '", $calendarBackup, "'\n"; + + switch ($driver) { + case 'mysql' : + $pdo->exec('RENAME TABLE calendars TO ' . $calendarBackup); + break; + case 'sqlite' : + $pdo->exec('ALTER TABLE calendars RENAME TO ' . $calendarBackup); + break; + + } + + echo "Creating new calendars table.\n"; + switch ($driver) { + case 'mysql' : + $pdo->exec(<<<SQL +CREATE TABLE calendars ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1', + components VARBINARY(20) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +SQL +); + break; + case 'sqlite' : + $pdo->exec(<<<SQL +CREATE TABLE calendars ( + id integer primary key asc NOT NULL, + synctoken integer DEFAULT 1 NOT NULL, + components text NOT NULL +); +SQL + ); + break; + + } + + echo "Migrating data from old to new table\n"; + + $pdo->exec(<<<SQL +INSERT INTO calendars (id, synctoken, components) SELECT id, synctoken, COALESCE(components,"VEVENT,VTODO,VJOURNAL") as components FROM $calendarBackup +SQL + ); + +} + + +echo "Upgrade to 3.2 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/naturalselection b/vendor/sabre/dav/bin/naturalselection index 52720e31e..7e20439c1 100755 --- a/vendor/sabre/dav/bin/naturalselection +++ b/vendor/sabre/dav/bin/naturalselection @@ -107,7 +107,7 @@ def main(): parser.add_option( '-m', '--min-erase', help="Minimum number of bytes to erase when the threshold is reached. " + - "Setting this option higher will reduce the amount of times the cache directory will need to be scanned. " + + "Setting this option higher will reduce the number of times the cache directory will need to be scanned. " + "(the default is 1073741824, which is 1GB.)", type="int", dest="min_erase", diff --git a/vendor/sabre/dav/examples/sql/mysql.addressbook.sql b/vendor/sabre/dav/examples/sql/mysql.addressbook.sql index 9ec88babe..5ec8428a7 100644 --- a/vendor/sabre/dav/examples/sql/mysql.addressbook.sql +++ b/vendor/sabre/dav/examples/sql/mysql.addressbook.sql @@ -6,7 +6,7 @@ CREATE TABLE addressbooks ( description TEXT, synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', UNIQUE(principaluri(100), uri(100)) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE cards ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -16,7 +16,7 @@ CREATE TABLE cards ( lastmodified INT(11) UNSIGNED, etag VARBINARY(32), size INT(11) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE addressbookchanges ( id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -25,4 +25,4 @@ CREATE TABLE addressbookchanges ( addressbookid INT(11) UNSIGNED NOT NULL, operation TINYINT(1) NOT NULL, INDEX addressbookid_synctoken (addressbookid, synctoken) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/vendor/sabre/dav/examples/sql/mysql.calendars.sql b/vendor/sabre/dav/examples/sql/mysql.calendars.sql index d41f11076..21c5bcb44 100644 --- a/vendor/sabre/dav/examples/sql/mysql.calendars.sql +++ b/vendor/sabre/dav/examples/sql/mysql.calendars.sql @@ -10,22 +10,34 @@ CREATE TABLE calendarobjects ( firstoccurence INT(11) UNSIGNED, lastoccurence INT(11) UNSIGNED, uid VARBINARY(200), - UNIQUE(calendarid, uri) + UNIQUE(calendarid, uri), + INDEX calendarid_time (calendarid, firstoccurence) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE calendars ( id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1', + components VARBINARY(21) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE calendarinstances ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + calendarid INTEGER UNSIGNED NOT NULL, principaluri VARBINARY(100), + access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite', displayname VARCHAR(100), uri VARBINARY(200), - synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1', description TEXT, calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', calendarcolor VARBINARY(10), timezone TEXT, - components VARBINARY(21), transparent TINYINT(1) NOT NULL DEFAULT '0', - UNIQUE(principaluri, uri) + share_href VARBINARY(100), + share_displayname VARCHAR(100), + share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid', + UNIQUE(principaluri, uri), + UNIQUE(calendarid, principaluri), + UNIQUE(calendarid, share_href) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; CREATE TABLE calendarchanges ( diff --git a/vendor/sabre/dav/examples/sql/pgsql.calendars.sql b/vendor/sabre/dav/examples/sql/pgsql.calendars.sql index d31084b86..67dc41a5a 100644 --- a/vendor/sabre/dav/examples/sql/pgsql.calendars.sql +++ b/vendor/sabre/dav/examples/sql/pgsql.calendars.sql @@ -1,27 +1,6 @@ -CREATE TABLE calendars ( - id SERIAL NOT NULL, - principaluri VARCHAR(100), - displayname VARCHAR(100), - uri VARCHAR(200), - synctoken INTEGER NOT NULL DEFAULT 1, - description TEXT, - calendarorder INTEGER NOT NULL DEFAULT 0, - calendarcolor VARCHAR(10), - timezone TEXT, - components VARCHAR(20), - uid VARCHAR(200), - transparent SMALLINT NOT NULL DEFAULT '0' -); - -ALTER TABLE ONLY calendars - ADD CONSTRAINT calendars_pkey PRIMARY KEY (id); - -CREATE UNIQUE INDEX calendars_ukey - ON calendars USING btree (principaluri, uri); - CREATE TABLE calendarobjects ( id SERIAL NOT NULL, - calendardata TEXT, + calendardata BYTEA, uri VARCHAR(200), calendarid INTEGER NOT NULL, lastmodified INTEGER, @@ -39,9 +18,46 @@ ALTER TABLE ONLY calendarobjects CREATE UNIQUE INDEX calendarobjects_ukey ON calendarobjects USING btree (calendarid, uri); -ALTER TABLE ONLY calendarobjects - ADD CONSTRAINT calendarobjects_calendarid_fkey FOREIGN KEY (calendarid) REFERENCES calendars(id) - ON DELETE CASCADE; + +CREATE TABLE calendars ( + id SERIAL NOT NULL, + synctoken INTEGER NOT NULL DEFAULT 1, + components VARCHAR(21) +); + +ALTER TABLE ONLY calendars + ADD CONSTRAINT calendars_pkey PRIMARY KEY (id); + + +CREATE TABLE calendarinstances ( + id SERIAL NOT NULL, + calendarid INTEGER NOT NULL, + principaluri VARCHAR(100), + access SMALLINT NOT NULL DEFAULT '1', -- '1 = owner, 2 = read, 3 = readwrite' + displayname VARCHAR(100), + uri VARCHAR(200), + description TEXT, + calendarorder INTEGER NOT NULL DEFAULT 0, + calendarcolor VARCHAR(10), + timezone TEXT, + transparent SMALLINT NOT NULL DEFAULT '0', + share_href VARCHAR(100), + share_displayname VARCHAR(100), + share_invitestatus SMALLINT NOT NULL DEFAULT '2' -- '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid' +); + +ALTER TABLE ONLY calendarinstances + ADD CONSTRAINT calendarinstances_pkey PRIMARY KEY (id); + +CREATE UNIQUE INDEX calendarinstances_principaluri_uri + ON calendarinstances USING btree (principaluri, uri); + + +CREATE UNIQUE INDEX calendarinstances_principaluri_calendarid + ON calendarinstances USING btree (principaluri, calendarid); + +CREATE UNIQUE INDEX calendarinstances_principaluri_share_href + ON calendarinstances USING btree (principaluri, share_href); CREATE TABLE calendarsubscriptions ( id SERIAL NOT NULL, @@ -78,10 +94,6 @@ ALTER TABLE ONLY calendarchanges CREATE INDEX calendarchanges_calendarid_synctoken_ix ON calendarchanges USING btree (calendarid, synctoken); -ALTER TABLE ONLY calendarchanges - ADD CONSTRAINT calendarchanges_calendar_fk FOREIGN KEY (calendarid) REFERENCES calendars(id) - ON DELETE CASCADE; - CREATE TABLE schedulingobjects ( id SERIAL NOT NULL, principaluri VARCHAR(255), diff --git a/vendor/sabre/dav/examples/sql/pgsql.principals.sql b/vendor/sabre/dav/examples/sql/pgsql.principals.sql index 9157acde0..5a65260a2 100644 --- a/vendor/sabre/dav/examples/sql/pgsql.principals.sql +++ b/vendor/sabre/dav/examples/sql/pgsql.principals.sql @@ -23,14 +23,6 @@ ALTER TABLE ONLY groupmembers CREATE UNIQUE INDEX groupmembers_ukey ON groupmembers USING btree (principal_id, member_id); -ALTER TABLE ONLY groupmembers - ADD CONSTRAINT groupmembers_principal_id_fkey FOREIGN KEY (principal_id) REFERENCES principals(id) - ON DELETE CASCADE; - -ALTER TABLE ONLY groupmembers - ADD CONSTRAINT groupmembers_member_id_id_fkey FOREIGN KEY (member_id) REFERENCES principals(id) - ON DELETE CASCADE; - INSERT INTO principals (uri,email,displayname) VALUES ('principals/admin', 'admin@example.org','Administrator'), ('principals/admin/calendar-proxy-read', null, null), diff --git a/vendor/sabre/dav/examples/sql/sqlite.calendars.sql b/vendor/sabre/dav/examples/sql/sqlite.calendars.sql index a8654032d..1c8070496 100644 --- a/vendor/sabre/dav/examples/sql/sqlite.calendars.sql +++ b/vendor/sabre/dav/examples/sql/sqlite.calendars.sql @@ -14,16 +14,28 @@ CREATE TABLE calendarobjects ( CREATE TABLE calendars ( id integer primary key asc NOT NULL, - principaluri text NOT NULL, + synctoken integer DEFAULT 1 NOT NULL, + components text NOT NULL +); + +CREATE TABLE calendarinstances ( + id integer primary key asc NOT NULL, + calendarid integer NOT NULL, + principaluri text NULL, + access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1', displayname text, uri text NOT NULL, - synctoken integer DEFAULT 1 NOT NULL, description text, calendarorder integer, calendarcolor text, timezone text, - components text NOT NULL, - transparent bool + transparent bool, + share_href text, + share_displayname text, + share_invitestatus integer DEFAULT '2', + UNIQUE (principaluri, uri), + UNIQUE (calendarid, principaluri), + UNIQUE (calendarid, share_href) ); CREATE TABLE calendarchanges ( diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php index 7513fb60d..bd8ee7602 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php @@ -44,10 +44,12 @@ interface BackendInterface { * If the creation was a success, an id must be returned that can be used to * reference this calendar in other methods, such as updateCalendar. * + * The id can be any type, including ints, strings, objects or array. + * * @param string $principalUri * @param string $calendarUri * @param array $properties - * @return void + * @return mixed */ function createCalendar($principalUri, $calendarUri, array $properties); @@ -63,7 +65,7 @@ interface BackendInterface { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch * @return void */ diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php index 19b9b22a7..9c00a89ef 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/NotificationSupport.php @@ -43,4 +43,19 @@ interface NotificationSupport extends BackendInterface { */ function deleteNotification($principalUri, NotificationInterface $notification); + /** + * This method is called when a user replied to a request to share. + * + * If the user chose to accept the share, this method should return the + * newly created calendar url. + * + * @param string href The sharee who is replying (often a mailto: address) + * @param int status One of the SharingPlugin::STATUS_* constants + * @param string $calendarUri The url to the calendar thats being shared + * @param string $inReplyTo The unique id this message is a response to + * @param string $summary A description of the reply + * @return null|string + */ + function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); + } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php index 76b69dc6e..b1c013d62 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php @@ -2,10 +2,11 @@ namespace Sabre\CalDAV\Backend; -use Sabre\VObject; use Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\Exception\Forbidden; +use Sabre\VObject; +use Sabre\DAV\Xml\Element\Sharee; /** * PDO CalDAV backend @@ -17,7 +18,12 @@ use Sabre\DAV\Exception\Forbidden; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport { +class PDO extends AbstractBackend + implements + SyncSupport, + SubscriptionSupport, + SchedulingSupport, + SharingSupport { /** * We need to specify a max date, because we need to stop *somewhere* @@ -44,6 +50,16 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S public $calendarTableName = 'calendars'; /** + * The table name that will be used for calendars instances. + * + * A single calendar can have multiple instances, if the calendar is + * shared. + * + * @var string + */ + public $calendarInstancesTableName = 'calendarinstances'; + + /** * The table name that will be used for calendar objects * * @var string @@ -140,16 +156,23 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S function getCalendarsForUser($principalUri) { $fields = array_values($this->propertyMap); - $fields[] = 'id'; + $fields[] = 'calendarid'; $fields[] = 'uri'; $fields[] = 'synctoken'; $fields[] = 'components'; $fields[] = 'principaluri'; $fields[] = 'transparent'; + $fields[] = 'access'; // Making fields a comma-delimited list $fields = implode(', ', $fields); - $stmt = $this->pdo->prepare("SELECT " . $fields . " FROM " . $this->calendarTableName . " WHERE principaluri = ? ORDER BY calendarorder ASC"); + $stmt = $this->pdo->prepare(<<<SQL +SELECT {$this->calendarInstancesTableName}.id as id, $fields FROM {$this->calendarInstancesTableName} + LEFT JOIN {$this->calendarTableName} ON + {$this->calendarInstancesTableName}.calendarid = {$this->calendarTableName}.id +WHERE principaluri = ? ORDER BY calendarorder ASC +SQL + ); $stmt->execute([$principalUri]); $calendars = []; @@ -161,15 +184,27 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S } $calendar = [ - 'id' => $row['id'], + 'id' => [(int)$row['calendarid'], (int)$row['id']], 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken'] ? $row['synctoken'] : '0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components), '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), + 'share-resource-uri' => '/ns/share/' . $row['calendarid'], ]; + $calendar['share-access'] = (int)$row['access']; + // 1 = owner, 2 = readonly, 3 = readwrite + if ($row['access'] > 1) { + // We need to find more information about the original owner. + //$stmt2 = $this->pdo->prepare('SELECT principaluri FROM ' . $this->calendarInstancesTableName . ' WHERE access = 1 AND id = ?'); + //$stmt2->execute([$row['id']]); + + // read-only is for backwards compatbility. Might go away in + // the future. + $calendar['read-only'] = (int)$row['access'] === \Sabre\DAV\Sharing\Plugin::ACCESS_READ; + } foreach ($this->propertyMap as $xmlName => $dbName) { $calendar[$xmlName] = $row[$dbName]; @@ -199,31 +234,38 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S $fieldNames = [ 'principaluri', 'uri', - 'synctoken', 'transparent', + 'calendarid', ]; $values = [ ':principaluri' => $principalUri, ':uri' => $calendarUri, - ':synctoken' => 1, ':transparent' => 0, ]; - // Default value + $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; - $fieldNames[] = 'components'; if (!isset($properties[$sccs])) { - $values[':components'] = 'VEVENT,VTODO'; + // Default value + $components = 'VEVENT,VTODO'; } else { if (!($properties[$sccs] instanceof CalDAV\Xml\Property\SupportedCalendarComponentSet)) { throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet'); } - $values[':components'] = implode(',', $properties[$sccs]->getValue()); + $components = implode(',', $properties[$sccs]->getValue()); } $transp = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; if (isset($properties[$transp])) { - $values[':transparent'] = $properties[$transp]->getValue() === 'transparent'; + $values[':transparent'] = $properties[$transp]->getValue() === 'transparent' ? 1 : 0; } + $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarTableName . " (synctoken, components) VALUES (1, ?)"); + $stmt->execute([$components]); + + $calendarId = $this->pdo->lastInsertId( + $this->calendarTableName . '_id_seq' + ); + + $values[':calendarid'] = $calendarId; foreach ($this->propertyMap as $xmlName => $dbName) { if (isset($properties[$xmlName])) { @@ -233,10 +275,14 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S } } - $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarInstancesTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); + $stmt->execute($values); - return $this->pdo->lastInsertId(); + return [ + $calendarId, + $this->pdo->lastInsertId($this->calendarInstancesTableName . '_id_seq') + ]; } @@ -252,16 +298,21 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S * * Read the PropPatch documenation for more info and examples. * - * @param string $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch * @return void */ function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $supportedProperties = array_keys($this->propertyMap); $supportedProperties[] = '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp'; - $propPatch->handle($supportedProperties, function($mutations) use ($calendarId) { + $propPatch->handle($supportedProperties, function($mutations) use ($calendarId, $instanceId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { @@ -282,8 +333,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S $valuesSql[] = $fieldName . ' = ?'; } - $stmt = $this->pdo->prepare("UPDATE " . $this->calendarTableName . " SET " . implode(', ', $valuesSql) . " WHERE id = ?"); - $newValues['id'] = $calendarId; + $stmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET " . implode(', ', $valuesSql) . " WHERE id = ?"); + $newValues['id'] = $instanceId; $stmt->execute(array_values($newValues)); $this->addChange($calendarId, "", 2); @@ -297,19 +348,49 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S /** * Delete a calendar and all it's objects * - * @param string $calendarId + * @param mixed $calendarId * @return void */ function deleteCalendar($calendarId) { - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); - $stmt->execute([$calendarId]); + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarTableName . ' WHERE id = ?'); - $stmt->execute([$calendarId]); + $stmt = $this->pdo->prepare('SELECT access FROM ' . $this->calendarInstancesTableName . ' where id = ?'); + $stmt->execute([$instanceId]); + $access = (int)$stmt->fetchColumn(); + + if ($access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { + + /** + * If the user is the owner of the calendar, we delete all data and all + * instances. + **/ + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); + $stmt->execute([$calendarId]); + + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarChangesTableName . ' WHERE calendarid = ?'); + $stmt->execute([$calendarId]); + + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE calendarid = ?'); + $stmt->execute([$calendarId]); + + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarTableName . ' WHERE id = ?'); + $stmt->execute([$calendarId]); + + } else { + + /** + * If it was an instance of a shared calendar, we only delete that + * instance. + */ + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + $stmt->execute([$instanceId]); + + } - $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarChangesTableName . ' WHERE calendarid = ?'); - $stmt->execute([$calendarId]); } @@ -341,11 +422,16 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S * used/fetched to determine these numbers. If both are specified the * amount of times this is needed is reduced by a great degree. * - * @param string $calendarId + * @param mixed $calendarId * @return array */ function getCalendarObjects($calendarId) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ?'); $stmt->execute([$calendarId]); @@ -354,9 +440,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'lastmodified' => $row['lastmodified'], + 'lastmodified' => (int)$row['lastmodified'], 'etag' => '"' . $row['etag'] . '"', - 'calendarid' => $row['calendarid'], 'size' => (int)$row['size'], 'component' => strtolower($row['componenttype']), ]; @@ -378,12 +463,17 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S * * This method must return null if the object did not exist. * - * @param string $calendarId + * @param mixed $calendarId * @param string $objectUri * @return array|null */ function getCalendarObject($calendarId, $objectUri) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -393,9 +483,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S return [ 'id' => $row['id'], 'uri' => $row['uri'], - 'lastmodified' => $row['lastmodified'], + 'lastmodified' => (int)$row['lastmodified'], 'etag' => '"' . $row['etag'] . '"', - 'calendarid' => $row['calendarid'], 'size' => (int)$row['size'], 'calendardata' => $row['calendardata'], 'component' => strtolower($row['componenttype']), @@ -417,6 +506,11 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S */ function getMultipleCalendarObjects($calendarId, array $uris) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri IN ('; // Inserting a whole bunch of question marks $query .= implode(',', array_fill(0, count($uris), '?')); @@ -431,9 +525,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'lastmodified' => $row['lastmodified'], + 'lastmodified' => (int)$row['lastmodified'], 'etag' => '"' . $row['etag'] . '"', - 'calendarid' => $row['calendarid'], 'size' => (int)$row['size'], 'calendardata' => $row['calendardata'], 'component' => strtolower($row['componenttype']), @@ -465,6 +558,11 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S */ function createCalendarObject($calendarId, $objectUri, $calendarData) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $extraData = $this->getDenormalizedData($calendarData); $stmt = $this->pdo->prepare('INSERT INTO ' . $this->calendarObjectTableName . ' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)'); @@ -506,6 +604,11 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S */ function updateCalendarObject($calendarId, $objectUri, $calendarData) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $extraData = $this->getDenormalizedData($calendarData); $stmt = $this->pdo->prepare('UPDATE ' . $this->calendarObjectTableName . ' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?'); @@ -583,6 +686,10 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S } } + + // Ensure Occurence values are positive + if ($firstOccurence < 0) $firstOccurence = 0; + if ($lastOccurence < 0) $lastOccurence = 0; } // Destroy circular references to PHP will GC the object. @@ -604,12 +711,17 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S * * The object uri is only the basename, or filename and not a full path. * - * @param string $calendarId + * @param mixed $calendarId * @param string $objectUri * @return void */ function deleteCalendarObject($calendarId, $objectUri) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->calendarObjectTableName . ' WHERE calendarid = ? AND uri = ?'); $stmt->execute([$calendarId, $objectUri]); @@ -665,12 +777,17 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S * This specific implementation (for the PDO) backend optimizes filters on * specific components, and VEVENT time-ranges. * - * @param string $calendarId + * @param mixed $calendarId * @param array $filters * @return array */ function calendarQuery($calendarId, array $filters) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + $componentType = null; $requirePostFilter = true; $timeRange = null; @@ -766,14 +883,14 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport, S $query = <<<SQL SELECT - calendars.uri AS calendaruri, calendarobjects.uri as objecturi + calendar_instances.uri AS calendaruri, calendarobjects.uri as objecturi FROM $this->calendarObjectTableName AS calendarobjects LEFT JOIN - $this->calendarTableName AS calendars - ON calendarobjects.calendarid = calendars.id + $this->calendarInstancesTableName AS calendar_instances + ON calendarobjects.calendarid = calendar_instances.calendarid WHERE - calendars.principaluri = ? + calendar_instances.principaluri = ? AND calendarobjects.uid = ? SQL; @@ -837,7 +954,7 @@ SQL; * * The limit is 'suggestive'. You are free to ignore it. * - * @param string $calendarId + * @param mixed $calendarId * @param string $syncToken * @param int $syncLevel * @param int $limit @@ -845,6 +962,11 @@ SQL; */ function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + // Current synctoken $stmt = $this->pdo->prepare('SELECT synctoken FROM ' . $this->calendarTableName . ' WHERE id = ?'); $stmt->execute([ $calendarId ]); @@ -1043,7 +1165,9 @@ SQL; $stmt = $this->pdo->prepare("INSERT INTO " . $this->calendarSubscriptionsTableName . " (" . implode(', ', $fieldNames) . ") VALUES (" . implode(', ', array_keys($values)) . ")"); $stmt->execute($values); - return $this->pdo->lastInsertId(); + return $this->pdo->lastInsertId( + $this->calendarSubscriptionsTableName . '_id_seq' + ); } @@ -1207,4 +1331,179 @@ SQL; } + /** + * Updates the list of shares. + * + * @param mixed $calendarId + * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees + * @return void + */ + function updateInvites($calendarId, array $sharees) { + + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId'); + } + $currentInvites = $this->getInvites($calendarId); + list($calendarId, $instanceId) = $calendarId; + + $removeStmt = $this->pdo->prepare("DELETE FROM " . $this->calendarInstancesTableName . " WHERE calendarid = ? AND share_href = ? AND access IN (2,3)"); + $updateStmt = $this->pdo->prepare("UPDATE " . $this->calendarInstancesTableName . " SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?"); + + $insertStmt = $this->pdo->prepare(' +INSERT INTO ' . $this->calendarInstancesTableName . ' + ( + calendarid, + principaluri, + access, + displayname, + uri, + description, + calendarorder, + calendarcolor, + timezone, + transparent, + share_href, + share_displayname, + share_invitestatus + ) + SELECT + ?, + ?, + ?, + displayname, + ?, + description, + calendarorder, + calendarcolor, + timezone, + 1, + ?, + ?, + ? + FROM ' . $this->calendarInstancesTableName . ' WHERE id = ?'); + + foreach ($sharees as $sharee) { + + if ($sharee->access === \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS) { + // if access was set no NOACCESS, it means access for an + // existing sharee was removed. + $removeStmt->execute([$calendarId, $sharee->href]); + continue; + } + + if (is_null($sharee->principal)) { + // If the server could not determine the principal automatically, + // we will mark the invite status as invalid. + $sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_INVALID; + } else { + // Because sabre/dav does not yet have an invitation system, + // every invite is automatically accepted for now. + $sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED; + } + + foreach ($currentInvites as $oldSharee) { + + if ($oldSharee->href === $sharee->href) { + // This is an update + $sharee->properties = array_merge( + $oldSharee->properties, + $sharee->properties + ); + $updateStmt->execute([ + $sharee->access, + isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, + $sharee->inviteStatus ?: $oldSharee->inviteStatus, + $calendarId, + $sharee->href + ]); + continue 2; + } + + } + // If we got here, it means it was a new sharee + $insertStmt->execute([ + $calendarId, + $sharee->principal, + $sharee->access, + \Sabre\DAV\UUIDUtil::getUUID(), + $sharee->href, + isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null, + $sharee->inviteStatus ?: \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, + $instanceId + ]); + + } + + } + + /** + * Returns the list of people whom a calendar is shared with. + * + * Every item in the returned list must be a Sharee object with at + * least the following properties set: + * $href + * $shareAccess + * $inviteStatus + * + * and optionally: + * $properties + * + * @param mixed $calendarId + * @return \Sabre\DAV\Xml\Element\Sharee[] + */ + function getInvites($calendarId) { + + if (!is_array($calendarId)) { + throw new \InvalidArgumentException('The value passed to getInvites() is expected to be an array with a calendarId and an instanceId'); + } + list($calendarId, $instanceId) = $calendarId; + + $query = <<<SQL +SELECT + principaluri, + access, + share_href, + share_displayname, + share_invitestatus +FROM {$this->calendarInstancesTableName} +WHERE + calendarid = ? +SQL; + + $stmt = $this->pdo->prepare($query); + $stmt->execute([$calendarId]); + + $result = []; + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + + $result[] = new Sharee([ + 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']), + 'access' => (int)$row['access'], + /// Everyone is always immediately accepted, for now. + 'inviteStatus' => (int)$row['share_invitestatus'], + 'properties' => + !empty($row['share_displayname']) + ? [ '{DAV:}displayname' => $row['share_displayname'] ] + : [], + 'principal' => $row['principaluri'], + ]); + + } + return $result; + + } + + /** + * Publishes a calendar + * + * @param mixed $calendarId + * @param bool $value + * @return void + */ + function setPublishStatus($calendarId, $value) { + + throw new \Exception('Not implemented'); + + } + } diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php index 6a11b0ab1..8b6e074e0 100644 --- a/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SharingSupport.php @@ -5,231 +5,48 @@ namespace Sabre\CalDAV\Backend; /** * Adds support for sharing features to a CalDAV server. * - * Note: This feature is experimental, and may change in between different - * SabreDAV versions. + * CalDAV backends that implement this interface, must make the following + * modifications to getCalendarsForUser: * - * Early warning: Currently SabreDAV provides no implementation for this. This - * is, because in it's current state there is no elegant way to do this. - * The problem lies in the fact that a real CalDAV server with sharing support - * would first need email support (with invite notifications), and really also - * a browser-frontend that allows people to accept or reject these shares. - * - * In addition, the CalDAV backends are currently kept as independent as - * possible, and should not be aware of principals, email addresses or - * accounts. - * - * Adding an implementation for Sharing to standard-sabredav would contradict - * these goals, so for this reason this is currently not implemented, although - * it may very well in the future; but probably not before SabreDAV 2.0. - * - * The interface works however, so if you implement all this, and do it - * correctly sharing _will_ work. It's not particularly easy, and I _urge you_ - * to make yourself acquainted with the following document first: - * - * https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt - * - * An overview - * =========== - * - * Implementing this interface will allow a user to share his or her calendars - * to other users. Effectively, when a calendar is shared the calendar will - * show up in both the Sharer's and Sharee's calendar-home root. - * This interface adds a few methods that ensure that this happens, and there - * are also a number of new requirements in the base-class you must now follow. - * - * - * How it works - * ============ - * - * When a user shares a calendar, the updateShares() method will be called with - * a list of sharees that are now added, and a list of sharees that have been - * removed. - * Removal is instant, but when a sharee is added the sharee first gets a - * chance to accept or reject the invitation for a share. - * - * After a share is accepted, the calendar will be returned from - * getUserCalendars for both the sharer, and the sharee. - * - * If the sharee deletes the calendar, only their share gets deleted. When the - * owner deletes a calendar, it will be removed for everybody. - * - * - * Notifications - * ============= - * - * During all these sharing operations, a lot of notifications are sent back - * and forward. - * - * Whenever the list of sharees for a calendar has been changed (they have been - * added, removed or modified) all sharees should get a notification for this - * change. - * This notification is always represented by: - * - * Sabre\CalDAV\Notifications\Notification\Invite - * - * In the case of an invite, the sharee may reply with an 'accept' or - * 'decline'. These are always represented by: - * - * Sabre\CalDAV\Notifications\Notification\InviteReply - * - * - * Calendar access by sharees - * ========================== - * - * As mentioned earlier, shared calendars must now also be returned for - * getCalendarsForUser for sharees. A few things change though. - * - * The following properties must be specified: - * - * 1. {http://calendarserver.org/ns/}shared-url - * - * This property MUST contain the url to the original calendar, that is.. the - * path to the calendar from the owner. - * - * 2. {http://sabredav.org/ns}owner-principal - * - * This is a url to to the principal who is sharing the calendar. - * - * 3. {http://sabredav.org/ns}read-only - * - * This should be either 0 or 1, depending on if the user has read-only or - * read-write access to the calendar. - * - * Only when this is done, the calendar will correctly be marked as a calendar - * that's shared to him, thus allowing clients to display the correct interface - * and ACL enforcement. - * - * If a sharee deletes their calendar, only their instance of the calendar - * should be deleted, the original should still exists. - * Pretty much any 'dead' WebDAV properties on these shared calendars should be - * specific to a user. This means that if the displayname is changed by a - * sharee, the original is not affected. This is also true for: - * * The description - * * The color - * * The order - * * And any other dead properties. - * - * Properties like a ctag should not be different for multiple instances of the - * calendar. - * - * Lastly, objects *within* calendars should also have user-specific data. The - * two things that are user-specific are: - * * VALARM objects - * * The TRANSP property - * - * This _also_ implies that if a VALARM is deleted by a sharee for some event, - * this has no effect on the original VALARM. - * - * Understandably, the this last requirement is one of the hardest. - * Realisticly, I can see people ignoring this part of the spec, but that could - * cause a different set of issues. - * - * - * Publishing - * ========== - * - * When a user publishes a url, the server should generate a 'publish url'. - * This is a read-only url, anybody can use to consume the calendar feed. - * - * Calendars are in one of two states: - * * published - * * unpublished - * - * If a calendar is published, the following property should be returned - * for each calendar in getCalendarsForUser. - * - * {http://calendarserver.org/ns/}publish-url - * - * This element should contain a {DAV:}href element, which points to the - * public url that does not require authentication. Unlike every other href, - * this url must be absolute. - * - * Ideally, the following property is always returned - * - * {http://calendarserver.org/ns/}pre-publish-url - * - * This property should contain the url that the calendar _would_ have, if it - * were to be published. iCal uses this to display the url, before the user - * will actually publish it. - * - * - * Selectively disabling publish or share feature - * ============================================== - * - * If Sabre\CalDAV\Property\AllowedSharingModes is returned from - * getCalendarsForUser, this allows the server to specify whether either sharing, - * or publishing is supported. - * - * This allows a client to determine in advance which features are available, - * and update the interface appropriately. If this property is not returned by - * the backend, the SharingPlugin automatically injects it and assumes both - * features are available. + * 1. Return shared calendars for users. + * 2. For every calendar, return calendar-resource-uri. This strings is a URI or + * relative URI reference that must be unique for every calendar, but + * identical for every instance of the same shared calenar. + * 3. For every calenar, you must return a share-access element. This element + * should contain one of the Sabre\DAV\Sharing\Plugin:ACCESS_* contants and + * indicates the access level the user has. * * @copyright Copyright (C) fruux GmbH (https://fruux.com/) * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface SharingSupport extends NotificationSupport { +interface SharingSupport extends BackendInterface { /** * Updates the list of shares. * - * The first array is a list of people that are to be added to the - * calendar. - * - * Every element in the add array has the following properties: - * * href - A url. Usually a mailto: address - * * commonName - Usually a first and last name, or false - * * summary - A description of the share, can also be false - * * readOnly - A boolean value - * - * Every element in the remove array is just the address string. - * - * Note that if the calendar is currently marked as 'not shared' by and - * this method is called, the calendar should be 'upgraded' to a shared - * calendar. - * * @param mixed $calendarId - * @param array $add - * @param array $remove + * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees * @return void */ - function updateShares($calendarId, array $add, array $remove); + function updateInvites($calendarId, array $sharees); /** * Returns the list of people whom this calendar is shared with. * - * Every element in this array should have the following properties: - * * href - Often a mailto: address - * * commonName - Optional, for example a first + last name - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. - * * readOnly - boolean - * * summary - Optional, a description for the share + * Every item in the returned list must be a Sharee object with at + * least the following properties set: + * $href + * $shareAccess + * $inviteStatus * - * This method may be called by either the original instance of the - * calendar, as well as the shared instances. In the case of the shared - * instances, it is perfectly acceptable to return an empty array in case - * there are privacy concerns. + * and optionally: + * $properties * * @param mixed $calendarId - * @return array - */ - function getShares($calendarId); - - /** - * This method is called when a user replied to a request to share. - * - * If the user chose to accept the share, this method should return the - * newly created calendar url. - * - * @param string href The sharee who is replying (often a mailto: address) - * @param int status One of the SharingPlugin::STATUS_* constants - * @param string $calendarUri The url to the calendar thats being shared - * @param string $inReplyTo The unique id this message is a response to - * @param string $summary A description of the reply - * @return null|string + * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); + function getInvites($calendarId); /** * Publishes a calendar diff --git a/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php new file mode 100644 index 000000000..f8238ea9a --- /dev/null +++ b/vendor/sabre/dav/lib/CalDAV/Backend/SimplePDO.php @@ -0,0 +1,296 @@ +<?php + +namespace Sabre\CalDAV\Backend; + +use Sabre\CalDAV; +use Sabre\DAV; + +/** + * Simple PDO CalDAV backend. + * + * This class is basically the most minmum example to get a caldav backend up + * and running. This class uses the following schema (MySQL example): + * + * CREATE TABLE simple_calendars ( + * id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + * uri VARBINARY(200) NOT NULL, + * principaluri VARBINARY(200) NOT NULL + * ); + * + * CREATE TABLE simple_calendarobjects ( + * id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + * calendarid INT UNSIGNED NOT NULL, + * uri VARBINARY(200) NOT NULL, + * calendardata MEDIUMBLOB + * ) + * + * To make this class work, you absolutely need to have the PropertyStorage + * plugin enabled. + * + * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class SimplePDO extends AbstractBackend { + + /** + * pdo + * + * @var \PDO + */ + protected $pdo; + + /** + * Creates the backend + * + * @param \PDO $pdo + */ + function __construct(\PDO $pdo) { + + $this->pdo = $pdo; + + } + + /** + * Returns a list of calendars for a principal. + * + * Every project is an array with the following keys: + * * id, a unique id that will be used by other functions to modify the + * calendar. This can be the same as the uri or a database key. + * * uri. This is just the 'base uri' or 'filename' of the calendar. + * * principaluri. The owner of the calendar. Almost always the same as + * principalUri passed to this method. + * + * Furthermore it can contain webdav properties in clark notation. A very + * common one is '{DAV:}displayname'. + * + * Many clients also require: + * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set + * For this property, you can just return an instance of + * Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet. + * + * If you return {http://sabredav.org/ns}read-only and set the value to 1, + * ACL will automatically be put in read-only mode. + * + * @param string $principalUri + * @return array + */ + function getCalendarsForUser($principalUri) { + + // Making fields a comma-delimited list + $stmt = $this->pdo->prepare("SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC"); + $stmt->execute([$principalUri]); + + $calendars = []; + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + + $calendars[] = [ + 'id' => $row['id'], + 'uri' => $row['uri'], + 'principaluri' => $principalUri, + ]; + + } + + return $calendars; + + } + + /** + * Creates a new calendar for a principal. + * + * If the creation was a success, an id must be returned that can be used + * to reference this calendar in other methods, such as updateCalendar. + * + * @param string $principalUri + * @param string $calendarUri + * @param array $properties + * @return string + */ + function createCalendar($principalUri, $calendarUri, array $properties) { + + $stmt = $this->pdo->prepare("INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)"); + $stmt->execute([$principalUri, $calendarUri]); + + return $this->pdo->lastInsertId(); + + } + + /** + * Delete a calendar and all it's objects + * + * @param string $calendarId + * @return void + */ + function deleteCalendar($calendarId) { + + $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ?'); + $stmt->execute([$calendarId]); + + $stmt = $this->pdo->prepare('DELETE FROM simple_calendars WHERE id = ?'); + $stmt->execute([$calendarId]); + + } + + /** + * Returns all calendar objects within a calendar. + * + * Every item contains an array with the following keys: + * * calendardata - The iCalendar-compatible calendar data + * * uri - a unique key which will be used to construct the uri. This can + * be any arbitrary string, but making sure it ends with '.ics' is a + * good idea. This is only the basename, or filename, not the full + * path. + * * lastmodified - a timestamp of the last modification time + * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: + * ' "abcdef"') + * * size - The size of the calendar objects, in bytes. + * * component - optional, a string containing the type of object, such + * as 'vevent' or 'vtodo'. If specified, this will be used to populate + * the Content-Type header. + * + * Note that the etag is optional, but it's highly encouraged to return for + * speed reasons. + * + * The calendardata is also optional. If it's not returned + * 'getCalendarObject' will be called later, which *is* expected to return + * calendardata. + * + * If neither etag or size are specified, the calendardata will be + * used/fetched to determine these numbers. If both are specified the + * amount of times this is needed is reduced by a great degree. + * + * @param string $calendarId + * @return array + */ + function getCalendarObjects($calendarId) { + + $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ?'); + $stmt->execute([$calendarId]); + + $result = []; + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + $result[] = [ + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"' . md5($row['calendardata']) . '"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), + 'calendardata' => $row['calendardata'], + ]; + } + + return $result; + + } + + /** + * Returns information from a single calendar object, based on it's object + * uri. + * + * The object uri is only the basename, or filename and not a full path. + * + * The returned array must have the same keys as getCalendarObjects. The + * 'calendardata' object is required here though, while it's not required + * for getCalendarObjects. + * + * This method must return null if the object did not exist. + * + * @param string $calendarId + * @param string $objectUri + * @return array|null + */ + function getCalendarObject($calendarId, $objectUri) { + + $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); + $stmt->execute([$calendarId, $objectUri]); + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + + if (!$row) return null; + + return [ + 'id' => $row['id'], + 'uri' => $row['uri'], + 'etag' => '"' . md5($row['calendardata']) . '"', + 'calendarid' => $calendarId, + 'size' => strlen($row['calendardata']), + 'calendardata' => $row['calendardata'], + ]; + + } + + /** + * Creates a new calendar object. + * + * The object uri is only the basename, or filename and not a full path. + * + * It is possible return an etag from this function, which will be used in + * the response to this PUT request. Note that the ETag must be surrounded + * by double-quotes. + * + * However, you should only really return this ETag if you don't mangle the + * calendar-data. If the result of a subsequent GET to this object is not + * the exact same as this request body, you should omit the ETag. + * + * @param mixed $calendarId + * @param string $objectUri + * @param string $calendarData + * @return string|null + */ + function createCalendarObject($calendarId, $objectUri, $calendarData) { + + $stmt = $this->pdo->prepare('INSERT INTO simple_calendarobjects (calendarid, uri, calendardata) VALUES (?,?,?)'); + $stmt->execute([ + $calendarId, + $objectUri, + $calendarData + ]); + + return '"' . md5($calendarData) . '"'; + + } + + /** + * Updates an existing calendarobject, based on it's uri. + * + * The object uri is only the basename, or filename and not a full path. + * + * It is possible return an etag from this function, which will be used in + * the response to this PUT request. Note that the ETag must be surrounded + * by double-quotes. + * + * However, you should only really return this ETag if you don't mangle the + * calendar-data. If the result of a subsequent GET to this object is not + * the exact same as this request body, you should omit the ETag. + * + * @param mixed $calendarId + * @param string $objectUri + * @param string $calendarData + * @return string|null + */ + function updateCalendarObject($calendarId, $objectUri, $calendarData) { + + $stmt = $this->pdo->prepare('UPDATE simple_calendarobjects SET calendardata = ? WHERE calendarid = ? AND uri = ?'); + $stmt->execute([$calendarData, $calendarId, $objectUri]); + + return '"' . md5($calendarData) . '"'; + + } + + /** + * Deletes an existing calendar object. + * + * The object uri is only the basename, or filename and not a full path. + * + * @param string $calendarId + * @param string $objectUri + * @return void + */ + function deleteCalendarObject($calendarId, $objectUri) { + + $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?'); + $stmt->execute([$calendarId, $objectUri]); + + } + +} diff --git a/vendor/sabre/dav/lib/CalDAV/Calendar.php b/vendor/sabre/dav/lib/CalDAV/Calendar.php index ff8e19b15..90ace0d21 100644 --- a/vendor/sabre/dav/lib/CalDAV/Calendar.php +++ b/vendor/sabre/dav/lib/CalDAV/Calendar.php @@ -18,6 +18,8 @@ use Sabre\DAV\PropPatch; */ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, DAV\IMultiGet { + use DAVACL\ACLTrait; + /** * This is an array with calendar information * @@ -86,7 +88,7 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, foreach ($this->calendarInfo as $propName => $propValue) { - if ($propName[0] === '{') + if (!is_null($propValue) && $propName[0] === '{') $response[$propName] = $this->calendarInfo[$propName]; } @@ -227,7 +229,7 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, /** * Returns the last modification date as a unix timestamp. * - * @return void + * @return null */ function getLastModified() { @@ -249,19 +251,6 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -360,50 +349,6 @@ class Calendar implements ICalendar, DAV\IProperties, DAV\Sync\ISyncCollection, } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See \Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet(); - - // We need to inject 'read-free-busy' in the tree, aggregated under - // {DAV:}read. - foreach ($default['aggregates'] as &$agg) { - - if ($agg['privilege'] !== '{DAV:}read') continue; - - $agg['aggregates'][] = [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', - ]; - - } - return $default; - - } /** * Performs a calendar-query on the contents of this calendar. diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php index a53f829e2..0a4bfb68f 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarHome.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarHome.php @@ -22,6 +22,8 @@ use Sabre\HTTP\URLUtil; */ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { + use DAVACL\ACLTrait; + /** * CalDAV backend * @@ -147,11 +149,7 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { if ($calendar['uri'] === $name) { if ($this->caldavBackend instanceof Backend\SharingSupport) { - if (isset($calendar['{http://calendarserver.org/ns/}shared-url'])) { - return new SharedCalendar($this->caldavBackend, $calendar); - } else { - return new ShareableCalendar($this->caldavBackend, $calendar); - } + return new SharedCalendar($this->caldavBackend, $calendar); } else { return new Calendar($this->caldavBackend, $calendar); } @@ -198,11 +196,7 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { $objs = []; foreach ($calendars as $calendar) { if ($this->caldavBackend instanceof Backend\SharingSupport) { - if (isset($calendar['{http://calendarserver.org/ns/}shared-url'])) { - $objs[] = new SharedCalendar($this->caldavBackend, $calendar); - } else { - $objs[] = new ShareableCalendar($this->caldavBackend, $calendar); - } + $objs[] = new SharedCalendar($this->caldavBackend, $calendar); } else { $objs[] = new Calendar($this->caldavBackend, $calendar); } @@ -278,11 +272,9 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { } /** - * Returns the owner principal + * Returns the owner of the calendar home. * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null + * @return string */ function getOwner() { @@ -291,19 +283,6 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -348,37 +327,6 @@ class CalendarHome implements DAV\IExtendedCollection, DAVACL\IACL { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } /** * This method is called when a user replied to a request to share. diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php index 393ca4cbd..001b35112 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarObject.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarObject.php @@ -11,6 +11,8 @@ namespace Sabre\CalDAV; */ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL { + use \Sabre\DAVACL\ACLTrait; + /** * Sabre\CalDAV\Backend\BackendInterface * @@ -192,19 +194,6 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -226,22 +215,12 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ // The default ACL return [ [ - 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->calendarInfo['principaluri'], 'protected' => true, ], [ - 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', 'protected' => true, ], @@ -255,36 +234,4 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new \Sabre\DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See \Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php index 8c296d50f..a3a824c71 100644 --- a/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php @@ -170,13 +170,13 @@ class ICSExportPlugin extends DAV\ServerPlugin { protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) { $calDataProp = '{' . Plugin::NS_CALDAV . '}calendar-data'; + $calendarNode = $this->server->tree->getNodeForPath($path); $blobs = []; if ($start || $end || $componentType) { // If there was a start or end filter, we need to enlist // calendarQuery for speed. - $calendarNode = $this->server->tree->getNodeForPath($path); $queryResult = $calendarNode->calendarQuery([ 'name' => 'VCALENDAR', 'comp-filters' => [ @@ -246,17 +246,29 @@ class ICSExportPlugin extends DAV\ServerPlugin { $mergedCalendar = $mergedCalendar->expand($start, $end, $calendarTimeZone); } - $response->setHeader('Content-Type', $format); + $filenameExtension = '.ics'; switch ($format) { case 'text/calendar' : $mergedCalendar = $mergedCalendar->serialize(); + $filenameExtension = '.ics'; break; case 'application/calendar+json' : $mergedCalendar = json_encode($mergedCalendar->jsonSerialize()); + $filenameExtension = '.json'; break; } + $filename = preg_replace( + '/[^a-zA-Z0-9-_ ]/um', + '', + $calendarNode->getName() + ); + $filename .= '-' . date('Y-m-d') . $filenameExtension; + + $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $response->setHeader('Content-Type', $format); + $response->setStatus(200); $response->setBody($mergedCalendar); @@ -272,11 +284,11 @@ class ICSExportPlugin extends DAV\ServerPlugin { function mergeObjects(array $properties, array $inputObjects) { $calendar = new VObject\Component\VCalendar(); - $calendar->version = '2.0'; + $calendar->VERSION = '2.0'; if (DAV\Server::$exposeVersion) { - $calendar->prodid = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN'; + $calendar->PRODID = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN'; } else { - $calendar->prodid = '-//SabreDAV//SabreDAV//EN'; + $calendar->PRODID = '-//SabreDAV//SabreDAV//EN'; } if (isset($properties['{DAV:}displayname'])) { $calendar->{'X-WR-CALNAME'} = $properties['{DAV:}displayname']; diff --git a/vendor/sabre/dav/lib/CalDAV/IShareableCalendar.php b/vendor/sabre/dav/lib/CalDAV/IShareableCalendar.php index cfda91a55..7420d94f7 100644 --- a/vendor/sabre/dav/lib/CalDAV/IShareableCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/IShareableCalendar.php @@ -5,7 +5,7 @@ namespace Sabre\CalDAV; /** * This interface represents a Calendar that can be shared with other users. * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ diff --git a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php index 84442ac21..15f3b5335 100644 --- a/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ISharedCalendar.php @@ -2,6 +2,8 @@ namespace Sabre\CalDAV; +use Sabre\DAV\Sharing\ISharedNode; + /** * This interface represents a Calendar that is shared by a different user. * @@ -9,28 +11,16 @@ namespace Sabre\CalDAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedCalendar extends ICalendar { - - /** - * This method should return the url of the owners' copy of the shared - * calendar. - * - * @return string - */ - function getSharedUrl(); +interface ISharedCalendar extends ISharedNode { /** - * Returns the list of people whom this calendar is shared with. + * Marks this calendar as published. * - * Every element in this array should have the following properties: - * * href - Often a mailto: address - * * commonName - Optional, for example a first + last name - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. - * * readOnly - boolean - * * summary - Optional, a description for the share + * Publishing a calendar should automatically create a read-only, public, + * subscribable calendar. * - * @return array + * @param bool $value + * @return void */ - function getShares(); - + function setPublishStatus($value); } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php index 1fcc1171c..5fda61dfa 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Collection.php @@ -22,6 +22,8 @@ use Sabre\DAVACL; */ class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { + use DAVACL\ACLTrait; + /** * The notification backend * @@ -96,78 +98,4 @@ class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** - * Returns a list of ACE's for this node. - * - * Each ACE has the following properties: - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are - * currently the only supported privileges - * * 'principal', a url to the principal who owns the node - * * 'protected' (optional), indicating that this ACE is not allowed to - * be updated. - * - * @return array - */ - function getACL() { - - return [ - [ - 'principal' => $this->getOwner(), - 'privilege' => '{DAV:}read', - 'protected' => true, - ], - [ - 'principal' => $this->getOwner(), - 'privilege' => '{DAV:}write', - 'protected' => true, - ] - ]; - - } - - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\NotImplemented('Updating ACLs is not implemented here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php index 47e78d5de..11df0c94b 100644 --- a/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php +++ b/vendor/sabre/dav/lib/CalDAV/Notifications/Node.php @@ -20,6 +20,8 @@ use Sabre\DAVACL; */ class Node extends DAV\File implements INode, DAVACL\IACL { + use DAVACL\ACLTrait; + /** * The notification backend * @@ -116,78 +118,4 @@ class Node extends DAV\File implements INode, DAVACL\IACL { } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** - * Returns a list of ACE's for this node. - * - * Each ACE has the following properties: - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are - * currently the only supported privileges - * * 'principal', a url to the principal who owns the node - * * 'protected' (optional), indicating that this ACE is not allowed to - * be updated. - * - * @return array - */ - function getACL() { - - return [ - [ - 'principal' => $this->getOwner(), - 'privilege' => '{DAV:}read', - 'protected' => true, - ], - [ - 'principal' => $this->getOwner(), - 'privilege' => '{DAV:}write', - 'protected' => true, - ] - ]; - - } - - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\NotImplemented('Updating ACLs is not implemented here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Plugin.php index 663490023..71ba75206 100644 --- a/vendor/sabre/dav/lib/CalDAV/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Plugin.php @@ -5,8 +5,9 @@ namespace Sabre\CalDAV; use DateTimeZone; use Sabre\DAV; use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\INode; use Sabre\DAV\MkCol; -use Sabre\DAV\Xml\Property\Href; +use Sabre\DAV\Xml\Property\LocalHref; use Sabre\DAVACL; use Sabre\VObject; use Sabre\HTTP; @@ -186,6 +187,7 @@ class Plugin extends DAV\ServerPlugin { $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); $server->on('afterMethod:GET', [$this, 'httpAfterGET']); + $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); $server->xml->namespaceMap[self::NS_CALDAV] = 'cal'; $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs'; @@ -233,9 +235,10 @@ class Plugin extends DAV\ServerPlugin { * * @param string $reportName * @param mixed $report + * @param mixed $path * @return bool */ - function report($reportName, $report) { + function report($reportName, $report, $path) { switch ($reportName) { case '{' . self::NS_CALDAV . '}calendar-multiget' : @@ -341,7 +344,7 @@ class Plugin extends DAV\ServerPlugin { $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl); if (is_null($calendarHomePath)) return null; - return new Href($calendarHomePath . '/'); + return new LocalHref($calendarHomePath . '/'); }); // The calendar-user-address-set property is basically mapped to @@ -349,7 +352,7 @@ class Plugin extends DAV\ServerPlugin { $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function() use ($node) { $addresses = $node->getAlternateUriSet(); $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/'; - return new Href($addresses, false); + return new LocalHref($addresses); }); // For some reason somebody thought it was a good idea to add // another one of these properties. We're supporting it too. @@ -394,8 +397,8 @@ class Plugin extends DAV\ServerPlugin { } - $propFind->set($propRead, new Href($readList)); - $propFind->set($propWrite, new Href($writeList)); + $propFind->set($propRead, new LocalHref($readList)); + $propFind->set($propWrite, new LocalHref($writeList)); } @@ -821,11 +824,7 @@ class Plugin extends DAV\ServerPlugin { $data = stream_get_contents($data); } - $before = md5($data); - // Converting the data to unicode, if needed. - $data = DAV\StringUtil::ensureUTF8($data); - - if ($before !== md5($data)) $modified = true; + $before = $data; try { @@ -865,7 +864,7 @@ class Plugin extends DAV\ServerPlugin { } $foundType = null; - $foundUID = null; + foreach ($vobj->getComponents() as $component) { switch ($component->name) { case 'VTIMEZONE' : @@ -873,31 +872,59 @@ class Plugin extends DAV\ServerPlugin { case 'VEVENT' : case 'VTODO' : case 'VJOURNAL' : - if (is_null($foundType)) { - $foundType = $component->name; - if (!in_array($foundType, $supportedComponents)) { - throw new Exception\InvalidComponentType('This calendar only supports ' . implode(', ', $supportedComponents) . '. We found a ' . $foundType); - } - if (!isset($component->UID)) { - throw new DAV\Exception\BadRequest('Every ' . $component->name . ' component must have an UID'); - } - $foundUID = (string)$component->UID; - } else { - if ($foundType !== $component->name) { - throw new DAV\Exception\BadRequest('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as a ' . $foundType); - } - if ($foundUID !== (string)$component->UID) { - throw new DAV\Exception\BadRequest('Every ' . $component->name . ' in this object must have identical UIDs'); - } - } + $foundType = $component->name; break; - default : - throw new DAV\Exception\BadRequest('You are not allowed to create components of type: ' . $component->name . ' here'); + } + + } + + if (!$foundType || !in_array($foundType, $supportedComponents)) { + throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type ' . implode(', ', $supportedComponents)); + } + + $options = VObject\Node::PROFILE_CALDAV; + $prefer = $this->server->getHTTPPrefer(); + + if ($prefer['handling'] !== 'strict') { + $options |= VObject\Node::REPAIR; + } + + $messages = $vobj->validate($options); + $highestLevel = 0; + $warningMessage = null; + + // $messages contains a list of problems with the vcard, along with + // their severity. + foreach ($messages as $message) { + + if ($message['level'] > $highestLevel) { + // Recording the highest reported error level. + $highestLevel = $message['level']; + $warningMessage = $message['message']; } + switch ($message['level']) { + + case 1 : + // Level 1 means that there was a problem, but it was repaired. + $modified = true; + break; + case 2 : + // Level 2 means a warning, but not critical + break; + case 3 : + // Level 3 means a critical error + throw new DAV\Exception\UnsupportedMediaType('Validation error in iCalendar: ' . $message['message']); + + } + + } + if ($warningMessage) { + $response->setHeader( + 'X-Sabre-Ew-Gross', + 'iCalendar validation warning: ' . $warningMessage + ); } - if (!$foundType) - throw new DAV\Exception\BadRequest('iCalendar object must contain at least 1 of VEVENT, VTODO or VJOURNAL'); // We use an extra variable to allow event handles to tell us wether // the object was modified or not. @@ -917,12 +944,12 @@ class Plugin extends DAV\ServerPlugin { ] ); - if ($subModified) { + if ($modified || $subModified) { // An event handler told us that it modified the object. $data = $vobj->serialize(); // Using md5 to figure out if there was an *actual* change. - if (!$modified && $before !== md5($data)) { + if (!$modified && strcmp($data, $before) !== 0) { $modified = true; } @@ -933,6 +960,22 @@ class Plugin extends DAV\ServerPlugin { } + /** + * This method is triggered whenever a subsystem reqeuests the privileges + * that are supported on a particular node. + * + * @param INode $node + * @param array $supportedPrivilegeSet + */ + function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { + + if ($node instanceof ICalendar) { + $supportedPrivilegeSet['{DAV:}read']['aggregates']['{' . self::NS_CALDAV . '}read-free-busy'] = [ + 'abstract' => false, + 'aggregates' => [], + ]; + } + } /** * This method is used to generate HTML output for the diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php index 13212565e..6b374ea3f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php @@ -17,6 +17,8 @@ use Sabre\VObject; */ class Inbox extends DAV\Collection implements IInbox { + use DAVACL\ACLTrait; + /** * CalDAV backend * @@ -119,19 +121,6 @@ class Inbox extends DAV\Collection implements IInbox { } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -167,58 +156,11 @@ class Inbox extends DAV\Collection implements IInbox { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver-invite', + 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver', 'principal' => '{DAV:}authenticated', 'protected' => true, ], - [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver-reply', - 'principal' => '{DAV:}authenticated', - 'protected' => true, - ], - ]; - - } - - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('You\'re not allowed to update the ACL'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - $ns = '{' . CalDAV\Plugin::NS_CALDAV . '}'; - - $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet(); - $default['aggregates'][] = [ - 'privilege' => $ns . 'schedule-deliver', - 'aggregates' => [ - ['privilege' => $ns . 'schedule-deliver-invite'], - ['privilege' => $ns . 'schedule-deliver-reply'], - ], ]; - return $default; } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php index dabaee2ca..29eefa744 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php @@ -19,6 +19,8 @@ use Sabre\DAVACL; */ class Outbox extends DAV\Collection implements IOutbox { + use DAVACL\ACLTrait; + /** * The principal Uri * @@ -75,19 +77,6 @@ class Outbox extends DAV\Collection implements IOutbox { } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -103,12 +92,7 @@ class Outbox extends DAV\Collection implements IOutbox { return [ [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', - 'principal' => $this->getOwner(), - 'protected' => true, - ], - [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', + 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', 'principal' => $this->getOwner(), 'protected' => true, ], @@ -118,12 +102,7 @@ class Outbox extends DAV\Collection implements IOutbox { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', - 'principal' => $this->getOwner() . '/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', + 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', 'principal' => $this->getOwner() . '/calendar-proxy-write', 'protected' => true, ], @@ -141,44 +120,4 @@ class Outbox extends DAV\Collection implements IOutbox { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('You\'re not allowed to update the ACL'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet(); - $default['aggregates'][] = [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', - ]; - $default['aggregates'][] = [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', - ]; - - return $default; - - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php index 827d6209b..47511140f 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php @@ -5,10 +5,12 @@ namespace Sabre\CalDAV\Schedule; use DateTimeZone; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; +use Sabre\DAV\Sharing; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; use Sabre\DAV\INode; use Sabre\DAV\Xml\Property\Href; +use Sabre\DAV\Xml\Property\LocalHref; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Sabre\VObject; @@ -100,12 +102,13 @@ class Plugin extends ServerPlugin { function initialize(Server $server) { $this->server = $server; - $server->on('method:POST', [$this, 'httpPost']); - $server->on('propFind', [$this, 'propFind']); - $server->on('propPatch', [$this, 'propPatch']); - $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); - $server->on('beforeUnbind', [$this, 'beforeUnbind']); - $server->on('schedule', [$this, 'scheduleLocalDelivery']); + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); + $server->on('propPatch', [$this, 'propPatch']); + $server->on('calendarObjectChange', [$this, 'calendarObjectChange']); + $server->on('beforeUnbind', [$this, 'beforeUnbind']); + $server->on('schedule', [$this, 'scheduleLocalDelivery']); + $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); $ns = '{' . self::NS_CALDAV . '}'; @@ -215,7 +218,7 @@ class Plugin extends ServerPlugin { } $outboxPath = $calendarHomePath . '/outbox/'; - return new Href($outboxPath); + return new LocalHref($outboxPath); }); // schedule-inbox-URL property @@ -227,7 +230,7 @@ class Plugin extends ServerPlugin { } $inboxPath = $calendarHomePath . '/inbox/'; - return new Href($inboxPath); + return new LocalHref($inboxPath); }); @@ -245,18 +248,28 @@ class Plugin extends ServerPlugin { $result = $this->server->getPropertiesForPath($calendarHomePath, [ '{DAV:}resourcetype', + '{DAV:}share-access', $sccs, ], 1); foreach ($result as $child) { - if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar') || $child[200]['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared')) { - // Node is either not a calendar or a shared instance. + if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar')) { + // Node is either not a calendar continue; } + if (isset($child[200]['{DAV:}share-access'])) { + $shareAccess = $child[200]['{DAV:}share-access']->getValue(); + if ($shareAccess !== Sharing\Plugin::ACCESS_NOTSHARED && $shareAccess !== Sharing\Plugin::ACCESS_SHAREDOWNER) { + // Node is a shared node, not owned by the relevant + // user. + continue; + } + + } if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) { // Either there is no supported-calendar-component-set // (which is fine) or we found one that supports VEVENT. - return new Href($child['href']); + return new LocalHref($child['href']); } } @@ -492,7 +505,7 @@ class Plugin extends ServerPlugin { } if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS . $privilege, DAVACL\Plugin::R_PARENT, false)) { - $iTipMessage->scheduleStatus = '3.8;organizer did not have the ' . $privilege . ' privilege on the attendees inbox'; + $iTipMessage->scheduleStatus = '3.8;insufficient privileges: ' . $privilege . ' is required on the recipient schedule inbox.'; return; } @@ -561,6 +574,65 @@ class Plugin extends ServerPlugin { } /** + * This method is triggered whenever a subsystem requests the privileges + * that are supported on a particular node. + * + * We need to add a number of privileges for scheduling purposes. + * + * @param INode $node + * @param array $supportedPrivilegeSet + */ + function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { + + $ns = '{' . self::NS_CALDAV . '}'; + if ($node instanceof IOutbox) { + $supportedPrivilegeSet[$ns . 'schedule-send'] = [ + 'abstract' => false, + 'aggregates' => [ + $ns . 'schedule-send-invite' => [ + 'abstract' => false, + 'aggregates' => [], + ], + $ns . 'schedule-send-reply' => [ + 'abstract' => false, + 'aggregates' => [], + ], + $ns . 'schedule-send-freebusy' => [ + 'abstract' => false, + 'aggregates' => [], + ], + // Privilege from an earlier scheduling draft, but still + // used by some clients. + $ns . 'schedule-post-vevent' => [ + 'abstract' => false, + 'aggregates' => [], + ], + ] + ]; + } + if ($node instanceof IInbox) { + $supportedPrivilegeSet[$ns . 'schedule-deliver'] = [ + 'abstract' => false, + 'aggregates' => [ + $ns . 'schedule-deliver-invite' => [ + 'abstract' => false, + 'aggregates' => [], + ], + $ns . 'schedule-deliver-reply' => [ + 'abstract' => false, + 'aggregates' => [], + ], + $ns . 'schedule-query-freebusy' => [ + 'abstract' => false, + 'aggregates' => [], + ], + ] + ]; + } + + } + + /** * This method looks at an old iCalendar object, a new iCalendar object and * starts sending scheduling messages based on the changes. * @@ -647,7 +719,7 @@ class Plugin extends ServerPlugin { /** * This method handles POST requests to the schedule-outbox. * - * Currently, two types of requests are support: + * Currently, two types of requests are supported: * * FREEBUSY requests from RFC 6638 * * Simple iTIP messages from draft-desruisseaux-caldav-sched-04 * @@ -699,7 +771,7 @@ class Plugin extends ServerPlugin { if ($componentType === 'VFREEBUSY' && $method === 'REQUEST') { - $acl && $acl->checkPrivileges($outboxPath, '{' . self::NS_CALDAV . '}schedule-query-freebusy'); + $acl && $acl->checkPrivileges($outboxPath, '{' . self::NS_CALDAV . '}schedule-send-freebusy'); $this->handleFreeBusyRequest($outboxNode, $vObject, $request, $response); // Destroy circular references so PHP can GC the object. @@ -727,7 +799,7 @@ class Plugin extends ServerPlugin { protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) { $vFreeBusy = $vObject->VFREEBUSY; - $organizer = $vFreeBusy->organizer; + $organizer = $vFreeBusy->ORGANIZER; $organizer = (string)$organizer; @@ -863,6 +935,9 @@ class Plugin extends ServerPlugin { $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref(); $inboxUrl = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref(); + // Do we have permission? + $aclPlugin->checkPrivileges($inboxUrl, $caldavNS . 'schedule-query-freebusy'); + // Grabbing the calendar list $objects = []; $calendarTimeZone = new DateTimeZone('UTC'); @@ -882,8 +957,6 @@ class Plugin extends ServerPlugin { continue; } - $aclPlugin->checkPrivileges($homeSet . $node->getName(), $caldavNS . 'read-free-busy'); - if (isset($props[$ctz])) { $vtimezoneObj = VObject\Reader::read($props[$ctz]); $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone(); diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php index a36646e6c..6d9d3d5ec 100644 --- a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php +++ b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php @@ -134,22 +134,12 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli // The default ACL return [ [ - 'privilege' => '{DAV:}read', - 'principal' => $this->objectData['principaluri'], - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => $this->objectData['principaluri'], - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-write', + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, ], [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-write', 'protected' => true, ], diff --git a/vendor/sabre/dav/lib/CalDAV/ShareableCalendar.php b/vendor/sabre/dav/lib/CalDAV/ShareableCalendar.php index c11695d5f..c81c96300 100644 --- a/vendor/sabre/dav/lib/CalDAV/ShareableCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/ShareableCalendar.php @@ -6,7 +6,7 @@ namespace Sabre\CalDAV; * This object represents a CalDAV calendar that can be shared with other * users. * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ diff --git a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php index 7973eff9c..7a77616e3 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php +++ b/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php @@ -2,6 +2,8 @@ namespace Sabre\CalDAV; +use Sabre\DAV\Sharing\Plugin as SPlugin; + /** * This object represents a CalDAV calendar that is shared by a different user. * @@ -12,50 +14,84 @@ namespace Sabre\CalDAV; class SharedCalendar extends Calendar implements ISharedCalendar { /** - * Constructor + * Returns the 'access level' for the instance of this shared resource. + * + * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_ + * constants. * - * @param Backend\BackendInterface $caldavBackend - * @param array $calendarInfo + * @return int */ - function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) { - - $required = [ - '{http://calendarserver.org/ns/}shared-url', - '{http://sabredav.org/ns}owner-principal', - '{http://sabredav.org/ns}read-only', - ]; - foreach ($required as $r) { - if (!isset($calendarInfo[$r])) { - throw new \InvalidArgumentException('The ' . $r . ' property must be specified for SharedCalendar(s)'); - } - } + function getShareAccess() { - parent::__construct($caldavBackend, $calendarInfo); + return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED; } /** - * This method should return the url of the owners' copy of the shared - * calendar. + * This function must return a URI that uniquely identifies the shared + * resource. This URI should be identical across instances, and is + * also used in several other XML bodies to connect invites to + * resources. + * + * This may simply be a relative reference to the original shared instance, + * but it could also be a urn. As long as it's a valid URI and unique. * * @return string */ - function getSharedUrl() { + function getShareResourceUri() { + + return $this->calendarInfo['share-resource-uri']; + + } + + /** + * Updates the list of sharees. + * + * Every item must be a Sharee object. + * + * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees + * @return void + */ + function updateInvites(array $sharees) { - return $this->calendarInfo['{http://calendarserver.org/ns/}shared-url']; + $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees); } /** - * Returns the owner principal + * Returns the list of people whom this resource is shared with. + * + * Every item in the returned array must be a Sharee object with + * at least the following properties set: + * + * * $href + * * $shareAccess + * * $inviteStatus * - * This must be a url to a principal, or null if there's no owner + * and optionally: * - * @return string|null + * * $properties + * + * @return \Sabre\DAV\Xml\Element\Sharee[] */ - function getOwner() { + function getInvites() { - return $this->calendarInfo['{http://sabredav.org/ns}owner-principal']; + return $this->caldavBackend->getInvites($this->calendarInfo['id']); + + } + + /** + * Marks this calendar as published. + * + * Publishing a calendar should automatically create a read-only, public, + * subscribable calendar. + * + * @param bool $value + * @return void + */ + function setPublishStatus($value) { + + $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value); } @@ -73,32 +109,72 @@ class SharedCalendar extends Calendar implements ISharedCalendar { */ function getACL() { - // The top-level ACL only contains access information for the true - // owner of the calendar, so we need to add the information for the - // sharee. - $acl = parent::getACL(); - $acl[] = [ - 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ]; - if ($this->calendarInfo['{http://sabredav.org/ns}read-only']) { - $acl[] = [ - 'privilege' => '{DAV:}write-properties', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ]; - } else { - $acl[] = [ - 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ]; + $acl = []; + + switch ($this->getShareAccess()) { + case SPlugin::ACCESS_NOTSHARED : + case SPlugin::ACCESS_SHAREDOWNER : + $acl[] = [ + 'privilege' => '{DAV:}share', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}share', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + // No break intentional! + case SPlugin::ACCESS_READWRITE : + $acl[] = [ + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + // No break intentional! + case SPlugin::ACCESS_READ : + $acl[] = [ + 'privilege' => '{DAV:}write-properties', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}write-properties', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'principal' => '{DAV:}authenticated', + 'protected' => true, + ]; + break; } return $acl; } + /** * This method returns the ACL's for calendar objects in this calendar. * The result of this method automatically gets passed to the @@ -108,40 +184,45 @@ class SharedCalendar extends Calendar implements ISharedCalendar { */ function getChildACL() { - $acl = parent::getChildACL(); - $acl[] = [ - 'privilege' => '{DAV:}read', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ]; - - if (!$this->calendarInfo['{http://sabredav.org/ns}read-only']) { - $acl[] = [ - 'privilege' => '{DAV:}write', - 'principal' => $this->calendarInfo['principaluri'], - 'protected' => true, - ]; + $acl = []; + + switch ($this->getShareAccess()) { + case SPlugin::ACCESS_NOTSHARED : + // No break intentional + case SPlugin::ACCESS_SHAREDOWNER : + // No break intentional + case SPlugin::ACCESS_READWRITE: + $acl[] = [ + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}write', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + // No break intentional + case SPlugin::ACCESS_READ: + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'], + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-write', + 'protected' => true, + ]; + $acl[] = [ + 'privilege' => '{DAV:}read', + 'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read', + 'protected' => true, + ]; + break; } - return $acl; - - } - - /** - * Returns the list of people whom this calendar is shared with. - * - * Every element in this array should have the following properties: - * * href - Often a mailto: address - * * commonName - Optional, for example a first + last name - * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants. - * * readOnly - boolean - * * summary - Optional, a description for the share - * - * @return array - */ - function getShares() { - - return $this->caldavBackend->getShares($this->calendarInfo['id']); + return $acl; } diff --git a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php index 5154fb1de..6f7df02bc 100644 --- a/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php +++ b/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php @@ -4,6 +4,7 @@ namespace Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\Xml\Property\Href; +use Sabre\DAV\Xml\Property\LocalHref; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; @@ -26,15 +27,6 @@ use Sabre\HTTP\ResponseInterface; class SharingPlugin extends DAV\ServerPlugin { /** - * These are the various status constants used by sharing-messages. - */ - const STATUS_ACCEPTED = 1; - const STATUS_DECLINED = 2; - const STATUS_DELETED = 3; - const STATUS_NORESPONSE = 4; - const STATUS_INVALID = 5; - - /** * Reference to SabreDAV server object. * * @var Sabre\DAV\Server @@ -83,7 +75,10 @@ class SharingPlugin extends DAV\ServerPlugin { function initialize(DAV\Server $server) { $this->server = $server; - $server->resourceTypeMapping['Sabre\\CalDAV\\ISharedCalendar'] = '{' . Plugin::NS_CALENDARSERVER . '}shared'; + + if (is_null($this->server->getPlugin('sharing'))) { + throw new \LogicException('The generic "sharing" plugin must be loaded before the caldav sharing plugin. Call $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); before this one.'); + } array_push( $this->server->protectedProperties, @@ -114,24 +109,8 @@ class SharingPlugin extends DAV\ServerPlugin { */ function propFindEarly(DAV\PropFind $propFind, DAV\INode $node) { - if ($node instanceof IShareableCalendar) { - - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}invite', function() use ($node) { - return new Xml\Property\Invite( - $node->getShares() - ); - }); - - } - if ($node instanceof ISharedCalendar) { - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}shared-url', function() use ($node) { - return new Href( - $node->getSharedUrl() - ); - }); - $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}invite', function() use ($node) { // Fetching owner information @@ -158,7 +137,7 @@ class SharingPlugin extends DAV\ServerPlugin { } return new Xml\Property\Invite( - $node->getShares(), + $node->getInvites(), $ownerInfo ); @@ -179,10 +158,18 @@ class SharingPlugin extends DAV\ServerPlugin { */ function propFindLate(DAV\PropFind $propFind, DAV\INode $node) { - if ($node instanceof IShareableCalendar) { + if ($node instanceof ISharedCalendar) { + $shareAccess = $node->getShareAccess(); if ($rt = $propFind->get('{DAV:}resourcetype')) { - if (count($node->getShares()) > 0) { - $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); + switch ($shareAccess) { + case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER : + $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared-owner'); + break; + case \Sabre\DAV\Sharing\Plugin::ACCESS_READ : + case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE : + $rt->add('{' . Plugin::NS_CALENDARSERVER . '}shared'); + break; + } } $propFind->handle('{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', function() { @@ -211,21 +198,24 @@ class SharingPlugin extends DAV\ServerPlugin { function propPatch($path, DAV\PropPatch $propPatch) { $node = $this->server->tree->getNodeForPath($path); - if (!$node instanceof IShareableCalendar) + if (!$node instanceof ISharedCalendar) return; - $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) { - if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false; - $shares = $node->getShares(); - $remove = []; - foreach ($shares as $share) { - $remove[] = $share['href']; - } - $node->updateShares([], $remove); + if ($node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER || $node->getShareAccess() === \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED) { - return true; + $propPatch->handle('{DAV:}resourcetype', function($value) use ($node) { + if ($value->is('{' . Plugin::NS_CALENDARSERVER . '}shared-owner')) return false; + $shares = $node->getInvites(); + foreach ($shares as $share) { + $share->access = DAV\Sharing\Plugin::ACCESS_NOACCESS; + } + $node->updateInvites($shares); - }); + return true; + + }); + + } } @@ -267,26 +257,12 @@ class SharingPlugin extends DAV\ServerPlugin { switch ($documentType) { - // Dealing with the 'share' document, which modified invitees on a - // calendar. + // Both the DAV:share-resource and CALENDARSERVER:share requests + // behave identically. case '{' . Plugin::NS_CALENDARSERVER . '}share' : - // We can only deal with IShareableCalendar objects - if (!$node instanceof IShareableCalendar) { - return; - } - - $this->server->transactionType = 'post-calendar-share'; - - // Getting ACL info - $acl = $this->server->getPlugin('acl'); - - // If there's no ACL support, we allow everything - if ($acl) { - $acl->checkPrivileges($path, '{DAV:}write'); - } - - $node->updateShares($message->set, $message->remove); + $sharingPlugin = $this->server->getPlugin('sharing'); + $sharingPlugin->shareResource($path, $message->sharees); $response->setStatus(200); // Adding this because sending a response body may cause issues, @@ -328,11 +304,11 @@ class SharingPlugin extends DAV\ServerPlugin { $response->setHeader('X-Sabre-Status', 'everything-went-well'); if ($url) { - $writer = $this->server->xml->getWriter($this->server->getBaseUri()); + $writer = $this->server->xml->getWriter(); $writer->openMemory(); $writer->startDocument(); $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}shared-as'); - $writer->write(new Href($url)); + $writer->write(new LocalHref($url)); $writer->endElement(); $response->setHeader('Content-Type', 'application/xml'); $response->setBody($writer->outputMemory()); @@ -345,7 +321,7 @@ class SharingPlugin extends DAV\ServerPlugin { case '{' . Plugin::NS_CALENDARSERVER . '}publish-calendar' : // We can only deal with IShareableCalendar objects - if (!$node instanceof IShareableCalendar) { + if (!$node instanceof ISharedCalendar) { return; } $this->server->transactionType = 'post-publish-calendar'; @@ -355,7 +331,7 @@ class SharingPlugin extends DAV\ServerPlugin { // If there's no ACL support, we allow everything if ($acl) { - $acl->checkPrivileges($path, '{DAV:}write'); + $acl->checkPrivileges($path, '{DAV:}share'); } $node->setPublishStatus(true); @@ -373,7 +349,7 @@ class SharingPlugin extends DAV\ServerPlugin { case '{' . Plugin::NS_CALENDARSERVER . '}unpublish-calendar' : // We can only deal with IShareableCalendar objects - if (!$node instanceof IShareableCalendar) { + if (!$node instanceof ISharedCalendar) { return; } $this->server->transactionType = 'post-unpublish-calendar'; @@ -383,7 +359,7 @@ class SharingPlugin extends DAV\ServerPlugin { // If there's no ACL support, we allow everything if ($acl) { - $acl->checkPrivileges($path, '{DAV:}write'); + $acl->checkPrivileges($path, '{DAV:}share'); } $node->setPublishStatus(false); diff --git a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php index ee53da2c6..3bb3451f3 100644 --- a/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php +++ b/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php @@ -5,8 +5,8 @@ namespace Sabre\CalDAV\Subscriptions; use Sabre\DAV\Collection; use Sabre\DAV\Xml\Property\Href; use Sabre\DAV\PropPatch; -use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAVACL\IACL; +use Sabre\DAVACL\ACLTrait; use Sabre\CalDAV\Backend\SubscriptionSupport; /** @@ -20,6 +20,8 @@ use Sabre\CalDAV\Backend\SubscriptionSupport; */ class Subscription extends Collection implements ISubscription, IACL { + use ACLTrait; + /** * caldavBackend * @@ -144,7 +146,7 @@ class Subscription extends Collection implements ISubscription, IACL { * The Server class will filter out the extra. * * @param array $properties - * @return void + * @return array */ function getProperties($properties) { @@ -154,7 +156,7 @@ class Subscription extends Collection implements ISubscription, IACL { switch ($prop) { case '{http://calendarserver.org/ns/}source' : - $r[$prop] = new Href($this->subscriptionInfo['source'], false); + $r[$prop] = new Href($this->subscriptionInfo['source']); break; default : if (array_key_exists($prop, $this->subscriptionInfo)) { @@ -183,19 +185,6 @@ class Subscription extends Collection implements ISubscription, IACL { } /** - * Returns a group principal. - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -211,22 +200,12 @@ class Subscription extends Collection implements ISubscription, IACL { return [ [ - 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner(), - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->getOwner(), 'protected' => true, ], [ - 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner() . '/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->getOwner() . '/calendar-proxy-write', 'protected' => true, ], @@ -239,36 +218,4 @@ class Subscription extends Collection implements ISubscription, IACL { } - /** - * Updates the ACL. - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See \Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php index 7fb022e33..1ca64f3e8 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php @@ -5,6 +5,7 @@ namespace Sabre\CalDAV\Xml\Notification; use Sabre\Xml\Writer; use Sabre\CalDAV\SharingPlugin as SharingPlugin; use Sabre\CalDAV; +use Sabre\DAV; /** * This class represents the cs:invite-notification notification element. @@ -210,16 +211,10 @@ class Invite implements NotificationInterface { switch ($this->type) { - case SharingPlugin::STATUS_ACCEPTED : + case DAV\Sharing\Plugin::INVITE_ACCEPTED : $writer->writeElement($cs . 'invite-accepted'); break; - case SharingPlugin::STATUS_DECLINED : - $writer->writeElement($cs . 'invite-declined'); - break; - case SharingPlugin::STATUS_DELETED : - $writer->writeElement($cs . 'invite-deleted'); - break; - case SharingPlugin::STATUS_NORESPONSE : + case DAV\Sharing\Plugin::INVITE_NORESPONSE : $writer->writeElement($cs . 'invite-noresponse'); break; diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php index 945323fed..51bfc178a 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php @@ -5,6 +5,7 @@ namespace Sabre\CalDAV\Xml\Notification; use Sabre\Xml\Writer; use Sabre\CalDAV; use Sabre\CalDAV\SharingPlugin; +use Sabre\DAV; /** * This class represents the cs:invite-reply notification element. @@ -162,10 +163,10 @@ class InviteReply implements NotificationInterface { switch ($this->type) { - case SharingPlugin::STATUS_ACCEPTED : + case DAV\Sharing\Plugin::INVITE_ACCEPTED : $writer->writeElement($cs . 'invite-accepted'); break; - case SharingPlugin::STATUS_DECLINED : + case DAV\Sharing\Plugin::INVITE_DECLINED : $writer->writeElement($cs . 'invite-declined'); break; diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php index 3ee053214..40ff6b936 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php @@ -2,11 +2,10 @@ namespace Sabre\CalDAV\Xml\Property; -use Sabre\Xml\Element; -use Sabre\Xml\Reader; +use Sabre\Xml\XmlSerializable; use Sabre\Xml\Writer; use Sabre\CalDAV\Plugin; -use Sabre\CalDAV\SharingPlugin; +use Sabre\DAV; /** * Invite property @@ -20,53 +19,23 @@ use Sabre\CalDAV\SharingPlugin; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Invite implements Element { +class Invite implements XmlSerializable { /** * The list of users a calendar has been shared to. * - * @var array + * @var Sharee[] */ - protected $users; - - /** - * The organizer contains information about the person who shared the - * object. - * - * @var array - */ - protected $organizer; + protected $sharees; /** * Creates the property. * - * Users is an array. Each element of the array has the following - * properties: - * - * * href - Often a mailto: address - * * commonName - Optional, for example a first and lastname for a user. - * * status - One of the SharingPlugin::STATUS_* constants. - * * readOnly - true or false - * * summary - Optional, description of the share - * - * The organizer key is optional to specify. It's only useful when a - * 'sharee' requests the sharing information. - * - * The organizer may have the following properties: - * * href - Often a mailto: address. - * * commonName - Optional human-readable name. - * * firstName - Optional first name. - * * lastName - Optional last name. - * - * If you wonder why these two structures are so different, I guess a - * valid answer is that the current spec is still a draft. - * - * @param array $users + * @param Sharee[] $sharees */ - function __construct(array $users, array $organizer = null) { + function __construct(array $sharees) { - $this->users = $users; - $this->organizer = $organizer; + $this->sharees = $sharees; } @@ -77,7 +46,7 @@ class Invite implements Element { */ function getValue() { - return $this->users; + return $this->sharees; } @@ -104,149 +73,55 @@ class Invite implements Element { $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; - if (!is_null($this->organizer)) { - - $writer->startElement($cs . 'organizer'); - $writer->writeElement('{DAV:}href', $this->organizer['href']); - - if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); - } - if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); - } - if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); - } - $writer->endElement(); // organizer + foreach ($this->sharees as $sharee) { - } - - foreach ($this->users as $user) { - - $writer->startElement($cs . 'user'); - $writer->writeElement('{DAV:}href', $user['href']); - if (isset($user['commonName']) && $user['commonName']) { - $writer->writeElement($cs . 'common-name', $user['commonName']); - } - switch ($user['status']) { - - case SharingPlugin::STATUS_ACCEPTED : - $writer->writeElement($cs . 'invite-accepted'); - break; - case SharingPlugin::STATUS_DECLINED : - $writer->writeElement($cs . 'invite-declined'); - break; - case SharingPlugin::STATUS_NORESPONSE : - $writer->writeElement($cs . 'invite-noresponse'); - break; - case SharingPlugin::STATUS_INVALID : - $writer->writeElement($cs . 'invite-invalid'); - break; - } - - $writer->startElement($cs . 'access'); - if ($user['readOnly']) { - $writer->writeElement($cs . 'read'); + if ($sharee->access === \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER) { + $writer->startElement($cs . 'organizer'); } else { - $writer->writeElement($cs . 'read-write'); - } - $writer->endElement(); // access - - if (isset($user['summary']) && $user['summary']) { - $writer->writeElement($cs . 'summary', $user['summary']); - } - - $writer->endElement(); //user - - } - - } - - /** - * The deserialize method is called during xml parsing. - * - * This method is called statictly, this is because in theory this method - * may be used as a type of constructor, or factory method. - * - * Often you want to return an instance of the current class, but you are - * free to return other data as well. - * - * You are responsible for advancing the reader to the next element. Not - * doing anything will result in a never-ending loop. - * - * If you just want to skip parsing for this element altogether, you can - * just call $reader->next(); - * - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to - * the next element. - * - * @param Reader $reader - * @return mixed - */ - static function xmlDeserialize(Reader $reader) { - - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; - - $users = []; - - foreach ($reader->parseInnerTree() as $elem) { + $writer->startElement($cs . 'user'); - if ($elem['name'] !== $cs . 'user') - continue; - - $user = [ - 'href' => null, - 'commonName' => null, - 'readOnly' => null, - 'summary' => null, - 'status' => null, - ]; - - foreach ($elem['value'] as $userElem) { - - switch ($userElem['name']) { - case $cs . 'invite-accepted' : - $user['status'] = SharingPlugin::STATUS_ACCEPTED; - break; - case $cs . 'invite-declined' : - $user['status'] = SharingPlugin::STATUS_DECLINED; + switch ($sharee->inviteStatus) { + case DAV\Sharing\Plugin::INVITE_ACCEPTED : + $writer->writeElement($cs . 'invite-accepted'); break; - case $cs . 'invite-noresponse' : - $user['status'] = SharingPlugin::STATUS_NORESPONSE; + case DAV\Sharing\Plugin::INVITE_DECLINED : + $writer->writeElement($cs . 'invite-declined'); break; - case $cs . 'invite-invalid' : - $user['status'] = SharingPlugin::STATUS_INVALID; + case DAV\Sharing\Plugin::INVITE_NORESPONSE : + $writer->writeElement($cs . 'invite-noresponse'); break; - case '{DAV:}href' : - $user['href'] = $userElem['value']; + case DAV\Sharing\Plugin::INVITE_INVALID : + $writer->writeElement($cs . 'invite-invalid'); break; - case $cs . 'common-name' : - $user['commonName'] = $userElem['value']; - break; - case $cs . 'access' : - foreach ($userElem['value'] as $accessHref) { - if ($accessHref['name'] === $cs . 'read') { - $user['readOnly'] = true; - } - } + } + + $writer->startElement($cs . 'access'); + switch ($sharee->access) { + case DAV\Sharing\Plugin::ACCESS_READWRITE : + $writer->writeElement($cs . 'read-write'); break; - case $cs . 'summary' : - $user['summary'] = $userElem['value']; + case DAV\Sharing\Plugin::ACCESS_READ : + $writer->writeElement($cs . 'read'); break; } + $writer->endElement(); // access } - if (!$user['status']) { - throw new \InvalidArgumentException('Every user must have one of cs:invite-accepted, cs:invite-declined, cs:invite-noresponse or cs:invite-invalid'); - } - $users[] = $user; + $href = new \Sabre\DAV\Xml\Property\Href($sharee->href); + $href->xmlSerialize($writer); - } + if (isset($sharee->properties['{DAV:}displayname'])) { + $writer->writeElement($cs . 'common-name', $sharee->properties['{DAV:}displayname']); + } + if ($sharee->comment) { + $writer->writeElement($cs . 'summary', $sharee->comment); + } + $writer->endElement(); // organizer or user - return new self($users); + } } + } diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php index ec627156f..2ecf6c2bb 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php @@ -2,12 +2,13 @@ namespace Sabre\CalDAV\Xml\Request; +use Sabre\CalDAV\Plugin; +use Sabre\CalDAV\SharingPlugin; +use Sabre\DAV; +use Sabre\DAV\Exception\BadRequest; use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; use Sabre\Xml\Element\KeyValue; -use Sabre\DAV\Exception\BadRequest; -use Sabre\CalDAV\Plugin; -use Sabre\CalDAV\SharingPlugin; /** * Invite-reply POST request parser @@ -121,10 +122,10 @@ class InviteReply implements XmlDeserializable { } break; case '{' . Plugin::NS_CALENDARSERVER . '}invite-accepted' : - $status = SharingPlugin::STATUS_ACCEPTED; + $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; break; case '{' . Plugin::NS_CALENDARSERVER . '}invite-declined' : - $status = SharingPlugin::STATUS_DECLINED; + $status = DAV\Sharing\Plugin::INVITE_DECLINED; break; case '{' . Plugin::NS_CALENDARSERVER . '}in-reply-to' : $inReplyTo = $value; diff --git a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php index dacc5dc94..b5d9a133c 100644 --- a/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php +++ b/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php @@ -2,9 +2,10 @@ namespace Sabre\CalDAV\Xml\Request; +use Sabre\CalDAV\Plugin; +use Sabre\DAV\Xml\Element\Sharee; use Sabre\Xml\Reader; use Sabre\Xml\XmlDeserializable; -use Sabre\CalDAV\Plugin; /** * Share POST request parser @@ -20,37 +21,20 @@ use Sabre\CalDAV\Plugin; class Share implements XmlDeserializable { /** - * The list of new people added or updated. - * - * Every element has the following keys: - * 1. href - An email address - * 2. commonName - Some name - * 3. summary - An optional description of the share - * 4. readOnly - true or false - * - * @var array - */ - public $set = []; - - /** - * List of people removed from the share list. - * - * The list is a flat list of email addresses (including mailto:). + * The list of new people added or updated or removed from the share. * - * @var array + * @var Sharee[] */ - public $remove = []; + public $sharees = []; /** * Constructor * - * @param array $set - * @param array $remove + * @param Sharee[] $sharees */ - function __construct(array $set, array $remove) { + function __construct(array $sharees) { - $this->set = $set; - $this->remove = $remove; + $this->sharees = $sharees; } @@ -77,13 +61,12 @@ class Share implements XmlDeserializable { */ static function xmlDeserialize(Reader $reader) { - $elems = $reader->parseInnerTree([ + $elems = $reader->parseGetElements([ '{' . Plugin::NS_CALENDARSERVER . '}set' => 'Sabre\\Xml\\Element\\KeyValue', '{' . Plugin::NS_CALENDARSERVER . '}remove' => 'Sabre\\Xml\\Element\\KeyValue', ]); - $set = []; - $remove = []; + $sharees = []; foreach ($elems as $elem) { switch ($elem['name']) { @@ -94,22 +77,34 @@ class Share implements XmlDeserializable { $sumElem = '{' . Plugin::NS_CALENDARSERVER . '}summary'; $commonName = '{' . Plugin::NS_CALENDARSERVER . '}common-name'; - $set[] = [ + $properties = []; + if (isset($sharee[$commonName])) { + $properties['{DAV:}displayname'] = $sharee[$commonName]; + } + + $access = array_key_exists('{' . Plugin::NS_CALENDARSERVER . '}read-write', $sharee) + ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE + : \Sabre\DAV\Sharing\Plugin::ACCESS_READ; + + $sharees[] = new Sharee([ 'href' => $sharee['{DAV:}href'], - 'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null, - 'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, - 'readOnly' => !array_key_exists('{' . Plugin::NS_CALENDARSERVER . '}read-write', $sharee), - ]; + 'properties' => $properties, + 'access' => $access, + 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null + ]); break; case '{' . Plugin::NS_CALENDARSERVER . '}remove' : - $remove[] = $elem['value']['{DAV:}href']; + $sharees[] = new Sharee([ + 'href' => $elem['value']['{DAV:}href'], + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS + ]); break; } } - return new self($set, $remove); + return new self($sharees); } diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBook.php b/vendor/sabre/dav/lib/CardDAV/AddressBook.php index 70bec8760..6dd098618 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBook.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBook.php @@ -16,6 +16,8 @@ use Sabre\DAVACL; */ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyncCollection, DAV\IMultiGet { + use DAVACL\ACLTrait; + /** * This is an array with addressbook information * @@ -236,48 +238,6 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** - * Returns a list of ACE's for this node. - * - * Each ACE has the following properties: - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are - * currently the only supported privileges - * * 'principal', a url to the principal who owns the node - * * 'protected' (optional), indicating that this ACE is not allowed to - * be updated. - * - * @return array - */ - function getACL() { - - return [ - [ - 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner(), - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => $this->getOwner(), - 'protected' => true, - ], - - ]; - - } /** * This method returns the ACL's for card nodes in this address book. @@ -290,12 +250,7 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie return [ [ - 'privilege' => '{DAV:}read', - 'principal' => $this->getOwner(), - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->getOwner(), 'protected' => true, ], @@ -303,37 +258,6 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } /** * This method returns the current sync-token for this collection. diff --git a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php index ebc251832..888a44a40 100644 --- a/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php +++ b/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php @@ -18,6 +18,8 @@ use Sabre\Uri; */ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL { + use DAVACL\ACLTrait; + /** * Principal uri * @@ -186,78 +188,4 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection, } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** - * Returns a list of ACE's for this node. - * - * Each ACE has the following properties: - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are - * currently the only supported privileges - * * 'principal', a url to the principal who owns the node - * * 'protected' (optional), indicating that this ACE is not allowed to - * be updated. - * - * @return array - */ - function getACL() { - - return [ - [ - 'privilege' => '{DAV:}read', - 'principal' => $this->principalUri, - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => $this->principalUri, - 'protected' => true, - ], - ]; - - } - - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php index b9691b906..54e42b899 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php @@ -55,12 +55,15 @@ interface BackendInterface { function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch); /** - * Creates a new address book + * Creates a new address book. + * + * This method should return the id of the new address book. The id can be + * in any format, including ints, strings, arrays or objects. * * @param string $principalUri * @param string $url Just the 'basename' of the url. * @param array $properties - * @return void + * @return mixed */ function createAddressBook($principalUri, $url, array $properties); diff --git a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php index 5509ddc02..7c3feff93 100644 --- a/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php +++ b/vendor/sabre/dav/lib/CardDAV/Backend/PDO.php @@ -128,7 +128,7 @@ class PDO extends AbstractBackend implements SyncSupport { } else { $query .= ', '; } - $query .= ' `' . $key . '` = :' . $key . ' '; + $query .= ' ' . $key . ' = :' . $key . ' '; } $query .= ' WHERE id = :addressbookid'; @@ -180,7 +180,9 @@ class PDO extends AbstractBackend implements SyncSupport { $query = 'INSERT INTO ' . $this->addressBooksTableName . ' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)'; $stmt = $this->pdo->prepare($query); $stmt->execute($values); - return $this->pdo->lastInsertId(); + return $this->pdo->lastInsertId( + $this->addressBooksTableName . '_id_seq' + ); } @@ -230,6 +232,7 @@ class PDO extends AbstractBackend implements SyncSupport { $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $row['etag'] = '"' . $row['etag'] . '"'; + $row['lastmodified'] = (int)$row['lastmodified']; $result[] = $row; } return $result; @@ -258,6 +261,7 @@ class PDO extends AbstractBackend implements SyncSupport { if (!$result) return false; $result['etag'] = '"' . $result['etag'] . '"'; + $result['lastmodified'] = (int)$result['lastmodified']; return $result; } @@ -286,6 +290,7 @@ class PDO extends AbstractBackend implements SyncSupport { $result = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $row['etag'] = '"' . $row['etag'] . '"'; + $row['lastmodified'] = (int)$row['lastmodified']; $result[] = $row; } return $result; diff --git a/vendor/sabre/dav/lib/CardDAV/Card.php b/vendor/sabre/dav/lib/CardDAV/Card.php index 8da672502..0a040be6b 100644 --- a/vendor/sabre/dav/lib/CardDAV/Card.php +++ b/vendor/sabre/dav/lib/CardDAV/Card.php @@ -14,6 +14,8 @@ use Sabre\DAV; */ class Card extends DAV\File implements ICard, DAVACL\IACL { + use DAVACL\ACLTrait; + /** * CardDAV backend * @@ -181,18 +183,6 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } /** * Returns a list of ACE's for this node. @@ -215,12 +205,7 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { return [ [ - 'privilege' => '{DAV:}read', - 'principal' => $this->addressBookInfo['principaluri'], - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', + 'privilege' => '{DAV:}all', 'principal' => $this->addressBookInfo['principaluri'], 'protected' => true, ], @@ -228,36 +213,4 @@ class Card extends DAV\File implements ICard, DAVACL\IACL { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/CardDAV/Plugin.php b/vendor/sabre/dav/lib/CardDAV/Plugin.php index b8bded098..0507df100 100644 --- a/vendor/sabre/dav/lib/CardDAV/Plugin.php +++ b/vendor/sabre/dav/lib/CardDAV/Plugin.php @@ -4,7 +4,7 @@ namespace Sabre\CardDAV; use Sabre\DAV; use Sabre\DAV\Exception\ReportNotSupported; -use Sabre\DAV\Xml\Property\Href; +use Sabre\DAV\Xml\Property\LocalHref; use Sabre\DAVACL; use Sabre\HTTP; use Sabre\HTTP\RequestInterface; @@ -156,11 +156,11 @@ class Plugin extends DAV\ServerPlugin { $path = $propFind->getPath(); $propFind->handle('{' . self::NS_CARDDAV . '}addressbook-home-set', function() use ($path) { - return new Href($this->getAddressBookHomeForPrincipal($path) . '/'); + return new LocalHref($this->getAddressBookHomeForPrincipal($path) . '/'); }); if ($this->directories) $propFind->handle('{' . self::NS_CARDDAV . '}directory-gateway', function() { - return new Href($this->directories); + return new LocalHref($this->directories); }); } @@ -334,12 +334,7 @@ class Plugin extends DAV\ServerPlugin { $data = stream_get_contents($data); } - $before = md5($data); - - // Converting the data to unicode, if needed. - $data = DAV\StringUtil::ensureUTF8($data); - - if (md5($data) !== $before) $modified = true; + $before = $data; try { @@ -366,11 +361,56 @@ class Plugin extends DAV\ServerPlugin { throw new DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.'); } - if (!isset($vobj->UID)) { - // No UID in vcards is invalid, but we'll just add it in anyway. - $vobj->add('UID', DAV\UUIDUtil::getUUID()); + $options = VObject\Node::PROFILE_CARDDAV; + $prefer = $this->server->getHTTPPrefer(); + + if ($prefer['handling'] !== 'strict') { + $options |= VObject\Node::REPAIR; + } + + $messages = $vobj->validate($options); + + $highestLevel = 0; + $warningMessage = null; + + // $messages contains a list of problems with the vcard, along with + // their severity. + foreach ($messages as $message) { + + if ($message['level'] > $highestLevel) { + // Recording the highest reported error level. + $highestLevel = $message['level']; + $warningMessage = $message['message']; + } + + switch ($message['level']) { + + case 1 : + // Level 1 means that there was a problem, but it was repaired. + $modified = true; + break; + case 2 : + // Level 2 means a warning, but not critical + break; + case 3 : + // Level 3 means a critical error + throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: ' . $message['message']); + + } + + } + if ($warningMessage) { + $this->server->httpResponse->setHeader( + 'X-Sabre-Ew-Gross', + 'vCard validation warning: ' . $warningMessage + ); + + // Re-serializing object. $data = $vobj->serialize(); - $modified = true; + if (!$modified && strcmp($data, $before) !== 0) { + // This ensures that the system does not send an ETag back. + $modified = true; + } } // Destroy circular references to PHP will GC the object. @@ -803,33 +843,49 @@ class Plugin extends DAV\ServerPlugin { /** * Converts a vcard blob to a different version, or jcard. * - * @param string $data + * @param string|resource $data * @param string $target * @return string */ protected function convertVCard($data, $target) { - $data = VObject\Reader::read($data); - switch ($target) { - default : - case 'vcard3' : - $data = $data->convert(VObject\Document::VCARD30); - $newResult = $data->serialize(); - break; - case 'vcard4' : - $data = $data->convert(VObject\Document::VCARD40); - $newResult = $data->serialize(); - break; - case 'jcard' : - $data = $data->convert(VObject\Document::VCARD40); - $newResult = json_encode($data->jsonSerialize()); - break; - + if (is_resource($data)) { + $data = stream_get_contents($data); } - // Destroy circular references to PHP will GC the object. - $data->destroy(); + $input = VObject\Reader::read($data); + $output = null; + try { - return $newResult; + switch ($target) { + default : + case 'vcard3' : + if ($input->getDocumentType() === VObject\Document::VCARD30) { + // Do nothing + return $data; + } + $output = $input->convert(VObject\Document::VCARD30); + return $output->serialize(); + case 'vcard4' : + if ($input->getDocumentType() === VObject\Document::VCARD40) { + // Do nothing + return $data; + } + $output = $input->convert(VObject\Document::VCARD40); + return $output->serialize(); + case 'jcard' : + $output = $input->convert(VObject\Document::VCARD40); + return json_encode($output); + + } + + } finally { + + // Destroy circular references to PHP will GC the object. + $input->destroy(); + if (!is_null($output)) { + $output->destroy(); + } + } } diff --git a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php index de8b3bb84..d015589ad 100644 --- a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php +++ b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php @@ -70,14 +70,34 @@ class VCFExportPlugin extends DAV\ServerPlugin { $aclPlugin->checkPrivileges($path, '{DAV:}read'); } - $response->setHeader('Content-Type', 'text/directory'); - $response->setStatus(200); - $nodes = $this->server->getPropertiesForPath($path, [ '{' . Plugin::NS_CARDDAV . '}address-data', ], 1); - $response->setBody($this->generateVCF($nodes)); + $format = 'text/directory'; + + $output = null; + $filenameExtension = null; + + switch ($format) { + case 'text/directory': + $output = $this->generateVCF($nodes); + $filenameExtension = '.vcf'; + break; + } + + $filename = preg_replace( + '/[^a-zA-Z0-9-_ ]/um', + '', + $node->getName() + ); + $filename .= '-' . date('Y-m-d') . $filenameExtension; + + $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $response->setHeader('Content-Type', $format); + + $response->setStatus(200); + $response->setBody($output); // Returning false to break the event chain return false; diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php index 0251decc1..85c5f30d5 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php @@ -155,8 +155,14 @@ abstract class AbstractDigest implements BackendInterface { $response ); $auth->init(); + + $oldStatus = $response->getStatus() ?: 200; $auth->requireLogin(); + // Preventing the digest utility from modifying the http status code, + // this should be handled by the main plugin. + $response->setStatus($oldStatus); + } } diff --git a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php index 818d8a4ad..4b5f35ac3 100644 --- a/vendor/sabre/dav/lib/DAV/Auth/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Auth/Plugin.php @@ -4,7 +4,6 @@ namespace Sabre\DAV\Auth; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -use Sabre\HTTP\URLUtil; use Sabre\DAV\Exception\NotAuthenticated; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; @@ -26,6 +25,20 @@ use Sabre\DAV\ServerPlugin; class Plugin extends ServerPlugin { /** + * By default this plugin will require that the user is authenticated, + * and refuse any access if the user is not authenticated. + * + * If this setting is set to false, we let the user through, whether they + * are authenticated or not. + * + * This is useful if you want to allow both authenticated and + * unauthenticated access to your server. + * + * @param bool + */ + public $autoRequireLogin = true; + + /** * authentication backends */ protected $backends; @@ -108,27 +121,6 @@ class Plugin extends ServerPlugin { } /** - * Returns the current username. - * - * This method is deprecated and is only kept for backwards compatibility - * purposes. Please switch to getCurrentPrincipal(). - * - * @deprecated Will be removed in a future version! - * @return string|null - */ - function getCurrentUser() { - - // We just do a 'basename' on the principal to give back a sane value - // here. - list(, $userName) = URLUtil::splitPath( - $this->getCurrentPrincipal() - ); - - return $userName; - - } - - /** * This method is called before any HTTP method and forces users to be authenticated * * @param RequestInterface $request @@ -154,6 +146,50 @@ class Plugin extends ServerPlugin { return; } + + $authResult = $this->check($request, $response); + + if ($authResult[0]) { + // Auth was successful + $this->currentPrincipal = $authResult[1]; + $this->loginFailedReasons = null; + return; + } + + + + // If we got here, it means that no authentication backend was + // successful in authenticating the user. + $this->currentPrincipal = null; + $this->loginFailedReasons = $authResult[1]; + + if ($this->autoRequireLogin) { + $this->challenge($request, $response); + throw new NotAuthenticated(implode(', ', $authResult[1])); + } + + } + + /** + * Checks authentication credentials, and logs the user in if possible. + * + * This method returns an array. The first item in the array is a boolean + * indicating if login was successful. + * + * If login was successful, the second item in the array will contain the + * current principal url/path of the logged in user. + * + * If login was not successful, the second item in the array will contain a + * an array with strings. The strings are a list of reasons why login was + * unsuccesful. For every auth backend there will be one reason, so usually + * there's just one. + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @return array + */ + function check(RequestInterface $request, ResponseInterface $response) { + if (!$this->backends) { throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.'); } @@ -172,20 +208,56 @@ class Plugin extends ServerPlugin { if ($result[0]) { $this->currentPrincipal = $result[1]; // Exit early - return; + return [true, $result[1]]; } $reasons[] = $result[1]; } - // If we got here, it means that no authentication backend was - // successful in authenticating the user. - $this->currentPrincipal = null; + return [false, $reasons]; + + } + + /** + * This method sends authentication challenges to the user. + * + * This method will for example cause a HTTP Basic backend to set a + * WWW-Authorization header, indicating to the client that it should + * authenticate. + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @return array + */ + function challenge(RequestInterface $request, ResponseInterface $response) { foreach ($this->backends as $backend) { $backend->challenge($request, $response); } - throw new NotAuthenticated(implode(', ', $reasons)); + + } + + /** + * List of reasons why login failed for the last login operation. + * + * @var string[]|null + */ + protected $loginFailedReasons; + + /** + * Returns a list of reasons why login was unsuccessful. + * + * This method will return the login failed reasons for the last login + * operation. One for each auth backend. + * + * This method returns null if the last authentication attempt was + * successful, or if there was no authentication attempt yet. + * + * @return string[]|null + */ + function getLoginFailedReasons() { + + return $this->loginFailedReasons; } diff --git a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php index 07ca6c3e5..49359a045 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/Plugin.php +++ b/vendor/sabre/dav/lib/DAV/Browser/Plugin.php @@ -48,7 +48,7 @@ class Plugin extends DAV\ServerPlugin { public $uninterestingProperties = [ '{DAV:}supportedlock', '{DAV:}acl-restrictions', - '{DAV:}supported-privilege-set', +// '{DAV:}supported-privilege-set', '{DAV:}supported-method-set', ]; @@ -112,7 +112,7 @@ class Plugin extends DAV\ServerPlugin { $getVars = $request->getQueryParameters(); // CSP headers - $this->server->httpResponse->setHeader('Content-Security-Policy', "img-src 'self'; style-src 'self';"); + $this->server->httpResponse->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"); $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null; @@ -354,7 +354,7 @@ class Plugin extends DAV\ServerPlugin { $output = ''; if ($this->enablePost) { - $this->server->emit('onHTMLActionsPanel', [$node, &$output]); + $this->server->emit('onHTMLActionsPanel', [$node, &$output, $path]); } if ($output) { @@ -368,7 +368,7 @@ class Plugin extends DAV\ServerPlugin { $html .= $this->generateFooter(); - $this->server->httpResponse->setHeader('Content-Security-Policy', "img-src 'self'; style-src 'self';"); + $this->server->httpResponse->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"); return $html; @@ -477,7 +477,7 @@ HTML; $version = DAV\Version::VERSION; return <<<HTML -<footer>Generated by SabreDAV $version (c)2007-2015 <a href="http://sabre.io/">http://sabre.io/</a></footer> +<footer>Generated by SabreDAV $version (c)2007-2016 <a href="http://sabre.io/">http://sabre.io/</a></footer> </body> </html> HTML; @@ -493,9 +493,10 @@ HTML; * * @param DAV\INode $node * @param mixed $output + * @param string $path * @return void */ - function htmlActionsPanel(DAV\INode $node, &$output) { + function htmlActionsPanel(DAV\INode $node, &$output, $path) { if (!$node instanceof DAV\ICollection) return; diff --git a/vendor/sabre/dav/lib/DAV/Browser/assets/sabredav.css b/vendor/sabre/dav/lib/DAV/Browser/assets/sabredav.css index c9ab2c74f..8869597f0 100644 --- a/vendor/sabre/dav/lib/DAV/Browser/assets/sabredav.css +++ b/vendor/sabre/dav/lib/DAV/Browser/assets/sabredav.css @@ -96,12 +96,12 @@ header a { vertical-align: middle; border: 0; } -input, button { +input, button, select { font: inherit; color: inherit; } -input[type=text] { +input[type=text], select { border: 1px solid #bbbbbb; line-height: 22px; padding: 5px 10px; @@ -200,7 +200,7 @@ section table { line-height: 40px; } -.actions input[type=text] { +.actions input[type=text], select { width: 450px; } diff --git a/vendor/sabre/dav/lib/DAV/Client.php b/vendor/sabre/dav/lib/DAV/Client.php index d46b397b6..08d5d4702 100644 --- a/vendor/sabre/dav/lib/DAV/Client.php +++ b/vendor/sabre/dav/lib/DAV/Client.php @@ -3,6 +3,7 @@ namespace Sabre\DAV; use Sabre\HTTP; +use Sabre\Uri; /** * SabreDAV DAV client @@ -387,20 +388,10 @@ class Client extends HTTP\Client { */ function getAbsoluteUrl($url) { - // If the url starts with http:// or https://, the url is already absolute. - if (preg_match('/^http(s?):\/\//', $url)) { - return $url; - } - - // If the url starts with a slash, we must calculate the url based off - // the root of the base url. - if (strpos($url, '/') === 0) { - $parts = parse_url($this->baseUri); - return $parts['scheme'] . '://' . $parts['host'] . (isset($parts['port']) ? ':' . $parts['port'] : '') . $url; - } - - // Otherwise... - return $this->baseUri . $url; + return Uri\resolve( + $this->baseUri, + $url + ); } diff --git a/vendor/sabre/dav/lib/DAV/CorePlugin.php b/vendor/sabre/dav/lib/DAV/CorePlugin.php index 3a70b2a7e..a1b052915 100644 --- a/vendor/sabre/dav/lib/DAV/CorePlugin.php +++ b/vendor/sabre/dav/lib/DAV/CorePlugin.php @@ -50,6 +50,8 @@ class CorePlugin extends ServerPlugin { $server->on('propFind', [$this, 'propFindNode'], 120); $server->on('propFind', [$this, 'propFindLate'], 200); + $server->on('exception', [$this, 'exception']); + } /** @@ -844,10 +846,8 @@ class CorePlugin extends ServerPlugin { if ($node instanceof IProperties && $propertyNames = $propFind->get404Properties()) { $nodeProperties = $node->getProperties($propertyNames); - foreach ($propertyNames as $propertyName) { - if (array_key_exists($propertyName, $nodeProperties)) { - $propFind->set($propertyName, $nodeProperties[$propertyName], 200); - } + foreach ($nodeProperties as $propertyName => $propertyValue) { + $propFind->set($propertyName, $propertyValue, 200); } } @@ -905,6 +905,38 @@ class CorePlugin extends ServerPlugin { } /** + * Listens for exception events, and automatically logs them. + * + * @param Exception $e + */ + function exception($e) { + + $logLevel = \Psr\Log\LogLevel::CRITICAL; + if ($e instanceof \Sabre\DAV\Exception) { + // If it's a standard sabre/dav exception, it means we have a http + // status code available. + $code = $e->getHTTPCode(); + + if ($code >= 400 && $code < 500) { + // user error + $logLevel = \Psr\Log\LogLevel::INFO; + } else { + // Server-side error. We mark it's as an error, but it's not + // critical. + $logLevel = \Psr\Log\LogLevel::ERROR; + } + } + + $this->server->getLogger()->log( + $logLevel, + 'Uncaught exception', + [ + 'exception' => $e, + ] + ); + } + + /** * Returns a bunch of meta-data about the plugin. * * Providing this information is optional, and is mainly displayed by the diff --git a/vendor/sabre/dav/lib/DAV/FS/Directory.php b/vendor/sabre/dav/lib/DAV/FS/Directory.php index 963e5554c..362f7a411 100644 --- a/vendor/sabre/dav/lib/DAV/FS/Directory.php +++ b/vendor/sabre/dav/lib/DAV/FS/Directory.php @@ -140,10 +140,10 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota { * @return array */ function getQuotaInfo() { - + $absolute = realpath($this->path); return [ - disk_total_space($this->path) - disk_free_space($this->path), - disk_free_space($this->path) + disk_total_space($absolute) - disk_free_space($absolute), + disk_free_space($absolute) ]; } diff --git a/vendor/sabre/dav/lib/DAV/File.php b/vendor/sabre/dav/lib/DAV/File.php index e0a0391db..675956b22 100644 --- a/vendor/sabre/dav/lib/DAV/File.php +++ b/vendor/sabre/dav/lib/DAV/File.php @@ -15,12 +15,24 @@ namespace Sabre\DAV; abstract class File extends Node implements IFile { /** - * Updates the data + * Replaces the contents of the file. * - * data is a readable stream resource. + * The data argument is a readable stream resource. * - * @param resource $data - * @return void + * After a succesful put operation, you may choose to return an ETag. The + * etag must always be surrounded by double-quotes. These quotes must + * appear in the actual string you're returning. + * + * Clients may use the ETag from a PUT request to later on make sure that + * when they update the file, the contents haven't changed in the mean + * time. + * + * If you don't plan to store the file byte-by-byte, and you return a + * different object on a subsequent GET you are strongly recommended to not + * return an ETag, and just return null. + * + * @param string|resource $data + * @return string|null */ function put($data) { diff --git a/vendor/sabre/dav/lib/DAV/ICollection.php b/vendor/sabre/dav/lib/DAV/ICollection.php index 390d9b741..7793070d3 100644 --- a/vendor/sabre/dav/lib/DAV/ICollection.php +++ b/vendor/sabre/dav/lib/DAV/ICollection.php @@ -54,14 +54,14 @@ interface ICollection extends INode { * exist. * * @param string $name - * @return DAV\INode + * @return INode */ function getChild($name); /** * Returns an array with all the child nodes * - * @return DAV\INode[] + * @return INode[] */ function getChildren(); diff --git a/vendor/sabre/dav/lib/DAV/IFile.php b/vendor/sabre/dav/lib/DAV/IFile.php index e16a3a58a..37e7cd33c 100644 --- a/vendor/sabre/dav/lib/DAV/IFile.php +++ b/vendor/sabre/dav/lib/DAV/IFile.php @@ -32,7 +32,7 @@ interface IFile extends INode { * different object on a subsequent GET you are strongly recommended to not * return an ETag, and just return null. * - * @param resource $data + * @param resource|data $data * @return string|null */ function put($data); diff --git a/vendor/sabre/dav/lib/DAV/INode.php b/vendor/sabre/dav/lib/DAV/INode.php index b5e6cb9ef..bb884934d 100644 --- a/vendor/sabre/dav/lib/DAV/INode.php +++ b/vendor/sabre/dav/lib/DAV/INode.php @@ -36,9 +36,10 @@ interface INode { function setName($name); /** - * Returns the last modification time, as a unix timestamp + * Returns the last modification time, as a unix timestamp. Return null + * if the information is not available. * - * @return int + * @return int|null */ function getLastModified(); diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php index 910e4979d..2fe843884 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php @@ -88,6 +88,9 @@ class PDO implements BackendInterface { $stmt->execute([$path]); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + if (gettype($row['value']) === 'resource') { + $row['value'] = stream_get_contents($row['value']); + } switch ($row['valuetype']) { case null : case self::VT_STRING : @@ -121,7 +124,26 @@ class PDO implements BackendInterface { $propPatch->handleRemaining(function($properties) use ($path) { - $updateStmt = $this->pdo->prepare("REPLACE INTO " . $this->tableName . " (path, name, valuetype, value) VALUES (?, ?, ?, ?)"); + + if ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'pgsql') { + + $updateSql = <<<SQL +INSERT INTO {$this->tableName} (path, name, valuetype, value) +VALUES (:path, :name, :valuetype, :value) +ON CONFLICT (path, name) +DO UPDATE SET valuetype = :valuetype, value = :value +SQL; + + + } else { + $updateSql = <<<SQL +REPLACE INTO {$this->tableName} (path, name, valuetype, value) +VALUES (:path, :name, :valuetype, :value) +SQL; + + } + + $updateStmt = $this->pdo->prepare($updateSql); $deleteStmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? AND name = ?"); foreach ($properties as $name => $value) { @@ -136,7 +158,14 @@ class PDO implements BackendInterface { $valueType = self::VT_OBJECT; $value = serialize($value); } - $updateStmt->execute([$path, $name, $valueType, $value]); + + $updateStmt->bindParam('path', $path, \PDO::PARAM_STR); + $updateStmt->bindParam('name', $name, \PDO::PARAM_STR); + $updateStmt->bindParam('valuetype', $valueType, \PDO::PARAM_INT); + $updateStmt->bindParam('value', $value, \PDO::PARAM_LOB); + + $updateStmt->execute(); + } else { $deleteStmt->execute([$path, $name]); } diff --git a/vendor/sabre/dav/lib/DAV/Server.php b/vendor/sabre/dav/lib/DAV/Server.php index b37652812..024b7a557 100644 --- a/vendor/sabre/dav/lib/DAV/Server.php +++ b/vendor/sabre/dav/lib/DAV/Server.php @@ -8,6 +8,10 @@ use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Sabre\HTTP\URLUtil; use Sabre\Uri; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; /** * Main DAV server class @@ -16,7 +20,9 @@ use Sabre\Uri; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Server extends EventEmitter { +class Server extends EventEmitter implements LoggerAwareInterface { + + use LoggerAwareTrait; /** * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree @@ -431,6 +437,20 @@ class Server extends EventEmitter { } /** + * Returns the PSR-3 logger objcet. + * + * @return LoggerInterface + */ + function getLogger() { + + if (!$this->logger) { + $this->logger = new NullLogger(); + } + return $this->logger; + + } + + /** * Handles a http request, and execute a method based on its name * * @param RequestInterface $request @@ -1177,9 +1197,20 @@ class Server extends EventEmitter { if (!$success) { $result = $mkCol->getResult(); - // generateMkCol needs the href key to exist. - $result['href'] = $uri; - return $result; + + $formattedResult = [ + 'href' => $uri, + ]; + + foreach ($result as $propertyName => $status) { + + if (!isset($formattedResult[$status])) { + $formattedResult[$status] = []; + } + $formattedResult[$status][$propertyName] = null; + + } + return $formattedResult; } $this->tree->markDirty($parentUri); diff --git a/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php new file mode 100644 index 000000000..034aefbdc --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Sharing/ISharedNode.php @@ -0,0 +1,69 @@ +<?php + +namespace Sabre\DAV\Sharing; + +use Sabre\DAV\INode; + +/** + * This interface represents a resource that has sharing capabilities, either + * because it's possible for an owner to share the resource, or because this is + * an instance of a shared resource. + * + * @copyright Copyright (C) fruux GmbH. (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +interface ISharedNode extends INode { + + /** + * Returns the 'access level' for the instance of this shared resource. + * + * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_ + * constants. + * + * @return int + */ + function getShareAccess(); + + /** + * This function must return a URI that uniquely identifies the shared + * resource. This URI should be identical across instances, and is + * also used in several other XML bodies to connect invites to + * resources. + * + * This may simply be a relative reference to the original shared instance, + * but it could also be a urn. As long as it's a valid URI and unique. + * + * @return string + */ + function getShareResourceUri(); + + /** + * Updates the list of sharees. + * + * Every item must be a Sharee object. + * + * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees + * @return void + */ + function updateInvites(array $sharees); + + /** + * Returns the list of people whom this resource is shared with. + * + * Every item in the returned array must be a Sharee object with + * at least the following properties set: + * + * * $href + * * $shareAccess + * * $inviteStatus + * + * and optionally: + * + * * $properties + * + * @return \Sabre\DAV\Xml\Element\Sharee[] + */ + function getInvites(); + +} diff --git a/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php new file mode 100644 index 000000000..354d06a56 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Sharing/Plugin.php @@ -0,0 +1,342 @@ +<?php + +namespace Sabre\DAV\Sharing; + +use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\INode; +use Sabre\DAV\PropFind; +use Sabre\DAV\Server; +use Sabre\DAV\ServerPlugin; +use Sabre\DAV\Xml\Property; +use Sabre\DAV\Xml\Element\Sharee; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; + +/** + * This plugin implements HTTP requests and properties related to: + * + * draft-pot-webdav-resource-sharing + * + * This specification allows people to share webdav resources with others. + * + * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class Plugin extends ServerPlugin { + + const ACCESS_NOTSHARED = 0; + const ACCESS_SHAREDOWNER = 1; + const ACCESS_READ = 2; + const ACCESS_READWRITE = 3; + const ACCESS_NOACCESS = 4; + + const INVITE_NORESPONSE = 1; + const INVITE_ACCEPTED = 2; + const INVITE_DECLINED = 3; + const INVITE_INVALID = 4; + + /** + * Reference to SabreDAV server object. + * + * @var Sabre\DAV\Server + */ + protected $server; + + /** + * This method should return a list of server-features. + * + * This is for example 'versioning' and is added to the DAV: header + * in an OPTIONS response. + * + * @return array + */ + function getFeatures() { + + return ['resource-sharing']; + + } + + /** + * Returns a plugin name. + * + * Using this name other plugins will be able to access other plugins + * using \Sabre\DAV\Server::getPlugin + * + * @return string + */ + function getPluginName() { + + return 'sharing'; + + } + + /** + * This initializes the plugin. + * + * This function is called by Sabre\DAV\Server, after + * addPlugin is called. + * + * This method should set up the required event subscriptions. + * + * @param Server $server + * @return void + */ + function initialize(Server $server) { + + $this->server = $server; + + $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource'; + + array_push( + $server->protectedProperties, + '{DAV:}share-mode' + ); + + $server->on('method:POST', [$this, 'httpPost']); + $server->on('propFind', [$this, 'propFind']); + $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']); + $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('onBrowserPostAction', [$this, 'browserPostAction']); + + } + + /** + * Updates the list of sharees on a shared resource. + * + * The sharees array is a list of people that are to be added modified + * or removed in the list of shares. + * + * @param string $path + * @param Sharee[] $sharees + * @return void + */ + function shareResource($path, array $sharees) { + + $node = $this->server->tree->getNodeForPath($path); + + if (!$node instanceof ISharedNode) { + + throw new Forbidden('Sharing is not allowed on this node'); + + } + + // Getting ACL info + $acl = $this->server->getPlugin('acl'); + + // If there's no ACL support, we allow everything + if ($acl) { + $acl->checkPrivileges($path, '{DAV:}share'); + } + + foreach ($sharees as $sharee) { + // We're going to attempt to get a local principal uri for a share + // href by emitting the getPrincipalByUri event. + $principal = null; + $this->server->emit('getPrincipalByUri', [$sharee->href, &$principal]); + $sharee->principal = $principal; + } + $node->updateInvites($sharees); + + } + + /** + * This event is triggered when properties are requested for nodes. + * + * This allows us to inject any sharings-specific properties. + * + * @param PropFind $propFind + * @param INode $node + * @return void + */ + function propFind(PropFind $propFind, INode $node) { + + if ($node instanceof ISharedNode) { + + $propFind->handle('{DAV:}share-access', function() use ($node) { + + return new Property\ShareAccess($node->getShareAccess()); + + }); + $propFind->handle('{DAV:}invite', function() use ($node) { + + return new Property\Invite($node->getInvites()); + + }); + $propFind->handle('{DAV:}share-resource-uri', function() use ($node) { + + return new Property\Href($node->getShareResourceUri()); + + }); + + } + + } + + /** + * We intercept this to handle POST requests on shared resources + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @return null|bool + */ + function httpPost(RequestInterface $request, ResponseInterface $response) { + + $path = $request->getPath(); + $contentType = $request->getHeader('Content-Type'); + + // We're only interested in the davsharing content type. + if (strpos($contentType, 'application/davsharing+xml') === false) { + return; + } + + $message = $this->server->xml->parse( + $request->getBody(), + $request->getUrl(), + $documentType + ); + + switch ($documentType) { + + case '{DAV:}share-resource': + + $this->shareResource($path, $message->sharees); + $response->setStatus(200); + // Adding this because sending a response body may cause issues, + // and I wanted some type of indicator the response was handled. + $response->setHeader('X-Sabre-Status', 'everything-went-well'); + + // Breaking the event chain + return false; + + default : + throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type'); + + } + + } + + /** + * This method is triggered whenever a subsystem reqeuests the privileges + * hat are supported on a particular node. + * + * We need to add a number of privileges for scheduling purposes. + * + * @param INode $node + * @param array $supportedPrivilegeSet + */ + function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) { + + if ($node instanceof ISharedNode) { + $supportedPrivilegeSet['{DAV:}share'] = [ + 'abstract' => false, + 'aggregates' => [], + ]; + } + } + + /** + * Returns a bunch of meta-data about the plugin. + * + * Providing this information is optional, and is mainly displayed by the + * Browser plugin. + * + * The description key in the returned array may contain html and will not + * be sanitized. + * + * @return array + */ + function getPluginInfo() { + + return [ + 'name' => $this->getPluginName(), + 'description' => 'This plugin implements WebDAV resource sharing', + 'link' => 'https://github.com/evert/webdav-sharing' + ]; + + } + + /** + * This method is used to generate HTML output for the + * DAV\Browser\Plugin. + * + * @param INode $node + * @param string $output + * @param string $path + * @return bool|null + */ + function htmlActionsPanel(INode $node, &$output, $path) { + + if (!$node instanceof ISharedNode) { + return; + } + + $aclPlugin = $this->server->getPlugin('acl'); + if ($aclPlugin) { + if (!$aclPlugin->checkPrivileges($path, '{DAV:}share', \Sabre\DAVACL\Plugin::R_PARENT, false)) { + // Sharing is not permitted, we will not draw this interface. + return; + } + } + + $output .= '<tr><td colspan="2"><form method="post" action=""> + <h3>Share this resource</h3> + <input type="hidden" name="sabreAction" value="share" /> + <label>Share with (uri):</label> <input type="text" name="href" placeholder="mailto:user@example.org"/><br /> + <label>Access</label> + <select name="access"> + <option value="readwrite">Read-write</option> + <option value="read">Read-only</option> + <option value="no-access">Revoke access</option> + </select><br /> + <input type="submit" value="share" /> + </form> + </td></tr>'; + + } + + /** + * This method is triggered for POST actions generated by the browser + * plugin. + * + * @param string $path + * @param string $action + * @param array $postVars + */ + function browserPostAction($path, $action, $postVars) { + + if ($action !== 'share') { + return; + } + + if (empty($postVars['href'])) { + throw new BadRequest('The "href" POST parameter is required'); + } + if (empty($postVars['access'])) { + throw new BadRequest('The "access" POST parameter is required'); + } + + $accessMap = [ + 'readwrite' => self::ACCESS_READWRITE, + 'read' => self::ACCESS_READ, + 'no-access' => self::ACCESS_NOACCESS, + ]; + + if (!isset($accessMap[$postVars['access']])) { + throw new BadRequest('The "access" POST must be readwrite, read or no-access'); + } + $sharee = new Sharee([ + 'href' => $postVars['href'], + 'access' => $accessMap[$postVars['access']], + ]); + + $this->shareResource( + $path, + [$sharee] + ); + return false; + + } + +} diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php index 4563f7c72..5d2792503 100644 --- a/vendor/sabre/dav/lib/DAV/Tree.php +++ b/vendor/sabre/dav/lib/DAV/Tree.php @@ -229,7 +229,7 @@ class Tree { // flushing the entire cache $path = trim($path, '/'); foreach ($this->cache as $nodePath => $node) { - if ($nodePath == $path || strpos($nodePath, $path . '/') === 0) + if ($path === '' || $nodePath == $path || strpos($nodePath, $path . '/') === 0) unset($this->cache[$nodePath]); } diff --git a/vendor/sabre/dav/lib/DAV/Version.php b/vendor/sabre/dav/lib/DAV/Version.php index f9331943a..5430b967c 100644 --- a/vendor/sabre/dav/lib/DAV/Version.php +++ b/vendor/sabre/dav/lib/DAV/Version.php @@ -14,6 +14,6 @@ class Version { /** * Full version number */ - const VERSION = '3.1.3'; + const VERSION = '3.2.0-beta1'; } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php new file mode 100644 index 000000000..dcfd7bd2e --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Xml/Element/Sharee.php @@ -0,0 +1,199 @@ +<?php + +namespace Sabre\DAV\Xml\Element; + +use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Sharing\Plugin; +use Sabre\DAV\Xml\Property\Href; +use Sabre\DAV\Xml\Property\ShareAccess; +use Sabre\Xml\Deserializer; +use Sabre\Xml\Element; +use Sabre\Xml\Reader; +use Sabre\Xml\Writer; + +/** + * This class represents the {DAV:}sharee element. + * + * @copyright Copyright (C) fruux GmbH. (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class Sharee implements Element { + + /** + * A URL. Usually a mailto: address, could also be a principal url. + * This uniquely identifies the sharee. + * + * @var string + */ + public $href; + + /** + * A local principal path. The server will do its best to locate the + * principal uri based on the given uri. If we could find a local matching + * principal uri, this property will contain the value. + * + * @var string|null + */ + public $principal; + + /** + * A list of WebDAV properties that describe the sharee. This might for + * example contain a {DAV:}displayname with the real name of the user. + * + * @var array + */ + public $properties = []; + + /** + * Share access level. One of the Sabre\DAV\Sharing\Plugin::ACCESS + * constants. + * + * Can be one of: + * + * ACCESS_READ + * ACCESS_READWRITE + * ACCESS_SHAREDOWNER + * ACCESS_NOACCESS + * + * depending on context. + * + * @var int + */ + public $access; + + /** + * When a sharee is originally invited to a share, the sharer may add + * a comment. This will be placed in this property. + * + * @var string + */ + public $comment; + + /** + * The status of the invite, should be one of the + * Sabre\DAV\Sharing\Plugin::INVITE constants. + * + * @var int + */ + public $inviteStatus; + + /** + * Creates the object + * + * $properties will be used to populate all internal properties. + * + * @param array $properties + */ + function __construct(array $properties = []) { + + foreach ($properties as $k => $v) { + + if (property_exists($this, $k)) { + $this->$k = $v; + } else { + throw new \InvalidArgumentException('Unknown property: ' . $k); + } + + } + + } + + /** + * The xmlSerialize method is called during xml writing. + * + * Use the $writer argument to write its own xml serialization. + * + * An important note: do _not_ create a parent element. Any element + * implementing XmlSerializble should only ever write what's considered + * its 'inner xml'. + * + * The parent of the current element is responsible for writing a + * containing element. + * + * This allows serializers to be re-used for different element names. + * + * If you are opening new elements, you must also close them again. + * + * @param Writer $writer + * @return void + */ + function xmlSerialize(Writer $writer) { + + + $writer->write([ + new Href($this->href), + '{DAV:}prop' => $this->properties, + '{DAV:}share-access' => new ShareAccess($this->access), + ]); + switch ($this->inviteStatus) { + case Plugin::INVITE_NORESPONSE : + $writer->writeElement('{DAV:}invite-noresponse'); + break; + case Plugin::INVITE_ACCEPTED : + $writer->writeElement('{DAV:}invite-accepted'); + break; + case Plugin::INVITE_DECLINED : + $writer->writeElement('{DAV:}invite-declined'); + break; + case Plugin::INVITE_INVALID : + $writer->writeElement('{DAV:}invite-invalid'); + break; + } + + } + + /** + * The deserialize method is called during xml parsing. + * + * This method is called statictly, this is because in theory this method + * may be used as a type of constructor, or factory method. + * + * Often you want to return an instance of the current class, but you are + * free to return other data as well. + * + * You are responsible for advancing the reader to the next element. Not + * doing anything will result in a never-ending loop. + * + * If you just want to skip parsing for this element altogether, you can + * just call $reader->next(); + * + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to + * the next element. + * + * @param Reader $reader + * @return mixed + */ + static function xmlDeserialize(Reader $reader) { + + // Temporarily override configuration + $reader->pushContext(); + $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\keyValue'; + + $elems = Deserializer\keyValue($reader, 'DAV:'); + + // Restore previous configuration + $reader->popContext(); + + $sharee = new self(); + if (!isset($elems['href'])) { + throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element'); + } + $sharee->href = $elems['href']; + + if (isset($elems['prop'])) { + $sharee->properties = $elems['prop']; + } + if (isset($elems['comment'])) { + $sharee->comment = $elems['comment']; + } + if (!isset($elems['share-access'])) { + throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); + } + $sharee->access = $elems['share-access']->getValue(); + return $sharee; + + } + +} diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php index 538e98d0f..0027f72e1 100644 --- a/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Href.php @@ -7,6 +7,7 @@ use Sabre\DAV\Browser\HtmlOutputHelper; use Sabre\Xml\Element; use Sabre\Xml\Reader; use Sabre\Xml\Writer; +use Sabre\Uri; /** * Href property @@ -32,13 +33,6 @@ class Href implements Element, HtmlOutput { protected $hrefs; /** - * Automatically prefix the url with the server base directory - * - * @var bool - */ - protected $autoPrefix = true; - - /** * Constructor * * You must either pass a string for a single href, or an array of hrefs. @@ -47,16 +41,13 @@ class Href implements Element, HtmlOutput { * and not relative to the servers base uri. * * @param string|string[] $href - * @param bool $autoPrefix */ - function __construct($hrefs, $autoPrefix = true) { + function __construct($hrefs) { if (is_string($hrefs)) { $hrefs = [$hrefs]; } $this->hrefs = $hrefs; - $this->autoPrefix = $autoPrefix; - } @@ -104,9 +95,7 @@ class Href implements Element, HtmlOutput { function xmlSerialize(Writer $writer) { foreach ($this->getHrefs() as $href) { - if ($this->autoPrefix) { - $href = $writer->contextUri . \Sabre\HTTP\encodePath($href); - } + $href = Uri\resolve($writer->contextUri, $href); $writer->writeElement('{DAV:}href', $href); } diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php new file mode 100644 index 000000000..0616ff113 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/Invite.php @@ -0,0 +1,70 @@ +<?php + +namespace Sabre\DAV\Xml\Property; + +use Sabre\DAV\Sharing\Sharee; +use Sabre\Xml\XmlSerializable; +use Sabre\Xml\Writer; + +/** + * This class represents the {DAV:}invite property. + * + * This property is defined here: + * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-03#section-4.4.2 + * + * This property is used by clients to determine who currently has access to + * a shared resource, what their access level is and what their invite status + * is. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class Invite implements XmlSerializable { + + /** + * A list of sharees + * + * @var Sharee[] + */ + public $sharees = []; + + /** + * Creates the property. + * + * @param Sharee[] $sharees + */ + function __construct(array $sharees) { + + $this->sharees = $sharees; + + } + + /** + * The xmlSerialize method is called during xml writing. + * + * Use the $writer argument to write its own xml serialization. + * + * An important note: do _not_ create a parent element. Any element + * implementing XmlSerializble should only ever write what's considered + * its 'inner xml'. + * + * The parent of the current element is responsible for writing a + * containing element. + * + * This allows serializers to be re-used for different element names. + * + * If you are opening new elements, you must also close them again. + * + * @param Writer $writer + * @return void + */ + function xmlSerialize(Writer $writer) { + + foreach ($this->sharees as $sharee) { + $writer->writeElement('{DAV:}sharee', $sharee); + } + + } + +} diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php new file mode 100644 index 000000000..76a27b95d --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/LocalHref.php @@ -0,0 +1,48 @@ +<?php + +namespace Sabre\DAV\Xml\Property; + +use Sabre\HTTP; + +/** + * LocalHref property + * + * Like the Href property, this element represents {DAV:}href. The difference + * is that this is used stricly for paths on the server. The LocalHref property + * will prepare the path so it's a valid URI. + * + * These two objects behave identically: + * new LocalHref($path) + * new Href(\Sabre\HTTP\encodePath($path)) + * + * LocalPath basically ensures that your spaces are %20, and everything that + * needs to be is uri encoded. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://sabre.io/license/ Modified BSD License + */ +class LocalHref extends Href { + + /** + * Constructor + * + * You must either pass a string for a single href, or an array of hrefs. + * + * If auto-prefix is set to false, the hrefs will be treated as absolute + * and not relative to the servers base uri. + * + * @param string|string[] $href + */ + function __construct($hrefs) { + + parent::__construct(array_map( + function($href) { + return \Sabre\HTTP\encodePath($href); + }, + (array)$hrefs + )); + + } + +} diff --git a/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php new file mode 100644 index 000000000..f27af5415 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Xml/Property/ShareAccess.php @@ -0,0 +1,143 @@ +<?php + +namespace Sabre\DAV\Xml\Property; + +use Sabre\DAV\Sharing\Plugin as SharingPlugin; +use Sabre\DAV\Exception\BadRequest; +use Sabre\Xml\Element; +use Sabre\Xml\Reader; +use Sabre\Xml\Writer; + +/** + * This class represents the {DAV:}share-access property. + * + * This property is defined here: + * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-03#section-4.4.1 + * + * This property is used to indicate if a resource is a shared resource, and + * whether the instance of the shared resource is the original instance, or + * an instance belonging to a sharee. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class ShareAccess implements Element { + + /** + * Either SHARED or SHAREDOWNER + * + * @var int + */ + protected $value; + + /** + * Creates the property. + * + * The constructor value must be one of the + * \Sabre\DAV\Sharing\Plugin::ACCESS_ constants. + * + * @param int $shareAccess + */ + function __construct($shareAccess) { + + $this->value = $shareAccess; + + } + + /** + * Returns the current value. + * + * @return int + */ + function getValue() { + + return $this->value; + + } + + /** + * The xmlSerialize method is called during xml writing. + * + * Use the $writer argument to write its own xml serialization. + * + * An important note: do _not_ create a parent element. Any element + * implementing XmlSerializble should only ever write what's considered + * its 'inner xml'. + * + * The parent of the current element is responsible for writing a + * containing element. + * + * This allows serializers to be re-used for different element names. + * + * If you are opening new elements, you must also close them again. + * + * @param Writer $writer + * @return void + */ + function xmlSerialize(Writer $writer) { + + switch ($this->value) { + + case SharingPlugin::ACCESS_NOTSHARED : + $writer->writeElement('{DAV:}not-shared'); + break; + case SharingPlugin::ACCESS_SHAREDOWNER : + $writer->writeElement('{DAV:}shared-owner'); + break; + case SharingPlugin::ACCESS_READ : + $writer->writeElement('{DAV:}read'); + break; + case SharingPlugin::ACCESS_READWRITE : + $writer->writeElement('{DAV:}read-write'); + break; + case SharingPlugin::ACCESS_NOACCESS : + $writer->writeElement('{DAV:}no-access'); + break; + + } + + } + + /** + * The deserialize method is called during xml parsing. + * + * This method is called statictly, this is because in theory this method + * may be used as a type of constructor, or factory method. + * + * Often you want to return an instance of the current class, but you are + * free to return other data as well. + * + * You are responsible for advancing the reader to the next element. Not + * doing anything will result in a never-ending loop. + * + * If you just want to skip parsing for this element altogether, you can + * just call $reader->next(); + * + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to + * the next element. + * + * @param Reader $reader + * @return mixed + */ + static function xmlDeserialize(Reader $reader) { + + $elems = $reader->parseInnerTree(); + foreach ($elems as $elem) { + switch ($elem['name']) { + case '{DAV:}not-shared' : + return new self(SharingPlugin::ACCESS_NOTSHARED); + case '{DAV:}sharedowner' : + return new self(SharingPlugin::ACCESS_SHAREDOWNER); + case '{DAV:}read' : + return new self(SharingPlugin::ACCESS_READ); + case '{DAV:}read-write' : + return new self(SharingPlugin::ACCESS_READWRITE); + case '{DAV:}no-access' : + return new self(SharingPlugin::ACCESS_NOACCESS); + } + } + throw new BadRequest('Invalid value for {DAV:}share-access element'); + + } +} diff --git a/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php new file mode 100644 index 000000000..965e5857c --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Xml/Request/ShareResource.php @@ -0,0 +1,81 @@ +<?php + +namespace Sabre\DAV\Xml\Request; + +use Sabre\Xml\Reader; +use Sabre\Xml\XmlDeserializable; +use Sabre\DAV\Xml\Element\Sharee; + +/** + * ShareResource request parser. + * + * This class parses the {DAV:}share-resource POST request as defined in: + * + * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-01#section-5.3.2.1 + * + * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://sabre.io/license/ Modified BSD License + */ +class ShareResource implements XmlDeserializable { + + /** + * The list of new people added or updated or removed from the share. + * + * @var Sharee[] + */ + public $sharees = []; + + /** + * Constructor + * + * @param Sharee[] $sharees + */ + function __construct(array $sharees) { + + $this->sharees = $sharees; + + } + + /** + * The deserialize method is called during xml parsing. + * + * This method is called statictly, this is because in theory this method + * may be used as a type of constructor, or factory method. + * + * Often you want to return an instance of the current class, but you are + * free to return other data as well. + * + * You are responsible for advancing the reader to the next element. Not + * doing anything will result in a never-ending loop. + * + * If you just want to skip parsing for this element altogether, you can + * just call $reader->next(); + * + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to + * the next element. + * + * @param Reader $reader + * @return mixed + */ + static function xmlDeserialize(Reader $reader) { + + $elems = $reader->parseInnerTree([ + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', + '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', + ]); + + $sharees = []; + + foreach ($elems as $elem) { + if ($elem['name'] !== '{DAV:}sharee') continue; + $sharees[] = $elem['value']; + + } + + return new self($sharees); + + } + +} diff --git a/vendor/sabre/dav/lib/DAVACL/ACLTrait.php b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php new file mode 100644 index 000000000..602654a2e --- /dev/null +++ b/vendor/sabre/dav/lib/DAVACL/ACLTrait.php @@ -0,0 +1,100 @@ +<?php + +namespace Sabre\DAVACL; + +/** + * This trait is a default implementation of the IACL interface. + * + * In many cases you only want to implement 1 or to of the IACL functions, + * this trait allows you to be a bit lazier. + * + * By default this trait grants all privileges to the owner of the resource. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (https://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +trait ACLTrait { + + /** + * Returns the owner principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + function getOwner() { + + return null; + + } + + /** + * Returns a group principal + * + * This must be a url to a principal, or null if there's no owner + * + * @return string|null + */ + function getGroup() { + + return null; + + } + + /** + * Returns a list of ACE's for this node. + * + * Each ACE has the following properties: + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are + * currently the only supported privileges + * * 'principal', a url to the principal who owns the node + * * 'protected' (optional), indicating that this ACE is not allowed to + * be updated. + * + * @return array + */ + function getACL() { + + return [ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', + 'protected' => true, + ] + ]; + + } + + /** + * Updates the ACL + * + * This method will receive a list of new ACE's as an array argument. + * + * @param array $acl + * @return void + */ + function setACL(array $acl) { + + throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node'); + } + + /** + * Returns the list of supported privileges for this node. + * + * The returned data structure is a list of nested privileges. + * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple + * standard structure. + * + * If null is returned from this method, the default privilege set is used, + * which is fine for most common usecases. + * + * @return array|null + */ + function getSupportedPrivilegeSet() { + + return null; + + } + +} diff --git a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php index 460f78981..9d2026380 100644 --- a/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php @@ -110,7 +110,7 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * * @param string $name * @throws DAV\Exception\NotFound - * @return IPrincipal + * @return DAV\INode */ function getChild($name) { diff --git a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php index 5fab4768c..1c08b43b1 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/Collection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/Collection.php @@ -3,6 +3,7 @@ namespace Sabre\DAVACL\FS; use Sabre\DAV\FSExt\Directory as BaseCollection; +use Sabre\DAVACL\ACLTrait; use Sabre\DAVACL\IACL; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; @@ -16,6 +17,8 @@ use Sabre\DAV\Exception\NotFound; */ class Collection extends BaseCollection implements IACL { + use ACLTrait; + /** * A list of ACL rules. * @@ -52,8 +55,8 @@ class Collection extends BaseCollection implements IACL { * exist. * * @param string $name - * @throws DAV\Exception\NotFound - * @return DAV\INode + * @throws NotFound + * @return \Sabre\DAV\INode */ function getChild($name) { @@ -88,19 +91,6 @@ class Collection extends BaseCollection implements IACL { } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -118,36 +108,4 @@ class Collection extends BaseCollection implements IACL { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new Forbidden('Setting ACL is not allowed here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/File.php b/vendor/sabre/dav/lib/DAVACL/FS/File.php index 0d549528b..387597bf7 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/File.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/File.php @@ -4,7 +4,7 @@ namespace Sabre\DAVACL\FS; use Sabre\DAV\FSExt\File as BaseFile; use Sabre\DAVACL\IACL; -use Sabre\DAV\Exception\Forbidden; +use Sabre\DAVACL\ACLTrait; /** * This is an ACL-enabled file node. @@ -15,6 +15,8 @@ use Sabre\DAV\Exception\Forbidden; */ class File extends BaseFile implements IACL { + use ACLTrait; + /** * A list of ACL rules. * @@ -58,19 +60,6 @@ class File extends BaseFile implements IACL { } /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -88,36 +77,4 @@ class File extends BaseFile implements IACL { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new Forbidden('Setting ACL is not allowed here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php index c27616770..9e21353ea 100644 --- a/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php @@ -2,8 +2,8 @@ namespace Sabre\DAVACL\FS; -use Sabre\DAV\Exception\Forbidden; use Sabre\DAVACL\AbstractPrincipalCollection; +use Sabre\DAVACL\ACLTrait; use Sabre\DAVACL\IACL; use Sabre\DAVACL\PrincipalBackend\BackendInterface; use Sabre\Uri; @@ -21,6 +21,8 @@ use Sabre\Uri; */ class HomeCollection extends AbstractPrincipalCollection implements IACL { + use ACLTrait; + /** * Name of this collection. * @@ -70,20 +72,15 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { * supplied by the authentication backend. * * @param array $principalInfo - * @return void + * @return \Sabre\DAVACL\INode */ function getChildForPrincipal(array $principalInfo) { $owner = $principalInfo['uri']; $acl = [ [ - 'privilege' => '{DAV:}read', - 'principal' => $owner, - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => $owner, + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, ], ]; @@ -103,31 +100,6 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { } - /** - * Returns the owner principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getOwner() { - - return null; - - } - - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } /** * Returns a list of ACE's for this node. @@ -153,36 +125,4 @@ class HomeCollection extends AbstractPrincipalCollection implements IACL { } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new Forbidden('Setting ACL is not allowed here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/IACL.php b/vendor/sabre/dav/lib/DAVACL/IACL.php index 81908d08f..f7a138665 100644 --- a/vendor/sabre/dav/lib/DAVACL/IACL.php +++ b/vendor/sabre/dav/lib/DAVACL/IACL.php @@ -71,5 +71,4 @@ interface IACL extends DAV\INode { */ function getSupportedPrivilegeSet(); - } diff --git a/vendor/sabre/dav/lib/DAVACL/Plugin.php b/vendor/sabre/dav/lib/DAVACL/Plugin.php index 601dffecc..59a7b0922 100644 --- a/vendor/sabre/dav/lib/DAVACL/Plugin.php +++ b/vendor/sabre/dav/lib/DAVACL/Plugin.php @@ -4,7 +4,11 @@ namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\DAV\INode; +use Sabre\DAV\Xml\Property\Href; use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\Exception\NotAuthenticated; +use Sabre\DAVACL\Exception\NeedPrivileges; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Sabre\Uri; @@ -64,18 +68,6 @@ class Plugin extends DAV\ServerPlugin { ]; /** - * By default ACL is only enforced for nodes that have ACL support (the - * ones that implement IACL). For any other node, access is - * always granted. - * - * To override this behaviour you can turn this setting off. This is useful - * if you plan to fully support ACL in the entire tree. - * - * @var bool - */ - public $allowAccessToNodesWithoutACL = true; - - /** * By default nodes that are inaccessible by the user, can still be seen * in directory listings (PROPFIND on parent with Depth: 1) * @@ -109,6 +101,18 @@ class Plugin extends DAV\ServerPlugin { public $adminPrincipals = []; /** + * The ACL plugin allows privileges to be assigned to users that are not + * logged in. To facilitate that, it modifies the auth plugin's behavior + * to only require login when a privileged operation was denied. + * + * Unauthenticated access can be considered a security concern, so it's + * possible to turn this feature off to harden the server's security. + * + * @var bool + */ + public $allowUnauthenticatedAccess = true; + + /** * Returns a list of features added by this plugin. * * This list is used in the response of a HTTP OPTIONS request. @@ -161,6 +165,7 @@ class Plugin extends DAV\ServerPlugin { return [ '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set', ]; @@ -179,7 +184,8 @@ class Plugin extends DAV\ServerPlugin { * @param array|string $privileges * @param int $recursion * @param bool $throwExceptions if set to false, this method won't throw exceptions. - * @throws Sabre\DAVACL\Exception\NeedPrivileges + * @throws NeedPrivileges + * @throws NotAuthenticated * @return bool */ function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) { @@ -188,18 +194,6 @@ class Plugin extends DAV\ServerPlugin { $acl = $this->getCurrentUserPrivilegeSet($uri); - if (is_null($acl)) { - if ($this->allowAccessToNodesWithoutACL) { - return true; - } else { - if ($throwExceptions) - throw new Exception\NeedPrivileges($uri, $privileges); - else - return false; - - } - } - $failed = []; foreach ($privileges as $priv) { @@ -210,10 +204,22 @@ class Plugin extends DAV\ServerPlugin { } if ($failed) { - if ($throwExceptions) - throw new Exception\NeedPrivileges($uri, $failed); - else + if ($this->allowUnauthenticatedAccess && is_null($this->getCurrentUserPrincipal())) { + // We are not authenticated. Kicking in the Auth plugin. + $authPlugin = $this->server->getPlugin('auth'); + $reasons = $authPlugin->getLoginFailedReasons(); + $authPlugin->challenge( + $this->server->httpRequest, + $this->server->httpResponse + ); + throw new notAuthenticated(implode(', ', $reasons) . '. Login was needed for privilege: ' . implode(', ', $failed) . ' on ' . $uri); + } + if ($throwExceptions) { + + throw new NeedPrivileges($uri, $failed); + } else { return false; + } } return true; @@ -229,10 +235,11 @@ class Plugin extends DAV\ServerPlugin { */ function getCurrentUserPrincipal() { - $authPlugin = $this->server->getPlugin('auth'); - if (is_null($authPlugin)) return null; /** @var $authPlugin Sabre\DAV\Auth\Plugin */ - + $authPlugin = $this->server->getPlugin('auth'); + if (!$authPlugin) { + return null; + } return $authPlugin->getCurrentPrincipal(); } @@ -258,6 +265,56 @@ class Plugin extends DAV\ServerPlugin { } /** + * Sets the default ACL rules. + * + * These rules are used for all nodes that don't implement the IACL interface. + * + * @param array $acl + * @return void + */ + function setDefaultAcl(array $acl) { + + $this->defaultAcl = $acl; + + } + + /** + * Returns the default ACL rules. + * + * These rules are used for all nodes that don't implement the IACL interface. + * + * @param array $acl + * @return void + */ + function getDefaultAcl() { + + return $this->defaultAcl; + + } + + /** + * The default ACL rules. + * + * These rules are used for nodes that don't implement IACL. These default + * set of rules allow anyone to do anything, as long as they are + * authenticated. + * + * var array + */ + protected $defaultAcl = [ + [ + 'principal' => '{DAV:}authenticated', + 'protected' => true, + 'privilege' => '{DAV:}all', + ], + [ + 'principal' => '{DAV:}unauthenticated', + 'protected' => true, + 'privilege' => '{DAV:}read', + ], + ]; + + /** * This array holds a cache for all the principals that are associated with * a single principal. * @@ -311,13 +368,77 @@ class Plugin extends DAV\ServerPlugin { } /** - * Returns the supported privilege structure for this ACL plugin. + * Find out of a principal equals another principal. + * + * This is a quick way to find out wether a principal URI is part of a + * group, or any subgroups. * - * See RFC3744 for more details. Currently we default on a simple, - * standard structure. + * The first argument is the principal URI you want to check against. For + * example the principal group, and the second argument is the principal of + * which you want to find out of it is the same as the first principal, or + * in a member of the first principal's group or subgroups. * - * You can either get the list of privileges by a uri (path) or by - * specifying a Node. + * So the arguments are not interchangable. If principal A is in group B, + * passing 'B', 'A' will yield true, but 'A', 'B' is false. + * + * If the sceond argument is not passed, we will use the current user + * principal. + * + * @param string $checkPrincipal + * @param string $currentPrincipal + * @return bool + */ + function principalMatchesPrincipal($checkPrincipal, $currentPrincipal = null) { + + if (is_null($currentPrincipal)) { + $currentPrincipal = $this->getCurrentUserPrincipal(); + } + if ($currentPrincipal === $checkPrincipal) { + return true; + } + return in_array( + $checkPrincipal, + $this->getPrincipalMembership($currentPrincipal) + ); + + } + + + /** + * Returns a tree of supported privileges for a resource. + * + * The returned array structure should be in this form: + * + * [ + * [ + * 'privilege' => '{DAV:}read', + * 'abstract' => false, + * 'aggregates' => [] + * ] + * ] + * + * Privileges can be nested using "aggregrates". Doing so means that + * if you assign someone the aggregrating privilege, all the + * sub-privileges will automatically be granted. + * + * Marking a privilege as abstract means that the privilege cannot be + * directly assigned, but must be assigned via the parent privilege. + * + * So a more complex version might look like this: + * + * [ + * [ + * 'privilege' => '{DAV:}read', + * 'abstract' => false, + * 'aggregates' => [ + * [ + * 'privilege' => '{DAV:}read-acl', + * 'abstract' => false, + * 'aggregates' => [], + * ] + * ] + * ] + * ] * * @param string|INode $node * @return array @@ -328,73 +449,71 @@ class Plugin extends DAV\ServerPlugin { $node = $this->server->tree->getNodeForPath($node); } + $supportedPrivileges = null; if ($node instanceof IACL) { - $result = $node->getSupportedPrivilegeSet(); - - if ($result) - return $result; + $supportedPrivileges = $node->getSupportedPrivilegeSet(); } - return self::getDefaultSupportedPrivilegeSet(); + if (is_null($supportedPrivileges)) { - } - - /** - * Returns a fairly standard set of privileges, which may be useful for - * other systems to use as a basis. - * - * @return array - */ - static function getDefaultSupportedPrivilegeSet() { - - return [ - 'privilege' => '{DAV:}all', - 'abstract' => true, - 'aggregates' => [ - [ - 'privilege' => '{DAV:}read', + // Default + $supportedPrivileges = [ + '{DAV:}read' => [ + 'abstract' => false, 'aggregates' => [ - [ - 'privilege' => '{DAV:}read-acl', - 'abstract' => false, + '{DAV:}read-acl' => [ + 'abstract' => false, + 'aggregates' => [], ], - [ - 'privilege' => '{DAV:}read-current-user-privilege-set', - 'abstract' => false, + '{DAV:}read-current-user-privilege-set' => [ + 'abstract' => false, + 'aggregates' => [], ], ], - ], // {DAV:}read - [ - 'privilege' => '{DAV:}write', + ], + '{DAV:}write' => [ + 'abstract' => false, 'aggregates' => [ - [ - 'privilege' => '{DAV:}write-acl', - 'abstract' => false, - ], - [ - 'privilege' => '{DAV:}write-properties', - 'abstract' => false, - ], - [ - 'privilege' => '{DAV:}write-content', - 'abstract' => false, + '{DAV:}write-properties' => [ + 'abstract' => false, + 'aggregates' => [], ], - [ - 'privilege' => '{DAV:}bind', - 'abstract' => false, + '{DAV:}write-content' => [ + 'abstract' => false, + 'aggregates' => [], ], - [ - 'privilege' => '{DAV:}unbind', - 'abstract' => false, - ], - [ - 'privilege' => '{DAV:}unlock', - 'abstract' => false, + '{DAV:}unlock' => [ + 'abstract' => false, + 'aggregates' => [], ], ], - ], // {DAV:}write - ], - ]; // {DAV:}all + ], + ]; + if ($node instanceof \Sabre\DAV\ICollection) { + $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}bind'] = [ + 'abstract' => false, + 'aggregates' => [], + ]; + $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}unbind'] = [ + 'abstract' => false, + 'aggregates' => [], + ]; + } + if ($node instanceof \Sabre\DAVACL\IACL) { + $supportedPrivileges['{DAV:}write']['aggregates']['{DAV:}write-acl'] = [ + 'abstract' => false, + 'aggregates' => [], + ]; + } + + } + + $this->server->emit( + 'getSupportedPrivilegeSet', + [$node, &$supportedPrivileges] + ); + + return $supportedPrivileges; } @@ -414,35 +533,38 @@ class Plugin extends DAV\ServerPlugin { */ final function getFlatPrivilegeSet($node) { - $privs = $this->getSupportedPrivilegeSet($node); + $privs = [ + 'abstract' => false, + 'aggregates' => $this->getSupportedPrivilegeSet($node) + ]; $fpsTraverse = null; - $fpsTraverse = function($priv, $concrete, &$flat) use (&$fpsTraverse) { + $fpsTraverse = function($privName, $privInfo, $concrete, &$flat) use (&$fpsTraverse) { $myPriv = [ - 'privilege' => $priv['privilege'], - 'abstract' => isset($priv['abstract']) && $priv['abstract'], + 'privilege' => $privName, + 'abstract' => isset($privInfo['abstract']) && $privInfo['abstract'], 'aggregates' => [], - 'concrete' => isset($priv['abstract']) && $priv['abstract'] ? $concrete : $priv['privilege'], + 'concrete' => isset($privInfo['abstract']) && $privInfo['abstract'] ? $concrete : $privName, ]; - if (isset($priv['aggregates'])) { + if (isset($privInfo['aggregates'])) { - foreach ($priv['aggregates'] as $subPriv) { + foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $myPriv['aggregates'][] = $subPriv['privilege']; + $myPriv['aggregates'][] = $subPrivName; } } - $flat[$priv['privilege']] = $myPriv; + $flat[$privName] = $myPriv; - if (isset($priv['aggregates'])) { + if (isset($privInfo['aggregates'])) { - foreach ($priv['aggregates'] as $subPriv) { + foreach ($privInfo['aggregates'] as $subPrivName => $subPrivInfo) { - $fpsTraverse($subPriv, $myPriv['concrete'], $flat); + $fpsTraverse($subPrivName, $subPrivInfo, $myPriv['concrete'], $flat); } @@ -451,7 +573,7 @@ class Plugin extends DAV\ServerPlugin { }; $flat = []; - $fpsTraverse($privs, null, $flat); + $fpsTraverse('{DAV:}all', $privs, null, $flat); return $flat; @@ -467,13 +589,13 @@ class Plugin extends DAV\ServerPlugin { * @param string|DAV\INode $node * @return array */ - function getACL($node) { + function getAcl($node) { if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } if (!$node instanceof IACL) { - return null; + return $this->getDefaultAcl(); } $acl = $node->getACL(); foreach ($this->adminPrincipals as $adminPrincipal) { @@ -506,12 +628,10 @@ class Plugin extends DAV\ServerPlugin { $acl = $this->getACL($node); - if (is_null($acl)) return null; - - $principals = $this->getCurrentUserPrincipals(); - $collected = []; + $isAuthenticated = $this->getCurrentUserPrincipal() !== null; + foreach ($acl as $ace) { $principal = $ace['principal']; @@ -520,7 +640,7 @@ class Plugin extends DAV\ServerPlugin { case '{DAV:}owner' : $owner = $node->getOwner(); - if ($owner && in_array($owner, $principals)) { + if ($owner && $this->principalMatchesPrincipal($owner)) { $collected[] = $ace; } break; @@ -528,21 +648,25 @@ class Plugin extends DAV\ServerPlugin { // 'all' matches for every user case '{DAV:}all' : + $collected[] = $ace; + break; - // 'authenticated' matched for every user that's logged in. - // Since it's not possible to use ACL while not being logged - // in, this is also always true. case '{DAV:}authenticated' : - $collected[] = $ace; + // Authenticated users only + if ($isAuthenticated) { + $collected[] = $ace; + } break; - // 'unauthenticated' can never occur either, so we simply - // ignore these. case '{DAV:}unauthenticated' : + // Unauthenticated users only + if (!$isAuthenticated) { + $collected[] = $ace; + } break; default : - if (in_array($ace['principal'], $principals)) { + if ($this->principalMatchesPrincipal($ace['principal'])) { $collected[] = $ace; } break; @@ -561,6 +685,11 @@ class Plugin extends DAV\ServerPlugin { $current = array_pop($collected); $collected2[] = $current['privilege']; + if (!isset($flat[$current['privilege']])) { + // Ignoring privileges that are not in the supported-privileges list. + $this->server->getLogger()->debug('A node has the "' . $current['privilege'] . '" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.'); + continue; + } foreach ($flat[$current['privilege']]['aggregates'] as $subPriv) { $collected2[] = $subPriv; $collected[] = $flat[$subPriv]; @@ -587,7 +716,13 @@ class Plugin extends DAV\ServerPlugin { $collections = $this->principalCollectionSet; foreach ($collections as $collection) { - $principalCollection = $this->server->tree->getNodeForPath($collection); + try { + $principalCollection = $this->server->tree->getNodeForPath($collection); + } catch (NotFound $e) { + // Ignore and move on + continue; + } + if (!$principalCollection instanceof IPrincipalCollection) { // Not a principal collection, we're simply going to ignore // this. @@ -673,6 +808,14 @@ class Plugin extends DAV\ServerPlugin { */ function initialize(DAV\Server $server) { + if ($this->allowUnauthenticatedAccess) { + $authPlugin = $server->getPlugin('auth'); + if (!$authPlugin) { + throw new \Exception('The Auth plugin must be loaded before the ACL plugin if you want to allow unauthenticated access.'); + } + $authPlugin->autoRequireLogin = false; + } + $this->server = $server; $server->on('propFind', [$this, 'propFind'], 20); $server->on('beforeMethod', [$this, 'beforeMethod'], 20); @@ -683,6 +826,14 @@ class Plugin extends DAV\ServerPlugin { $server->on('report', [$this, 'report']); $server->on('method:ACL', [$this, 'httpAcl']); $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']); + $server->on('getPrincipalByUri', function($principal, &$uri) { + + $uri = $this->getPrincipalByUri($principal); + + // Break event chain + if ($uri) return false; + + }); array_push($server->protectedProperties, '{DAV:}alternate-URI-set', @@ -707,9 +858,11 @@ class Plugin extends DAV\ServerPlugin { // class. $server->xml->elementMap['{DAV:}group-member-set'] = 'Sabre\\DAV\\Xml\\Property\\Href'; $server->xml->elementMap['{DAV:}acl'] = 'Sabre\\DAVACL\\Xml\\Property\\Acl'; + $server->xml->elementMap['{DAV:}acl-principal-prop-set'] = 'Sabre\\DAVACL\\Xml\\Request\\AclPrincipalPropSetReport'; $server->xml->elementMap['{DAV:}expand-property'] = 'Sabre\\DAVACL\\Xml\\Request\\ExpandPropertyReport'; $server->xml->elementMap['{DAV:}principal-property-search'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport'; $server->xml->elementMap['{DAV:}principal-search-property-set'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport'; + $server->xml->elementMap['{DAV:}principal-match'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport'; } @@ -743,7 +896,6 @@ class Plugin extends DAV\ServerPlugin { case 'PUT' : case 'LOCK' : - case 'UNLOCK' : // This method requires the write-content priv if the node // already exists, and bind on the parent if the node is being // created. @@ -751,6 +903,9 @@ class Plugin extends DAV\ServerPlugin { $this->checkPrivileges($path, '{DAV:}write-content'); break; + case 'UNLOCK' : + // Unlock is always allowed at the moment. + break; case 'PROPPATCH' : $this->checkPrivileges($path, '{DAV:}write-properties'); @@ -774,7 +929,6 @@ class Plugin extends DAV\ServerPlugin { // If MOVE is used beforeUnbind will also be used to check if // the sourcenode can be deleted. $this->checkPrivileges($path, '{DAV:}read', self::R_RECURSIVE); - break; } @@ -864,24 +1018,24 @@ class Plugin extends DAV\ServerPlugin { if ($node instanceof IPrincipal) { $propFind->handle('{DAV:}alternate-URI-set', function() use ($node) { - return new DAV\Xml\Property\Href($node->getAlternateUriSet()); + return new Href($node->getAlternateUriSet()); }); $propFind->handle('{DAV:}principal-URL', function() use ($node) { - return new DAV\Xml\Property\Href($node->getPrincipalUrl() . '/'); + return new Href($node->getPrincipalUrl() . '/'); }); $propFind->handle('{DAV:}group-member-set', function() use ($node) { $members = $node->getGroupMemberSet(); foreach ($members as $k => $member) { $members[$k] = rtrim($member, '/') . '/'; } - return new DAV\Xml\Property\Href($members); + return new Href($members); }); $propFind->handle('{DAV:}group-membership', function() use ($node) { $members = $node->getGroupMembership(); foreach ($members as $k => $member) { $members[$k] = rtrim($member, '/') . '/'; } - return new DAV\Xml\Property\Href($members); + return new Href($members); }); $propFind->handle('{DAV:}displayname', [$node, 'getDisplayName']); @@ -892,7 +1046,7 @@ class Plugin extends DAV\ServerPlugin { $val = $this->principalCollectionSet; // Ensuring all collections end with a slash foreach ($val as $k => $v) $val[$k] = $v . '/'; - return new DAV\Xml\Property\Href($val); + return new Href($val); }); $propFind->handle('{DAV:}current-user-principal', function() { @@ -910,9 +1064,7 @@ class Plugin extends DAV\ServerPlugin { $propFind->set('{DAV:}current-user-privilege-set', null, 403); } else { $val = $this->getCurrentUserPrivilegeSet($node); - if (!is_null($val)) { - return new Xml\Property\CurrentUserPrivilegeSet($val); - } + return new Xml\Property\CurrentUserPrivilegeSet($val); } }); $propFind->handle('{DAV:}acl', function() use ($node, $propFind, $path) { @@ -921,9 +1073,7 @@ class Plugin extends DAV\ServerPlugin { $propFind->set('{DAV:}acl', null, 403); } else { $acl = $this->getACL($node); - if (!is_null($acl)) { - return new Xml\Property\Acl($this->getACL($node)); - } + return new Xml\Property\Acl($this->getACL($node)); } }); $propFind->handle('{DAV:}acl-restrictions', function() { @@ -933,7 +1083,7 @@ class Plugin extends DAV\ServerPlugin { /* Adding ACL properties */ if ($node instanceof IACL) { $propFind->handle('{DAV:}owner', function() use ($node) { - return new DAV\Xml\Property\Href($node->getOwner() . '/'); + return new Href($node->getOwner() . '/'); }); } @@ -952,7 +1102,7 @@ class Plugin extends DAV\ServerPlugin { $propPatch->handle('{DAV:}group-member-set', function($value) use ($path) { if (is_null($value)) { $memberSet = []; - } elseif ($value instanceof DAV\Xml\Property\Href) { + } elseif ($value instanceof Href) { $memberSet = array_map( [$this->server, 'calculateUri'], $value->getHrefs() @@ -990,15 +1140,23 @@ class Plugin extends DAV\ServerPlugin { case '{DAV:}principal-property-search' : $this->server->transactionType = 'report-principal-property-search'; - $this->principalPropertySearchReport($report); + $this->principalPropertySearchReport($path, $report); return false; case '{DAV:}principal-search-property-set' : $this->server->transactionType = 'report-principal-search-property-set'; - $this->principalSearchPropertySetReport($report); + $this->principalSearchPropertySetReport($path, $report); return false; case '{DAV:}expand-property' : $this->server->transactionType = 'report-expand-property'; - $this->expandPropertyReport($report); + $this->expandPropertyReport($path, $report); + return false; + case '{DAV:}principal-match' : + $this->server->transactionType = 'report-principal-match'; + $this->principalMatchReport($path, $report); + return false; + case '{DAV:}acl-principal-prop-set' : + $this->server->transactionType = 'acl-principal-prop-set'; + $this->aclPrincipalPropSetReport($path, $report); return false; } @@ -1073,7 +1231,7 @@ class Plugin extends DAV\ServerPlugin { // Looking up the principal try { $principal = $this->server->tree->getNodeForPath($newAce['principal']); - } catch (DAV\Exception\NotFound $e) { + } catch (NotFound $e) { throw new Exception\NotRecognizedPrincipal('The specified principal (' . $newAce['principal'] . ') does not exist'); } if (!($principal instanceof IPrincipal)) { @@ -1095,7 +1253,110 @@ class Plugin extends DAV\ServerPlugin { /* Reports {{{ */ /** - * The expand-property report is defined in RFC3253 section 3-8. + * The principal-match report is defined in RFC3744, section 9.3. + * + * This report allows a client to figure out based on the current user, + * or a principal URL, the principal URL and principal URLs of groups that + * principal belongs to. + * + * @param string $path + * @param Xml\Request\PrincipalMatchReport $report + * @return void + */ + protected function principalMatchReport($path, Xml\Request\PrincipalMatchReport $report) { + + $depth = $this->server->getHTTPDepth(0); + if ($depth !== 0) { + throw new BadRequest('The principal-match report is only defined on Depth: 0'); + } + + $currentPrincipals = $this->getCurrentUserPrincipals(); + + $result = []; + + if ($report->type === Xml\Request\PrincipalMatchReport::SELF) { + + // Finding all principals under the request uri that match the + // current principal. + foreach ($currentPrincipals as $currentPrincipal) { + + if ($currentPrincipal === $path || strpos($currentPrincipal, $path . '/') === 0) { + $result[] = $currentPrincipal; + } + + } + + } else { + + // We need to find all resources that have a property that matches + // one of the current principals. + $candidates = $this->server->getPropertiesForPath( + $path, + [$report->principalProperty], + 1 + ); + + foreach ($candidates as $candidate) { + + if (!isset($candidate[200][$report->principalProperty])) { + continue; + } + + $hrefs = $candidate[200][$report->principalProperty]; + + if (!$hrefs instanceof Href) { + continue; + } + + foreach ($hrefs->getHrefs() as $href) { + if (in_array(trim($href, '/'), $currentPrincipals)) { + $result[] = $candidate['href']; + continue 2; + } + } + } + + } + + $responses = []; + + foreach ($result as $item) { + + $properties = []; + + if ($report->properties) { + + $foo = $this->server->getPropertiesForPath($item, $report->properties); + $foo = $foo[0]; + $item = $foo['href']; + unset($foo['href']); + $properties = $foo; + + } + + $responses[] = new DAV\Xml\Element\Response( + $item, + $properties, + '200' + ); + + } + + $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); + $this->server->httpResponse->setStatus(207); + $this->server->httpResponse->setBody( + $this->server->xml->write( + '{DAV:}multistatus', + $responses, + $this->server->getBaseUri() + ) + ); + + + } + + /** + * The expand-property report is defined in RFC3253 section 3.8. * * This report is very similar to a standard PROPFIND. The difference is * that it has the additional ability to look at properties containing a @@ -1105,15 +1366,15 @@ class Plugin extends DAV\ServerPlugin { * Other rfc's, such as ACL rely on this report, so it made sense to put * it in this plugin. * + * @param string $path * @param Xml\Request\ExpandPropertyReport $report * @return void */ - protected function expandPropertyReport($report) { + protected function expandPropertyReport($path, $report) { $depth = $this->server->getHTTPDepth(0); - $requestUri = $this->server->getRequestUri(); - $result = $this->expandProperties($requestUri, $report->properties, $depth); + $result = $this->expandProperties($path, $report->properties, $depth); $xml = $this->server->xml->write( '{DAV:}multistatus', @@ -1187,10 +1448,11 @@ class Plugin extends DAV\ServerPlugin { * of properties the client may search on, using the * {DAV:}principal-property-search report. * + * @param string $path * @param Xml\Request\PrincipalSearchPropertySetReport $report * @return void */ - protected function principalSearchPropertySetReport($report) { + protected function principalSearchPropertySetReport($path, $report) { $httpDepth = $this->server->getHTTPDepth(0); if ($httpDepth !== 0) { @@ -1241,14 +1503,14 @@ class Plugin extends DAV\ServerPlugin { * clients to search for groups of principals, based on the value of one * or more properties. * + * @param string $path * @param Xml\Request\PrincipalPropertySearchReport $report * @return void */ - protected function principalPropertySearchReport($report) { + protected function principalPropertySearchReport($path, Xml\Request\PrincipalPropertySearchReport $report) { - $uri = null; - if (!$report->applyToPrincipalCollectionSet) { - $uri = $this->server->httpRequest->getPath(); + if ($report->applyToPrincipalCollectionSet) { + $path = null; } if ($this->server->getHttpDepth('0') !== 0) { throw new BadRequest('Depth must be 0'); @@ -1256,7 +1518,7 @@ class Plugin extends DAV\ServerPlugin { $result = $this->principalSearch( $report->searchProperties, $report->properties, - $uri, + $path, $report->test ); @@ -1269,6 +1531,64 @@ class Plugin extends DAV\ServerPlugin { } + /** + * aclPrincipalPropSet REPORT + * + * This method is responsible for handling the {DAV:}acl-principal-prop-set + * REPORT, as defined in: + * + * https://tools.ietf.org/html/rfc3744#section-9.2 + * + * This REPORT allows a user to quickly fetch information about all + * principals specified in the access control list. Most commonly this + * is used to for example generate a UI with ACL rules, allowing you + * to show names for principals for every entry. + * + * @param string $path + * @param Xml\Request\AclPrincipalPropSetReport $report + * @return void + */ + protected function aclPrincipalPropSetReport($path, Xml\Request\AclPrincipalPropSetReport $report) { + + if ($this->server->getHTTPDepth(0) !== 0) { + throw new BadRequest('The {DAV:}acl-principal-prop-set REPORT only supports Depth 0'); + } + + // Fetching ACL rules for the given path. We're using the property + // API and not the local getACL, because it will ensure that all + // business rules and restrictions are applied. + $acl = $this->server->getProperties($path, '{DAV:}acl'); + + if (!$acl || !isset($acl['{DAV:}acl'])) { + throw new Forbidden('Could not fetch ACL rules for this path'); + } + + $principals = []; + foreach ($acl['{DAV:}acl']->getPrivileges() as $ace) { + + if ($ace['principal'][0] === '{') { + // It's not a principal, it's one of the special rules such as {DAV:}authenticated + continue; + } + + $principals[] = $ace['principal']; + + } + + $properties = $this->server->getPropertiesForMultiplePaths( + $principals, + $report->properties + ); + + $this->server->httpResponse->setStatus(207); + $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); + $this->server->httpResponse->setBody( + $this->server->generateMultiStatus($properties) + ); + + } + + /* }}} */ /** diff --git a/vendor/sabre/dav/lib/DAVACL/Principal.php b/vendor/sabre/dav/lib/DAVACL/Principal.php index 16375d3fc..6ebb30907 100644 --- a/vendor/sabre/dav/lib/DAVACL/Principal.php +++ b/vendor/sabre/dav/lib/DAVACL/Principal.php @@ -22,6 +22,8 @@ use Sabre\HTTP\URLUtil; */ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { + use ACLTrait; + /** * Struct with principal information. * @@ -216,73 +218,4 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { } - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - - return null; - - } - - /** - * Returns a list of ACE's for this node. - * - * Each ACE has the following properties: - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are - * currently the only supported privileges - * * 'principal', a url to the principal who owns the node - * * 'protected' (optional), indicating that this ACE is not allowed to - * be updated. - * - * @return array - */ - function getACL() { - - return [ - [ - 'privilege' => '{DAV:}read', - 'principal' => '{DAV:}authenticated', - 'protected' => true, - ], - ]; - - } - - /** - * Updates the ACL - * - * This method will receive a list of new ACE's. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new DAV\Exception\MethodNotAllowed('Updating ACLs is not allowed here'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php index 01b7a175c..a491dc88f 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php @@ -300,7 +300,7 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport { $value = null; $scheme = null; list($scheme, $value) = explode(":", $uri, 2); - if ($value == null) return null; + if (empty($value)) return null; $uri = null; switch ($scheme){ diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php index 54911e7b5..d8a90153a 100644 --- a/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php +++ b/vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php @@ -3,7 +3,6 @@ namespace Sabre\DAVACL; use Sabre\DAV\Exception\InvalidResourceType; -use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\IExtendedCollection; use Sabre\DAV\MkCol; @@ -19,6 +18,8 @@ use Sabre\DAV\MkCol; */ class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL { + use ACLTrait; + /** * This method returns a node for a principal. * @@ -73,28 +74,6 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend } /** - * Returns the owner principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getOwner() { - return null; - } - - /** - * Returns a group principal - * - * This must be a url to a principal, or null if there's no owner - * - * @return string|null - */ - function getGroup() { - return null; - } - - /** * Returns a list of ACE's for this node. * * Each ACE has the following properties: @@ -116,36 +95,4 @@ class PrincipalCollection extends AbstractPrincipalCollection implements IExtend ]; } - /** - * Updates the ACL - * - * This method will receive a list of new ACE's as an array argument. - * - * @param array $acl - * @return void - */ - function setACL(array $acl) { - - throw new Forbidden('Updating ACLs is not allowed on this node'); - - } - - /** - * Returns the list of supported privileges for this node. - * - * The returned data structure is a list of nested privileges. - * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple - * standard structure. - * - * If null is returned from this method, the default privilege set is used, - * which is fine for most common usecases. - * - * @return array|null - */ - function getSupportedPrivilegeSet() { - - return null; - - } - } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php index 572bed4dd..55e7783ae 100644 --- a/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php @@ -73,7 +73,7 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { */ function xmlSerialize(Writer $writer) { - $this->serializePriv($writer, $this->privileges); + $this->serializePriv($writer, '{DAV:}all', [ 'aggregates' => $this->privileges]); } @@ -93,9 +93,9 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { */ function toHtml(HtmlOutputHelper $html) { - $traverse = function($priv) use (&$traverse, $html) { + $traverse = function($privName, $priv) use (&$traverse, $html) { echo "<li>"; - echo $html->xmlName($priv['privilege']); + echo $html->xmlName($privName); if (isset($priv['abstract']) && $priv['abstract']) { echo " <i>(abstract)</i>"; } @@ -104,8 +104,8 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { } if (isset($priv['aggregates'])) { echo "\n<ul>\n"; - foreach ($priv['aggregates'] as $subPriv) { - $traverse($subPriv); + foreach ($priv['aggregates'] as $subPrivName => $subPriv) { + $traverse($subPrivName, $subPriv); } echo "</ul>"; } @@ -114,7 +114,7 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { ob_start(); echo "<ul class=\"tree\">"; - $traverse($this->getValue()); + $traverse('{DAV:}all', [ 'aggregates' => $this->getValue() ]); echo "</ul>\n"; return ob_get_clean(); @@ -132,12 +132,12 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { * @param array $privilege * @return void */ - private function serializePriv(Writer $writer, $privilege) { + private function serializePriv(Writer $writer, $privName, $privilege) { $writer->startElement('{DAV:}supported-privilege'); $writer->startElement('{DAV:}privilege'); - $writer->writeElement($privilege['privilege']); + $writer->writeElement($privName); $writer->endElement(); // privilege if (!empty($privilege['abstract'])) { @@ -147,8 +147,8 @@ class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput { $writer->writeElement('{DAV:}description', $privilege['description']); } if (isset($privilege['aggregates'])) { - foreach ($privilege['aggregates'] as $subPrivilege) { - $this->serializePriv($writer, $subPrivilege); + foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) { + $this->serializePriv($writer, $subPrivName, $subPrivilege); } } diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php new file mode 100644 index 000000000..f01c1e6ab --- /dev/null +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php @@ -0,0 +1,67 @@ +<?php + +namespace Sabre\DAVACL\Xml\Request; + +use Sabre\Xml\XmlDeserializable; +use Sabre\Xml\Reader; +use Sabre\Xml\Deserializer; + +/** + * AclPrincipalPropSet request parser. + * + * This class parses the {DAV:}acl-principal-prop-set REPORT, as defined in: + * + * https://tools.ietf.org/html/rfc3744#section-9.2 + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (https://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class AclPrincipalPropSetReport implements XmlDeserializable { + + public $properties = []; + + /** + * The deserialize method is called during xml parsing. + * + * This method is called statictly, this is because in theory this method + * may be used as a type of constructor, or factory method. + * + * Often you want to return an instance of the current class, but you are + * free to return other data as well. + * + * You are responsible for advancing the reader to the next element. Not + * doing anything will result in a never-ending loop. + * + * If you just want to skip parsing for this element altogether, you can + * just call $reader->next(); + * + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to + * the next element. + * + * @param Reader $reader + * @return mixed + */ + static function xmlDeserialize(Reader $reader) { + + $reader->pushContext(); + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; + + $elems = Deserializer\keyValue( + $reader, + 'DAV:' + ); + + $reader->popContext(); + + $report = new self(); + + if (!empty($elems['prop'])) { + $report->properties = $elems['prop']; + } + + return $report; + + } + +} diff --git a/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php new file mode 100644 index 000000000..5c4e88189 --- /dev/null +++ b/vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php @@ -0,0 +1,107 @@ +<?php + +namespace Sabre\DAVACL\Xml\Request; + +use Sabre\Xml\XmlDeserializable; +use Sabre\Xml\Reader; +use Sabre\Xml\Deserializer; + +/** + * PrincipalMatchReport request parser. + * + * This class parses the {DAV:}principal-match REPORT, as defined + * in: + * + * https://tools.ietf.org/html/rfc3744#section-9.3 + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class PrincipalMatchReport implements XmlDeserializable { + + /** + * Report on a list of principals that match the current principal. + */ + const SELF = 1; + + /** + * Report on a property on resources, such as {DAV:}owner, that match the current principal. + */ + const PRINCIPAL_PROPERTY = 2; + + /** + * Must be SELF or PRINCIPAL_PROPERTY + * + * @var int + */ + public $type; + + /** + * List of properties that are being requested for matching resources. + * + * @var string[] + */ + public $properties = []; + + /** + * If $type = PRINCIPAL_PROPERTY, which WebDAV property we should compare + * to the current principal. + * + * @var string + */ + public $principalProperty; + + /** + * The deserialize method is called during xml parsing. + * + * This method is called statictly, this is because in theory this method + * may be used as a type of constructor, or factory method. + * + * Often you want to return an instance of the current class, but you are + * free to return other data as well. + * + * You are responsible for advancing the reader to the next element. Not + * doing anything will result in a never-ending loop. + * + * If you just want to skip parsing for this element altogether, you can + * just call $reader->next(); + * + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to + * the next element. + * + * @param Reader $reader + * @return mixed + */ + static function xmlDeserialize(Reader $reader) { + + $reader->pushContext(); + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum'; + + $elems = Deserializer\keyValue( + $reader, + 'DAV:' + ); + + $reader->popContext(); + + $principalMatch = new self(); + + if (array_key_exists('self', $elems)) { + $principalMatch->type = self::SELF; + } + + if (array_key_exists('principal-property', $elems)) { + $principalMatch->type = self::PRINCIPAL_PROPERTY; + $principalMatch->principalProperty = $elems['principal-property'][0]['name']; + } + + if (!empty($elems['prop'])) { + $principalMatch->properties = $elems['prop']; + } + + return $principalMatch; + + } + +} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php index 25f8b1794..35d6da353 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php @@ -5,11 +5,30 @@ namespace Sabre\CalDAV\Backend; use Sabre\CalDAV; use Sabre\DAV; use Sabre\DAV\PropPatch; +use Sabre\DAV\Xml\Element\Sharee; abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { + use DAV\DbTestHelperTrait; + protected $pdo; + function setUp() { + + $this->dropTables([ + 'calendarobjects', + 'calendars', + 'calendarinstances', + 'calendarchanges', + 'calendarsubscriptions', + 'schedulingobjects', + ]); + $this->createSchema('calendars'); + + $this->pdo = $this->getDb(); + + } + function testConstruct() { $backend = new PDO($this->pdo); @@ -42,11 +61,11 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendars = $backend->getCalendarsForUser('principals/user2'); $elementCheck = [ - 'id' => $returnedId, 'uri' => 'somerandomid', '{DAV:}displayname' => 'Hello!', '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, ]; $this->assertInternalType('array', $calendars); @@ -110,6 +129,27 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } /** + * @depends testConstruct + * @expectedException \InvalidArgumentException + */ + function testUpdateCalendarBadId() { + + $backend = new PDO($this->pdo); + + //Creating a new calendar + $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); + + $propPatch = new PropPatch([ + '{DAV:}displayname' => 'myCalendar', + '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), + ]); + + // Updating the calendar + $backend->updateCalendar('raaaa', $propPatch); + + } + + /** * @depends testUpdateCalendarAndFetch */ function testUpdateCalendarUnknownProperty() { @@ -156,6 +196,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { /** * @depends testCreateCalendarAndFetch + * @expectedException \InvalidArgumentException + */ + function testDeleteCalendarBadID() { + + $backend = new PDO($this->pdo); + $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), + '{DAV:}displayname' => 'Hello!', + ]); + + $backend->deleteCalendar('bad-id'); + + } + + /** + * @depends testCreateCalendarAndFetch * @expectedException \Sabre\DAV\Exception */ function testCreateCalendarIncorrectComponentSet() {; @@ -178,7 +234,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -186,7 +248,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('20120101'), 'lastoccurence' => strtotime('20120101') + (3600 * 24), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } function testGetMultipleObjects() { @@ -207,7 +269,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, - 'calendarid' => $returnedId, ], [ 'id' => 2, @@ -216,7 +277,6 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, - 'calendarid' => $returnedId, ], ]; @@ -224,12 +284,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { foreach ($check as $index => $props) { - foreach ($props as $key => $value) { + foreach ($props as $key => $expected) { + + $actual = $result[$index][$key]; + + switch ($key) { + case 'lastmodified' : + $this->assertInternalType('int', $actual); + break; + case 'calendardata' : + if (is_resource($actual)) { + $actual = stream_get_contents($actual); + } + // no break intentional + default : + $this->assertEquals($expected, $actual); - if ($key !== 'lastmodified') { - $this->assertEquals($value, $result[$index][$key]); - } else { - $this->assertTrue(isset($result[$index][$key])); } } @@ -239,6 +309,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } /** + * @depends testGetMultipleObjects + * @expectedException \InvalidArgumentException + */ + function testGetMultipleObjectsBadId() { + + $backend = new PDO($this->pdo); + $backend->getMultipleCalendarObjects('bad-id', ['foo-bar']); + + } + + /** * @expectedException Sabre\DAV\Exception\BadRequest * @depends testCreateCalendarObject */ @@ -265,7 +346,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -273,10 +360,26 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('20120101'), 'lastoccurence' => strtotime('20120101') + (3600 * 48), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); + + } + + /** + * @depends testCreateCalendarObject + * @expectedException \InvalidArgumentException + */ + function testCreateCalendarObjectBadId() { + + $backend = new PDO($this->pdo); + $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); + + $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; + + $backend->createCalendarObject('bad-id', 'random-id', $object); } + /** * @depends testCreateCalendarObject */ @@ -289,7 +392,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -297,7 +405,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('2012-01-01 10:00:00'), 'lastoccurence' => strtotime('2012-01-01 10:00:00'), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } @@ -313,7 +421,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -321,7 +434,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('2012-01-01 10:00:00'), 'lastoccurence' => strtotime('2012-01-01 11:00:00'), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } @@ -337,7 +450,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -345,7 +463,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('2012-01-01 10:00:00'), 'lastoccurence' => strtotime(PDO::MAX_DATE), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } @@ -361,7 +479,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -369,7 +492,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => strtotime('2012-01-01 10:00:00'), 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), 'componenttype' => 'VEVENT', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } @@ -385,7 +508,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createCalendarObject($returnedId, 'random-id', $object); - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = "random-id"'); + $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); + $row = $result->fetch(\PDO::FETCH_ASSOC); + if (is_resource($row['calendardata'])) { + $row['calendardata'] = stream_get_contents($row['calendardata']); + } + $this->assertEquals([ 'etag' => md5($object), 'size' => strlen($object), @@ -393,7 +521,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'firstoccurence' => null, 'lastoccurence' => null, 'componenttype' => 'VTODO', - ], $result->fetch(\PDO::FETCH_ASSOC)); + ], $row); } @@ -408,17 +536,38 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject($returnedId, 'random-id', $object); - $data = $backend->getCalendarObjects($returnedId, 'random-id'); + $data = $backend->getCalendarObjects($returnedId); $this->assertEquals(1, count($data)); $data = $data[0]; - $this->assertEquals($returnedId, $data['calendarid']); $this->assertEquals('random-id', $data['uri']); $this->assertEquals(strlen($object), $data['size']); + } + + /** + * @depends testGetCalendarObjects + * @expectedException \InvalidArgumentException + */ + function testGetCalendarObjectsBadId() { + + $backend = new PDO($this->pdo); + $backend->getCalendarObjects('bad-id'); } + + /** + * @depends testGetCalendarObjects + * @expectedException \InvalidArgumentException + */ + function testGetCalendarObjectBadId() { + + $backend = new PDO($this->pdo); + $backend->getCalendarObject('bad-id', 'foo-bar'); + + } + /** * @depends testCreateCalendarObject */ @@ -455,14 +604,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $data = $backend->getCalendarObject($returnedId, 'random-id'); + if (is_resource($data['calendardata'])) { + $data['calendardata'] = stream_get_contents($data['calendardata']); + } + $this->assertEquals($object2, $data['calendardata']); - $this->assertEquals($returnedId, $data['calendarid']); $this->assertEquals('random-id', $data['uri']); } /** + * @depends testUpdateCalendarObject + * @expectedException \InvalidArgumentException + */ + function testUpdateCalendarObjectBadId() { + + $backend = new PDO($this->pdo); + $backend->updateCalendarObject('bad-id', 'object-id', 'objectdata'); + + } + + /** * @depends testCreateCalendarObject */ function testDeleteCalendarObject() { @@ -479,6 +642,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } + /** + * @depends testDeleteCalendarObject + * @expectedException \InvalidArgumentException + */ + function testDeleteCalendarObjectBadId() { + + $backend = new PDO($this->pdo); + $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); + + $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; + $backend->createCalendarObject($returnedId, 'random-id', $object); + $backend->deleteCalendarObject('bad-id', 'random-id'); + + } + function testCalendarQueryNoResult() { $abstract = new PDO($this->pdo); @@ -499,15 +677,42 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals([ - ], $abstract->calendarQuery(1, $filters)); + ], $abstract->calendarQuery([1, 1], $filters)); + + } + + /** + * @expectedException \InvalidArgumentException + * @depends testCalendarQueryNoResult + */ + function testCalendarQueryBadId() { + + $abstract = new PDO($this->pdo); + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], + 'is-not-defined' => false, + 'time-range' => null, + ], + ], + 'prop-filters' => [], + 'is-not-defined' => false, + 'time-range' => null, + ]; + + $abstract->calendarQuery('bad-id', $filters); } function testCalendarQueryTodo() { $backend = new PDO($this->pdo); - $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ 'name' => 'VCALENDAR', @@ -527,14 +732,14 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ "todo", - ], $backend->calendarQuery(1, $filters)); + ], $backend->calendarQuery([1, 1], $filters)); } function testCalendarQueryTodoNotMatch() { $backend = new PDO($this->pdo); - $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ 'name' => 'VCALENDAR', @@ -561,15 +766,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals([ - ], $backend->calendarQuery(1, $filters)); + ], $backend->calendarQuery([1, 1], $filters)); } function testCalendarQueryNoFilter() { $backend = new PDO($this->pdo); - $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ 'name' => 'VCALENDAR', @@ -579,7 +784,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'time-range' => null, ]; - $result = $backend->calendarQuery(1, $filters); + $result = $backend->calendarQuery([1, 1], $filters); $this->assertTrue(in_array('todo', $result)); $this->assertTrue(in_array('event', $result)); @@ -588,9 +793,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { function testCalendarQueryTimeRange() { $backend = new PDO($this->pdo); - $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ 'name' => 'VCALENDAR', @@ -613,15 +818,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ "event2", - ], $backend->calendarQuery(1, $filters)); + ], $backend->calendarQuery([1, 1], $filters)); } function testCalendarQueryTimeRangeNoEnd() { $backend = new PDO($this->pdo); - $backend->createCalendarObject(1, "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject(1, "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ 'name' => 'VCALENDAR', @@ -644,7 +849,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ "event2", - ], $backend->calendarQuery(1, $filters)); + ], $backend->calendarQuery([1, 1], $filters)); } @@ -694,6 +899,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { ], $result); } + /** + * @depends testGetChanges + * @expectedException \InvalidArgumentException + */ + function testGetChangesBadId() { + + $backend = new PDO($this->pdo); + $id = $backend->createCalendar( + 'principals/user1', + 'bla', + [] + ); + $backend->getChangesForCalendar('bad-id', null, 1); + + } + function testCreateSubscriptions() { $props = [ @@ -862,6 +1083,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); foreach ($expected as $k => $v) { $this->assertArrayHasKey($k, $result); + if (is_resource($result[$k])) { + $result[$k] = stream_get_contents($result[$k]); + } $this->assertEquals($v, $result[$k]); } @@ -870,6 +1094,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($results)); $result = $results[0]; foreach ($expected as $k => $v) { + if (is_resource($result[$k])) { + $result[$k] = stream_get_contents($result[$k]); + } $this->assertEquals($v, $result[$k]); } @@ -880,4 +1107,315 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } + function testGetInvites() { + + $backend = new PDO($this->pdo); + + // creating a new calendar + $backend->createCalendar('principals/user1', 'somerandomid', []); + $calendar = $backend->getCalendarsForUser('principals/user1')[0]; + + $result = $backend->getInvites($calendar['id']); + $expected = [ + new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]) + ]; + + $this->assertEquals($expected, $result); + + } + + /** + * @depends testGetInvites + * @expectedException \InvalidArgumentException + */ + function testGetInvitesBadId() { + + $backend = new PDO($this->pdo); + + // creating a new calendar + $backend->createCalendar('principals/user1', 'somerandomid', []); + $calendar = $backend->getCalendarsForUser('principals/user1')[0]; + + $backend->getInvites('bad-id'); + + } + + /** + * @depends testCreateCalendarAndFetch + */ + function testUpdateInvites() { + + $backend = new PDO($this->pdo); + + // creating a new calendar + $backend->createCalendar('principals/user1', 'somerandomid', []); + $calendar = $backend->getCalendarsForUser('principals/user1')[0]; + + $ownerSharee = new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]); + + // Add a new invite + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]) + ] + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + $ownerSharee, + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + 'properties' => [ + '{DAV:}displayname' => 'User 2', + ], + ]) + ]; + $this->assertEquals($expected, $result); + + // Checking calendar_instances too + $expectedCalendar = [ + 'id' => [1,2], + 'principaluri' => 'principals/user2', + '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', + ]; + $calendars = $backend->getCalendarsForUser('principals/user2'); + + foreach ($expectedCalendar as $k => $v) { + $this->assertEquals( + $v, + $calendars[0][$k], + "Key " . $k . " in calendars array did not have the expected value." + ); + } + + + // Updating an invite + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]) + ] + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + $ownerSharee, + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + 'properties' => [ + '{DAV:}displayname' => 'User 2', + ], + ]) + ]; + $this->assertEquals($expected, $result); + + // Removing an invite + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'mailto:user@example.org', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, + ]) + ] + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + $ownerSharee + ]; + $this->assertEquals($expected, $result); + + // Preventing the owner share from being removed + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, + ]) + ] + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]), + ]; + $this->assertEquals($expected, $result); + + } + + /** + * @depends testUpdateInvites + * @expectedException \InvalidArgumentException + */ + function testUpdateInvitesBadId() { + + $backend = new PDO($this->pdo); + // Add a new invite + $backend->updateInvites( + 'bad-id', + [] + ); + + } + + /** + * @depends testUpdateInvites + */ + function testUpdateInvitesNoPrincipal() { + + $backend = new PDO($this->pdo); + + // creating a new calendar + $backend->createCalendar('principals/user1', 'somerandomid', []); + $calendar = $backend->getCalendarsForUser('principals/user1')[0]; + + $ownerSharee = new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]); + + // Add a new invite + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]) + ] + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + $ownerSharee, + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_INVALID, + 'properties' => [ + '{DAV:}displayname' => 'User 2', + ], + ]) + ]; + $this->assertEquals($expected, $result, null, 0.0, 10, true); // Last argument is $canonicalize = true, which allows us to compare, ignoring the order, because it's different between MySQL and Sqlite. + + } + + /** + * @depends testUpdateInvites + */ + function testDeleteSharedCalendar() { + + $backend = new PDO($this->pdo); + + // creating a new calendar + $backend->createCalendar('principals/user1', 'somerandomid', []); + $calendar = $backend->getCalendarsForUser('principals/user1')[0]; + + $ownerSharee = new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]); + + // Add a new invite + $backend->updateInvites( + $calendar['id'], + [ + new Sharee([ + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]) + ] + ); + + $expectedCalendar = [ + 'id' => [1,2], + 'principaluri' => 'principals/user2', + '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', + ]; + $calendars = $backend->getCalendarsForUser('principals/user2'); + + foreach ($expectedCalendar as $k => $v) { + $this->assertEquals( + $v, + $calendars[0][$k], + "Key " . $k . " in calendars array did not have the expected value." + ); + } + + // Removing the shared calendar. + $backend->deleteCalendar($calendars[0]['id']); + + $this->assertEquals( + [], + $backend->getCalendarsForUser('principals/user2') + ); + + $result = $backend->getInvites($calendar['id']); + $expected = [ + new Sharee([ + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, + ]), + ]; + $this->assertEquals($expected, $result); + + } + } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php index 4412e5531..d4dcc07dc 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php @@ -82,6 +82,46 @@ class Mock extends AbstractBackend { } /** + * Updates properties for a calendar. + * + * 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 mixed $calendarId + * @param \Sabre\DAV\PropPatch $propPatch + * @return void + */ + function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { + + $propPatch->handleRemaining(function($props) use ($calendarId) { + + foreach ($this->calendars as $k => $calendar) { + + if ($calendar['id'] === $calendarId) { + foreach ($props as $propName => $propValue) { + if (is_null($propValue)) { + unset($this->calendars[$k][$propName]); + } else { + $this->calendars[$k][$propName] = $propValue; + } + } + return true; + + } + + } + + }); + + } + + /** * Delete a calendar and all it's objects * * @param string $calendarId @@ -139,18 +179,22 @@ class Mock extends AbstractBackend { * Returns information from a single calendar object, based on it's object * uri. * + * The object uri is only the basename, or filename and not a full path. + * * The returned array must have the same keys as getCalendarObjects. The * 'calendardata' object is required here though, while it's not required * for getCalendarObjects. * - * @param string $calendarId + * This method must return null if the object did not exist. + * + * @param mixed $calendarId * @param string $objectUri - * @return array + * @return array|null */ function getCalendarObject($calendarId, $objectUri) { if (!isset($this->calendarData[$calendarId][$objectUri])) { - throw new DAV\Exception\NotFound('Object could not be found'); + return null; } $object = $this->calendarData[$calendarId][$objectUri]; $object['calendarid'] = $calendarId; @@ -207,8 +251,7 @@ class Mock extends AbstractBackend { */ function deleteCalendarObject($calendarId, $objectUri) { - throw new Exception('Not implemented'); - + unset($this->calendarData[$calendarId][$objectUri]); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php index c215ca171..e068ff1e7 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php @@ -2,38 +2,8 @@ namespace Sabre\CalDAV\Backend; -require_once 'Sabre/TestUtil.php'; -require_once 'Sabre/CalDAV/TestUtil.php'; -require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php'; - class PDOMySQLTest extends AbstractPDOTest { - function setup() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to mysql database'); - - $pdo->query('DROP TABLE IF EXISTS calendarobjects, calendars, calendarchanges, calendarsubscriptions, schedulingobjects'); - - $queries = explode( - ';', - file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.calendars.sql') - ); - - foreach ($queries as $query) { - $query = trim($query, " \r\n\t"); - if ($query) - $pdo->exec($query); - } - $this->pdo = $pdo; - - } - - function teardown() { - - $this->pdo = null; - - } + public $driver = 'mysql'; } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php index 4074259f2..90ad5a171 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php @@ -2,36 +2,8 @@ namespace Sabre\CalDAV\Backend; -use Sabre\CalDAV; - -require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php'; - class PDOSqliteTest extends AbstractPDOTest { - function setup() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - - if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite')) - unlink(SABRE_TEMPDIR . '/testdb.sqlite'); - - $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - - // Yup this is definitely not 'fool proof', but good enough for now. - $queries = explode(';', file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.calendars.sql')); - foreach ($queries as $query) { - $pdo->exec($query); - } - $this->pdo = $pdo; - - } - - function teardown() { - - $this->pdo = null; - unlink(SABRE_TEMPDIR . '/testdb.sqlite'); - - } + public $driver = 'sqlite'; } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php index 9fc1eee4c..0d98922ff 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php @@ -1,7 +1,6 @@ <?php namespace Sabre\CalDAV; -use Sabre\DAVACL; require_once 'Sabre/CalDAV/TestUtil.php'; @@ -19,11 +18,10 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { function setup() { - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); $this->backend = TestUtil::getBackend(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals(2,count($calendars)); + $this->assertEquals(2, count($calendars)); $this->calendar = new Calendar($this->backend, $calendars[0]); } @@ -40,10 +38,10 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); - $this->assertInternalType('string',$children[0]->getName()); - $this->assertInternalType('string',$children[0]->get()); - $this->assertInternalType('string',$children[0]->getETag()); - $this->assertEquals('text/calendar; charset=utf-8; component=vevent', $children[0]->getContentType()); + $this->assertInternalType('string', $children[0]->getName()); + $this->assertInternalType('string', $children[0]->get()); + $this->assertInternalType('string', $children[0]->getETag()); + $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType()); } @@ -53,9 +51,9 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { function testInvalidArg1() { $obj = new CalendarObject( - new Backend\Mock(array(),array()), - array(), - array() + new Backend\Mock([], []), + [], + [] ); } @@ -66,9 +64,9 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { function testInvalidArg2() { $obj = new CalendarObject( - new Backend\Mock(array(),array()), - array(), - array('calendarid' => '1') + new Backend\Mock([], []), + [], + ['calendarid' => '1'] ); } @@ -96,7 +94,7 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($children[0] instanceof CalendarObject); $newData = TestUtil::getTestCalendarData(); - $stream = fopen('php://temp','r+'); + $stream = fopen('php://temp', 'r+'); fwrite($stream, $newData); rewind($stream); $children[0]->put($stream); @@ -117,7 +115,7 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $obj->delete(); $children2 = $this->calendar->getChildren(); - $this->assertEquals(count($children)-1, count($children2)); + $this->assertEquals(count($children) - 1, count($children2)); } @@ -132,7 +130,7 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $obj = $children[0]; $lastMod = $obj->getLastModified(); - $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod)); + $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod) || is_null($lastMod)); } @@ -173,33 +171,33 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { function testGetACL() { - $expected = array( - array( + $expected = [ + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-read', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}write', 'principal' => 'principals/user1', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}write', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - ); + ], + ]; $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -213,40 +211,30 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $backend = new Backend\Mock([], []); $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']); - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', + $expected = [ + [ + 'privilege' => '{DAV:}all', 'principal' => 'principals/user1', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', + ], + [ + 'privilege' => '{DAV:}all', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-read', 'protected' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $calendarObject->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\Forbidden */ function testSetACL() { @@ -254,7 +242,7 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; - $obj->setACL(array()); + $obj->setACL([]); } @@ -306,15 +294,15 @@ END:VCALENDAR"; function testGetRefetch() { - $backend = new Backend\Mock(array(), array( - 1 => array( - 'foo' => array( + $backend = new Backend\Mock([], [ + 1 => [ + 'foo' => [ 'calendardata' => 'foo', - 'uri' => 'foo' - ), - ) - )); - $obj = new CalendarObject($backend, array('id' => 1), array('uri' => 'foo')); + 'uri' => 'foo' + ], + ] + ]); + $obj = new CalendarObject($backend, ['id' => 1], ['uri' => 'foo']); $this->assertEquals('foo', $obj->get()); @@ -322,15 +310,15 @@ END:VCALENDAR"; function testGetEtag1() { - $objectInfo = array( + $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'etag' => 'bar', - 'calendarid' => 1 - ); + 'uri' => 'foo', + 'etag' => 'bar', + 'calendarid' => 1 + ]; - $backend = new Backend\Mock(array(), array()); - $obj = new CalendarObject($backend, array(), $objectInfo); + $backend = new Backend\Mock([], []); + $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals('bar', $obj->getETag()); @@ -338,14 +326,14 @@ END:VCALENDAR"; function testGetEtag2() { - $objectInfo = array( + $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 - ); + 'uri' => 'foo', + 'calendarid' => 1 + ]; - $backend = new Backend\Mock(array(), array()); - $obj = new CalendarObject($backend, array(), $objectInfo); + $backend = new Backend\Mock([], []); + $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals('"' . md5('foo') . '"', $obj->getETag()); @@ -353,42 +341,42 @@ END:VCALENDAR"; function testGetSupportedPrivilegesSet() { - $objectInfo = array( + $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 - ); + 'uri' => 'foo', + 'calendarid' => 1 + ]; - $backend = new Backend\Mock(array(), array()); - $obj = new CalendarObject($backend, array(), $objectInfo); + $backend = new Backend\Mock([], []); + $obj = new CalendarObject($backend, [], $objectInfo); $this->assertNull($obj->getSupportedPrivilegeSet()); } function testGetSize1() { - $objectInfo = array( + $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 - ); + 'uri' => 'foo', + 'calendarid' => 1 + ]; - $backend = new Backend\Mock(array(), array()); - $obj = new CalendarObject($backend, array(), $objectInfo); + $backend = new Backend\Mock([], []); + $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(3, $obj->getSize()); } function testGetSize2() { - $objectInfo = array( - 'uri' => 'foo', + $objectInfo = [ + 'uri' => 'foo', 'calendarid' => 1, - 'size' => 4, - ); + 'size' => 4, + ]; - $backend = new Backend\Mock(array(), array()); - $obj = new CalendarObject($backend, array(), $objectInfo); + $backend = new Backend\Mock([], []); + $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(4, $obj->getSize()); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php index 9de24d3aa..ca06d8ffa 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php @@ -26,32 +26,32 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $vcalendar->add($vevent); - $filter = array( - 'name' => 'VCALENDAR', + $filter = [ + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => array(), - 'comp-filters' => array( - array( - 'name' => 'VEVENT', + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ + [ + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => array(), - 'comp-filters' => array( - array( - 'name' => 'VALARM', + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ + [ + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => array(), - 'comp-filters' => array(), - 'time-range' => array( + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2012-05-10'), - 'end' => new \DateTime('2012-05-20'), - ), - ), - ), - ), - ), - ); + 'end' => new \DateTime('2012-05-20'), + ], + ], + ], + ], + ], + ]; $validator = new CalendarQueryValidator(); $this->assertTrue($validator->validate($vcalendar, $filter)); @@ -87,32 +87,32 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $vcalendar->add($vevent); - $filter = array( - 'name' => 'VCALENDAR', + $filter = [ + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => array(), - 'comp-filters' => array( - array( - 'name' => 'VEVENT', + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ + [ + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => array(), - 'comp-filters' => array( - array( - 'name' => 'VALARM', + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ + [ + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => array(), - 'comp-filters' => array(), - 'time-range' => array( + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-12-10'), - 'end' => new \DateTime('2011-12-20'), - ), - ), - ), - ), - ), - ); + 'end' => new \DateTime('2011-12-20'), + ], + ], + ], + ], + ], + ]; $validator = new CalendarQueryValidator(); $this->assertTrue($validator->validate($vcalendar, $filter)); diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php index 9822e82e2..4c2558a9b 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php @@ -1,8 +1,8 @@ <?php namespace Sabre\CalDAV; + use Sabre\VObject; -use Sabre\DAV; class CalendarQueryValidatorTest extends \PHPUnit_Framework_TestCase { @@ -29,17 +29,17 @@ ICS; // Wrapping filter in a VCALENDAR component filter, as this is always // there anyway. - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array($filters), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [$filters], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; $vObject = VObject\Reader::read($icalObject); - switch($outcome) { + switch ($outcome) { case 0 : $this->assertFalse($validator->validate($vObject, $filters)); break; @@ -392,13 +392,13 @@ END:VEVENT END:VCALENDAR yow; - $filter1 = array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter1 = [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; $filter2 = $filter1; $filter2['name'] = 'VTODO'; @@ -410,25 +410,25 @@ yow; $filter4['is-not-defined'] = true; $filter5 = $filter1; - $filter5['comp-filters'] = array( - array( - 'name' => 'VALARM', + $filter5['comp-filters'] = [ + [ + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => array(), - 'prop-filters' => array(), - 'time-range' => null, - ), - ); + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => null, + ], + ]; $filter6 = $filter1; - $filter6['prop-filters'] = array( - array( - 'name' => 'SUMMARY', + $filter6['prop-filters'] = [ + [ + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => array(), - 'time-range' => null, - 'text-match' => null, - ), - ); + 'param-filters' => [], + 'time-range' => null, + 'text-match' => null, + ], + ]; $filter7 = $filter6; $filter7['prop-filters'][0]['name'] = 'DESCRIPTION'; @@ -443,21 +443,21 @@ yow; // Param filters $filter11 = $filter1; - $filter11['prop-filters'] = array( - array( - 'name' => 'DTSTART', + $filter11['prop-filters'] = [ + [ + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => array( - array( - 'name' => 'VALUE', + 'param-filters' => [ + [ + 'name' => 'VALUE', 'is-not-defined' => false, - 'text-match' => null, - ), - ), + 'text-match' => null, + ], + ], 'time-range' => null, 'text-match' => null, - ), - ); + ], + ]; $filter12 = $filter11; $filter12['prop-filters'][0]['param-filters'][0]['name'] = 'TZID'; @@ -470,11 +470,11 @@ yow; // Param text filter $filter15 = $filter11; - $filter15['prop-filters'][0]['param-filters'][0]['text-match'] = array( - 'collation' => 'i;ascii-casemap', - 'value' => 'dAtE', + $filter15['prop-filters'][0]['param-filters'][0]['text-match'] = [ + 'collation' => 'i;ascii-casemap', + 'value' => 'dAtE', 'negate-condition' => false, - ); + ]; $filter16 = $filter15; $filter16['prop-filters'][0]['param-filters'][0]['text-match']['collation'] = 'i;octet'; @@ -487,31 +487,31 @@ yow; // prop + text $filter19 = $filter5; - $filter19['comp-filters'][0]['prop-filters'] = array( - array( - 'name' => 'action', + $filter19['comp-filters'][0]['prop-filters'] = [ + [ + 'name' => 'action', 'is-not-defined' => false, - 'time-range' => null, - 'param-filters' => array(), - 'text-match' => array( - 'collation' => 'i;ascii-casemap', - 'value' => 'display', + 'time-range' => null, + 'param-filters' => [], + 'text-match' => [ + 'collation' => 'i;ascii-casemap', + 'value' => 'display', 'negate-condition' => false, - ), - ), - ); + ], + ], + ]; // Time range - $filter20 = array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter20 = [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ), - ); + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + ], + ]; // Time range, no end date $filter21 = $filter20; $filter21['time-range']['end'] = null; @@ -522,105 +522,105 @@ yow; // Time range, other dates $filter23 = $filter20; - $filter23['time-range'] = array( + $filter23['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), - ); + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + ]; // Time range - $filter24 = array( - 'name' => 'VTODO', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter24 = [ + 'name' => 'VTODO', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ), - ); + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + ], + ]; // Time range, other dates (1 month in the future) $filter25 = $filter24; - $filter25['time-range'] = array( + $filter25['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), - ); + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + ]; $filter26 = $filter24; - $filter26['time-range'] = array( + $filter26['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ); + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + ]; // Time range for VJOURNAL - $filter27 = array( - 'name' => 'VJOURNAL', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter27 = [ + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ), - ); + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + ], + ]; $filter28 = $filter27; - $filter28['time-range'] = array( + $filter28['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ); + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + ]; // Time range for VFREEBUSY - $filter29 = array( - 'name' => 'VFREEBUSY', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter29 = [ + 'name' => 'VFREEBUSY', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ), - ); + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + ], + ]; // Time range filter on property - $filter30 = array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array( - array( - 'name' => 'DTSTART', + $filter30 = [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [ + [ + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => array(), - 'time-range' => array( + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + ], 'text-match' => null, - ), - ), + ], + ], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; // Time range for alarm - $filter31 = array( - 'name' => 'VEVENT', - 'prop-filters' => array(), - 'comp-filters' => array( - array( - 'name' => 'VALARM', + $filter31 = [ + 'name' => 'VEVENT', + 'prop-filters' => [], + 'comp-filters' => [ + [ + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => array(), - 'prop-filters' => array(), - 'time-range' => array( + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), - ), + 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), + ], 'text-match' => null, - ), - ), + ], + ], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; $filter32 = $filter31; - $filter32['comp-filters'][0]['time-range'] = array( + $filter32['comp-filters'][0]['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ); + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + ]; $filter33 = $filter31; $filter33['name'] = 'VTODO'; @@ -632,194 +632,194 @@ yow; $filter36['name'] = 'VJOURNAL'; // Time range filter on non-datetime property - $filter37 = array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array( - array( - 'name' => 'SUMMARY', + $filter37 = [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [ + [ + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => array(), - 'time-range' => array( + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + ], 'text-match' => null, - ), - ), + ], + ], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; - $filter38 = array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filter38 = [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2012-07-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), - ) - ); - $filter39 = array( - 'name' => 'VEVENT', - 'comp-filters' => array( - array( - 'name' => 'VALARM', - 'comp-filters' => array(), - 'prop-filters' => array(), + 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), + ] + ]; + $filter39 = [ + 'name' => 'VEVENT', + 'comp-filters' => [ + [ + 'name' => 'VALARM', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2012-09-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), - ) - ), - ), - 'prop-filters' => array(), + 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), + ] + ], + ], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; - return array( + return [ // Component check - array($blob1, $filter1, 1), - array($blob1, $filter2, 0), - array($blob1, $filter3, 0), - array($blob1, $filter4, 1), + [$blob1, $filter1, 1], + [$blob1, $filter2, 0], + [$blob1, $filter3, 0], + [$blob1, $filter4, 1], // Subcomponent check (4) - array($blob1, $filter5, 0), - array($blob2, $filter5, 1), + [$blob1, $filter5, 0], + [$blob2, $filter5, 1], // Property checki (6) - array($blob1, $filter6, 1), - array($blob1, $filter7, 0), - array($blob1, $filter8, 0), - array($blob1, $filter9, 1), + [$blob1, $filter6, 1], + [$blob1, $filter7, 0], + [$blob1, $filter8, 0], + [$blob1, $filter9, 1], // Subcomponent + property (10) - array($blob2, $filter10, 1), + [$blob2, $filter10, 1], // Param filter (11) - array($blob3, $filter11, 1), - array($blob3, $filter12, 0), - array($blob3, $filter13, 0), - array($blob3, $filter14, 1), + [$blob3, $filter11, 1], + [$blob3, $filter12, 0], + [$blob3, $filter13, 0], + [$blob3, $filter14, 1], // Param + text (15) - array($blob3, $filter15, 1), - array($blob3, $filter16, 0), - array($blob3, $filter17, 0), - array($blob3, $filter18, 1), + [$blob3, $filter15, 1], + [$blob3, $filter16, 0], + [$blob3, $filter17, 0], + [$blob3, $filter18, 1], // Prop + text (19) - array($blob2, $filter19, 1), + [$blob2, $filter19, 1], // Incorrect object (vcard) (20) - array($blob4, $filter1, -1), + [$blob4, $filter1, -1], // Time-range for event (21) - array($blob5, $filter20, 1), - array($blob6, $filter20, 1), - array($blob7, $filter20, 1), - array($blob8, $filter20, 1), + [$blob5, $filter20, 1], + [$blob6, $filter20, 1], + [$blob7, $filter20, 1], + [$blob8, $filter20, 1], - array($blob5, $filter21, 1), - array($blob5, $filter22, 1), + [$blob5, $filter21, 1], + [$blob5, $filter22, 1], - array($blob5, $filter23, 0), - array($blob6, $filter23, 0), - array($blob7, $filter23, 0), - array($blob8, $filter23, 0), + [$blob5, $filter23, 0], + [$blob6, $filter23, 0], + [$blob7, $filter23, 0], + [$blob8, $filter23, 0], // Time-range for todo (31) - array($blob9, $filter24, 1), - array($blob9, $filter25, 0), - array($blob9, $filter26, 1), - array($blob10, $filter24, 1), - array($blob10, $filter25, 0), - array($blob10, $filter26, 1), + [$blob9, $filter24, 1], + [$blob9, $filter25, 0], + [$blob9, $filter26, 1], + [$blob10, $filter24, 1], + [$blob10, $filter25, 0], + [$blob10, $filter26, 1], - array($blob11, $filter24, 0), - array($blob11, $filter25, 0), - array($blob11, $filter26, 1), + [$blob11, $filter24, 0], + [$blob11, $filter25, 0], + [$blob11, $filter26, 1], - array($blob12, $filter24, 1), - array($blob12, $filter25, 0), - array($blob12, $filter26, 0), + [$blob12, $filter24, 1], + [$blob12, $filter25, 0], + [$blob12, $filter26, 0], - array($blob13, $filter24, 1), - array($blob13, $filter25, 0), - array($blob13, $filter26, 1), + [$blob13, $filter24, 1], + [$blob13, $filter25, 0], + [$blob13, $filter26, 1], - array($blob14, $filter24, 1), - array($blob14, $filter25, 0), - array($blob14, $filter26, 0), + [$blob14, $filter24, 1], + [$blob14, $filter25, 0], + [$blob14, $filter26, 0], - array($blob15, $filter24, 1), - array($blob15, $filter25, 1), - array($blob15, $filter26, 1), + [$blob15, $filter24, 1], + [$blob15, $filter25, 1], + [$blob15, $filter26, 1], - array($blob16, $filter24, 1), - array($blob16, $filter25, 1), - array($blob16, $filter26, 1), + [$blob16, $filter24, 1], + [$blob16, $filter25, 1], + [$blob16, $filter26, 1], // Time-range for journals (55) - array($blob17, $filter27, 0), - array($blob17, $filter28, 0), - array($blob18, $filter27, 0), - array($blob18, $filter28, 1), - array($blob19, $filter27, 1), - array($blob19, $filter28, 1), + [$blob17, $filter27, 0], + [$blob17, $filter28, 0], + [$blob18, $filter27, 0], + [$blob18, $filter28, 1], + [$blob19, $filter27, 1], + [$blob19, $filter28, 1], // Time-range for free-busy (61) - array($blob20, $filter29, -1), + [$blob20, $filter29, -1], // Time-range on property (62) - array($blob5, $filter30, 1), - array($blob3, $filter37, -1), - array($blob3, $filter30, 0), + [$blob5, $filter30, 1], + [$blob3, $filter37, -1], + [$blob3, $filter30, 0], // Time-range on alarm in vevent (65) - array($blob21, $filter31, 1), - array($blob21, $filter32, 0), - array($blob22, $filter31, 1), - array($blob22, $filter32, 0), - array($blob23, $filter31, 1), - array($blob23, $filter32, 0), - array($blob24, $filter31, 1), - array($blob24, $filter32, 0), - array($blob25, $filter31, 1), - array($blob25, $filter32, 0), - array($blob26, $filter31, 1), - array($blob26, $filter32, 0), + [$blob21, $filter31, 1], + [$blob21, $filter32, 0], + [$blob22, $filter31, 1], + [$blob22, $filter32, 0], + [$blob23, $filter31, 1], + [$blob23, $filter32, 0], + [$blob24, $filter31, 1], + [$blob24, $filter32, 0], + [$blob25, $filter31, 1], + [$blob25, $filter32, 0], + [$blob26, $filter31, 1], + [$blob26, $filter32, 0], // Time-range on alarm for vtodo (77) - array($blob27, $filter33, 1), - array($blob27, $filter34, 0), + [$blob27, $filter33, 1], + [$blob27, $filter34, 0], // Time-range on alarm for vjournal (79) - array($blob28, $filter35, -1), - array($blob28, $filter36, -1), + [$blob28, $filter35, -1], + [$blob28, $filter36, -1], // Time-range on alarm with duration (81) - array($blob29, $filter31, 1), - array($blob29, $filter32, 0), - array($blob30, $filter31, 0), - array($blob30, $filter32, 0), + [$blob29, $filter31, 1], + [$blob29, $filter32, 0], + [$blob30, $filter31, 0], + [$blob30, $filter32, 0], // Time-range with RRULE (85) - array($blob31, $filter20, 1), - array($blob32, $filter20, 0), + [$blob31, $filter20, 1], + [$blob32, $filter20, 0], // Bug reported on mailing list, related to all-day events (87) //array($blob33, $filter38, 1), // Event in timerange, but filtered alarm is in the far future (88). - array($blob34, $filter39, 0), - ); + [$blob34, $filter39, 0], + ]; } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php index ea744d2cf..df85b6ded 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php @@ -3,7 +3,6 @@ namespace Sabre\CalDAV; use Sabre\DAV\PropPatch; -use Sabre\DAVACL; require_once 'Sabre/CalDAV/TestUtil.php'; @@ -25,8 +24,6 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function setup() { - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $this->backend = TestUtil::getBackend(); $this->calendars = $this->backend->getCalendarsForUser('principals/user1'); @@ -63,7 +60,7 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(true, $result); $calendars2 = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals('NewName',$calendars2[0]['{DAV:}displayname']); + $this->assertEquals('NewName', $calendars2[0]['{DAV:}displayname']); } @@ -72,15 +69,15 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { */ function testGetProperties() { - $question = array( + $question = [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set', - ); + ]; $result = $this->calendar->getProperties($question); - foreach($question as $q) $this->assertArrayHasKey($q,$result); + foreach ($question as $q) $this->assertArrayHasKey($q, $result); - $this->assertEquals(array('VEVENT','VTODO'), $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); + $this->assertEquals(['VEVENT', 'VTODO'], $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); } @@ -100,7 +97,7 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function testGetChildren() { $children = $this->calendar->getChildren(); - $this->assertEquals(1,count($children)); + $this->assertEquals(1, count($children)); $this->assertTrue($children[0] instanceof CalendarObject); @@ -145,11 +142,11 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function testCreateFile() { - $file = fopen('php://memory','r+'); - fwrite($file,TestUtil::getTestCalendarData()); + $file = fopen('php://memory', 'r+'); + fwrite($file, TestUtil::getTestCalendarData()); rewind($file); - $this->calendar->createFile('hello',$file); + $this->calendar->createFile('hello', $file); $file = $this->calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); @@ -158,12 +155,12 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function testCreateFileNoSupportedComponents() { - $file = fopen('php://memory','r+'); - fwrite($file,TestUtil::getTestCalendarData()); + $file = fopen('php://memory', 'r+'); + fwrite($file, TestUtil::getTestCalendarData()); rewind($file); $calendar = new Calendar($this->backend, $this->calendars[1]); - $calendar->createFile('hello',$file); + $calendar->createFile('hello', $file); $file = $calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); @@ -180,7 +177,7 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function testGetOwner() { - $this->assertEquals('principals/user1',$this->calendar->getOwner()); + $this->assertEquals('principals/user1', $this->calendar->getOwner()); } @@ -192,98 +189,68 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { function testGetACL() { - $expected = array( - array( + $expected = [ + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-read', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}write', 'principal' => 'principals/user1', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}write', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $this->calendar->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\Forbidden */ function testSetACL() { - $this->calendar->setACL(array()); - - } - - function testGetSupportedPrivilegesSet() { - - $result = $this->calendar->getSupportedPrivilegeSet(); - - $this->assertEquals( - '{' . Plugin::NS_CALDAV . '}read-free-busy', - $result['aggregates'][0]['aggregates'][2]['privilege'] - ); + $this->calendar->setACL([]); } function testGetSyncToken() { - $this->assertEquals(2, $this->calendar->getSyncToken()); - - } - function testGetSyncToken2() { - - $calendar = new Calendar(new Backend\Mock([],[]), [ - '{DAV:}sync-token' => 2 - ]); - $this->assertEquals(2, $this->calendar->getSyncToken()); + $this->assertNull($this->calendar->getSyncToken()); } function testGetSyncTokenNoSyncSupport() { - $calendar = new Calendar(new Backend\Mock([],[]), []); + $calendar = new Calendar(new Backend\Mock([], []), []); $this->assertNull($calendar->getSyncToken()); } function testGetChanges() { - $this->assertEquals([ - 'syncToken' => 2, - 'modified' => [], - 'deleted' => [], - 'added' => ['UUID-2345'], - ], $this->calendar->getChanges(1, 1)); + $this->assertNull($this->calendar->getChanges(1, 1)); } - function testGetChangesNoSyncSupport() { - - $calendar = new Calendar(new Backend\Mock([],[]), []); - $this->assertNull($calendar->getChanges(1,null)); - - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php index b64fb122a..3a22e03d4 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php @@ -19,18 +19,18 @@ class ExpandEventsDoubleEventsTest extends \Sabre\DAVServerTest { protected $setupCalDAV = true; - protected $caldavCalendars = array( - array( - 'id' => 1, - 'name' => 'Calendar', + protected $caldavCalendars = [ + [ + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ) - ); + 'uri' => 'calendar1', + ] + ]; - protected $caldavCalendarObjects = array( - 1 => array( - 'event.ics' => array( + protected $caldavCalendarObjects = [ + 1 => [ + 'event.ics' => [ 'calendardata' => 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -50,17 +50,17 @@ RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500 END:VEVENT END:VCALENDAR ', - ), - ), - ); + ], + ], + ]; function testExpand() { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody('<?xml version="1.0" encoding="utf-8" ?> @@ -88,12 +88,12 @@ END:VCALENDAR $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13 ); - $body = str_replace(' ','',$body); + $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); + $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'])); @@ -101,4 +101,3 @@ END:VCALENDAR } } - diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php index 84f05f3c0..7a756774f 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php @@ -3,7 +3,6 @@ namespace Sabre\CalDAV; use Sabre\DAV; -use Sabre\DAVACL; use Sabre\HTTP; require_once 'Sabre/CalDAV/Backend/Mock.php'; @@ -31,8 +30,8 @@ END:VEVENT END:VCALENDAR ics; - $obj2 = fopen('php://memory','r+'); - fwrite($obj2,<<<ics + $obj2 = fopen('php://memory', 'r+'); + fwrite($obj2, <<<ics BEGIN:VCALENDAR BEGIN:VEVENT DTSTART:20121005T120000Z @@ -55,18 +54,18 @@ ics; $calendarData = [ 1 => [ 'obj1' => [ - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => $obj1, ], 'obj2' => [ - 'calendarid' => 1, - 'uri' => 'event2.ics', + 'calendarid' => 1, + 'uri' => 'event2.ics', 'calendardata' => $obj2 ], 'obj3' => [ - 'calendarid' => 1, - 'uri' => 'event3.ics', + 'calendarid' => 1, + 'uri' => 'event3.ics', 'calendardata' => $obj3 ] ], @@ -76,9 +75,9 @@ ics; $caldavBackend = new Backend\Mock([], $calendarData); $calendar = new Calendar($caldavBackend, [ - 'id' => 1, - 'uri' => 'calendar', - 'principaluri' => 'principals/user1', + 'id' => 1, + 'uri' => 'calendar', + 'principaluri' => 'principals/user1', '{' . Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", ]); @@ -105,13 +104,13 @@ ics; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report); + $this->plugin->report($rootElem, $report, null); $this->assertEquals(200, $this->server->httpResponse->status); $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type')); - $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')!==false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')!==false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')!==false); + $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY') !== false); + $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z') !== false); + $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z') !== false); } @@ -127,7 +126,6 @@ XML; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report); } @@ -136,9 +134,9 @@ XML; */ function testFreeBusyReportWrongNode() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_URI' => '/', - )); + ]); $this->server->httpRequest = $request; $reportXML = <<<XML @@ -149,7 +147,7 @@ XML; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report); + $this->plugin->report($rootElem, $report, null); } @@ -170,7 +168,7 @@ XML; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report); + $this->plugin->report($rootElem, $report, null); } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php index c3c97e8f6..5fd8d29a1 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php @@ -75,7 +75,7 @@ END:VCALENDAR $response = $this->request($request); - $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR')!==false); + $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR') !== false); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php index c123bd0c1..9719529fb 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -7,657 +7,380 @@ use Sabre\HTTP; use Sabre\VObject; use Sabre\DAVACL; -require_once 'Sabre/CalDAV/TestUtil.php'; -require_once 'Sabre/HTTP/ResponseMock.php'; +class ICSExportPluginTest extends \Sabre\DAVServerTest { -class ICSExportPluginTest extends \PHPUnit_Framework_TestCase { + protected $setupCalDAV = true; + + protected $icsExportPlugin; function setUp() { - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); + parent::setUp(); + $this->icsExportPlugin = new ICSExportPlugin(); + $this->server->addPlugin( + $this->icsExportPlugin + ); - } + $id = $this->caldavBackend->createCalendar( + 'principals/admin', + 'UUID-123467', + [ + '{DAV:}displayname' => 'Hello!', + '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', + ] + ); - function testInit() { + $this->caldavBackend->createCalendarObject( + $id, + 'event-1', + <<<ICS +BEGIN:VCALENDAR +BEGIN:VTIMEZONE +TZID:Europe/Amsterdam +END:VTIMEZONE +BEGIN:VEVENT +UID:event-1 +DTSTART;TZID=Europe/Amsterdam:20151020T000000 +END:VEVENT +END:VCALENDAR +ICS + ); + $this->caldavBackend->createCalendarObject( + $id, + 'todo-1', + <<<ICS +BEGIN:VCALENDAR +BEGIN:VTODO +UID:todo-1 +END:VTODO +END:VCALENDAR +ICS + ); - $p = new ICSExportPlugin(); - $s = new DAV\Server(); - $s->addPlugin($p); - $this->assertEquals($p, $s->getPlugin('ics-export')); - $this->assertEquals('ics-export', $p->getPluginInfo()['name']); } - function testBeforeMethod() { + function testInit() { - $cbackend = TestUtil::getBackend(); - - $props = [ - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - '{DAV:}displayname' => 'Hello!', - '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', - ]; - $tree = [ - new Calendar($cbackend,$props), - ]; - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $this->assertFalse($p->httpGet($h, $s->httpResponse)); - - $this->assertEquals(200, $s->httpResponse->status); - $this->assertEquals([ - 'Content-Type' => ['text/calendar'], - ], $s->httpResponse->getHeaders()); - - $obj = VObject\Reader::read($s->httpResponse->body); - - $this->assertEquals(7,count($obj->children())); - $this->assertEquals(1,count($obj->VERSION)); - $this->assertEquals(1,count($obj->CALSCALE)); - $this->assertEquals(1,count($obj->PRODID)); - $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION)!==false); - $this->assertEquals(1,count($obj->VTIMEZONE)); - $this->assertEquals(1,count($obj->VEVENT)); - $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"}); - $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"}); + $this->assertEquals( + $this->icsExportPlugin, + $this->server->getPlugin('ics-export') + ); + $this->assertEquals($this->icsExportPlugin, $this->server->getPlugin('ics-export')); + $this->assertEquals('ics-export', $this->icsExportPlugin->getPluginInfo()['name']); } - function testBeforeMethodNoVersion() { - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $cbackend = TestUtil::getBackend(); + function testBeforeMethod() { - $props = [ - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ]; - $tree = [ - new Calendar($cbackend,$props), - ]; + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export' + ); - $p = new ICSExportPlugin(); + $response = $this->request($request); - $s = new DAV\Server($tree); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); + $obj = VObject\Reader::read($response->body); - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - 'REQUEST_METHOD' => 'GET', - ]); + $this->assertEquals(8, count($obj->children())); + $this->assertEquals(1, count($obj->VERSION)); + $this->assertEquals(1, count($obj->CALSCALE)); + $this->assertEquals(1, count($obj->PRODID)); + $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertEquals(1, count($obj->VTIMEZONE)); + $this->assertEquals(1, count($obj->VEVENT)); + $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"}); + $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"}); - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); + } + function testBeforeMethodNoVersion() { + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export' + ); DAV\Server::$exposeVersion = false; - $this->assertFalse($p->httpGet($h, $s->httpResponse)); + $response = $this->request($request); DAV\Server::$exposeVersion = true; - $this->assertEquals(200, $s->httpResponse->status); - $this->assertEquals([ - 'Content-Type' => ['text/calendar'], - ], $s->httpResponse->getHeaders()); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - $obj = VObject\Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($response->body); - $this->assertEquals(5,count($obj->children())); - $this->assertEquals(1,count($obj->VERSION)); - $this->assertEquals(1,count($obj->CALSCALE)); - $this->assertEquals(1,count($obj->PRODID)); - $this->assertFalse(strpos((string)$obj->PRODID, DAV\Version::VERSION)!==false); - $this->assertEquals(1,count($obj->VTIMEZONE)); - $this->assertEquals(1,count($obj->VEVENT)); + $this->assertEquals(8, count($obj->children())); + $this->assertEquals(1, count($obj->VERSION)); + $this->assertEquals(1, count($obj->CALSCALE)); + $this->assertEquals(1, count($obj->PRODID)); + $this->assertFalse(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertEquals(1, count($obj->VTIMEZONE)); + $this->assertEquals(1, count($obj->VEVENT)); } function testBeforeMethodNoExport() { - $p = new ICSExportPlugin(); - - $s = new DAV\Server(); - $s->addPlugin($p); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467', - 'REQUEST_METHOD' => 'GET', - ]); - $this->assertNull($p->httpGet($h, $s->httpResponse)); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467' + ); + $response = new HTTP\Response(); + $this->assertNull($this->icsExportPlugin->httpGet($request, $response)); } function testACLIntegrationBlocked() { - $cbackend = TestUtil::getBackend(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $aclPlugin = new DAVACL\Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; + $this->server->addPlugin( + $aclPlugin ); - $tree = array( - new Calendar($cbackend,$props), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - $s->addPlugin(new DAVACL\Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - ]); - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $p->httpGet($h, $s->httpResponse); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export' + ); - // If the ACL system blocked this request, the effect will be that - // there's no response, because the calendar information could not be - // fetched. - $this->assertNull($s->httpResponse->getStatus()); + $this->request($request, 403); } function testACLIntegrationNotBlocked() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $aclPlugin = new DAVACL\Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; + $this->server->addPlugin( + $aclPlugin ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), + $this->server->addPlugin( + new Plugin() ); - $p = new ICSExportPlugin(); + $this->autoLogin('admin'); - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - $s->addPlugin(new DAVACL\Plugin()); - $s->addPlugin(new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'SabreDAV')); - - // Forcing login - $s->getPlugin('acl')->adminPrincipals = array('principals/admin'); - - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export' + ); - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $this->assertEquals(array( - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/calendar'], - ), $s->httpResponse->getHeaders()); + $response = $this->request($request, 200); + $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - $obj = VObject\Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($response->body); - $this->assertEquals(5,count($obj->children())); - $this->assertEquals(1,count($obj->VERSION)); - $this->assertEquals(1,count($obj->CALSCALE)); - $this->assertEquals(1,count($obj->PRODID)); - $this->assertEquals(1,count($obj->VTIMEZONE)); - $this->assertEquals(1,count($obj->VEVENT)); + $this->assertEquals(8, count($obj->children())); + $this->assertEquals(1, count($obj->VERSION)); + $this->assertEquals(1, count($obj->CALSCALE)); + $this->assertEquals(1, count($obj->PRODID)); + $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertEquals(1, count($obj->VTIMEZONE)); + $this->assertEquals(1, count($obj->VEVENT)); } function testBadStartParam() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&start=foo' ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&start=foo', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); + $this->request($request, 400); } function testBadEndParam() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&end=foo' ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&end=foo', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); + $this->request($request, 400); } function testFilterStartEnd() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&start=1&end=2' ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&start=1&end=2', - 'REQUEST_METHOD' => 'GET', - ]); + $response = $this->request($request, 200); - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); + $obj = VObject\Reader::read($response->getBody()); - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $obj = VObject\Reader::read($s->httpResponse->body); - - $this->assertEquals(0,count($obj->VTIMEZONE)); - $this->assertEquals(0,count($obj->VEVENT)); + $this->assertEquals(0, count($obj->VTIMEZONE)); + $this->assertEquals(0, count($obj->VEVENT)); } function testExpandNoStart() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&expand=1&end=2' ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&expand=1&end=1', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); + $this->request($request, 400); } function testExpand() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&start=1&end=2000000000&expand=1' ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&start=1&end=2000000000&expand=1', - 'REQUEST_METHOD' => 'GET', - ]); + $response = $this->request($request, 200); - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); + $obj = VObject\Reader::read($response->getBody()); - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $obj = VObject\Reader::read($s->httpResponse->body); - - $this->assertEquals(0,count($obj->VTIMEZONE)); - $this->assertEquals(1,count($obj->VEVENT)); + $this->assertEquals(0, count($obj->VTIMEZONE)); + $this->assertEquals(1, count($obj->VEVENT)); } function testJCal() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export', + ['Accept' => 'application/calendar+json'] ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ); - - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - 'REQUEST_METHOD' => 'GET', - 'HTTP_ACCEPT' => 'application/calendar+json', - ]); - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $this->assertEquals('application/calendar+json', $s->httpResponse->getHeader('Content-Type')); + $response = $this->request($request, 200); + $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); } function testJCalInUrl() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&accept=jcal' ); - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&accept=jcal', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $this->assertEquals('application/calendar+json', $s->httpResponse->getHeader('Content-Type')); + $response = $this->request($request, 200); + $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); } function testNegotiateDefault() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ); - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export', + ['Accept' => 'text/plain'] ); - $p = new ICSExportPlugin(); - - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export', - 'REQUEST_METHOD' => 'GET', - 'HTTP_ACCEPT' => 'text/plain', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $this->assertEquals('text/calendar', $s->httpResponse->getHeader('Content-Type')); + $response = $this->request($request, 200); + $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); } function testFilterComponentVEVENT() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); - - $props = array( - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ); - // add a todo to the calendar (see /tests/Sabre/TestUtil) - $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO()); - - $tree = array( - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&componentType=VEVENT' ); - $p = new ICSExportPlugin(); + $response = $this->request($request, 200); - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); - - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&componentType=VEVENT', - 'REQUEST_METHOD' => 'GET', - ]); - - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); - - $s->exec(); - - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $obj = VObject\Reader::read($s->httpResponse->body); - - $this->assertEquals(1,count($obj->VTIMEZONE)); - $this->assertEquals(1,count($obj->VEVENT)); - $this->assertEquals(0,count($obj->VTODO)); + $obj = VObject\Reader::read($response->body); + $this->assertEquals(1, count($obj->VTIMEZONE)); + $this->assertEquals(1, count($obj->VEVENT)); + $this->assertEquals(0, count($obj->VTODO)); } function testFilterComponentVTODO() { - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&componentType=VTODO' + ); - $props = [ - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ]; - // add a todo to the calendar (see /tests/Sabre/TestUtil) - $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO()); + $response = $this->request($request, 200); - $tree = [ - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ]; + $obj = VObject\Reader::read($response->body); - $p = new ICSExportPlugin(); + $this->assertEquals(0, count($obj->VTIMEZONE)); + $this->assertEquals(0, count($obj->VEVENT)); + $this->assertEquals(1, count($obj->VTODO)); - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); + } - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&componentType=VTODO', - 'REQUEST_METHOD' => 'GET', - ]); + function testFilterComponentBadComponent() { - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export&componentType=VVOODOO' + ); - $s->exec(); + $response = $this->request($request, 400); - $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); - $obj = VObject\Reader::read($s->httpResponse->body); + } - $this->assertEquals(0,count($obj->VTIMEZONE)); - $this->assertEquals(0,count($obj->VEVENT)); - $this->assertEquals(1,count($obj->VTODO)); + function testContentDisposition() { - } + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export' + ); - function testFilterComponentBadComponent() { + $response = $this->request($request, 200); + $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); + $this->assertEquals( + 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.ics"', + $response->getHeader('Content-Disposition') + ); - $cbackend = TestUtil::getBackend(); - $pbackend = new DAVACL\PrincipalBackend\Mock(); + } - $props = [ - 'uri'=>'UUID-123467', - 'principaluri' => 'admin', - 'id' => 1, - ]; - // add a todo to the calendar (see /tests/Sabre/TestUtil) - $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO()); + function testContentDispositionJson() { - $tree = [ - new Calendar($cbackend,$props), - new DAVACL\PrincipalCollection($pbackend), - ]; + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-123467?export', + ['Accept' => 'application/calendar+json'] + ); - $p = new ICSExportPlugin(); + $response = $this->request($request, 200); + $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); + $this->assertEquals( + 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.json"', + $response->getHeader('Content-Disposition') + ); - $s = new DAV\Server($tree); - $s->sapi = new HTTP\SapiMock(); - $s->addPlugin($p); - $s->addPlugin(new Plugin()); + } - $h = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/UUID-123467?export&componentType=VVOODOO', - 'REQUEST_METHOD' => 'GET', - ]); + function testContentDispositionBadChars() { - $s->httpRequest = $h; - $s->httpResponse = new HTTP\ResponseMock(); + $this->caldavBackend->createCalendar( + 'principals/admin', + 'UUID-b_ad"(ch)ars', + [ + '{DAV:}displayname' => 'Test bad characters', + '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', + ] + ); - $s->exec(); + $request = new HTTP\Request( + 'GET', + '/calendars/admin/UUID-b_ad"(ch)ars?export', + ['Accept' => 'application/calendar+json'] + ); - $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body); + $response = $this->request($request, 200); + $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); + $this->assertEquals( + 'attachment; filename="UUID-b_adchars-' . date('Y-m-d') . '.json"', + $response->getHeader('Content-Disposition') + ); } + } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php index f925224f2..a1a9b7c04 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php @@ -1,8 +1,8 @@ <?php namespace Sabre\CalDAV; + use Sabre\VObject; -use Sabre\DAV; class Issue166Test extends \PHPUnit_Framework_TestCase { @@ -37,26 +37,26 @@ HI; $validator = new CalendarQueryValidator(); - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array( - array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2011-12-01'), 'end' => new \DateTime('2012-02-01'), - ), - ), - ), - 'prop-filters' => array(), + ], + ], + ], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, - ); + 'time-range' => null, + ]; $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input,$filters)); + $this->assertTrue($validator->validate($input, $filters)); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php index ce6d364f6..e2b85c2bc 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php @@ -1,8 +1,8 @@ <?php namespace Sabre\CalDAV; + use Sabre\VObject; -use Sabre\DAV; class Issue172Test extends \PHPUnit_Framework_TestCase { @@ -18,24 +18,24 @@ END:VEVENT END:VCALENDAR HI; $validator = new CalendarQueryValidator(); - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array( - array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), - ), - ), - ), - 'prop-filters' => array(), - ); + ], + ], + ], + 'prop-filters' => [], + ]; $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input,$filters)); + $this->assertTrue($validator->validate($input, $filters)); } // Pacific Standard Time, translates to America/Los_Angeles (GMT-8 in January) @@ -65,24 +65,24 @@ END:VEVENT END:VCALENDAR HI; $validator = new CalendarQueryValidator(); - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array( - array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - ), - ), - ), - 'prop-filters' => array(), - ); + ], + ], + ], + 'prop-filters' => [], + ]; $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input,$filters)); + $this->assertTrue($validator->validate($input, $filters)); } // X-LIC-LOCATION, translates to America/Los_Angeles (GMT-8 in January) @@ -113,23 +113,23 @@ END:VEVENT END:VCALENDAR HI; $validator = new CalendarQueryValidator(); - $filters = array( - 'name' => 'VCALENDAR', - 'comp-filters' => array( - array( - 'name' => 'VEVENT', - 'comp-filters' => array(), - 'prop-filters' => array(), + $filters = [ + 'name' => 'VCALENDAR', + 'comp-filters' => [ + [ + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => array( + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - ), - ), - ), - 'prop-filters' => array(), - ); + ], + ], + ], + 'prop-filters' => [], + ]; $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input,$filters)); + $this->assertTrue($validator->validate($input, $filters)); } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php index 4a53fcbe2..ce40a90b0 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV; + use Sabre\HTTP; use Sabre\VObject; @@ -15,18 +16,18 @@ class Issue205Test extends \Sabre\DAVServerTest { protected $setupCalDAV = true; - protected $caldavCalendars = array( - array( - 'id' => 1, - 'name' => 'Calendar', + protected $caldavCalendars = [ + [ + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ) - ); + 'uri' => 'calendar1', + ] + ]; - protected $caldavCalendarObjects = array( - 1 => array( - 'event.ics' => array( + protected $caldavCalendarObjects = [ + 1 => [ + 'event.ics' => [ 'calendardata' => 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -44,18 +45,18 @@ END:VALARM END:VEVENT END:VCALENDAR ', - ), - ), - ); + ], + ], + ]; function testIssue205() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', + $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', - )); + '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"> @@ -87,7 +88,7 @@ END:VCALENDAR $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13 ); - $body = str_replace(' ','',$body); + $body = str_replace(' ', '', $body); $vObject = VObject\Reader::read($body); diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php index f291e5e57..950629fd8 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php @@ -1,8 +1,8 @@ <?php namespace Sabre\CalDAV; + use Sabre\HTTP; -use Sabre\VObject; /** * This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator @@ -15,18 +15,18 @@ class Issue211Test extends \Sabre\DAVServerTest { protected $setupCalDAV = true; - protected $caldavCalendars = array( - array( - 'id' => 1, - 'name' => 'Calendar', + protected $caldavCalendars = [ + [ + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ) - ); + 'uri' => 'calendar1', + ] + ]; - protected $caldavCalendarObjects = array( - 1 => array( - 'event.ics' => array( + protected $caldavCalendarObjects = [ + 1 => [ + 'event.ics' => [ 'calendardata' => 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -49,18 +49,18 @@ END:VALARM END:VEVENT END:VCALENDAR ', - ), - ), - ); + ], + ], + ]; function testIssue211() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', + $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', - )); + '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"> diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php index 7b5dbfe63..c3c0b5b48 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php @@ -15,18 +15,18 @@ class Issue220Test extends \Sabre\DAVServerTest { protected $setupCalDAV = true; - protected $caldavCalendars = array( - array( - 'id' => 1, - 'name' => 'Calendar', + protected $caldavCalendars = [ + [ + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ) - ); + 'uri' => 'calendar1', + ] + ]; - protected $caldavCalendarObjects = array( - 1 => array( - 'event.ics' => array( + protected $caldavCalendarObjects = [ + 1 => [ + 'event.ics' => [ 'calendardata' => 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -59,18 +59,18 @@ UID:b64f14c5-dccc-4eda-947f-bdb1f763fbcd END:VEVENT END:VCALENDAR ', - ), - ), - ); + ], + ], + ]; function testIssue220() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', + $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', - )); + '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"> diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php index ccc6b303a..d0783701d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV; + use Sabre\HTTP; /** @@ -14,18 +15,18 @@ class Issue228Test extends \Sabre\DAVServerTest { protected $setupCalDAV = true; - protected $caldavCalendars = array( - array( - 'id' => 1, - 'name' => 'Calendar', + protected $caldavCalendars = [ + [ + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ) - ); + 'uri' => 'calendar1', + ] + ]; - protected $caldavCalendarObjects = array( - 1 => array( - 'event.ics' => array( + protected $caldavCalendarObjects = [ + 1 => [ + 'event.ics' => [ 'calendardata' => 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT @@ -38,18 +39,18 @@ TRANSP:TRANSPARENT END:VEVENT END:VCALENDAR ', - ), - ), - ); + ], + ], + ]; function testIssue228() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', + $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', - )); + '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"> diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php index 68035184f..6585f85c3 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php @@ -14,13 +14,13 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { $this->principalUri = 'principals/user1'; - $this->notification = new CalDAV\Xml\Notification\SystemStatus(1,'"1"'); + $this->notification = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); - $this->caldavBackend = new CalDAV\Backend\MockSharing(array(),array(), array( - 'principals/user1' => array( + $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ + 'principals/user1' => [ $this->notification - ) - )); + ] + ]); return new Collection($this->caldavBackend, $this->principalUri); @@ -31,9 +31,9 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { $col = $this->getInstance(); $this->assertEquals('notifications', $col->getName()); - $this->assertEquals(array( + $this->assertEquals([ new Node($this->caldavBackend, $this->principalUri, $this->notification) - ), $col->getChildren()); + ], $col->getChildren()); } @@ -54,30 +54,25 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { function testGetACL() { $col = $this->getInstance(); - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => $this->principalUri, + $expected = [ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => $this->principalUri, - 'protected' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $col->getACL()); } /** - * @expectedException Sabre\DAV\Exception\NotImplemented + * @expectedException \Sabre\DAV\Exception\Forbidden */ function testSetACL() { $col = $this->getInstance(); - $col->setACL(array()); + $col->setACL([]); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php index d546116fc..6c6e02da8 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php @@ -13,7 +13,7 @@ class NodeTest extends \PHPUnit_Framework_TestCase { $principalUri = 'principals/user1'; - $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1,'"1"'); + $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 'principals/user1' => [ @@ -51,7 +51,7 @@ class NodeTest extends \PHPUnit_Framework_TestCase { $node = $this->getInstance(); $node->delete(); - $this->assertEquals(array(), $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); + $this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); } @@ -65,30 +65,25 @@ class NodeTest extends \PHPUnit_Framework_TestCase { function testGetACL() { $node = $this->getInstance(); - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', + $expected = [ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1', - 'protected' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $node->getACL()); } /** - * @expectedException Sabre\DAV\Exception\NotImplemented + * @expectedException \Sabre\DAV\Exception\Forbidden */ function testSetACL() { $node = $this->getInstance(); - $node->setACL(array()); + $node->setACL([]); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php index 138012ffa..8d538dee5 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php @@ -81,12 +81,14 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($this->plugin); // Adding ACL plugin - $this->server->addPlugin(new DAVACL\Plugin()); + $aclPlugin = new DAVACL\Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; + $this->server->addPlugin($aclPlugin); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->setPrincipal('principals/user1'); - $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); + $authPlugin = new DAV\Auth\Plugin($authBackend); $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response()); $this->server->addPlugin($authPlugin); @@ -480,8 +482,9 @@ END:VCALENDAR'; $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop); $value = [ '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set' + '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); @@ -508,6 +511,7 @@ END:VCALENDAR'; '{urn:ietf:params:xml:ns:caldav}calendar-query', '{urn:ietf:params:xml:ns:caldav}free-busy-query', '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set' ]; @@ -533,6 +537,7 @@ END:VCALENDAR'; $value = [ '{DAV:}sync-collection', '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set', ]; @@ -719,7 +724,7 @@ XML; '</c:calendar-query>'; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ - 'Depth' => '0', + 'Depth' => '0', 'User-Agent' => 'MSFT-WP/8.10.14219 (gzip)', ]); diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php index 625f64211..23c248825 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV\Principal; + use Sabre\DAVACL; class CollectionTest extends \PHPUnit_Framework_TestCase { @@ -9,9 +10,9 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { $back = new DAVACL\PrincipalBackend\Mock(); $col = new Collection($back); - $r = $col->getChildForPrincipal(array( + $r = $col->getChildForPrincipal([ 'uri' => 'principals/admin', - )); + ]); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\User', $r); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php index 1ee999a92..fe07f0131 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV\Principal; + use Sabre\DAVACL; class ProxyReadTest extends \PHPUnit_Framework_TestCase { @@ -10,9 +11,9 @@ class ProxyReadTest extends \PHPUnit_Framework_TestCase { function getInstance() { $backend = new DAVACL\PrincipalBackend\Mock(); - $principal = new ProxyRead($backend, array( + $principal = new ProxyRead($backend, [ 'uri' => 'principal/user', - )); + ]); $this->backend = $backend; return $principal; @@ -61,7 +62,7 @@ class ProxyReadTest extends \PHPUnit_Framework_TestCase { function testGetAlternateUriSet() { $i = $this->getInstance(); - $this->assertEquals(array(), $i->getAlternateUriSet()); + $this->assertEquals([], $i->getAlternateUriSet()); } @@ -75,25 +76,25 @@ class ProxyReadTest extends \PHPUnit_Framework_TestCase { function testGetGroupMemberSet() { $i = $this->getInstance(); - $this->assertEquals(array(), $i->getGroupMemberSet()); + $this->assertEquals([], $i->getGroupMemberSet()); } function testGetGroupMembership() { $i = $this->getInstance(); - $this->assertEquals(array(), $i->getGroupMembership()); + $this->assertEquals([], $i->getGroupMembership()); } function testSetGroupMemberSet() { $i = $this->getInstance(); - $i->setGroupMemberSet(array('principals/foo')); + $i->setGroupMemberSet(['principals/foo']); - $expected = array( - $i->getPrincipalUrl() => array('principals/foo') - ); + $expected = [ + $i->getPrincipalUrl() => ['principals/foo'] + ]; $this->assertEquals($expected, $this->backend->groupMembers); diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php index c0186ff0d..6cdb9b30e 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV\Principal; + use Sabre\DAVACL; class ProxyWriteTest extends ProxyReadTest { @@ -8,9 +9,9 @@ class ProxyWriteTest extends ProxyReadTest { function getInstance() { $backend = new DAVACL\PrincipalBackend\Mock(); - $principal = new ProxyWrite($backend, array( + $principal = new ProxyWrite($backend, [ 'uri' => 'principal/user', - )); + ]); $this->backend = $backend; return $principal; diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php index 37b5eae97..420bb3b1a 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV\Principal; + use Sabre\DAVACL; class UserTest extends \PHPUnit_Framework_TestCase { @@ -8,18 +9,18 @@ class UserTest extends \PHPUnit_Framework_TestCase { function getInstance() { $backend = new DAVACL\PrincipalBackend\Mock(); - $backend->addPrincipal(array( + $backend->addPrincipal([ 'uri' => 'principals/user/calendar-proxy-read', - )); - $backend->addPrincipal(array( + ]); + $backend->addPrincipal([ 'uri' => 'principals/user/calendar-proxy-write', - )); - $backend->addPrincipal(array( + ]); + $backend->addPrincipal([ 'uri' => 'principals/user/random', - )); - return new User($backend, array( + ]); + return new User($backend, [ 'uri' => 'principals/user', - )); + ]); } @@ -100,23 +101,23 @@ class UserTest extends \PHPUnit_Framework_TestCase { function testGetACL() { - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => '{DAV:}authenticated', + $expected = [ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user/calendar-proxy-read', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user/calendar-proxy-write', 'protected' => true, - ), - ); + ], + ]; $u = $this->getInstance(); $this->assertEquals($expected, $u->getACL()); diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php index 933c7157b..04d4b1237 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\CalDAV\Schedule; + use Sabre\CalDAV; use Sabre\DAV; @@ -10,80 +11,38 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { $outbox = new Outbox('principals/user1'); $this->assertEquals('outbox', $outbox->getName()); - $this->assertEquals(array(), $outbox->getChildren()); + $this->assertEquals([], $outbox->getChildren()); $this->assertEquals('principals/user1', $outbox->getOwner()); $this->assertEquals(null, $outbox->getGroup()); - $this->assertEquals(array( - array( - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', - 'principal' => 'principals/user1', - 'protected' => true, - ), - - array( - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', + $this->assertEquals([ + [ + 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', 'principal' => 'principals/user1', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', 'protected' => true, - ), - array( - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', + ], + [ + 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - array( - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-read', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, - ), - ), $outbox->getACL()); - - $ok = false; - try { - $outbox->setACL(array()); - } catch (DAV\Exception\MethodNotAllowed $e) { - $ok = true; - } - if (!$ok) { - $this->fail('Exception was not emitted'); - } - - } - - function testGetSupportedPrivilegeSet() { - - $outbox = new Outbox('principals/user1'); - $r = $outbox->getSupportedPrivilegeSet(); - - $ok = 0; - foreach($r['aggregates'] as $priv) { - - if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy') { - $ok++; - } - if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent') { - $ok++; - } - } - - $this->assertEquals(2, $ok, "We're missing one or more privileges"); + ], + ], $outbox->getACL()); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php index 337b658f4..f71c19523 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php @@ -2,7 +2,8 @@ namespace Sabre\CalDAV; -use Sabre\DAVACL; +use Sabre\DAV\Sharing; +use Sabre\DAV\Xml\Element\Sharee; class SharedCalendarTest extends \PHPUnit_Framework_TestCase { @@ -11,96 +12,95 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { function getInstance(array $props = null) { if (is_null($props)) { - $props = array( - 'id' => 1, + $props = [ + 'id' => 1, '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original', - '{http://sabredav.org/ns}owner-principal' => 'principals/owner', - '{http://sabredav.org/ns}read-only' => false, - 'principaluri' => 'principals/sharee', - ); + '{http://sabredav.org/ns}owner-principal' => 'principals/owner', + '{http://sabredav.org/ns}read-only' => false, + 'share-access' => Sharing\Plugin::ACCESS_READWRITE, + 'principaluri' => 'principals/sharee', + ]; } $this->backend = new Backend\MockSharing( - array($props), - array(), - array() + [$props], + [], + [] ); - $this->backend->updateShares(1, array( - array( - 'href' => 'mailto:removeme@example.org', - 'commonName' => 'To be removed', - 'readOnly' => true, - ), - ), array()); + + $sharee = new Sharee(); + $sharee->href = 'mailto:removeme@example.org'; + $sharee->properties['{DAV:}displayname'] = 'To be removed'; + $sharee->access = Sharing\Plugin::ACCESS_READ; + $this->backend->updateInvites(1, [$sharee]); return new SharedCalendar($this->backend, $props); } - function testGetSharedUrl() { - $this->assertEquals('calendars/owner/original', $this->getInstance()->getSharedUrl()); - } + function testGetInvites() { - function testGetShares() { + $sharee = new Sharee(); + $sharee->href = 'mailto:removeme@example.org'; + $sharee->properties['{DAV:}displayname'] = 'To be removed'; + $sharee->access = Sharing\Plugin::ACCESS_READ; + $sharee->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; - $this->assertEquals(array(array( - 'href' => 'mailto:removeme@example.org', - 'commonName' => 'To be removed', - 'readOnly' => true, - 'status' => SharingPlugin::STATUS_NORESPONSE, - )), $this->getInstance()->getShares()); + $this->assertEquals( + [$sharee], + $this->getInstance()->getInvites() + ); } function testGetOwner() { - $this->assertEquals('principals/owner', $this->getInstance()->getOwner()); + $this->assertEquals('principals/sharee', $this->getInstance()->getOwner()); } function testGetACL() { - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner', + $expected = [ + [ + 'privilege' => '{DAV:}write', + 'principal' => 'principals/sharee', 'protected' => true, - ), - - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-write', + ], + [ + 'privilege' => '{DAV:}write', + 'principal' => 'principals/sharee/calendar-proxy-write', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-read', + ], + [ + 'privilege' => '{DAV:}write-properties', + 'principal' => 'principals/sharee', 'protected' => true, - ), - array( - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', - 'principal' => '{DAV:}authenticated', + ], + [ + 'privilege' => '{DAV:}write-properties', + 'principal' => 'principals/sharee/calendar-proxy-write', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/owner', + ], + [ + 'privilege' => '{DAV:}read', + 'principal' => 'principals/sharee', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/owner/calendar-proxy-write', + ], + [ + 'privilege' => '{DAV:}read', + 'principal' => 'principals/sharee/calendar-proxy-read', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee', + 'principal' => 'principals/sharee/calendar-proxy-write', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee', + ], + [ + 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'principal' => '{DAV:}authenticated', 'protected' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $this->getInstance()->getACL()); @@ -108,96 +108,69 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { function testGetChildACL() { - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-write', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-read', - 'protected' => true, - ), - array( + $expected = [ + [ 'privilege' => '{DAV:}write', - 'principal' => 'principals/owner', + 'principal' => 'principals/sharee', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}write', - 'principal' => 'principals/owner/calendar-proxy-write', + 'principal' => 'principals/sharee/calendar-proxy-write', 'protected' => true, - ), - array( + ], + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/sharee', 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee', + ], + [ + 'privilege' => '{DAV:}read', + 'principal' => 'principals/sharee/calendar-proxy-write', 'protected' => true, - ), - ); + ], + [ + 'privilege' => '{DAV:}read', + 'principal' => 'principals/sharee/calendar-proxy-read', + 'protected' => true, + ], + + ]; $this->assertEquals($expected, $this->getInstance()->getChildACL()); } - function testGetChildACLReadOnly() { + function testUpdateInvites() { - $expected = array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-write', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/owner/calendar-proxy-read', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee', - 'protected' => true, - ), - ); + $instance = $this->getInstance(); + $newSharees = [ + new Sharee(), + new Sharee() + ]; + $newSharees[0]->href = 'mailto:test@example.org'; + $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar'; + $newSharees[0]->comment = 'Booh'; + $newSharees[0]->access = Sharing\Plugin::ACCESS_READWRITE; - $props = array( - 'id' => 1, - '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original', - '{http://sabredav.org/ns}owner-principal' => 'principals/owner', - '{http://sabredav.org/ns}read-only' => true, - 'principaluri' => 'principals/sharee', - ); - $this->assertEquals($expected, $this->getInstance($props)->getChildACL()); + $newSharees[1]->href = 'mailto:removeme@example.org'; + $newSharees[1]->access = Sharing\Plugin::ACCESS_NOACCESS; + + $instance->updateInvites($newSharees); + + $expected = [ + clone $newSharees[0] + ]; + $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; + $this->assertEquals($expected, $instance->getInvites()); } - /** - * @expectedException InvalidArgumentException - */ - public function testCreateInstanceMissingArg() { + function testPublish() { - $this->getInstance(array( - 'id' => 1, - '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original', - '{http://sabredav.org/ns}read-only' => false, - 'principaluri' => 'principals/sharee', - )); + $instance = $this->getInstance(); + $this->assertNull($instance->setPublishStatus(true)); + $this->assertNull($instance->setPublishStatus(false)); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php index b4270da7d..6e9e88419 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php @@ -3,6 +3,7 @@ namespace Sabre\CalDAV; use Sabre\DAV; +use Sabre\DAV\Xml\Element\Sharee; use Sabre\HTTP; class SharingPluginTest extends \Sabre\DAVServerTest { @@ -14,31 +15,28 @@ class SharingPluginTest extends \Sabre\DAVServerTest { function setUp() { - $this->caldavCalendars = array( - array( + $this->caldavCalendars = [ + [ 'principaluri' => 'principals/user1', - 'id' => 1, - 'uri' => 'cal1', - ), - array( + 'id' => 1, + 'uri' => 'cal1', + ], + [ 'principaluri' => 'principals/user1', - 'id' => 2, - 'uri' => 'cal2', - '{' . Plugin::NS_CALENDARSERVER . '}shared-url' => 'calendars/user1/cal2', - '{http://sabredav.org/ns}owner-principal' => 'principals/user2', - '{http://sabredav.org/ns}read-only' => 'true', - ), - array( + 'id' => 2, + 'uri' => 'cal2', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + ], + [ 'principaluri' => 'principals/user1', - 'id' => 3, - 'uri' => 'cal3', - ), - ); + 'id' => 3, + 'uri' => 'cal3', + ], + ]; parent::setUp(); // Making the logged in user an admin, for full access: - $this->aclPlugin->adminPrincipals[] = 'principals/user1'; $this->aclPlugin->adminPrincipals[] = 'principals/user2'; } @@ -53,9 +51,21 @@ class SharingPluginTest extends \Sabre\DAVServerTest { } + /** + * @expectedException \LogicException + */ + function testSetupWithoutCoreSharingPlugin() { + + $server = new DAV\Server(); + $server->addPlugin( + new SharingPlugin() + ); + + } + function testGetFeatures() { - $this->assertEquals(array('calendarserver-sharing'), $this->caldavSharingPlugin->getFeatures()); + $this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures()); } @@ -63,10 +73,10 @@ class SharingPluginTest extends \Sabre\DAVServerTest { // Forcing the server to authenticate: $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $props = $this->server->getProperties('calendars/user1/cal1', array( + $props = $this->server->getProperties('calendars/user1/cal1', [ '{' . Plugin::NS_CALENDARSERVER . '}invite', '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', - )); + ]); $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']); @@ -75,56 +85,55 @@ class SharingPluginTest extends \Sabre\DAVServerTest { function testBeforeGetSharedCalendar() { - $props = $this->server->getProperties('calendars/user1/cal2', array( + $props = $this->server->getProperties('calendars/user1/cal2', [ '{' . Plugin::NS_CALENDARSERVER . '}shared-url', '{' . Plugin::NS_CALENDARSERVER . '}invite', - )); + ]); $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); - $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']); + //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']); } - function testUpdateProperties() { + function testUpdateResourceType() { - $this->caldavBackend->updateShares(1, - array( - array( + $this->caldavBackend->updateInvites(1, + [ + new Sharee([ 'href' => 'mailto:joe@example.org', - ), - ), - array() + ]) + ] ); - $result = $this->server->updateProperties('calendars/user1/cal1', array( + $result = $this->server->updateProperties('calendars/user1/cal1', [ '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']) - )); + ]); $this->assertEquals([ '{DAV:}resourcetype' => 200 ], $result); - $this->assertEquals(0, count($this->caldavBackend->getShares(1))); + $this->assertEquals(0, count($this->caldavBackend->getInvites(1))); } function testUpdatePropertiesPassThru() { - $result = $this->server->updateProperties('calendars/user1/cal3', array( + $result = $this->server->updateProperties('calendars/user1/cal3', [ '{DAV:}foo' => 'bar', - )); + ]); - $this->assertEquals(array( - '{DAV:}foo' => 403, - ), $result); + $this->assertEquals([ + '{DAV:}foo' => 200, + ], $result); } function testUnknownMethodNoPOST() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/', - )); + ]); $response = $this->request($request); @@ -134,11 +143,11 @@ class SharingPluginTest extends \Sabre\DAVServerTest { function testUnknownMethodNoXML() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/', 'CONTENT_TYPE' => 'text/plain', - )); + ]); $response = $this->request($request); @@ -148,11 +157,11 @@ class SharingPluginTest extends \Sabre\DAVServerTest { function testUnknownMethodNoNode() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/foo', 'CONTENT_TYPE' => 'text/xml', - )); + ]); $response = $this->request($request); @@ -162,11 +171,7 @@ class SharingPluginTest extends \Sabre\DAVServerTest { function testShareRequest() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', - )); + $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = <<<RRR <?xml version="1.0"?> @@ -184,19 +189,28 @@ RRR; $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(200, $response->status, $response->body); + $response = $this->request($request, 200); + + $this->assertEquals( + [ + new Sharee([ + 'href' => 'mailto:joe@example.org', + 'properties' => [ + '{DAV:}displayname' => 'Joe Shmoe', + ], + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, + 'comment' => '', + ]), + ], + $this->caldavBackend->getInvites(1) + ); - $this->assertEquals(array(array( - 'href' => 'mailto:joe@example.org', - 'commonName' => 'Joe Shmoe', - 'readOnly' => false, - 'status' => SharingPlugin::STATUS_NORESPONSE, - 'summary' => '', - )), $this->caldavBackend->getShares(1)); + // Wiping out tree cache + $this->server->tree->markDirty(''); // Verifying that the calendar is now marked shared. - $props = $this->server->getProperties('calendars/user1/cal1', array('{DAV:}resourcetype')); + $props = $this->server->getProperties('calendars/user1/cal1', ['{DAV:}resourcetype']); $this->assertTrue( $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner') ); @@ -205,11 +219,11 @@ RRR; function testShareRequestNoShareableCalendar() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal2', - 'CONTENT_TYPE' => 'text/xml', - )); + $request = new HTTP\Request( + 'POST', + '/calendars/user1/cal2', + ['Content-Type' => 'text/xml'] + ); $xml = '<?xml version="1.0"?> <cs:share xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> @@ -226,18 +240,17 @@ RRR; $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(501, $response->status, $response->body); + $response = $this->request($request, 403); } function testInviteReply() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/calendars/user1', 'CONTENT_TYPE' => 'text/xml', - )); + ]); $xml = '<?xml version="1.0"?> <cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> @@ -254,11 +267,11 @@ RRR; function testInviteBadXML() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/calendars/user1', 'CONTENT_TYPE' => 'text/xml', - )); + ]); $xml = '<?xml version="1.0"?> <cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> @@ -272,11 +285,11 @@ RRR; function testInviteWrongUrl() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/calendars/user1/cal1', 'CONTENT_TYPE' => 'text/xml', - )); + ]); $xml = '<?xml version="1.0"?> <cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:"> @@ -295,11 +308,7 @@ RRR; function testPublish() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', - )); + $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = '<?xml version="1.0"?> <cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> @@ -312,13 +321,14 @@ RRR; } + function testUnpublish() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', - )); + $request = new HTTP\Request( + 'POST', + '/calendars/user1/cal1', + ['Content-Type' => 'text/xml'] + ); $xml = '<?xml version="1.0"?> <cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> @@ -333,49 +343,46 @@ RRR; function testPublishWrongUrl() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal2', - 'CONTENT_TYPE' => 'text/xml', - )); + $request = new HTTP\Request( + 'POST', + '/calendars/user1', + ['Content-Type' => 'text/xml'] + ); $xml = '<?xml version="1.0"?> <cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> '; $request->setBody($xml); - - $response = $this->request($request); - $this->assertEquals(501, $response->status, $response->body); + $this->request($request, 501); } function testUnpublishWrongUrl() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal2', - 'CONTENT_TYPE' => 'text/xml', - )); - + $request = new HTTP\Request( + 'POST', + '/calendars/user1', + ['Content-Type' => 'text/xml'] + ); $xml = '<?xml version="1.0"?> <cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" /> '; $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(501, $response->status, $response->body); + $this->request($request, 501); } function testUnknownXmlDoc() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal2', - 'CONTENT_TYPE' => 'text/xml', - )); + + $request = new HTTP\Request( + 'POST', + '/calendars/user1/cal2', + ['Content-Type' => 'text/xml'] + ); $xml = '<?xml version="1.0"?> <cs:foo-bar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />'; diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php index 19acea200..673d39c0a 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php @@ -6,48 +6,29 @@ class TestUtil { static function getBackend() { - $backend = new Backend\PDO(self::getSQLiteDB()); - return $backend; - - } - - static function getSQLiteDB() { - - if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite')) - unlink(SABRE_TEMPDIR . '/testdb.sqlite'); - - $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - - // Yup this is definitely not 'fool proof', but good enough for now. - $queries = explode(';', file_get_contents(__DIR__ . '/../../../examples/sql/sqlite.calendars.sql')); - foreach($queries as $query) { - $pdo->exec($query); - } - // Inserting events through a backend class. - $backend = new Backend\PDO($pdo); + $backend = new Backend\Mock(); $calendarId = $backend->createCalendar( 'principals/user1', 'UUID-123467', - array( - '{DAV:}displayname' => 'user1 calendar', + [ + '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - ) + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + ] ); $backend->createCalendar( 'principals/user1', 'UUID-123468', - array( - '{DAV:}displayname' => 'user1 calendar2', + [ + '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - ) + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + ] ); $backend->createCalendarObject($calendarId, 'UUID-2345', self::getTestCalendarData()); - return $pdo; + return $backend; } @@ -80,37 +61,37 @@ TRANSP:TRANSPARENT SUMMARY:Something here DTSTAMP:20100228T130202Z'; - switch($type) { + switch ($type) { case 1 : - $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; + $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; break; case 2 : - $calendarData.="\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; + $calendarData .= "\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; break; case 3 : - $calendarData.="\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; + $calendarData .= "\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; break; case 4 : - $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; + $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; break; case 5 : - $calendarData.="\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; + $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; break; case 6 : - $calendarData.="\nDTSTART;VALUE=DATE:20100223\n"; + $calendarData .= "\nDTSTART;VALUE=DATE:20100223\n"; break; case 7 : - $calendarData.="\nDTSTART;VALUE=DATETIME:20100223T060000\n"; + $calendarData .= "\nDTSTART;VALUE=DATETIME:20100223T060000\n"; break; // No DTSTART, so intentionally broken case 'X' : - $calendarData.="\n"; + $calendarData .= "\n"; break; } - $calendarData.='ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com + $calendarData .= 'ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com SEQUENCE:2 END:VEVENT END:VCALENDAR'; @@ -121,7 +102,7 @@ END:VCALENDAR'; static function getTestTODO($type = 'due') { - switch($type) { + switch ($type) { case 'due' : $extra = "DUE:20100104T000000Z"; diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php index be166d9e6..629df90c1 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php @@ -21,20 +21,20 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function setUp() { - $calendars = array( - array( - 'id' => 'calendar1', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar1', - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VEVENT','VTODO','VJOURNAL'] ), - ), - array( - 'id' => 'calendar2', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar2', - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VTODO','VJOURNAL'] ), - ) - ); + $calendars = [ + [ + 'id' => 'calendar1', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar1', + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO', 'VJOURNAL']), + ], + [ + 'id' => 'calendar2', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar2', + '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VJOURNAL']), + ] + ]; $this->calBackend = new Backend\Mock($calendars, []); $principalBackend = new DAVACL\PrincipalBackend\Mock(); @@ -66,10 +66,10 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function testCreateFile() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $response = $this->request($request); @@ -79,66 +79,168 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function testCreateFileValid() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics', + ['Prefer' => 'handling=strict'] + ); + + $ics = <<<ICS +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:foo +BEGIN:VEVENT +UID:foo +DTSTAMP:20160406T052348Z +DTSTART:20160706T140000Z +END:VEVENT +END:VCALENDAR +ICS; + + $request->setBody($ics); $response = $this->request($request); $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n") . '"'], - ), $response->getHeaders()); + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5($ics) . '"'], + ], $response->getHeaders()); - $expected = array( + $expected = [ 'uri' => 'blabla.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", + 'calendardata' => $ics, 'calendarid' => 'calendar1', 'lastmodified' => null, + ]; + + $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); + + } + + function testCreateFileNoVersion() { + + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics', + ['Prefer' => 'handling=strict'] ); - $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics')); + $ics = <<<ICS +BEGIN:VCALENDAR +PRODID:foo +BEGIN:VEVENT +UID:foo +DTSTAMP:20160406T052348Z +DTSTART:20160706T140000Z +END:VEVENT +END:VCALENDAR +ICS; + + $request->setBody($ics); + + $response = $this->request($request); + + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } - function testCreateFileNoComponents() { + function testCreateFileNoVersionFixed() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); - $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"); + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics', + ['Prefer' => 'handling=lenient'] + ); + + $ics = <<<ICS +BEGIN:VCALENDAR +PRODID:foo +BEGIN:VEVENT +UID:foo +DTSTAMP:20160406T052348Z +DTSTART:20160706T140000Z +END:VEVENT +END:VCALENDAR +ICS; + + $request->setBody($ics); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals([ + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Length' => ['0'], + 'X-Sabre-Ew-Gross' => ['iCalendar validation warning: VERSION MUST appear exactly once in a VCALENDAR component'], + ], $response->getHeaders()); + + $ics = <<<ICS +BEGIN:VCALENDAR\r +VERSION:2.0\r +PRODID:foo\r +BEGIN:VEVENT\r +UID:foo\r +DTSTAMP:20160406T052348Z\r +DTSTART:20160706T140000Z\r +END:VEVENT\r +END:VCALENDAR\r + +ICS; + + $expected = [ + 'uri' => 'blabla.ics', + 'calendardata' => $ics, + 'calendarid' => 'calendar1', + 'lastmodified' => null, + ]; + + $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); + + } + + function testCreateFileNoComponents() { + + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics', + ['Prefer' => 'handling=strict'] + ); + $ics = <<<ICS +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:foo +END:VCALENDAR +ICS; + + $request->setBody($ics); + + $response = $this->request($request); + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testCreateFileNoUID() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testCreateFileVCard() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); $response = $this->request($request); @@ -149,53 +251,53 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function testCreateFile2Components() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VJOURNAL\r\nUID:foo\r\nEND:VJOURNAL\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testCreateFile2UIDS() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VEVENT\r\nUID:bar\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testCreateFileWrongComponent() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VFREEBUSY\r\nUID:foo\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); } function testUpdateFile() { - $this->calBackend->createCalendarObject('calendar1','blabla.ics','foo'); - $request = HTTP\Sapi::createFromServerArray(array( + $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + ]); $response = $this->request($request); @@ -205,35 +307,45 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function testUpdateFileParsableBody() { - $this->calBackend->createCalendarObject('calendar1','blabla.ics','foo'); - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); - $body = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $request->setBody($body); - + $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics' + ); + $ics = <<<ICS +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:foo +BEGIN:VEVENT +UID:foo +DTSTAMP:20160406T052348Z +DTSTART:20160706T140000Z +END:VEVENT +END:VCALENDAR +ICS; + + $request->setBody($ics); $response = $this->request($request); $this->assertEquals(204, $response->status); - $expected = array( + $expected = [ 'uri' => 'blabla.ics', - 'calendardata' => $body, + 'calendardata' => $ics, 'calendarid' => 'calendar1', 'lastmodified' => null, - ); + ]; - $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics')); + $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); } function testCreateFileInvalidComponent() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); @@ -244,11 +356,11 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { function testUpdateFileInvalidComponent() { - $this->calBackend->createCalendarObject('calendar2','blabla.ics','foo'); - $request = HTTP\Sapi::createFromServerArray(array( + $this->calBackend->createCalendarObject('calendar2', 'blabla.ics', 'foo'); + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', - )); + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); @@ -266,11 +378,24 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { */ function testCreateFileModified() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - )); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nSUMMARY:Meeting in M\xfcnster\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $request = new HTTP\Request( + 'PUT', + '/calendars/admin/calendar1/blabla.ics' + ); + $ics = <<<ICS +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:foo +BEGIN:VEVENT +UID:foo +SUMMARY:Meeting in M\xfcnster +DTSTAMP:20160406T052348Z +DTSTART:20160706T140000Z +END:VEVENT +END:VCALENDAR +ICS; + + $request->setBody($ics); $response = $this->request($request); diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php index a123099a0..552e2ba77 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php @@ -26,13 +26,13 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase { $this->backend = new Backend\Mock(); $principalBackend = new DAVACL\PrincipalBackend\Mock(); - $tree = array( + $tree = [ new AddressBookRoot($principalBackend, $this->backend), new DAVACL\PrincipalCollection($principalBackend) - ); + ]; $this->plugin = new Plugin(); - $this->plugin->directories = array('directory'); + $this->plugin->directories = ['directory']; $this->server = new DAV\Server($tree); $this->server->sapi = new HTTP\SapiMock(); $this->server->addPlugin($this->plugin); diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php index 478f6beb5..2c3171bf3 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php @@ -12,11 +12,11 @@ class AddressBookQueryTest extends AbstractPluginTest { function testQuery() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', - )); + $request = new HTTP\Request( + 'REPORT', + '/addressbooks/user1/book1', + ['Depth' => '1'] + ); $request->setBody( '<?xml version="1.0"?> @@ -40,33 +40,33 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); - $this->assertEquals(array( - '/addressbooks/user1/book1/card1' => array( - 200 => array( + $this->assertEquals([ + '/addressbooks/user1/book1/card1' => [ + 200 => [ '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', - ), - ), - '/addressbooks/user1/book1/card2' => array( - 404 => array( + ], + ], + '/addressbooks/user1/book1/card2' => [ + 404 => [ '{DAV:}getetag' => null, - ), - ) - ), $result); + ], + ] + ], $result); } function testQueryDepth0() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1/card1', - 'HTTP_DEPTH' => '0', - )); + $request = new HTTP\Request( + 'REPORT', + '/addressbooks/user1/book1/card1', + ['Depth' => '0'] + ); $request->setBody( '<?xml version="1.0"?> @@ -90,28 +90,28 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); - $this->assertEquals(array( - '/addressbooks/user1/book1/card1' => array( - 200 => array( + $this->assertEquals([ + '/addressbooks/user1/book1/card1' => [ + 200 => [ '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', - ), - ), - ), $result); + ], + ], + ], $result); } function testQueryNoMatch() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', - )); + $request = new HTTP\Request( + 'REPORT', + '/addressbooks/user1/book1', + ['Depth' => '1'] + ); $request->setBody( '<?xml version="1.0"?> @@ -135,21 +135,21 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); } function testQueryLimit() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', - )); + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', + ]); $request->setBody( '<?xml version="1.0"?> @@ -174,17 +174,17 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['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"). '"', - ), - ), - ), $result); + $this->assertEquals([ + '/addressbooks/user1/book1/card1' => [ + 200 => [ + '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + ], + ], + ], $result); } @@ -217,20 +217,20 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); $vobjVersion = \Sabre\VObject\Version::VERSION; - $this->assertEquals(array( - '/addressbooks/user1/book1/card1' => array( - 200 => array( - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"', + $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); + ], + ], + ], $result); } @@ -262,20 +262,20 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); $vobjVersion = \Sabre\VObject\Version::VERSION; - $this->assertEquals(array( - '/addressbooks/user1/book1/card1' => array( - 200 => array( - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"', + $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); + ], + ], + ], $result); } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php index fe8ba9025..1a36fd10c 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php @@ -4,10 +4,10 @@ namespace Sabre\CardDAV; use Sabre\DAV\PropPatch; -require_once 'Sabre/CardDAV/Backend/Mock.php'; - class AddressBookTest extends \PHPUnit_Framework_TestCase { + use \Sabre\DAV\DbTestHelperTrait; + /** * @var Sabre\CardDAV\AddressBook */ @@ -19,12 +19,12 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->backend = new Backend\Mock(); $this->ab = new AddressBook( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', '{DAV:}displayname' => 'd-name', - 'principaluri' => 'principals/user1', - ) + 'principaluri' => 'principals/user1', + ] ); } @@ -73,10 +73,10 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { function testCreateFile() { - $file = fopen('php://memory','r+'); - fwrite($file,'foo'); + $file = fopen('php://memory', 'r+'); + fwrite($file, 'foo'); rewind($file); - $this->ab->createFile('card2',$file); + $this->ab->createFile('card2', $file); $this->assertEquals('foo', $this->backend->cards['foo']['card2']); @@ -85,7 +85,7 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { function testDelete() { $this->ab->delete(); - $this->assertEquals(array(), $this->backend->addressBooks); + $this->assertEquals([], $this->backend->addressBooks); } @@ -118,10 +118,10 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { function testGetProperties() { - $props = $this->ab->getProperties(array('{DAV:}displayname')); - $this->assertEquals(array( + $props = $this->ab->getProperties(['{DAV:}displayname']); + $this->assertEquals([ '{DAV:}displayname' => 'd-name', - ), $props); + ], $props); } @@ -129,27 +129,22 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('principals/user1', $this->ab->getOwner()); $this->assertNull($this->ab->getGroup()); - $this->assertEquals(array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1', + $this->assertEquals([ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ), - ), $this->ab->getACL()); + ], + ], $this->ab->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException Sabre\DAV\Exception\Forbidden */ function testSetACL() { - $this->ab->setACL(array()); + $this->ab->setACL([]); } @@ -168,45 +163,32 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { } function testGetChangesNoSyncSupport() { - $this->assertNull($this->ab->getChanges(1,null)); + $this->assertNull($this->ab->getChanges(1, null)); } function testGetSyncToken() { - if (!SABRE_HASSQLITE) { - $this->markTestSkipped('Sqlite is required for this test to run'); - } - $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{DAV:}sync-token' => 2]); + $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()); - TestUtil::deleteSQLiteDB(); } function testGetSyncToken2() { - if (!SABRE_HASSQLITE) { - $this->markTestSkipped('Sqlite is required for this test to run'); - } - $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{http://sabredav.org/ns}sync-token' => 2]); + $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()); - TestUtil::deleteSQLiteDB(); } - function testGetChanges() { - - if (!SABRE_HASSQLITE) { - $this->markTestSkipped('Sqlite is required for this test to run'); - } - $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{DAV:}sync-token' => 2]); - $this->assertEquals([ - 'syncToken' => 2, - 'modified' => [], - 'deleted' => [], - 'added' => ['UUID-2345'], - ], $ab->getChanges(1, 1)); - TestUtil::deleteSQLiteDB(); - - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php index d2ec278be..f62bfb1ae 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php @@ -7,52 +7,55 @@ use Sabre\DAV\PropPatch; abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { + use \Sabre\DAV\DbTestHelperTrait; + /** * @var CardDAV\Backend\PDO */ protected $backend; - /** - * @abstract - * @return PDO - */ - abstract function getPDO(); - - public function setUp() { + function setUp() { + $this->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)'); + $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() { + function testGetAddressBooksForUser() { $result = $this->backend->getAddressBooksForUser('principals/user1'); - $expected = array( - array( - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', + $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 - ) - ); + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1 + ] + ]; $this->assertEquals($expected, $result); } - public function testUpdateAddressBookInvalidProp() { + function testUpdateAddressBookInvalidProp() { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', + '{DAV:}displayname' => 'updated', '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', - '{DAV:}foo' => 'bar', + '{DAV:}foo' => 'bar', ]); $this->backend->updateAddressBook(1, $propPatch); @@ -62,23 +65,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $this->backend->getAddressBooksForUser('principals/user1'); - $expected = array( - array( - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', + $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 - ) - ); + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1 + ] + ]; $this->assertEquals($expected, $result); } - public function testUpdateAddressBookNoProps() { + function testUpdateAddressBookNoProps() { $propPatch = new PropPatch([ ]); @@ -89,27 +92,27 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $this->backend->getAddressBooksForUser('principals/user1'); - $expected = array( - array( - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', + $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 - ) - ); + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1 + ] + ]; $this->assertEquals($expected, $result); } - public function testUpdateAddressBookSuccess() { + function testUpdateAddressBookSuccess() { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', + '{DAV:}displayname' => 'updated', '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', ]); @@ -120,104 +123,108 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $this->backend->getAddressBooksForUser('principals/user1'); - $expected = array( - array( - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'updated', + $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 - ) - ); + '{http://calendarserver.org/ns/}getctag' => 2, + '{http://sabredav.org/ns}sync-token' => 2 + ] + ]; $this->assertEquals($expected, $result); } - public function testDeleteAddressBook() { + function testDeleteAddressBook() { $this->backend->deleteAddressBook(1); - $this->assertEquals(array(), $this->backend->getAddressBooksForUser('principals/user1')); + $this->assertEquals([], $this->backend->getAddressBooksForUser('principals/user1')); } /** * @expectedException Sabre\DAV\Exception\BadRequest */ - public function testCreateAddressBookUnsupportedProp() { + function testCreateAddressBookUnsupportedProp() { - $this->backend->createAddressBook('principals/user1','book2', array( + $this->backend->createAddressBook('principals/user1', 'book2', [ '{DAV:}foo' => 'bar', - )); + ]); } - public function testCreateAddressBookSuccess() { + function testCreateAddressBookSuccess() { - $this->backend->createAddressBook('principals/user1','book2', array( - '{DAV:}displayname' => 'book2', + $this->backend->createAddressBook('principals/user1', 'book2', [ + '{DAV:}displayname' => 'book2', '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', - )); - - $expected = array( - array( - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', + ]); + + $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, - ), - array( - 'id' => 2, - 'uri' => 'book2', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book2', + '{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, - ) - ); + '{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() { + function testGetCards() { $result = $this->backend->getCards(1); - $expected = array( - array( - 'id' => 1, - 'uri' => 'card1', + $expected = [ + [ + 'id' => 1, + 'uri' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 - ) - ); + 'etag' => '"' . md5('card1') . '"', + 'size' => 5 + ] + ]; $this->assertEquals($expected, $result); } - public function testGetCard() { + function testGetCard() { - $result = $this->backend->getCard(1,'card1'); + $result = $this->backend->getCard(1, 'card1'); - $expected = array( - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + $expected = [ + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 - ); + 'etag' => '"' . md5('card1') . '"', + 'size' => 5 + ]; + + if (is_resource($result['carddata'])) { + $result['carddata'] = stream_get_contents($result['carddata']); + } $this->assertEquals($expected, $result); @@ -226,13 +233,16 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { /** * @depends testGetCard */ - public function testCreateCard() { + function testCreateCard() { $result = $this->backend->createCard(1, 'card2', 'data2'); $this->assertEquals('"' . md5('data2') . '"', $result); - $result = $this->backend->getCard(1,'card2'); + $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']); } @@ -240,41 +250,52 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { /** * @depends testCreateCard */ - public function testGetMultiple() { + function testGetMultiple() { $result = $this->backend->createCard(1, 'card2', 'data2'); $result = $this->backend->createCard(1, 'card3', 'data3'); $check = [ [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, ], [ - 'id' => 2, - 'uri' => 'card2', - 'carddata' => 'data2', + 'id' => 2, + 'uri' => 'card2', + 'carddata' => 'data2', 'lastmodified' => time(), ], [ - 'id' => 3, - 'uri' => 'card3', - 'carddata' => 'data3', + 'id' => 3, + 'uri' => 'card3', + 'carddata' => 'data3', 'lastmodified' => time(), ], ]; - $result = $this->backend->getMultipleCards(1, ['card1','card2','card3']); + $result = $this->backend->getMultipleCards(1, ['card1', 'card2', 'card3']); + + foreach ($check as $index => $node) { - foreach($check as $index=>$node) { + foreach ($node as $k => $v) { - foreach($node as $k=>$v) { + $expected = $v; + $actual = $result[$index][$k]; - if ($k!=='lastmodified') { - $this->assertEquals($v, $result[$index][$k]); - } else { - $this->assertTrue(isset($result[$index][$k])); + switch ($k) { + case 'lastmodified' : + $this->assertInternalType('int', $actual); + break; + case 'carddata' : + if (is_resource($actual)) { + $actual = stream_get_contents($actual); + } + // No break intended. + default : + $this->assertEquals($expected, $actual); + break; } } @@ -287,13 +308,16 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { /** * @depends testGetCard */ - public function testUpdateCard() { + function testUpdateCard() { $result = $this->backend->updateCard(1, 'card1', 'newdata'); $this->assertEquals('"' . md5('newdata') . '"', $result); - $result = $this->backend->getCard(1,'card1'); + $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']); } @@ -301,10 +325,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { /** * @depends testGetCard */ - public function testDeleteCard() { + function testDeleteCard() { $this->backend->deleteCard(1, 'card1'); - $result = $this->backend->getCard(1,'card1'); + $result = $this->backend->getCard(1, 'card1'); $this->assertFalse($result); } @@ -347,4 +371,3 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } } - diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php index 3f96d3c5d..840b898e8 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php @@ -13,24 +13,24 @@ class Mock extends AbstractBackend { $this->cards = $cards; if (is_null($this->addressBooks)) { - $this->addressBooks = array( - array( - 'id' => 'foo', - 'uri' => 'book1', - 'principaluri' => 'principals/user1', + $this->addressBooks = [ + [ + 'id' => 'foo', + 'uri' => 'book1', + 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'd-name', - ), - ); + ], + ]; - $card2 = fopen('php://memory','r+'); - fwrite($card2,"BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD"); + $card2 = fopen('php://memory', 'r+'); + fwrite($card2, "BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD"); rewind($card2); - $this->cards = array( - 'foo' => array( + $this->cards = [ + 'foo' => [ 'card1' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", 'card2' => $card2, - ), - ); + ], + ]; } } @@ -38,8 +38,8 @@ class Mock extends AbstractBackend { function getAddressBooksForUser($principalUri) { - $books = array(); - foreach($this->addressBooks as $book) { + $books = []; + foreach ($this->addressBooks as $book) { if ($book['principaluri'] === $principalUri) { $books[] = $book; } @@ -64,14 +64,14 @@ class Mock extends AbstractBackend { * @param \Sabre\DAV\PropPatch $propPatch * @return void */ - public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { + function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { - foreach($this->addressBooks as &$book) { + foreach ($this->addressBooks as &$book) { if ($book['id'] !== $addressBookId) continue; $propPatch->handleRemaining(function($mutations) use (&$book) { - foreach($mutations as $key=>$value) { + foreach ($mutations as $key => $value) { $book[$key] = $value; } return true; @@ -83,17 +83,17 @@ class Mock extends AbstractBackend { function createAddressBook($principalUri, $url, array $properties) { - $this->addressBooks[] = array_merge($properties, array( - 'id' => $url, - 'uri' => $url, + $this->addressBooks[] = array_merge($properties, [ + 'id' => $url, + 'uri' => $url, 'principaluri' => $principalUri, - )); + ]); } function deleteAddressBook($addressBookId) { - foreach($this->addressBooks as $key=>$value) { + foreach ($this->addressBooks as $key => $value) { if ($value['id'] === $addressBookId) unset($this->addressBooks[$key]); } @@ -101,41 +101,142 @@ class Mock extends AbstractBackend { } + /** + * 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 + */ function getCards($addressBookId) { - $cards = array(); - foreach($this->cards[$addressBookId] as $uri=>$data) { - $cards[] = array( - 'uri' => $uri, - 'carddata' => $data, - ); + $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 + */ function getCard($addressBookId, $cardUri) { if (!isset($this->cards[$addressBookId][$cardUri])) { return false; } - return array( - 'uri' => $cardUri, - 'carddata' => $this->cards[$addressBookId][$cardUri], - ); + $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 + */ 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 + */ function updateCard($addressBookId, $cardUri, $cardData) { + if (is_resource($cardData)) { + $cardData = stream_get_contents($cardData); + } $this->cards[$addressBookId][$cardUri] = $cardData; + return '"' . md5($cardData) . '"'; } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php index 38cb655d0..c1b0e274e 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php @@ -2,35 +2,8 @@ namespace Sabre\CardDAV\Backend; -require_once 'Sabre/TestUtil.php'; - class PDOMySQLTest extends AbstractPDOTest { - /** - * @return PDO - */ - public function getPDO() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - - $pdo->query("DROP TABLE IF EXISTS addressbooks, cards, addressbookchanges"); - - $queries = explode( - ';', - file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.addressbook.sql') - ); - - foreach($queries as $query) { - $query = trim($query," \r\n\t"); - if ($query) - $pdo->exec($query); - } - return $pdo; - - } + public $driver = 'mysql'; } - diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php index 5a4a7a327..b187c4d78 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php @@ -2,53 +2,8 @@ namespace Sabre\CardDAV\Backend; -require_once 'Sabre/TestUtil.php'; - class PDOSqliteTest extends AbstractPDOTest { - function tearDown() { - - if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend'); - if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2'); - - } - - /** - * @return PDO - */ - function getPDO() { - - return self::getSQLite(); - - } - - /** - * @return PDO - */ - static function getSQLite() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - - $pdo->query("DROP TABLE IF EXISTS addressbooks"); - $pdo->query("DROP TABLE IF EXISTS addressbookchanges"); - $pdo->query("DROP TABLE IF EXISTS cards"); - - $queries = explode( - ';', - file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.addressbooks.sql') - ); - - foreach($queries as $query) { - $query = trim($query," \r\n\t"); - if ($query) - $pdo->exec($query); - } - - return $pdo; - - } + public $driver = 'sqlite'; } - diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php index cf8dbab0c..cb7d152c3 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php @@ -18,16 +18,16 @@ class CardTest extends \PHPUnit_Framework_TestCase { $this->backend = new Backend\Mock(); $this->card = new Card( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', - ), - array( - 'uri' => 'card1', + ], + [ + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - ) + 'carddata' => 'card', + ] ); } @@ -42,15 +42,15 @@ class CardTest extends \PHPUnit_Framework_TestCase { $this->card = new Card( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', - ), - array( - 'uri' => 'card1', + ], + [ + 'uri' => 'card1', 'addressbookid' => 'foo', - ) + ] ); $result = $this->card->get(); $this->assertEquals("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", $result); @@ -63,7 +63,7 @@ class CardTest extends \PHPUnit_Framework_TestCase { */ function testPut() { - $file = fopen('php://memory','r+'); + $file = fopen('php://memory', 'r+'); fwrite($file, 'newdata'); rewind($file); $this->card->put($file); @@ -88,7 +88,7 @@ class CardTest extends \PHPUnit_Framework_TestCase { function testGetETag() { - $this->assertEquals('"' . md5('card') . '"' , $this->card->getETag()); + $this->assertEquals('"' . md5('card') . '"', $this->card->getETag()); } @@ -96,19 +96,19 @@ class CardTest extends \PHPUnit_Framework_TestCase { $card = new Card( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', - ), - array( - 'uri' => 'card1', + ], + [ + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'etag' => '"blabla"', - ) + 'carddata' => 'card', + 'etag' => '"blabla"', + ] ); - $this->assertEquals('"blabla"' , $card->getETag()); + $this->assertEquals('"blabla"', $card->getETag()); } @@ -129,17 +129,17 @@ class CardTest extends \PHPUnit_Framework_TestCase { $card = new Card( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', - ), - array( - 'uri' => 'card1', + ], + [ + 'uri' => 'card1', 'addressbookid' => 'foo', - 'etag' => '"blabla"', - 'size' => 4, - ) + 'etag' => '"blabla"', + 'size' => 4, + ] ); $this->assertEquals(4, $card->getSize()); @@ -149,58 +149,53 @@ class CardTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('principals/user1', $this->card->getOwner()); $this->assertNull($this->card->getGroup()); - $this->assertEquals(array( - array( - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ), - array( - 'privilege' => '{DAV:}write', + $this->assertEquals([ + [ + 'privilege' => '{DAV:}all', 'principal' => 'principals/user1', 'protected' => true, - ), - ), $this->card->getACL()); + ], + ], $this->card->getACL()); } function testOverrideACL() { $card = new Card( $this->backend, - array( - 'uri' => 'book1', - 'id' => 'foo', + [ + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', - ), - array( - 'uri' => 'card1', + ], + [ + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'acl' => array( - array( + 'carddata' => 'card', + 'acl' => [ + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', 'protected' => true, - ), - ), - ) + ], + ], + ] ); - $this->assertEquals(array( - array( + $this->assertEquals([ + [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', 'protected' => true, - ), - ), $card->getACL()); + ], + ], $card->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException Sabre\DAV\Exception\Forbidden */ function testSetACL() { - $this->card->setACL(array()); + $this->card->setACL([]); } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php index 431cd2524..4796a131f 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php @@ -8,15 +8,15 @@ class IDirectoryTest extends \PHPUnit_Framework_TestCase { function testResourceType() { - $tree = array( + $tree = [ new DirectoryMock('directory') - ); + ]; $server = new DAV\Server($tree); $plugin = new Plugin(); $server->addPlugin($plugin); - $props = $server->getProperties('directory', array('{DAV:}resourcetype')); + $props = $server->getProperties('directory', ['{DAV:}resourcetype']); $this->assertTrue($props['{DAV:}resourcetype']->is('{' . Plugin::NS_CARDDAV . '}directory')); } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php index b0ee45880..d79239d0f 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php @@ -11,10 +11,10 @@ class MultiGetTest extends AbstractPluginTest { function testMultiGet() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - )); + 'REQUEST_URI' => '/addressbooks/user1/book1', + ]); $request->setBody( '<?xml version="1.0"?> @@ -37,27 +37,27 @@ class MultiGetTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['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\r\nVERSION:3.0\r\nUID:12345\r\nEND:VCARD\r\n", - ) - ) - ), $result); + $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); } function testMultiGetVCard4() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - )); + 'REQUEST_URI' => '/addressbooks/user1/book1', + ]); $request->setBody( '<?xml version="1.0"?> @@ -80,20 +80,20 @@ class MultiGetTest extends AbstractPluginTest { $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing - $client = new DAV\Client(array('baseUri'=>'/')); + $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); $prodId = "PRODID:-//Sabre//Sabre VObject " . \Sabre\VObject\Version::VERSION . "//EN"; - $this->assertEquals(array( - '/addressbooks/user1/book1/card1' => array( - 200 => array( - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + $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); + ] + ] + ], $result); } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php index 9c916350e..6962e7830 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php @@ -3,7 +3,6 @@ namespace Sabre\CardDAV; use Sabre\DAV; -use Sabre\DAV\Xml\Property\Href; class PluginTest extends AbstractPluginTest { @@ -18,23 +17,23 @@ class PluginTest extends AbstractPluginTest { function testSupportedReportSet() { - $this->assertEquals(array( + $this->assertEquals([ '{' . Plugin::NS_CARDDAV . '}addressbook-multiget', '{' . Plugin::NS_CARDDAV . '}addressbook-query', - ), $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); + ], $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); } function testSupportedReportSetEmpty() { - $this->assertEquals(array( - ), $this->plugin->getSupportedReportSet('')); + $this->assertEquals([ + ], $this->plugin->getSupportedReportSet('')); } function testAddressBookHomeSet() { - $result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}addressbook-home-set')); + $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'])); @@ -44,11 +43,11 @@ class PluginTest extends AbstractPluginTest { function testDirectoryGateway() { - $result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}directory-gateway')); + $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(array('directory'), $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs()); + $this->assertEquals(['directory'], $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs()); } @@ -64,7 +63,7 @@ class PluginTest extends AbstractPluginTest { $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]); $this->assertFalse($r); - $this->assertTrue(!!strpos($output,'Display name')); + $this->assertTrue(!!strpos($output, 'Display name')); } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php index f828cc25b..0ba4fd669 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php @@ -5,44 +5,44 @@ namespace Sabre\CardDAV; use Sabre\HTTP; use Sabre\DAV\PropFind; -class SogoStripContentType extends \Sabre\DAVServerTest { +class SogoStripContentTypeTest extends \Sabre\DAVServerTest { protected $setupCardDAV = true; - protected $carddavAddressBooks = array( - array( - 'id' => 1, - 'uri' => 'book1', + protected $carddavAddressBooks = [ + [ + 'id' => 1, + 'uri' => 'book1', 'principaluri' => 'principals/user1', - ), - ); - protected $carddavCards = array( - 1 => array( + ], + ]; + protected $carddavCards = [ + 1 => [ 'card1.vcf' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", - ), - ); + ], + ]; function testDontStrip() { - $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf',array('{DAV:}getcontenttype')); - $this->assertEquals(array( + $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); + $this->assertEquals([ '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8' - ), $result); + ], $result); } function testStrip() { - $this->server->httpRequest = HTTP\Sapi::createFromServerArray(array( + $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_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',array('{DAV:}getcontenttype')); - $this->assertEquals(array( + ]); + $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); + $this->assertEquals([ '{DAV:}getcontenttype' => 'text/x-vcard' - ), $result); + ], $result); } function testDontTouchOtherMimeTypes() { - $this->server->httpRequest = new HTTP\Request('GET','/addressbooks/user1/book1/card1.vcf', [ + $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', ]); diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php index c9cc10d35..ec8a3501e 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php @@ -2,8 +2,6 @@ namespace Sabre\CardDAV; -use PDO; - class TestUtil { static function getBackend() { @@ -22,18 +20,18 @@ class TestUtil { $addressbookId = $backend->createAddressBook( 'principals/user1', 'UUID-123467', - array( - '{DAV:}displayname' => 'user1 addressbook', + [ + '{DAV:}displayname' => 'user1 addressbook', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', - ) + ] ); $backend->createAddressBook( 'principals/user1', 'UUID-123468', - array( - '{DAV:}displayname' => 'user1 addressbook2', + [ + '{DAV:}displayname' => 'user1 addressbook2', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', - ) + ] ); $backend->createCard($addressbookId, 'UUID-2345', self::getTestCardData()); return $pdo; diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php index 71fde719d..82d82fadd 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php @@ -10,21 +10,21 @@ class VCFExportTest extends \Sabre\DAVServerTest { protected $autoLogin = 'user1'; protected $setupACL = true; - protected $carddavAddressBooks = array( - array( - 'id' => 'book1', - 'uri' => 'book1', + protected $carddavAddressBooks = [ + [ + 'id' => 'book1', + 'uri' => 'book1', 'principaluri' => 'principals/user1', - ) - ); - protected $carddavCards = array( - 'book1' => array( + ] + ]; + 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", - ) - ); + ] + ]; function setUp() { @@ -50,11 +50,11 @@ class VCFExportTest extends \Sabre\DAVServerTest { function testExport() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_URI' => '/addressbooks/user1/book1?export', - 'QUERY_STRING' => 'export', + $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->body); @@ -73,7 +73,7 @@ FN:Person4 END:VCARD "; // We actually expected windows line endings - $expected = str_replace("\n","\r\n", $expected); + $expected = str_replace("\n", "\r\n", $expected); $this->assertEquals($expected, $response->body); @@ -89,4 +89,47 @@ END:VCARD } + 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') + ); + + } + + 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 index c87716c10..57ac21b4a 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php @@ -48,35 +48,35 @@ HELLO; // Check if TITLE is defined $filter1 = - array('name' => 'title', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array()); + ['name' => 'title', 'is-not-defined' => false, 'param-filters' => [], 'text-matches' => []]; // Check if FOO is defined $filter2 = - array('name' => 'foo', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array()); + ['name' => 'foo', 'is-not-defined' => false, 'param-filters' => [], 'text-matches' => []]; // Check if TITLE is not defined $filter3 = - array('name' => 'title', 'is-not-defined' => true, 'param-filters' => array(), 'text-matches' => array()); + ['name' => 'title', 'is-not-defined' => true, 'param-filters' => [], 'text-matches' => []]; // Check if FOO is not defined $filter4 = - array('name' => 'foo', 'is-not-defined' => true, 'param-filters' => array(), 'text-matches' => array()); + ['name' => 'foo', 'is-not-defined' => true, 'param-filters' => [], 'text-matches' => []]; // Check if TEL[TYPE] is defined $filter5 = - array( - 'name' => 'tel', + [ + 'name' => 'tel', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => array( - array( - 'name' => 'type', + 'test' => 'anyof', + 'param-filters' => [ + [ + 'name' => 'type', 'is-not-defined' => false, - 'text-match' => null - ), - ), - 'text-matches' => array(), - ); + 'text-match' => null + ], + ], + 'text-matches' => [], + ]; // Check if TEL[FOO] is defined $filter6 = $filter5; @@ -101,20 +101,20 @@ HELLO; // Check if URL contains 'google' $filter11 = - array( - 'name' => 'url', + [ + 'name' => 'url', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => array(), - 'text-matches' => array( - array( - 'match-type' => 'contains', - 'value' => 'google', + 'test' => 'anyof', + 'param-filters' => [], + 'text-matches' => [ + [ + 'match-type' => 'contains', + 'value' => 'google', 'negate-condition' => false, - 'collation' => 'i;octet', - ), - ), - ); + 'collation' => 'i;octet', + ], + ], + ]; // Check if URL contains 'bing' $filter12 = $filter11; @@ -131,12 +131,12 @@ HELLO; // Param filter with text $filter15 = $filter5; - $filter15['param-filters'][0]['text-match'] = array( - 'match-type' => 'contains', - 'value' => 'WORK', - 'collation' => 'i;octet', + $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; @@ -144,60 +144,60 @@ HELLO; // Param filter + text filter $filter17 = $filter5; $filter17['test'] = 'anyof'; - $filter17['text-matches'][] = array( - 'match-type' => 'contains', - 'value' => '444', - 'collation' => 'i;octet', + $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 array( + return [ // Basic filters - array($body1, array($filter1), 'anyof',true), - array($body1, array($filter2), 'anyof',false), - array($body1, array($filter3), 'anyof',false), - array($body1, array($filter4), 'anyof',true), + [$body1, [$filter1], 'anyof',true], + [$body1, [$filter2], 'anyof',false], + [$body1, [$filter3], 'anyof',false], + [$body1, [$filter4], 'anyof',true], // Combinations - array($body1, array($filter1, $filter2), 'anyof',true), - array($body1, array($filter1, $filter2), 'allof',false), - array($body1, array($filter1, $filter4), 'anyof',true), - array($body1, array($filter1, $filter4), 'allof',true), - array($body1, array($filter2, $filter3), 'anyof',false), - array($body1, array($filter2, $filter3), 'allof',false), + [$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 - array($body1, array($filter5), 'anyof', true, 'TEL;TYPE is defined, so this should return true'), - array($body1, array($filter6), 'anyof', false, 'TEL;FOO is not defined, so this should return false'), + [$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'], - array($body1, array($filter7), 'anyof', false, 'TEL;TYPE is defined, so this should return false'), - array($body1, array($filter8), 'anyof', true, 'TEL;TYPE is not defined, so this should return true'), + [$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 - array($body1, array($filter9), 'anyof', true), - array($body1, array($filter10), 'anyof', false), + [$body1, [$filter9], 'anyof', true], + [$body1, [$filter10], 'anyof', false], // Text-filters - array($body1, array($filter11), 'anyof', true), - array($body1, array($filter12), 'anyof', false), - array($body1, array($filter13), 'anyof', false), - array($body1, array($filter14), 'anyof', true), + [$body1, [$filter11], 'anyof', true], + [$body1, [$filter12], 'anyof', false], + [$body1, [$filter13], 'anyof', false], + [$body1, [$filter14], 'anyof', true], // Param filter with text-match - array($body1, array($filter15), 'anyof', true), - array($body1, array($filter16), 'anyof', false), + [$body1, [$filter15], 'anyof', true], + [$body1, [$filter16], 'anyof', false], // Param filter + text filter - array($body1, array($filter17), 'anyof', true), - array($body1, array($filter18), 'anyof', false), - array($body1, array($filter18), 'anyof', false), - ); + [$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 index ad8495c13..dda8a0c37 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php @@ -15,20 +15,20 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { function setUp() { - $addressbooks = array( - array( - 'id' => 'addressbook1', + $addressbooks = [ + [ + 'id' => 'addressbook1', 'principaluri' => 'principals/admin', - 'uri' => 'addressbook1', - ) - ); + 'uri' => 'addressbook1', + ] + ]; - $this->cardBackend = new Backend\Mock($addressbooks,array()); + $this->cardBackend = new Backend\Mock($addressbooks, []); $principalBackend = new DAVACL\PrincipalBackend\Mock(); - $tree = array( + $tree = [ new AddressBookRoot($principalBackend, $this->cardBackend), - ); + ]; $this->server = new DAV\Server($tree); $this->server->sapi = new HTTP\SapiMock(); @@ -42,21 +42,36 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { } - function request(HTTP\Request $request) { + 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; } function testCreateFile() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - )); + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + ]); $response = $this->request($request); @@ -66,38 +81,159 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { function testCreateFileValid() { - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - )); - $request->setBody("BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n"); - - $response = $this->request($request); + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - $expected = array( - 'uri' => 'blabla.vcf', - 'carddata' => "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", + $vcard = <<<VCF +BEGIN:VCARD +VERSION:4.0 +UID:foo +FN:Firstname LastName +N:LastName;FirstName;;; +END:VCARD +VCF; + $request->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( + $response->getHeader('ETag') !== null, + 'We did not receive an etag' ); - $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1','blabla.vcf')); + + $expected = [ + 'uri' => 'blabla.vcf', + 'carddata' => $vcard, + 'size' => strlen($vcard), + 'etag' => '"' . md5($vcard) . '"', + ]; + + $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); } - function testCreateFileNoUID() { + /** + * This test creates an intentionally broken vCard that vobject is able + * to automatically repair. + * + * @depends testCreateFileValid + */ + function testCreateVCardAutoFix() { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' ); - $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); - $response = $this->request($request); + // The error in this vcard is that there's not enough semi-colons in N + $vcard = <<<VCF +BEGIN:VCARD +VERSION:4.0 +UID:foo +FN:Firstname LastName +N:LastName;FirstName;; +END:VCARD +VCF; - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $request->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 = <<<VCF +BEGIN:VCARD\r +VERSION:4.0\r +UID:foo\r +FN:Firstname LastName\r +N:LastName;FirstName;;;\r +END:VCARD\r + +VCF; + + $expected = [ + 'uri' => 'blabla.vcf', + 'carddata' => $expectedVCard, + 'size' => strlen($expectedVCard), + 'etag' => '"' . md5($expectedVCard) . '"', + ]; + + $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - $foo = $this->cardBackend->getCard('addressbook1','blabla.vcf'); - $this->assertTrue(strpos($foo['carddata'],'UID')!==false); + } + + /** + * 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 + */ + 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 = <<<VCF +BEGIN:VCARD +VERSION:4.0 +UID:foo +FN:Firstname LastName +N:LastName;FirstName;; +END:VCARD +VCF; + + $request->setBody($vcard); + $this->request($request, 415); + + } + + function testCreateFileNoUID() { + + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); + $vcard = <<<VCF +BEGIN:VCARD +VERSION:4.0 +FN:Firstname LastName +N:LastName;FirstName;;; +END:VCARD +VCF; + $request->setBody($vcard); + + $response = $this->request($request, 201); + + $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); + $this->assertTrue( + strpos($foo['carddata'], 'UID') !== false, + print_r($foo, true) + ); } function testCreateFileJson() { @@ -106,23 +242,23 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' ); - $request->setBody('[ "vcard" , [ [ "UID" , {}, "text", "foo" ] ] ]'); + $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->body); - $foo = $this->cardBackend->getCard('addressbook1','blabla.vcf'); - $this->assertEquals("BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", $foo['carddata']); + $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']); } function testCreateFileVCalendar() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - )); + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + ]); $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); @@ -133,40 +269,37 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { function testUpdateFile() { - $this->cardBackend->createCard('addressbook1','blabla.vcf','foo'); - $request = HTTP\Sapi::createFromServerArray(array( - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', - )); - - $response = $this->request($request); + $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); - $this->assertEquals(415, $response->status); + $response = $this->request($request, 415); } function testUpdateFileParsableBody() { - $this->cardBackend->createCard('addressbook1','blabla.vcf','foo'); - $request = HTTP\Sapi::createFromServerArray(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); + $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); + $request = new HTTP\Request( + 'PUT', + '/addressbooks/admin/addressbook1/blabla.vcf' + ); - $response = $this->request($request); + $body = "BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n"; + $request->setBody($body); - $this->assertEquals(204, $response->status); + $response = $this->request($request, 204); - $expected = array( + $expected = [ 'uri' => 'blabla.vcf', - 'carddata' => $body, - ); + 'carddata' => $body, + 'size' => strlen($body), + 'etag' => '"' . md5($body) . '"', + ]; - $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1','blabla.vcf')); + $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); } } - -?> diff --git a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php index b5b8d64ee..6a8d389a0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php @@ -24,7 +24,7 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase { $this->server->sapi = new HTTP\SapiMock(); $this->server->httpResponse = $this->response; $this->server->debugExceptions = true; - $this->deleteTree(SABRE_TEMPDIR,false); + $this->deleteTree(SABRE_TEMPDIR, false); file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents'); mkdir(SABRE_TEMPDIR . '/dir'); file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents'); @@ -34,7 +34,7 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase { function tearDown() { - $this->deleteTree(SABRE_TEMPDIR,false); + $this->deleteTree(SABRE_TEMPDIR, false); } @@ -44,12 +44,12 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase { } - private function deleteTree($path,$deleteRoot = true) { + private function deleteTree($path, $deleteRoot = true) { - foreach(scandir($path) as $node) { + foreach (scandir($path) as $node) { - if ($node=='.' || $node=='.svn' || $node=='..') continue; - $myPath = $path.'/'. $node; + if ($node == '.' || $node == '.svn' || $node == '..') continue; + $myPath = $path . '/' . $node; if (is_file($myPath)) { unlink($myPath); } else { diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php index 7d7a59898..455403aff 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class AbstractBasicTest extends \PHPUnit_Framework_TestCase { @@ -22,10 +21,10 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { function testCheckUnknownUser() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'wrongpassword', - )); + 'PHP_AUTH_PW' => 'wrongpassword', + ]); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); @@ -38,10 +37,10 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { function testCheckSuccess() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'password', - )); + 'PHP_AUTH_PW' => 'password', + ]); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php index 8ef416c37..14c72aaa0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class AbstractDigestTest extends \PHPUnit_Framework_TestCase { @@ -87,12 +86,12 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { function testCheck() { $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/')); - $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray(array( + $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=' . $digestHash . ', opaque=1, qop=auth, nc=1, cnonce=1'; + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $header, 'REQUEST_URI' => '/', - )); + ]); $response = new HTTP\Response(); @@ -127,10 +126,10 @@ class AbstractDigestMock extends AbstractDigest { function getDigestHash($realm, $userName) { - switch($userName) { + switch ($userName) { case 'null' : return null; case 'false' : return false; - case 'array' : return array(); + case 'array' : return []; case 'user' : return 'HELLO'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php index d22923d51..b14e9fa2e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php @@ -2,11 +2,21 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; - abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - abstract function getPDO(); + use \Sabre\DAV\DbTestHelperTrait; + + function setUp() { + + $this->dropTables('users'); + $this->createSchema('users'); + + $this->getPDO()->query( + "INSERT INTO users (username,digesta1) VALUES ('user','hash')" + + ); + + } function testConstruct() { @@ -24,11 +34,11 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $this->assertNull($backend->getDigestHash('realm','blabla')); + $this->assertNull($backend->getDigestHash('realm', 'blabla')); $expected = 'hash'; - $this->assertEquals($expected, $backend->getDigestHash('realm','user')); + $this->assertEquals($expected, $backend->getDigestHash('realm', 'user')); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php index 697b593db..29cbc2162 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php @@ -2,7 +2,6 @@ namespace Sabre\DAV\Auth\Backend; -use Sabre\DAV; use Sabre\HTTP; class ApacheTest extends \PHPUnit_Framework_TestCase { diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php index d2e5fe49b..9b66d642f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -6,7 +6,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { function tearDown() { - if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend'); + if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR . '/filebackend'); } @@ -22,20 +22,20 @@ class FileTest extends \PHPUnit_Framework_TestCase { */ function testLoadFileBroken() { - file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash'); + file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash'); $file = new File(); - $file->loadFile(SABRE_TEMPDIR .'/backend'); + $file->loadFile(SABRE_TEMPDIR . '/backend'); } function testLoadFile() { - file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password')); + file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:' . md5('user:realm:password')); $file = new File(); $file->loadFile(SABRE_TEMPDIR . '/backend'); - $this->assertFalse($file->getDigestHash('realm','blabla')); - $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm','user')); + $this->assertFalse($file->getDigestHash('realm', 'blabla')); + $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm', 'user')); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php index a782cb74d..b30b3f143 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php @@ -2,10 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -use - Sabre\DAV, - Sabre\HTTP\RequestInterface, - Sabre\HTTP\ResponseInterface; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class Mock implements BackendInterface { diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php index 8de2be667..18f59793a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php @@ -2,32 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -require_once 'Sabre/TestUtil.php'; - class PDOMySQLTest extends AbstractPDOTest { - function getPDO() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - $pdo->query("DROP TABLE IF EXISTS users"); - $pdo->query(<<<SQL -create table users ( - id integer unsigned not null primary key auto_increment, - username varchar(50), - digesta1 varchar(32), - email varchar(80), - displayname varchar(80), - unique(username) -) -SQL - ); - - $pdo->query("INSERT INTO users (username,digesta1,email,displayname) VALUES ('user','hash','user@example.org','User')"); - - return $pdo; - - } + public $driver = 'mysql'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php index abfb031bb..b1f382237 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php @@ -2,27 +2,8 @@ namespace Sabre\DAV\Auth\Backend; -require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php'; +class PDOSqliteTest extends AbstractPDOTest { -class PDOSQLiteTest extends AbstractPDOTest { - - function tearDown() { - - if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend'); - if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2'); - - } - - function getPDO() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - $pdo->query('CREATE TABLE users (username TEXT, digesta1 TEXT, email VARCHAR(80), displayname VARCHAR(80))'); - $pdo->query('INSERT INTO users VALUES ("user","hash","user@example.org","User")'); - - return $pdo; - - } + public $driver = 'sqlite'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 0ac9e0613..3ed79a7da 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -5,13 +5,11 @@ namespace Sabre\DAV\Auth; use Sabre\HTTP; use Sabre\DAV; -require_once 'Sabre/HTTP/ResponseMock.php'; - class PluginTest extends \PHPUnit_Framework_TestCase { function testInit() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); @@ -25,7 +23,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testAuthenticate() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $this->assertTrue( @@ -40,7 +38,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testAuthenticateFail() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; @@ -55,7 +53,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testMultipleBackend() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend1 = new Backend\Mock(); $backend2 = new Backend\Mock(); $backend2->fail = true; @@ -77,7 +75,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testNoAuthBackend() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(); $fakeServer->addPlugin($plugin); @@ -90,7 +88,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testInvalidCheckResponse() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->invalidCheckResponse = true; @@ -105,7 +103,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase { */ function testGetCurrentPrincipal() { - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); + $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); @@ -113,18 +111,4 @@ class PluginTest extends \PHPUnit_Framework_TestCase { } - /** - * @depends testAuthenticate - */ - function testGetCurrentUser() { - - $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock()); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - $this->assertEquals('admin', $plugin->getCurrentUser()); - - } - } - diff --git a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php index 155c785f8..ec104ec80 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php @@ -7,7 +7,7 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testPut() { + function testPut() { $file = new FileMock(); $file->put('hi'); @@ -17,29 +17,29 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testGet() { + function testGet() { $file = new FileMock(); $file->get(); } - public function testGetSize() { + function testGetSize() { $file = new FileMock(); - $this->assertEquals(0,$file->getSize()); + $this->assertEquals(0, $file->getSize()); } - public function testGetETag() { + function testGetETag() { $file = new FileMock(); $this->assertNull($file->getETag()); } - public function testGetContentType() { + function testGetContentType() { $file = new FileMock(); $this->assertNull($file->getContentType()); @@ -49,7 +49,7 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testDelete() { + function testDelete() { $file = new FileMock(); $file->delete(); @@ -59,24 +59,24 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testSetName() { + function testSetName() { $file = new FileMock(); $file->setName('hi'); } - public function testGetLastModified() { + function testGetLastModified() { $file = new FileMock(); // checking if lastmod is within the range of a few seconds $lastMod = $file->getLastModified(); - $compareTime = ($lastMod + 1)-time(); + $compareTime = ($lastMod + 1) - time(); $this->assertTrue($compareTime < 3); } - public function testGetChild() { + function testGetChild() { $dir = new DirectoryMock(); $file = $dir->getChild('mockfile'); @@ -84,14 +84,14 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { } - public function testChildExists() { + function testChildExists() { $dir = new DirectoryMock(); $this->assertTrue($dir->childExists('mockfile')); } - public function testChildExistsFalse() { + function testChildExistsFalse() { $dir = new DirectoryMock(); $this->assertFalse($dir->childExists('mockfile2')); @@ -101,7 +101,7 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\NotFound */ - public function testGetChild404() { + function testGetChild404() { $dir = new DirectoryMock(); $file = $dir->getChild('blabla'); @@ -111,26 +111,26 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testCreateFile() { + function testCreateFile() { $dir = new DirectoryMock(); - $dir->createFile('hello','data'); + $dir->createFile('hello', 'data'); } /** * @expectedException Sabre\DAV\Exception\Forbidden */ - public function testCreateDirectory() { + function testCreateDirectory() { $dir = new DirectoryMock(); $dir->createDirectory('hello'); } - public function testSimpleDirectoryConstruct() { + function testSimpleDirectoryConstruct() { - $dir = new SimpleCollection('simpledir',array()); + $dir = new SimpleCollection('simpledir', []); $this->assertInstanceOf('Sabre\DAV\SimpleCollection', $dir); } @@ -138,13 +138,13 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { /** * @depends testSimpleDirectoryConstruct */ - public function testSimpleDirectoryConstructChild() { + function testSimpleDirectoryConstructChild() { $file = new FileMock(); - $dir = new SimpleCollection('simpledir',array($file)); + $dir = new SimpleCollection('simpledir', [$file]); $file2 = $dir->getChild('mockfile'); - $this->assertEquals($file,$file2); + $this->assertEquals($file, $file2); } @@ -152,23 +152,23 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { * @expectedException Sabre\DAV\Exception * @depends testSimpleDirectoryConstruct */ - public function testSimpleDirectoryBadParam() { + function testSimpleDirectoryBadParam() { - $dir = new SimpleCollection('simpledir',array('string shouldn\'t be here')); + $dir = new SimpleCollection('simpledir', ['string shouldn\'t be here']); } /** * @depends testSimpleDirectoryConstruct */ - public function testSimpleDirectoryAddChild() { + function testSimpleDirectoryAddChild() { $file = new FileMock(); $dir = new SimpleCollection('simpledir'); $dir->addChild($file); $file2 = $dir->getChild('mockfile'); - $this->assertEquals($file,$file2); + $this->assertEquals($file, $file2); } @@ -176,23 +176,23 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { * @depends testSimpleDirectoryConstruct * @depends testSimpleDirectoryAddChild */ - public function testSimpleDirectoryGetChildren() { + function testSimpleDirectoryGetChildren() { $file = new FileMock(); $dir = new SimpleCollection('simpledir'); $dir->addChild($file); - $this->assertEquals(array($file),$dir->getChildren()); + $this->assertEquals([$file], $dir->getChildren()); } /* * @depends testSimpleDirectoryConstruct */ - public function testSimpleDirectoryGetName() { + function testSimpleDirectoryGetName() { $dir = new SimpleCollection('simpledir'); - $this->assertEquals('simpledir',$dir->getName()); + $this->assertEquals('simpledir', $dir->getName()); } @@ -200,7 +200,7 @@ class BasicNodeTest extends \PHPUnit_Framework_TestCase { * @depends testSimpleDirectoryConstruct * @expectedException Sabre\DAV\Exception\NotFound */ - public function testSimpleDirectoryGetChild404() { + function testSimpleDirectoryGetChild404() { $dir = new SimpleCollection('simpledir'); $dir->getChild('blabla'); @@ -218,7 +218,7 @@ class DirectoryMock extends Collection { function getChildren() { - return array(new FileMock()); + return [new FileMock()]; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php index 157c2170a..54a3053ec 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php @@ -11,8 +11,8 @@ class GuessContentTypeTest extends DAV\AbstractServer { parent::setUp(); \Sabre\TestUtil::clearTempDir(); - file_put_contents(SABRE_TEMPDIR . '/somefile.jpg','blabla'); - file_put_contents(SABRE_TEMPDIR . '/somefile.hoi','blabla'); + file_put_contents(SABRE_TEMPDIR . '/somefile.jpg', 'blabla'); + file_put_contents(SABRE_TEMPDIR . '/somefile.hoi', 'blabla'); } @@ -24,13 +24,13 @@ class GuessContentTypeTest extends DAV\AbstractServer { function testGetProperties() { - $properties = array( + $properties = [ '{DAV:}getcontenttype', - ); - $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties); - $this->assertArrayHasKey(0,$result); - $this->assertArrayHasKey(404,$result[0]); - $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]); + ]; + $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); + $this->assertArrayHasKey(0, $result); + $this->assertArrayHasKey(404, $result[0]); + $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][404]); } @@ -40,14 +40,14 @@ class GuessContentTypeTest extends DAV\AbstractServer { function testGetPropertiesPluginEnabled() { $this->server->addPlugin(new GuessContentType()); - $properties = array( + $properties = [ '{DAV:}getcontenttype', - ); - $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties); - $this->assertArrayHasKey(0,$result); - $this->assertArrayHasKey(200,$result[0], 'We received: ' . print_r($result,true)); - $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]); - $this->assertEquals('image/jpeg',$result[0][200]['{DAV:}getcontenttype']); + ]; + $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); + $this->assertArrayHasKey(0, $result); + $this->assertArrayHasKey(200, $result[0], 'We received: ' . print_r($result, true)); + $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); + $this->assertEquals('image/jpeg', $result[0][200]['{DAV:}getcontenttype']); } @@ -57,14 +57,14 @@ class GuessContentTypeTest extends DAV\AbstractServer { function testGetPropertiesUnknown() { $this->server->addPlugin(new GuessContentType()); - $properties = array( + $properties = [ '{DAV:}getcontenttype', - ); - $result = $this->server->getPropertiesForPath('/somefile.hoi',$properties); - $this->assertArrayHasKey(0,$result); - $this->assertArrayHasKey(200,$result[0]); - $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]); - $this->assertEquals('application/octet-stream',$result[0][200]['{DAV:}getcontenttype']); + ]; + $result = $this->server->getPropertiesForPath('/somefile.hoi', $properties); + $this->assertArrayHasKey(0, $result); + $this->assertArrayHasKey(200, $result[0]); + $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); + $this->assertEquals('application/octet-stream', $result[0][200]['{DAV:}getcontenttype']); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php index 9d9fbb319..33c4ede96 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php @@ -18,23 +18,23 @@ class MapGetToPropFindTest extends DAV\AbstractServer { function testCollectionGet() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status,'Incorrect status response received. Full response body: ' . $this->response->body); - $this->assertEquals(array( + $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body); + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol'], - 'Vary' => ['Brief,Prefer'], - ), + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol'], + 'Vary' => ['Brief,Prefer'], + ], $this->response->getHeaders() ); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php index 00beea9f2..f20c50f86 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php @@ -28,16 +28,16 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">')!==false); + $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); } @@ -54,16 +54,16 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">')!==false); + $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); } function testCollectionGetRoot() { @@ -75,17 +75,17 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); $this->assertTrue(strpos($body, '<title>/') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/">')!==false); - $this->assertTrue(strpos($body, '<span class="btn disabled">')!==false); + $this->assertTrue(strpos($body, '<a href="/dir/">') !== false); + $this->assertTrue(strpos($body, '<span class="btn disabled">') !== false); } @@ -122,15 +122,15 @@ class PluginTest extends DAV\AbstractServer{ function testPostMkCol() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - ); - $postVars = array( + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + ]; + $postVars = [ 'sabreAction' => 'mkcol', - 'name' => 'new_collection', - ); + 'name' => 'new_collection', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setPostData($postVars); @@ -138,10 +138,10 @@ class PluginTest extends DAV\AbstractServer{ $this->server->exec(); $this->assertEquals(302, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Location' => ['/'], - ), $this->response->getHeaders()); + 'Location' => ['/'], + ], $this->response->getHeaders()); $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection')); @@ -155,11 +155,11 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['image/vnd.microsoft.icon'], - 'Content-Length' => ['4286'], - 'Cache-Control' => ['public, max-age=1209600'], - 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['image/vnd.microsoft.icon'], + 'Content-Length' => ['4286'], + 'Cache-Control' => ['public, max-age=1209600'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] ], $this->response->getHeaders()); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php index d8b53a5a1..5a48b063c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php @@ -18,13 +18,13 @@ class ClientMock extends Client { * @param string $url * @return string */ - public function getAbsoluteUrl($url) { + function getAbsoluteUrl($url) { return parent::getAbsoluteUrl($url); } - public function doRequest(RequestInterface $request) { + function doRequest(RequestInterface $request) { $this->request = $request; return $this->response; diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php index c06d6aa1f..8788475cb 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php @@ -2,9 +2,8 @@ namespace Sabre\DAV\Exception; -use - Sabre\DAV, - DOMDocument; +use Sabre\DAV; +use DOMDocument; class LockedTest extends \PHPUnit_Framework_TestCase { @@ -15,7 +14,7 @@ class LockedTest extends \PHPUnit_Framework_TestCase { $root = $dom->createElement('d:root'); $dom->appendChild($root); - $root->setAttribute('xmlns:d','DAV:'); + $root->setAttribute('xmlns:d', 'DAV:'); $lockInfo = new DAV\Locks\LockInfo(); $lockInfo->uri = '/foo'; @@ -44,7 +43,7 @@ class LockedTest extends \PHPUnit_Framework_TestCase { $root = $dom->createElement('d:root'); $dom->appendChild($root); - $root->setAttribute('xmlns:d','DAV:'); + $root->setAttribute('xmlns:d', 'DAV:'); $lockInfo = new DAV\Locks\LockInfo(); $lockInfo->uri = '/foo&bar'; diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php index 6d6bf5668..0eb4f3dd8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php @@ -7,18 +7,18 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase { function testStatus() { $e = new Exception(); - $this->assertEquals(500,$e->getHTTPCode()); + $this->assertEquals(500, $e->getHTTPCode()); } function testExceptionStatuses() { - $c = array( + $c = [ 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, 'Sabre\\DAV\\Exception\\InsufficientStorage' => 507, - ); + ]; - foreach($c as $class=>$status) { + foreach ($c as $class => $status) { $obj = new $class(); $this->assertEquals($status, $obj->getHTTPCode()); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php index 3708594e0..f5d65a44f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php @@ -2,8 +2,6 @@ namespace Sabre\DAV\FSExt; -use Sabre\DAV; - require_once 'Sabre/TestUtil.php'; class FileTest extends \PHPUnit_Framework_TestCase { @@ -26,12 +24,12 @@ class FileTest extends \PHPUnit_Framework_TestCase { $file = new File($filename); $result = $file->put('New contents'); - $this->assertEquals('New contents',file_get_contents(SABRE_TEMPDIR . '/file.txt')); + $this->assertEquals('New contents', file_get_contents(SABRE_TEMPDIR . '/file.txt')); $this->assertEquals( '"' . sha1( fileinode($filename) . - filesize($filename ) . + filesize($filename) . filemtime($filename) ) . '"', $result @@ -45,13 +43,13 @@ class FileTest extends \PHPUnit_Framework_TestCase { $file->put('0000000'); $file->patch('111', 2, 3); - $this->assertEquals('0001110',file_get_contents(SABRE_TEMPDIR . '/file.txt')); + $this->assertEquals('0001110', file_get_contents(SABRE_TEMPDIR . '/file.txt')); } function testRangeStream() { - $stream = fopen('php://memory','r+'); + $stream = fopen('php://memory', 'r+'); fwrite($stream, "222"); rewind($stream); @@ -59,7 +57,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { $file->put('0000000'); $file->patch($stream, 2, 3); - $this->assertEquals('0002220',file_get_contents(SABRE_TEMPDIR . '/file.txt')); + $this->assertEquals('0002220', file_get_contents(SABRE_TEMPDIR . '/file.txt')); } @@ -67,7 +65,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { function testGet() { $file = new File(SABRE_TEMPDIR . '/file.txt'); - $this->assertEquals('Contents',stream_get_contents($file->get())); + $this->assertEquals('Contents', stream_get_contents($file->get())); } @@ -88,7 +86,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { '"' . sha1( fileinode($filename) . - filesize($filename ) . + filesize($filename) . filemtime($filename) ) . '"', $file->getETag() @@ -105,7 +103,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { function testGetSize() { $file = new File(SABRE_TEMPDIR . '/file.txt'); - $this->assertEquals(8,$file->getSize()); + $this->assertEquals(8, $file->getSize()); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php index 63d858de1..20fca490a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php @@ -28,7 +28,7 @@ class ServerTest extends DAV\AbstractServer{ 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))], - 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'], + 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], ], $this->response->getHeaders() ); @@ -50,12 +50,12 @@ class ServerTest extends DAV\AbstractServer{ 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))], - 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'], + 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], ], $this->response->getHeaders() ); - $this->assertEquals(200,$this->response->status); + $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); } @@ -71,12 +71,12 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Length' => ['0'], - 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'], + 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertEquals('Testing new file',file_get_contents($filename)); + $this->assertEquals('Testing new file', file_get_contents($filename)); } @@ -89,11 +89,11 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ],$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); $this->assertEquals(412, $this->response->status); - $this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt')); + $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir . '/test.txt')); } @@ -105,8 +105,8 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ],$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); @@ -125,7 +125,7 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt')); + $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt')); } @@ -137,8 +137,8 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ],$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); @@ -148,8 +148,8 @@ class ServerTest extends DAV\AbstractServer{ function testDeleteDirectory() { - mkdir($this->tempDir.'/testcol'); - file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan'); + mkdir($this->tempDir . '/testcol'); + file_put_contents($this->tempDir . '/testcol/test.txt', 'Hi! I\'m a file with a short lifespan'); $request = new HTTP\Request('DELETE', '/testcol'); $this->server->httpRequest = ($request); @@ -157,8 +157,8 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ],$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertFalse(file_exists($this->tempDir . '/testcol')); @@ -172,12 +172,12 @@ class ServerTest extends DAV\AbstractServer{ $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], - 'X-Sabre-Version'=> [DAV\Version::VERSION], + 'DAV' => ['1, 3, extended-mkcol'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); @@ -187,7 +187,7 @@ class ServerTest extends DAV\AbstractServer{ function testMove() { - mkdir($this->tempDir.'/testcol'); + mkdir($this->tempDir . '/testcol'); $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']); $this->server->httpRequest = ($request); @@ -197,9 +197,9 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], - 'X-Sabre-Version'=> [DAV\Version::VERSION], - ],$this->response->getHeaders()); + 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], + ], $this->response->getHeaders()); $this->assertTrue( is_file($this->tempDir . '/testcol/test2.txt') @@ -217,8 +217,8 @@ class ServerTest extends DAV\AbstractServer{ */ function testMoveOtherObject() { - mkdir($this->tempDir.'/tree1'); - mkdir($this->tempDir.'/tree2'); + mkdir($this->tempDir . '/tree1'); + mkdir($this->tempDir . '/tree2'); $tree = new DAV\Tree(new DAV\SimpleCollection('root', [ new DAV\FS\Directory($this->tempDir . '/tree1'), @@ -234,9 +234,9 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], - 'X-Sabre-Version'=> [DAV\Version::VERSION], - ],$this->response->getHeaders()); + 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], + ], $this->response->getHeaders()); $this->assertTrue( is_dir($this->tempDir . '/tree2/tree1') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php index 6c10afa9f..bd1b33150 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php @@ -19,12 +19,12 @@ class HttpDeleteTest extends DAVServerTest { * * @return void */ - public function setUpTree() { + function setUpTree() { $this->tree = new Mock\Collection('root', [ 'file1' => 'foo', - 'dir' => [ - 'subfile' => 'bar', + 'dir' => [ + 'subfile' => 'bar', 'subfile2' => 'baz', ], ]); @@ -34,7 +34,7 @@ class HttpDeleteTest extends DAVServerTest { /** * A successful DELETE */ - public function testDelete() { + function testDelete() { $request = new HTTP\Request('DELETE', '/file1'); @@ -49,7 +49,7 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); @@ -59,7 +59,7 @@ class HttpDeleteTest extends DAVServerTest { /** * Deleting a Directory */ - public function testDeleteDirectory() { + function testDeleteDirectory() { $request = new HTTP\Request('DELETE', '/dir'); @@ -74,7 +74,7 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); @@ -84,7 +84,7 @@ class HttpDeleteTest extends DAVServerTest { /** * DELETE on a node that does not exist */ - public function testDeleteNotFound() { + function testDeleteNotFound() { $request = new HTTP\Request('DELETE', '/file2'); $response = $this->request($request); @@ -100,7 +100,7 @@ class HttpDeleteTest extends DAVServerTest { /** * DELETE with preconditions */ - public function testDeletePreconditions() { + function testDeletePreconditions() { $request = new HTTP\Request('DELETE', '/file1', [ 'If-Match' => '"' . md5('foo') . '"', @@ -119,7 +119,7 @@ class HttpDeleteTest extends DAVServerTest { /** * DELETE with incorrect preconditions */ - public function testDeletePreconditionsFailed() { + function testDeletePreconditionsFailed() { $request = new HTTP\Request('DELETE', '/file1', [ 'If-Match' => '"' . md5('bar') . '"', diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php index eddaf3f22..86480b1c2 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php @@ -46,8 +46,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('hello') . '"'] ], $response->getHeaders() ); @@ -75,8 +75,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('bar') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('bar') . '"'] ], $response->getHeaders() ); @@ -109,8 +109,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('hello') . '"'] ], $response->getHeaders() ); @@ -143,8 +143,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('hello') . '"'], ], $response->getHeaders() ); @@ -196,8 +196,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('hello') . '"'] ], $response->getHeaders() ); @@ -291,8 +291,8 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"' . md5('hello') . '"'], ], $response->getHeaders() ); @@ -334,7 +334,7 @@ class HttpPutTest extends DAVServerTest { $request = new HTTP\Request('PUT', '/file2', [], 'hello'); $response = $this->request($request); - $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: ' .$response->getBodyAsString()); + $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: ' . $response->getBodyAsString()); $this->assertFalse( $this->server->tree->nodeExists('file2') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php index 4ccb42fbb..edd09e634 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php @@ -17,16 +17,16 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { function testCopyMoveInfo() { $bar = new SimpleCollection('bar'); - $root = new SimpleCollection('webdav',array($bar)); + $root = new SimpleCollection('webdav', [$bar]); $server = new Server($root); $server->setBaseUri('/webdav/'); - $serverVars = array( - 'REQUEST_URI' => '/webdav/bar', + $serverVars = [ + 'REQUEST_URI' => '/webdav/bar', 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ); + 'HTTP_OVERWRITE' => 'F', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -48,19 +48,19 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $dir->createDirectory('bar'); $tree = new Tree($dir); - $tree->move('bar',urldecode('%C3%A0fo%C3%B3')); + $tree->move('bar', urldecode('%C3%A0fo%C3%B3')); $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); - $this->assertEquals(urldecode('%C3%A0fo%C3%B3'),$node->getName()); + $this->assertEquals(urldecode('%C3%A0fo%C3%B3'), $node->getName()); } function testDirName() { $dirname1 = 'bar'; - $dirname2 = urlencode('%C3%A0fo%C3%B3');; + $dirname2 = urlencode('%C3%A0fo%C3%B3'); - $this->assertTrue(dirname($dirname1)==dirname($dirname2)); + $this->assertTrue(dirname($dirname1) == dirname($dirname2)); } @@ -71,12 +71,12 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { function testEverything() { // Request object - $serverVars = array( - 'REQUEST_METHOD' => 'MOVE', - 'REQUEST_URI' => '/webdav/bar', + $serverVars = [ + 'REQUEST_METHOD' => 'MOVE', + 'REQUEST_URI' => '/webdav/bar', 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ); + 'HTTP_OVERWRITE' => 'F', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php index f39e9a036..bbde69097 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php @@ -31,15 +31,15 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $lock->timeout = 60; $lock->created = time(); $lock->token = 'MY-UNIQUE-TOKEN'; - $lock->uri ='someuri'; + $lock->uri = 'someuri'; $this->assertTrue($backend->lock('someuri', $lock)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1,count($locks)); - $this->assertEquals('Sinterklaas',$locks[0]->owner); - $this->assertEquals('someuri',$locks[0]->uri); + $this->assertEquals(1, count($locks)); + $this->assertEquals('Sinterklaas', $locks[0]->owner); + $this->assertEquals('someuri', $locks[0]->uri); } @@ -61,9 +61,9 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri/child', false); - $this->assertEquals(1,count($locks)); - $this->assertEquals('Sinterklaas',$locks[0]->owner); - $this->assertEquals('someuri',$locks[0]->uri); + $this->assertEquals(1, count($locks)); + $this->assertEquals('Sinterklaas', $locks[0]->owner); + $this->assertEquals('someuri', $locks[0]->uri); } @@ -86,7 +86,7 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri/child', false); - $this->assertEquals(0,count($locks)); + $this->assertEquals(0, count($locks)); } @@ -104,13 +104,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($backend->lock('someuri/child', $lock)); $locks = $backend->getLocks('someuri/child', false); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(0,count($locks)); + $this->assertEquals(0, count($locks)); $locks = $backend->getLocks('someuri', true); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); } @@ -135,10 +135,10 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); - $this->assertEquals('Santa Clause',$locks[0]->owner); - $this->assertEquals('someuri',$locks[0]->uri); + $this->assertEquals('Santa Clause', $locks[0]->owner); + $this->assertEquals('someuri', $locks[0]->uri); } @@ -158,12 +158,12 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($backend->lock('someuri', $lock)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); - $this->assertTrue($backend->unlock('someuri',$lock)); + $this->assertTrue($backend->unlock('someuri', $lock)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(0,count($locks)); + $this->assertEquals(0, count($locks)); } @@ -183,13 +183,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($backend->lock('someuri', $lock)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); $lock->token = 'SOME-OTHER-TOKEN'; - $this->assertFalse($backend->unlock('someuri',$lock)); + $this->assertFalse($backend->unlock('someuri', $lock)); $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1,count($locks)); + $this->assertEquals(1, count($locks)); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php index b6f06224c..0ba02fc8b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php @@ -2,31 +2,8 @@ namespace Sabre\DAV\Locks\Backend; -require_once 'Sabre/TestUtil.php'; +class PDOMySQLTest extends PDOTest { -class PDOMySQLTest extends AbstractTest { - - function getBackend() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or it was not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - $pdo->query('DROP TABLE IF EXISTS locks;'); - $pdo->query(" -CREATE TABLE locks ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - owner VARCHAR(100), - timeout INTEGER UNSIGNED, - created INTEGER, - token VARCHAR(100), - scope TINYINT, - depth TINYINT, - uri text -);"); - - $backend = new PDO($pdo); - return $backend; - - } + public $driver = 'mysql'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php index d6336c7b2..a27eae93c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php @@ -2,27 +2,18 @@ namespace Sabre\DAV\Locks\Backend; -require_once 'Sabre/TestUtil.php'; -require_once 'Sabre/DAV/Locks/Backend/AbstractTest.php'; +abstract class PDOTest extends AbstractTest { -class PDOTest extends AbstractTest { + use \Sabre\DAV\DbTestHelperTrait; function getBackend() { - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - \Sabre\TestUtil::clearTempDir(); - mkdir(SABRE_TEMPDIR . '/pdolocks'); - $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/pdolocks/db.sqlite'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - $pdo->query('CREATE TABLE locks ( id integer primary key asc, owner text, timeout text, created integer, token text, scope integer, depth integer, uri text)'); - $backend = new PDO($pdo); - return $backend; + $this->dropTables('locks'); + $this->createSchema('locks'); - } - - function tearDown() { + $pdo = $this->getPDO(); - \Sabre\TestUtil::clearTempDir(); + return new PDO($pdo); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php index 23f283796..f08f19da5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php @@ -62,12 +62,12 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { function getLockRequest() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', 'HTTP_TIMEOUT' => 'Second-3600', 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - )); + ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> <D:lockscope> @@ -86,12 +86,12 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { } function getLockRequest2() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', 'HTTP_TIMEOUT' => 'Second-3600', 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - )); + ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> <D:lockscope> @@ -111,11 +111,11 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { function getPutRequest($lockToken) { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - 'HTTP_IF' => 'If: ('.$lockToken.')', - )); + 'HTTP_IF' => 'If: (' . $lockToken . ')', + ]); $request->setBody('FAKE BODY'); return $request; diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php index ef0e473ae..6511d4e7d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php @@ -35,13 +35,13 @@ class PluginTest extends DAV\AbstractServer { function testGetFeatures() { - $this->assertEquals(array(2),$this->locksPlugin->getFeatures()); + $this->assertEquals([2], $this->locksPlugin->getFeatures()); } function testGetHTTPMethods() { - $this->assertEquals(array('LOCK','UNLOCK'),$this->locksPlugin->getHTTPMethods('')); + $this->assertEquals(['LOCK', 'UNLOCK'], $this->locksPlugin->getHTTPMethods('')); } @@ -51,10 +51,10 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders() ); @@ -77,16 +77,16 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); - $this->assertEquals(200, $this->response->status,'Got an incorrect status back. Response body: ' . $this->response->body); + $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: ' . $this->response->body); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('d', 'urn:DAV'); - $elements = array( + $elements = [ '/d:prop', '/d:prop/d:lockdiscovery', '/d:prop/d:lockdiscovery/d:activelock', @@ -101,18 +101,18 @@ class PluginTest extends DAV\AbstractServer { '/d:prop/d:lockdiscovery/d:activelock/d:timeout', '/d:prop/d:lockdiscovery/d:activelock/d:locktoken', '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href', - ); + ]; - foreach($elements as $elem) { + foreach ($elements as $elem) { $data = $xml->xpath($elem); - $this->assertEquals(1,count($data),'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body); + $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body); } $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); - $this->assertEquals('infinity',(string)$depth[0]); + $this->assertEquals('infinity', (string)$depth[0]); $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href'); - $this->assertEquals($this->response->getHeader('Lock-Token'),'<' . (string)$token[0] . '>','Token in response body didn\'t match token in response header.'); + $this->assertEquals($this->response->getHeader('Lock-Token'), '<' . (string)$token[0] . '>', 'Token in response body didn\'t match token in response header.'); } @@ -139,7 +139,7 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); $this->assertEquals(423, $this->response->status, 'Full response: ' . $this->response->body); @@ -174,9 +174,9 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(200, $this->response->status,'We received an incorrect status code. Full response body: ' . $this->response->getBody()); + $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); } @@ -209,9 +209,9 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(423, $this->response->getStatus(),'We received an incorrect status code. Full response body: ' . $this->response->getBody()); + $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); } @@ -233,8 +233,8 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(201, $this->response->status); @@ -251,7 +251,7 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); @@ -271,7 +271,7 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); @@ -298,8 +298,8 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); @@ -308,8 +308,8 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(423, $this->response->status); @@ -340,10 +340,10 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204,$this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); @@ -372,17 +372,17 @@ class PluginTest extends DAV\AbstractServer { $lockToken = $this->server->httpResponse->getHeader('Lock-Token'); // See Issue 123 - $lockToken = trim($lockToken,'<>'); + $lockToken = trim($lockToken, '<>'); $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $lockToken]); $this->server->httpRequest = $request; $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204, $this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); @@ -396,7 +396,7 @@ class PluginTest extends DAV\AbstractServer { function testLockRetainOwner() { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/test.txt', + 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'LOCK', ]); $this->server->httpRequest = $request; @@ -412,8 +412,8 @@ class PluginTest extends DAV\AbstractServer { $lockToken = $this->server->httpResponse->getHeader('Lock-Token'); $locks = $this->locksPlugin->getLocks('test.txt'); - $this->assertEquals(1,count($locks)); - $this->assertEquals('Evert',$locks[0]->owner); + $this->assertEquals(1, count($locks)); + $this->assertEquals('Evert', $locks[0]->owner); } @@ -423,10 +423,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockPutBadToken() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -441,24 +441,24 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(<opaquelocktoken:token1>)', - ); + 'HTTP_IF' => '(<opaquelocktoken:token1>)', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); // $this->assertEquals('412 Precondition failed',$this->response->status); $this->assertEquals(423, $this->response->status); @@ -470,10 +470,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockDeleteParent() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -488,22 +488,22 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir', 'REQUEST_METHOD' => 'DELETE', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } /** @@ -511,10 +511,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockDeleteSucceed() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -529,23 +529,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ); + 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(204, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } @@ -554,10 +554,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockCopyLockSource() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -572,23 +572,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'COPY', 'HTTP_DESTINATION' => '/dir/child2.txt', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status,'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals(201, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } /** @@ -596,10 +596,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockCopyLockDestination() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child2.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -614,23 +614,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(201, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'COPY', 'HTTP_DESTINATION' => '/dir/child2.txt', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(423, $this->response->status,'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } @@ -639,10 +639,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockMoveLockSourceLocked() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -657,23 +657,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', 'HTTP_DESTINATION' => '/dir/child2.txt', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(423, $this->response->status,'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } @@ -682,10 +682,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockMoveLockSourceSucceed() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -700,23 +700,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ); + 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status,'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body); + $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body); } @@ -725,10 +725,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockMoveLockDestination() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir/child2.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -743,23 +743,23 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(201, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', 'HTTP_DESTINATION' => '/dir/child2.txt', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(423, $this->response->status,'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } /** @@ -767,11 +767,11 @@ class PluginTest extends DAV\AbstractServer { */ function testLockMoveLockParent() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir', 'REQUEST_METHOD' => 'LOCK', - 'HTTP_DEPTH' => 'infinite', - ); + 'HTTP_DEPTH' => 'infinite', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -786,24 +786,24 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); - $this->assertEquals(200,$this->response->status); + $this->assertEquals(200, $this->response->status); - $serverVars = array( - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', + $serverVars = [ + 'REQUEST_URI' => '/dir/child.txt', + 'REQUEST_METHOD' => 'MOVE', 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '</dir> (' . $this->response->getHeader('Lock-Token') . ')', - ); + 'HTTP_IF' => '</dir> (' . $this->response->getHeader('Lock-Token') . ')', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status,'We locked the parent of both the source and destination, but the move didn\'t succeed.'); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); + $this->assertEquals(201, $this->response->status, 'We locked the parent of both the source and destination, but the move didn\'t succeed.'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); } @@ -812,10 +812,10 @@ class PluginTest extends DAV\AbstractServer { */ function testLockPutGoodToken() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'LOCK', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -830,24 +830,24 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(200, $this->response->status); - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '('.$this->response->getHeader('Lock-Token').')', - ); + 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(204, $this->response->status); @@ -871,22 +871,22 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(201, $this->response->getStatus()); $request = new HTTP\Request( 'PUT', '/test.txt', - ['If' => '</unrelated.txt> ('.$this->response->getHeader('Lock-Token').')'] + ['If' => '</unrelated.txt> (' . $this->response->getHeader('Lock-Token') . ')'] ); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); $this->assertEquals(204, $this->response->status); @@ -894,11 +894,11 @@ class PluginTest extends DAV\AbstractServer { function testPutWithIncorrectETag() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["etag1"])', - ); + 'HTTP_IF' => '(["etag1"])', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('newbody'); @@ -920,14 +920,14 @@ class PluginTest extends DAV\AbstractServer { $filename = SABRE_TEMPDIR . '/test.txt'; $etag = sha1( fileinode($filename) . - filesize($filename ) . + filesize($filename) . filemtime($filename) ); - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["'.$etag.'"])', - ); + 'HTTP_IF' => '(["' . $etag . '"])', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('newbody'); @@ -939,11 +939,11 @@ class PluginTest extends DAV\AbstractServer { function testDeleteWithETagOnCollection() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/dir', 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(["etag1"])', - ); + 'HTTP_IF' => '(["etag1"])', + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; @@ -954,9 +954,9 @@ class PluginTest extends DAV\AbstractServer { function testGetTimeoutHeader() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'HTTP_TIMEOUT' => 'second-100', - )); + ]); $this->server->httpRequest = $request; $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader()); @@ -965,9 +965,9 @@ class PluginTest extends DAV\AbstractServer { function testGetTimeoutHeaderTwoItems() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'HTTP_TIMEOUT' => 'second-5, infinite', - )); + ]); $this->server->httpRequest = $request; $this->assertEquals(5, $this->locksPlugin->getTimeoutHeader()); @@ -976,9 +976,9 @@ class PluginTest extends DAV\AbstractServer { function testGetTimeoutHeaderInfinite() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'HTTP_TIMEOUT' => 'infinite, second-5', - )); + ]); $this->server->httpRequest = $request; $this->assertEquals(LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader()); @@ -990,9 +990,9 @@ class PluginTest extends DAV\AbstractServer { */ function testGetTimeoutHeaderInvalid() { - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'HTTP_TIMEOUT' => 'yourmom', - )); + ]); $this->server->httpRequest = $request; $this->locksPlugin->getTimeoutHeader(); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php index e6415792c..3213fcb1b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php @@ -18,27 +18,27 @@ class PluginTest extends DAV\AbstractServer { function testPassThrough() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(501, $this->response->status,'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body); + $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body); } function testMountResponse() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/?mount', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'mount', 'HTTP_HOST' => 'example.org', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = ($request); @@ -47,11 +47,11 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals(200, $this->response->status); $xml = simplexml_load_string($this->response->body); - $this->assertInstanceOf('SimpleXMLElement',$xml, 'Response was not a valid xml document. The list of errors:' . print_r(libxml_get_errors(),true) . '. xml body: ' . $this->response->body . '. What type we got: ' . gettype($xml) . ' class, if object: ' . get_class($xml)); + $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:' . print_r(libxml_get_errors(), true) . '. xml body: ' . $this->response->body . '. What type we got: ' . gettype($xml) . ' class, if object: ' . get_class($xml)); - $xml->registerXPathNamespace('dm','http://purl.org/NET/webdav/mount'); + $xml->registerXPathNamespace('dm', 'http://purl.org/NET/webdav/mount'); $url = $xml->xpath('//dm:url'); - $this->assertEquals('http://example.org/',(string)$url[0]); + $this->assertEquals('http://example.org/', (string)$url[0]); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php index 9b7eeb90c..15289ce52 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php @@ -13,8 +13,8 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { \Sabre\TestUtil::clearTempDir(); mkdir(SABRE_TEMPDIR . '/root'); mkdir(SABRE_TEMPDIR . '/root/subdir'); - file_put_contents(SABRE_TEMPDIR . '/root/file.txt','contents'); - file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt','subcontents'); + file_put_contents(SABRE_TEMPDIR . '/root/file.txt', 'contents'); + file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt', 'subcontents'); $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root'); $this->tree = new Tree($rootNode); @@ -29,22 +29,22 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { function testGetRootNode() { $root = $this->tree->getNodeForPath(''); - $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory',$root); + $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); } function testGetSubDir() { $root = $this->tree->getNodeForPath('subdir'); - $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory',$root); + $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); } function testCopyFile() { - $this->tree->copy('file.txt','file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); - $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); + $this->tree->copy('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); } @@ -53,10 +53,10 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { */ function testCopyDirectory() { - $this->tree->copy('subdir','subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->tree->copy('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); } @@ -65,10 +65,10 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { */ function testMoveFile() { - $this->tree->move('file.txt','file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); - $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); + $this->tree->move('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); } @@ -77,10 +77,10 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { */ function testMoveFileNewParent() { - $this->tree->move('file.txt','subdir/file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); - $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt')); + $this->tree->move('file.txt', 'subdir/file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/subdir/file2.txt')); } @@ -89,11 +89,11 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase { */ function testMoveDirectory() { - $this->tree->move('subdir','subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir')); - $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->tree->move('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/subdir')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php index d6cc406be..eff1e7d67 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php @@ -1,6 +1,7 @@ <?php namespace Sabre\DAV\PartialUpdate; + use Sabre\DAV; class FileMock implements IPatchSupport { @@ -49,10 +50,10 @@ class FileMock implements IPatchSupport { $data = stream_get_contents($data); } - switch($rangeType) { + switch ($rangeType) { case 1 : - $this->data.=$data; + $this->data .= $data; break; case 3 : // Turn the offset into an offset-offset. diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php index 31be2a1b1..ca8ca3f6e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php @@ -16,11 +16,11 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { protected $server; - public function setUp() { + function setUp() { - $tree = array( + $tree = [ new File(SABRE_TEMPDIR . '/foobar.txt') - ); + ]; $server = new Server($tree); $server->debugExceptions = true; $server->addPlugin(new Plugin()); @@ -31,7 +31,7 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { } - public function tearDown() { + function tearDown() { \Sabre\TestUtil::clearTempDir(); @@ -40,10 +40,10 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider data */ - public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) { + function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) { $headers = [ - 'Content-Type' => 'application/x-sabredav-partialupdate', + 'Content-Type' => 'application/x-sabredav-partialupdate', 'X-Update-Range' => $headerValue, ]; @@ -64,25 +64,25 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt')); } - } + } - public function data() { + function data() { - return array( + return [ // Problems - array('foo', 400, null), - array('bytes=0-3', 411, null, 0), - array('bytes=4-1', 416, null), - - array('bytes=0-3', 204, '----567890'), - array('bytes=1-4', 204, '1----67890'), - array('bytes=0-', 204, '----567890'), - array('bytes=-4', 204, '123456----'), - array('bytes=-2', 204, '12345678----'), - array('bytes=2-', 204, '12----7890'), - array('append', 204, '1234567890----'), - - ); + ['foo', 400, null], + ['bytes=0-3', 411, null, 0], + ['bytes=4-1', 416, null], + + ['bytes=0-3', 204, '----567890'], + ['bytes=1-4', 204, '1----67890'], + ['bytes=0-', 204, '----567890'], + ['bytes=-4', 204, '123456----'], + ['bytes=-2', 204, '12345678----'], + ['bytes=2-', 204, '12----7890'], + ['append', 204, '1234567890----'], + + ]; } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php index e35189ec3..557eddbbc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php @@ -8,20 +8,20 @@ class ServerMKCOLTest extends AbstractServer { function testMkcol() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(""); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ),$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); @@ -34,20 +34,20 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLUnknownBody() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody("Hello"); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); $this->assertEquals(415, $this->response->status); @@ -58,23 +58,23 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLBrokenXML() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody("Hello"); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); - $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString() ); + $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString()); } @@ -83,21 +83,21 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLUnknownXML() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?><html></html>'); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); $this->assertEquals(400, $this->response->getStatus()); @@ -108,11 +108,11 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLNoResourceType() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -126,12 +126,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); - $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -140,11 +140,11 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLIncorrectResourceType() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -158,12 +158,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); - $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -172,11 +172,11 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLSuccess() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -190,12 +190,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ),$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -204,11 +204,11 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLWhiteSpaceResourceType() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + $serverVars = [ + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> @@ -224,12 +224,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ),$this->response->getHeaders()); + 'Content-Length' => ['0'], + ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -238,10 +238,10 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLNoParent() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/testnoparent/409me', 'REQUEST_METHOD' => 'MKCOL', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); @@ -249,12 +249,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -263,10 +263,10 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLParentIsNoCollection() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt/409me', 'REQUEST_METHOD' => 'MKCOL', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); @@ -274,12 +274,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -288,10 +288,10 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLAlreadyExists() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'MKCOL', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); @@ -299,13 +299,13 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + ], $this->response->getHeaders()); - $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); } @@ -315,13 +315,11 @@ class ServerMKCOLTest extends AbstractServer { */ function testMKCOLAndProps() { - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', + $request = new HTTP\Request( + 'MKCOL', + '/testcol', + ['Content-Type' => 'application/xml'] ); - - $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody('<?xml version="1.0"?> <mkcol xmlns="DAV:"> <set> @@ -334,12 +332,34 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $this->response->getHeaders()); + + $responseBody = $this->response->getBodyAsString(); + + $expected = <<<XML +<?xml version="1.0"?> +<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> + <d:response> + <d:href>/testcol</d:href> + <d:propstat> + <d:prop> + <d:displayname /> + </d:prop> + <d:status>HTTP/1.1 403 Forbidden</d:status> + </d:propstat> + </d:response> +</d:multistatus> +XML; + + $this->assertXmlStringEqualsXmlString( + $expected, + $responseBody + ); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php index ab0ad295e..fa67102cc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php @@ -1,6 +1,7 @@ <?php namespace Sabre\DAV; + use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; @@ -28,13 +29,13 @@ class ServerPluginTest extends AbstractServer { function testBaseClass() { $p = new ServerPluginMock(); - $this->assertEquals([],$p->getFeatures()); - $this->assertEquals([],$p->getHTTPMethods('')); + $this->assertEquals([], $p->getFeatures()); + $this->assertEquals([], $p->getHTTPMethods('')); $this->assertEquals( [ - 'name' => 'Sabre\DAV\ServerPluginMock', + 'name' => 'Sabre\DAV\ServerPluginMock', 'description' => null, - 'link' => null + 'link' => null ], $p->getPluginInfo() ); @@ -42,34 +43,34 @@ class ServerPluginTest extends AbstractServer { function testOptions() { - $serverVars = array( + $serverVars = [ 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'OPTIONS', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(array( + $this->assertEquals([ 'DAV' => ['1, 3, extended-mkcol, drinking'], 'MS-Author-Via' => ['DAV'], 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], 'Accept-Ranges' => ['bytes'], 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertEquals('OPTIONS',$this->testPlugin->beforeMethod); + $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod); } function testGetPlugin() { - $this->assertEquals($this->testPlugin,$this->server->getPlugin(get_class($this->testPlugin))); + $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin))); } @@ -81,17 +82,17 @@ class ServerPluginTest extends AbstractServer { function testGetSupportedReportSet() { - $this->assertEquals(array(), $this->testPlugin->getSupportedReportSet('/')); + $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/')); } function testGetPlugins() { $this->assertEquals( - array( + [ get_class($this->testPlugin) => $this->testPlugin, - 'core' => $this->server->getPlugin('core'), - ), + 'core' => $this->server->getPlugin('core'), + ], $this->server->getPlugins() ); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php index 1dc8d8a37..203cf26d9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php @@ -13,7 +13,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchNoNode() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); @@ -25,7 +25,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchHasNode() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); @@ -38,7 +38,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchWrongEtag() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '1234']); $httpResponse = new HTTP\Response(); @@ -50,7 +50,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchCorrectEtag() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); @@ -65,7 +65,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchEvolutionEtag() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '\\"abc123\\"']); $httpResponse = new HTTP\Response(); @@ -77,7 +77,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfMatchMultiple() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"hellothere", "abc123"']); $httpResponse = new HTTP\Response(); @@ -89,7 +89,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfNoneMatchNoNode() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); @@ -102,7 +102,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfNoneMatchHasNode() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); @@ -114,7 +114,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfNoneMatchWrongEtag() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234"']); $httpResponse = new HTTP\Response(); @@ -126,7 +126,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { */ function testIfNoneMatchWrongEtagMultiple() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234", "5678"']); $httpResponse = new HTTP\Response(); @@ -137,9 +137,9 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\PreconditionFailed */ - public function testIfNoneMatchCorrectEtag() { + function testIfNoneMatchCorrectEtag() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); @@ -150,9 +150,9 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\PreconditionFailed */ - public function testIfNoneMatchCorrectEtagMultiple() { + function testIfNoneMatchCorrectEtagMultiple() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234, "abc123"']); $httpResponse = new HTTP\Response(); @@ -162,9 +162,9 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfNoneMatchCorrectEtagAsGet() { + function testIfNoneMatchCorrectEtagAsGet() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-None-Match' => '"abc123"']); $server->httpResponse = new HTTP\ResponseMock(); @@ -178,9 +178,9 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** * This was a test written for issue #515. */ - public function testNoneMatchCorrectEtagEnsureSapiSent() { + function testNoneMatchCorrectEtagEnsureSapiSent() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $server->sapi = new HTTP\SapiMock(); HTTP\SapiMock::$sent = 0; @@ -193,7 +193,7 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->getStatus()); $this->assertEquals([ - 'ETag' => ['"abc123"'], + 'ETag' => ['"abc123"'], 'X-Sabre-Version' => [Version::VERSION], ], $server->httpResponse->getHeaders()); $this->assertEquals(1, HTTP\SapiMock::$sent); @@ -202,35 +202,35 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfModifiedSinceUnModified() { + function testIfModifiedSinceUnModified() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $server->httpResponse = new HTTP\ResponseMock(); $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'Last-Modified' => ['Sat, 06 Apr 1985 23:30:00 GMT'], - ), $server->httpResponse->getHeaders()); + ], $server->httpResponse->getHeaders()); } /** */ - public function testIfModifiedSinceModified() { + function testIfModifiedSinceModified() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_MODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); @@ -239,14 +239,14 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfModifiedSinceInvalidDate() { + function testIfModifiedSinceInvalidDate() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_MODIFIED_SINCE' => 'Your mother', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\ResponseMock(); // Invalid dates must be ignored, so this should return true @@ -256,14 +256,14 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfModifiedSinceInvalidDate2() { + function testIfModifiedSinceInvalidDate2() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 EST', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); @@ -272,14 +272,14 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfUnmodifiedSinceUnModified() { + function testIfUnmodifiedSinceUnModified() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); @@ -289,14 +289,14 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\PreconditionFailed */ - public function testIfUnmodifiedSinceModified() { + function testIfUnmodifiedSinceModified() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_UNMODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\ResponseMock(); $server->checkPreconditions($httpRequest, $httpResponse); @@ -304,14 +304,14 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { /** */ - public function testIfUnmodifiedSinceInvalidDate() { + function testIfUnmodifiedSinceInvalidDate() { - $root = new SimpleCollection('root',array(new ServerPreconditionsNode())); + $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET', - 'REQUEST_URI' => '/foo' - )); + 'REQUEST_URI' => '/foo' + ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php index 66dde9db8..043179a00 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php @@ -463,7 +463,7 @@ class ServerSimpleTest extends AbstractServer{ * There are certain cases where no HTTP status may be set. We need to * intercept these and set it to a default error message. */ - function testNoHTTPSTatusSet() { + function testNoHTTPStatusSet() { $this->server->on('method:GET', function() { return false; }, 1); $this->server->httpRequest = new HTTP\Request('GET', '/'); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php index 7fde11b22..383f8e657 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php @@ -1,101 +1,100 @@ <?php namespace Sabre\DAV; -use Sabre\HTTP; class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { function testUpdatePropertiesFail() { - $tree = array( + $tree = [ new SimpleCollection('foo'), - ); + ]; $server = new Server($tree); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}foo' => 'bar' - )); + ]); - $expected = array( + $expected = [ '{DAV:}foo' => 403, - ); + ]; $this->assertEquals($expected, $result); } function testUpdatePropertiesProtected() { - $tree = array( + $tree = [ new SimpleCollection('foo'), - ); + ]; $server = new Server($tree); $server->on('propPatch', function($path, PropPatch $propPatch) { $propPatch->handleRemaining(function() { return true; }); }); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}getetag' => 'bla', - '{DAV:}foo' => 'bar' - )); + '{DAV:}foo' => 'bar' + ]); - $expected = array( + $expected = [ '{DAV:}getetag' => 403, - '{DAV:}foo' => 424, - ); + '{DAV:}foo' => 424, + ]; $this->assertEquals($expected, $result); } function testUpdatePropertiesEventFail() { - $tree = array( + $tree = [ new SimpleCollection('foo'), - ); + ]; $server = new Server($tree); $server->on('propPatch', function($path, PropPatch $propPatch) { $propPatch->setResultCode('{DAV:}foo', 404); $propPatch->handleRemaining(function() { return true; }); }); - $result = $server->updateProperties('foo', array( - '{DAV:}foo' => 'bar', + $result = $server->updateProperties('foo', [ + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', - )); + ]); - $expected = array( - '{DAV:}foo' => 404, + $expected = [ + '{DAV:}foo' => 404, '{DAV:}foo2' => 424, - ); + ]; $this->assertEquals($expected, $result); } function testUpdatePropertiesEventSuccess() { - $tree = array( + $tree = [ new SimpleCollection('foo'), - ); + ]; $server = new Server($tree); $server->on('propPatch', function($path, PropPatch $propPatch) { $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function() { return [ - '{DAV:}foo' => 200, + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, ]; }); }); - $result = $server->updateProperties('foo', array( - '{DAV:}foo' => 'bar', + $result = $server->updateProperties('foo', [ + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', - )); + ]); - $expected = array( - '{DAV:}foo' => 200, + $expected = [ + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, - ); + ]; $this->assertEquals($expected, $result); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php index 9b083b998..15ccfaf9e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php @@ -6,7 +6,7 @@ class SimpleFileTest extends \PHPUnit_Framework_TestCase { function testAll() { - $file = new SimpleFile('filename.txt','contents','text/plain'); + $file = new SimpleFile('filename.txt', 'contents', 'text/plain'); $this->assertEquals('filename.txt', $file->getName()); $this->assertEquals('contents', $file->get()); diff --git a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php index 941d1f913..8888f0276 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php @@ -15,61 +15,61 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { function dataset() { - return array( - array('FOOBAR', 'FOO', 'i;octet', 'contains', true), - array('FOOBAR', 'foo', 'i;octet', 'contains', false), - array('FÖÖBAR', 'FÖÖ', 'i;octet', 'contains', true), - array('FÖÖBAR', 'föö', 'i;octet', 'contains', false), - array('FOOBAR', 'FOOBAR', 'i;octet', 'equals', true), - array('FOOBAR', 'fooBAR', 'i;octet', 'equals', false), - array('FOOBAR', 'FOO', 'i;octet', 'starts-with', true), - array('FOOBAR', 'foo', 'i;octet', 'starts-with', false), - array('FOOBAR', 'BAR', 'i;octet', 'starts-with', false), - array('FOOBAR', 'bar', 'i;octet', 'starts-with', false), - array('FOOBAR', 'FOO', 'i;octet', 'ends-with', false), - array('FOOBAR', 'foo', 'i;octet', 'ends-with', false), - array('FOOBAR', 'BAR', 'i;octet', 'ends-with', true), - array('FOOBAR', 'bar', 'i;octet', 'ends-with', false), - - array('FOOBAR', 'FOO', 'i;ascii-casemap', 'contains', true), - array('FOOBAR', 'foo', 'i;ascii-casemap', 'contains', true), - array('FÖÖBAR', 'FÖÖ', 'i;ascii-casemap', 'contains', true), - array('FÖÖBAR', 'föö', 'i;ascii-casemap', 'contains', false), - array('FOOBAR', 'FOOBAR', 'i;ascii-casemap', 'equals', true), - array('FOOBAR', 'fooBAR', 'i;ascii-casemap', 'equals', true), - array('FOOBAR', 'FOO', 'i;ascii-casemap', 'starts-with', true), - array('FOOBAR', 'foo', 'i;ascii-casemap', 'starts-with', true), - array('FOOBAR', 'BAR', 'i;ascii-casemap', 'starts-with', false), - array('FOOBAR', 'bar', 'i;ascii-casemap', 'starts-with', false), - array('FOOBAR', 'FOO', 'i;ascii-casemap', 'ends-with', false), - array('FOOBAR', 'foo', 'i;ascii-casemap', 'ends-with', false), - array('FOOBAR', 'BAR', 'i;ascii-casemap', 'ends-with', true), - array('FOOBAR', 'bar', 'i;ascii-casemap', 'ends-with', true), - - array('FOOBAR', 'FOO', 'i;unicode-casemap', 'contains', true), - array('FOOBAR', 'foo', 'i;unicode-casemap', 'contains', true), - array('FÖÖBAR', 'FÖÖ', 'i;unicode-casemap', 'contains', true), - array('FÖÖBAR', 'föö', 'i;unicode-casemap', 'contains', true), - array('FOOBAR', 'FOOBAR', 'i;unicode-casemap', 'equals', true), - array('FOOBAR', 'fooBAR', 'i;unicode-casemap', 'equals', true), - array('FOOBAR', 'FOO', 'i;unicode-casemap', 'starts-with', true), - array('FOOBAR', 'foo', 'i;unicode-casemap', 'starts-with', true), - array('FOOBAR', 'BAR', 'i;unicode-casemap', 'starts-with', false), - array('FOOBAR', 'bar', 'i;unicode-casemap', 'starts-with', false), - array('FOOBAR', 'FOO', 'i;unicode-casemap', 'ends-with', false), - array('FOOBAR', 'foo', 'i;unicode-casemap', 'ends-with', false), - array('FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true), - array('FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true), - ); + return [ + ['FOOBAR', 'FOO', 'i;octet', 'contains', true], + ['FOOBAR', 'foo', 'i;octet', 'contains', false], + ['FÖÖBAR', 'FÖÖ', 'i;octet', 'contains', true], + ['FÖÖBAR', 'föö', 'i;octet', 'contains', false], + ['FOOBAR', 'FOOBAR', 'i;octet', 'equals', true], + ['FOOBAR', 'fooBAR', 'i;octet', 'equals', false], + ['FOOBAR', 'FOO', 'i;octet', 'starts-with', true], + ['FOOBAR', 'foo', 'i;octet', 'starts-with', false], + ['FOOBAR', 'BAR', 'i;octet', 'starts-with', false], + ['FOOBAR', 'bar', 'i;octet', 'starts-with', false], + ['FOOBAR', 'FOO', 'i;octet', 'ends-with', false], + ['FOOBAR', 'foo', 'i;octet', 'ends-with', false], + ['FOOBAR', 'BAR', 'i;octet', 'ends-with', true], + ['FOOBAR', 'bar', 'i;octet', 'ends-with', false], + + ['FOOBAR', 'FOO', 'i;ascii-casemap', 'contains', true], + ['FOOBAR', 'foo', 'i;ascii-casemap', 'contains', true], + ['FÖÖBAR', 'FÖÖ', 'i;ascii-casemap', 'contains', true], + ['FÖÖBAR', 'föö', 'i;ascii-casemap', 'contains', false], + ['FOOBAR', 'FOOBAR', 'i;ascii-casemap', 'equals', true], + ['FOOBAR', 'fooBAR', 'i;ascii-casemap', 'equals', true], + ['FOOBAR', 'FOO', 'i;ascii-casemap', 'starts-with', true], + ['FOOBAR', 'foo', 'i;ascii-casemap', 'starts-with', true], + ['FOOBAR', 'BAR', 'i;ascii-casemap', 'starts-with', false], + ['FOOBAR', 'bar', 'i;ascii-casemap', 'starts-with', false], + ['FOOBAR', 'FOO', 'i;ascii-casemap', 'ends-with', false], + ['FOOBAR', 'foo', 'i;ascii-casemap', 'ends-with', false], + ['FOOBAR', 'BAR', 'i;ascii-casemap', 'ends-with', true], + ['FOOBAR', 'bar', 'i;ascii-casemap', 'ends-with', true], + + ['FOOBAR', 'FOO', 'i;unicode-casemap', 'contains', true], + ['FOOBAR', 'foo', 'i;unicode-casemap', 'contains', true], + ['FÖÖBAR', 'FÖÖ', 'i;unicode-casemap', 'contains', true], + ['FÖÖBAR', 'föö', 'i;unicode-casemap', 'contains', true], + ['FOOBAR', 'FOOBAR', 'i;unicode-casemap', 'equals', true], + ['FOOBAR', 'fooBAR', 'i;unicode-casemap', 'equals', true], + ['FOOBAR', 'FOO', 'i;unicode-casemap', 'starts-with', true], + ['FOOBAR', 'foo', 'i;unicode-casemap', 'starts-with', true], + ['FOOBAR', 'BAR', 'i;unicode-casemap', 'starts-with', false], + ['FOOBAR', 'bar', 'i;unicode-casemap', 'starts-with', false], + ['FOOBAR', 'FOO', 'i;unicode-casemap', 'ends-with', false], + ['FOOBAR', 'foo', 'i;unicode-casemap', 'ends-with', false], + ['FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true], + ['FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true], + ]; } /** * @expectedException Sabre\DAV\Exception\BadRequest */ - public function testBadCollation() { + function testBadCollation() { - StringUtil::textMatch('foobar','foo','blabla','contains'); + StringUtil::textMatch('foobar', 'foo', 'blabla', 'contains'); } @@ -77,13 +77,13 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception\BadRequest */ - public function testBadMatchType() { + function testBadMatchType() { - StringUtil::textMatch('foobar','foo','i;octet','booh'); + StringUtil::textMatch('foobar', 'foo', 'i;octet', 'booh'); } - public function testEnsureUTF8_ascii() { + function testEnsureUTF8_ascii() { $inputString = "harkema"; $outputString = "harkema"; @@ -95,7 +95,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { } - public function testEnsureUTF8_latin1() { + function testEnsureUTF8_latin1() { $inputString = "m\xfcnster"; $outputString = "münster"; @@ -107,7 +107,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { } - public function testEnsureUTF8_utf8() { + function testEnsureUTF8_utf8() { $inputString = "m\xc3\xbcnster"; $outputString = "münster"; diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php index 7122f4a01..6acd6b077 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php @@ -25,7 +25,7 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(201, $this->response->status); $this->assertEquals('0', $this->response->getHeader('Content-Length')); - $this->assertEquals('Testing new file',file_get_contents(SABRE_TEMPDIR . '/testput.txt')); + $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR . '/testput.txt')); } @@ -39,11 +39,11 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals('', $this->response->body); $this->assertEquals(201, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.'); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); } @@ -57,20 +57,20 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals('', $this->response->body); $this->assertEquals(201, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.'); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); $this->server->exec(); $this->assertEquals(412, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); } @@ -83,9 +83,9 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals('', $this->response->body); $this->assertEquals(201, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); $request = new HTTP\Request('GET', '/._testput.txt'); @@ -93,13 +93,13 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->exec(); $this->assertEquals(200, $this->response->status); - $this->assertEquals(array( - 'X-Sabre-Temp' => ['true'], + $this->assertEquals([ + 'X-Sabre-Temp' => ['true'], 'Content-Length' => [16], - 'Content-Type' => ['application/octet-stream'], - ),$this->response->getHeaders()); + 'Content-Type' => ['application/octet-stream'], + ], $this->response->getHeaders()); - $this->assertEquals('Testing new file',stream_get_contents($this->response->body)); + $this->assertEquals('Testing new file', stream_get_contents($this->response->body)); } @@ -125,11 +125,11 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->exec(); $this->assertEquals(201, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8',$this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->getHeader('Lock-Token'))===1,'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); - $this->assertEquals('true',$this->response->getHeader('X-Sabre-Temp')); + $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); + $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertEquals('true', $this->response->getHeader('X-Sabre-Temp')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'),'._testlock.txt should not exist in the regular file structure.'); + $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); } @@ -143,20 +143,20 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals('', $this->response->body); $this->assertEquals(201, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); $request = new HTTP\Request('DELETE', '/._testput.txt'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n". $this->response->body); - $this->assertEquals(array( + $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n" . $this->response->body); + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); - $this->assertEquals('',$this->response->body); + $this->assertEquals('', $this->response->body); } @@ -169,30 +169,30 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals('', $this->response->body); $this->assertEquals(201, $this->response->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); $request = new HTTP\Request('PROPFIND', '/._testput.txt'); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status,'Incorrect status code returned. Body: ' . $this->response->body); - $this->assertEquals(array( + $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: ' . $this->response->body); + $this->assertEquals([ 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], - ),$this->response->getHeaders()); + ], $this->response->getHeaders()); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/","xmlns\\1=\"urn:DAV\"",$this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d','urn:DAV'); + $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/._testput.txt',(string)$data,'href element should have been /._testput.txt'); + $this->assertEquals('/._testput.txt', (string)$data, 'href element should have been /._testput.txt'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); - $this->assertEquals(1,count($data)); + $this->assertEquals(1, count($data)); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php index bb5ea6acc..619ac03fd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php @@ -2,9 +2,8 @@ namespace Sabre\DAV; -use - Sabre\HTTP\RequestInterface, - Sabre\HTTP\ResponseInterface; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class TestPlugin extends ServerPlugin { @@ -24,7 +23,7 @@ class TestPlugin extends ServerPlugin { function initialize(Server $server) { - $server->on('beforeMethod', [$this,'beforeMethod']); + $server->on('beforeMethod', [$this, 'beforeMethod']); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php index 9516c2390..ad33200c8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php @@ -16,18 +16,18 @@ class TreeTest extends \PHPUnit_Framework_TestCase { function testCopy() { $tree = new TreeMock(); - $tree->copy('hi','hi2'); + $tree->copy('hi', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); - $this->assertEquals(array('test1'=>'value'), $tree->getNodeForPath('hi/file')->getProperties(array())); + $this->assertEquals(['test1' => 'value'], $tree->getNodeForPath('hi/file')->getProperties([])); } function testMove() { $tree = new TreeMock(); - $tree->move('hi','hi2'); + $tree->move('hi', 'hi2'); $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); @@ -37,7 +37,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase { function testDeepMove() { $tree = new TreeMock(); - $tree->move('hi/sub','hi2'); + $tree->move('hi/sub', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); @@ -56,7 +56,7 @@ class TreeTest extends \PHPUnit_Framework_TestCase { $tree = new TreeMock(); $children = $tree->getChildren(''); - $this->assertEquals(2,count($children)); + $this->assertEquals(2, count($children)); $this->assertEquals('hi', $children[0]->getName()); } @@ -85,12 +85,12 @@ class TreeTest extends \PHPUnit_Framework_TestCase { class TreeMock extends Tree { - private $nodes = array(); + private $nodes = []; function __construct() { $file = new TreeFileTester('file'); - $file->properties = ['test1'=>'value']; + $file->properties = ['test1' => 'value']; $file->data = 'foobar'; parent::__construct( @@ -113,8 +113,8 @@ class TreeMock extends Tree { class TreeDirectoryTester extends SimpleCollection { - public $newDirectories = array(); - public $newFiles = array(); + public $newDirectories = []; + public $newFiles = []; public $isDeleted = false; public $isRenamed = false; @@ -124,7 +124,7 @@ class TreeDirectoryTester extends SimpleCollection { } - function createFile($name,$data = null) { + function createFile($name, $data = null) { $this->newFiles[$name] = $data; @@ -132,7 +132,7 @@ class TreeDirectoryTester extends SimpleCollection { function getChild($name) { - if (isset($this->newDirectories[$name])) return new TreeDirectoryTester($name); + if (isset($this->newDirectories[$name])) return new self($name); if (isset($this->newFiles[$name])) return new TreeFileTester($name, $this->newFiles[$name]); return parent::getChild($name); @@ -225,7 +225,7 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { function getMultipleChildren(array $paths) { $result = []; - foreach($paths as $path) { + foreach ($paths as $path) { try { $child = $this->getChild($path); $result[] = $child; diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php index 4ecd42717..7d7a54d06 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php @@ -14,6 +14,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $acl = new Plugin(); $server = new DAV\Server(); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpAcl($server->httpRequest, $server->httpResponse); @@ -21,15 +22,14 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { } /** - - /** + /** * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ function testNotSupportedByNode() { - $tree = array( + $tree = [ new DAV\SimpleCollection('test'), - ); + ]; $acl = new Plugin(); $server = new DAV\Server($tree); $server->httpRequest = new HTTP\Request(); @@ -37,6 +37,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { <d:acl xmlns:d="DAV:"> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -45,9 +46,9 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { function testSuccessSimple() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); $server->httpRequest = new HTTP\Request(); @@ -57,6 +58,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { <d:acl xmlns:d="DAV:"> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $this->assertFalse($acl->httpACL($server->httpRequest, $server->httpResponse)); @@ -68,12 +70,12 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnrecognizedPrincipal() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -82,6 +84,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -93,15 +96,15 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnrecognizedPrincipal2() { - $tree = array( - new MockACLNode('test',array()), - new DAV\SimpleCollection('principals',array( + $tree = [ + new MockACLNode('test', []), + new DAV\SimpleCollection('principals', [ new DAV\SimpleCollection('notaprincipal'), - )), - ); + ]), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -110,6 +113,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -121,12 +125,12 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnknownPrivilege() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -135,6 +139,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -146,20 +151,24 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testAbstractPrivilege() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->on('getSupportedPrivilegeSet', function($node, &$supportedPrivilegeSet) { + $supportedPrivilegeSet['{DAV:}foo'] = ['abstract' => true]; + }); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> - <d:grant><d:privilege><d:all /></d:privilege></d:grant> - <d:principal><d:href>/principals/notfound</d:href></d:principal> + <d:grant><d:privilege><d:foo /></d:privilege></d:grant> + <d:principal><d:href>/principals/foo/</d:href></d:principal> </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -171,20 +180,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -193,6 +202,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -204,20 +214,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege2() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -226,6 +236,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -237,20 +248,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege3() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -259,6 +270,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -267,28 +279,28 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { function testSuccessComplex() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true, - ), - array( + ], + [ 'principal' => 'principals/bar', 'privilege' => '{DAV:}read', - ), - ); - - $tree = array( - $node = new MockACLNode('test',$oldACL), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('foo','principals/foo'), - new MockPrincipal('baz','principals/baz'), - )), - ); + ], + ]; + + $tree = [ + $node = new MockACLNode('test', $oldACL), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('foo', 'principals/foo'), + new MockPrincipal('baz', 'principals/baz'), + ]), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> <d:ace> @@ -302,23 +314,24 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { </d:ace> </d:acl>'; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse)); - $this->assertEquals(array( - array( + $this->assertEquals([ + [ 'principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true, - ), - array( + ], + [ 'principal' => 'principals/baz', 'privilege' => '{DAV:}write', 'protected' => false, - ), - ), $node->getACL()); + ], + ], $node->getACL()); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php index 14a80003a..f16693625 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php @@ -3,7 +3,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class AllowAccessTest extends \PHPUnit_Framework_TestCase { @@ -14,13 +13,24 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { function setUp() { - $nodes = array( - new DAV\SimpleCollection('testdir'), - ); + $nodes = [ + new DAV\Mock\Collection('testdir', [ + 'file1.txt' => 'contents', + ]), + ]; $this->server = new DAV\Server($nodes); + $this->server->addPlugin( + new DAV\Auth\Plugin( + new DAV\Auth\Backend\Mock() + ) + ); + // Login + $this->server->getPlugin('auth')->beforeMethod( + new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Response() + ); $aclPlugin = new Plugin(); - $aclPlugin->allowAccessToNodesWithoutACL = true; $this->server->addPlugin($aclPlugin); } @@ -64,16 +74,7 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { function testPUT() { $this->server->httpRequest->setMethod('PUT'); - $this->server->httpRequest->setUrl('/testdir'); - - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - - } - - function testACL() { - - $this->server->httpRequest->setMethod('ACL'); - $this->server->httpRequest->setUrl('/testdir'); + $this->server->httpRequest->setUrl('/testdir/file1.txt'); $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php index be3e9dae9..ceae9aed0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php @@ -3,7 +3,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class BlockAccessTest extends \PHPUnit_Framework_TestCase { @@ -21,7 +20,17 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { $this->server = new DAV\Server($nodes); $this->plugin = new Plugin(); - $this->plugin->allowAccessToNodesWithoutACL = false; + $this->plugin->setDefaultAcl([]); + $this->server->addPlugin( + new DAV\Auth\Plugin( + new DAV\Auth\Backend\Mock() + ) + ); + // Login + $this->server->getPlugin('auth')->beforeMethod( + new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Response() + ); $this->server->addPlugin($this->plugin); } @@ -178,10 +187,10 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { 200 => [], 404 => [], 403 => [ - '{DAV:}displayname' => null, + '{DAV:}displayname' => null, '{DAV:}getcontentlength' => null, - '{DAV:}bar' => null, - '{DAV:}owner' => null, + '{DAV:}bar' => null, + '{DAV:}owner' => null, ], ]; diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php index fc48af67f..1cdf2949f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php @@ -11,24 +11,24 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $ex = new AceConflict('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:no-ace-conflict' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php index 7e66adab6..b13e7722d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php @@ -4,41 +4,41 @@ namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NeedPrivilegesTest extends \PHPUnit_Framework_TestCase { +class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { function testSerialize() { $uri = 'foo'; - $privileges = array( + $privileges = [ '{DAV:}read', '{DAV:}write', - ); + ]; $ex = new NeedPrivileges($uri, $privileges); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, - '/d:root/d:need-privileges' => 1, - '/d:root/d:need-privileges/d:resource' => 2, - '/d:root/d:need-privileges/d:resource/d:href' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, + $xpaths = [ + '/d:root' => 1, + '/d:root/d:need-privileges' => 1, + '/d:root/d:need-privileges/d:resource' => 2, + '/d:root/d:need-privileges/d:resource/d:href' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php index 2406c1c38..f52b17371 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php @@ -11,24 +11,24 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $ex = new NoAbstract('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:no-abstract' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php index 6077b0ba5..df89aaf84 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php @@ -11,24 +11,24 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $ex = new NotRecognizedPrincipal('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:recognized-principal' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php index 8e7b3685d..50623952b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php @@ -11,24 +11,24 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $ex = new NotSupportedPrivilege('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:not-supported-privilege' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php index 5e99f2e73..0612b5474 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php @@ -11,31 +11,31 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { function getServer() { - $tree = array( - new DAV\Mock\PropertiesCollection('node1', [], array( + $tree = [ + new DAV\Mock\PropertiesCollection('node1', [], [ '{http://sabredav.org/ns}simple' => 'foo', '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), - '{DAV:}displayname' => 'Node 1', - )), - new DAV\Mock\PropertiesCollection('node2', [], array( + '{DAV:}displayname' => 'Node 1', + ]), + new DAV\Mock\PropertiesCollection('node2', [], [ + '{http://sabredav.org/ns}simple' => 'simple', + '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']), + '{DAV:}displayname' => 'Node 2', + ]), + new DAV\Mock\PropertiesCollection('node3', [], [ '{http://sabredav.org/ns}simple' => 'simple', - '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1','node3']), - '{DAV:}displayname' => 'Node 2', - )), - new DAV\Mock\PropertiesCollection('node3', [], array( - '{http://sabredav.org/ns}simple' => 'simple', - '{DAV:}displayname' => 'Node 3', - )), - ); + '{DAV:}displayname' => 'Node 3', + ]), + ]; $fakeServer = new DAV\Server($tree); $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->debugExceptions = true; $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin(); - $plugin->allowAccessToNodesWithoutACL = true; - + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); + $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); @@ -53,11 +53,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { <d:property name="href" namespace="http://sabredav.org/ns" /> </d:expand-property>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node1', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -67,38 +67,38 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status,'Incorrect status code received. Full body: ' . $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: ' . $server->httpResponse->body); + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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: ' . $server->httpResponse->body); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body); } @@ -116,11 +116,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { </d:property> </d:expand-property>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node1', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -131,39 +131,39 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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->getBodyAsString()); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . ' Full response body: ' . $server->httpResponse->getBodyAsString()); } @@ -181,11 +181,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { </d:property> </d:expand-property>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node2', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -196,39 +196,39 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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)); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); } @@ -249,11 +249,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { </d:property> </d:expand-property>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node2', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -264,45 +264,45 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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)); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php index 7b3e8fc12..2d9744e29 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php @@ -3,14 +3,13 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class MockACLNode extends DAV\Node implements IACL { public $name; public $acl; - function __construct($name, array $acl = array()) { + function __construct($name, array $acl = []) { $this->name = $name; $this->acl = $acl; diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php index dd8542b8d..934906802 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php @@ -3,16 +3,15 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class MockPrincipal extends DAV\Node implements IPrincipal { public $name; public $principalUrl; - public $groupMembership = array(); - public $groupMemberSet = array(); + public $groupMembership = []; + public $groupMemberSet = []; - function __construct($name,$principalUrl,array $groupMembership = array(), array $groupMemberSet = array()) { + function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) { $this->name = $name; $this->principalUrl = $principalUrl; @@ -35,7 +34,7 @@ class MockPrincipal extends DAV\Node implements IPrincipal { function getAlternateUriSet() { - return array(); + return []; } @@ -63,4 +62,3 @@ class MockPrincipal extends DAV\Node implements IPrincipal { } } - diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php index fb7516a78..8552448f5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php @@ -5,7 +5,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; - require_once 'Sabre/DAVACL/MockACLNode.php'; require_once 'Sabre/HTTP/ResponseMock.php'; @@ -17,10 +16,10 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $principalBackend = new PrincipalBackend\Mock(); - $tree = array( - new MockACLNode('adminonly', array()), + $tree = [ + new MockACLNode('adminonly', []), new PrincipalCollection($principalBackend), - ); + ]; $this->server = new DAV\Server($tree); $this->server->sapi = new HTTP\SapiMock(); @@ -33,11 +32,11 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $plugin = new Plugin(); $this->server->addPlugin($plugin); - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', - )); + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', + ]); $response = new HTTP\ResponseMock(); @@ -56,16 +55,16 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { function testAdminAccess() { $plugin = new Plugin(); - $plugin->adminPrincipals = array( + $plugin->adminPrincipals = [ 'principals/admin', - ); + ]; $this->server->addPlugin($plugin); - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', - )); + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', + ]); $response = new HTTP\ResponseMock(); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php index e5b7e1a3f..5762ac902 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php @@ -10,6 +10,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testPrincipalCollectionSet() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $plugin->principalCollectionSet = [ 'principals1', 'principals2', @@ -25,8 +26,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}principal-collection-set',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}principal-collection-set', $result[200]); $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-collection-set']); $expected = [ @@ -56,8 +57,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]); $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType()); @@ -67,8 +68,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]); $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType()); $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref()); @@ -78,6 +79,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testSupportedPrivilegeSet() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($plugin); @@ -88,8 +90,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}supported-privilege-set',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}supported-privilege-set', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']); $server = new DAV\Server(); @@ -98,26 +100,25 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->xml->write('{DAV:}root', $prop); $xpaths = [ - '/d:root' => 1, - '/d:root/d:supported-privilege' => 1, - '/d:root/d:supported-privilege/d:privilege' => 1, - '/d:root/d:supported-privilege/d:privilege/d:all' => 1, - '/d:root/d:supported-privilege/d:abstract' => 1, - '/d:root/d:supported-privilege/d:supported-privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, + '/d:root' => 1, + '/d:root/d:supported-privilege' => 1, + '/d:root/d:supported-privilege/d:privilege' => 1, + '/d:root/d:supported-privilege/d:privilege/d:all' => 1, + '/d:root/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, ]; @@ -126,10 +127,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $dom2->loadXML($result); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count. ' Full XML: ' . $result); + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count . ' Full XML: ' . $result); } @@ -138,6 +139,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testACL() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $nodes = [ new MockACLNode('foo', [ @@ -147,7 +149,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ] ]), new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('admin','principals/admin'), + $principal = new MockPrincipal('admin', 'principals/admin'), ]), ]; @@ -167,8 +169,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); - $this->assertArrayHasKey('{DAV:}acl',$result[200]); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertArrayHasKey('{DAV:}acl', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']); } @@ -176,6 +178,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testACLRestrictions() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $nodes = [ new MockACLNode('foo', [ @@ -185,7 +188,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ] ]), new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('admin','principals/admin'), + $principal = new MockPrincipal('admin', 'principals/admin'), ]), ]; @@ -205,8 +208,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); - $this->assertArrayHasKey('{DAV:}acl-restrictions',$result[200]); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']); } @@ -215,7 +218,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]) ]; @@ -223,6 +226,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()) //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -243,7 +247,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; @@ -251,6 +255,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()); //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -272,7 +277,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; @@ -280,6 +285,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()); //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -301,12 +307,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; $fakeServer = new DAV\Server($tree); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -328,12 +335,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; $fakeServer = new DAV\Server($tree); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php index 64cedd142..0147e6a61 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php @@ -3,28 +3,25 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; - - -require_once 'Sabre/DAVACL/MockPrincipal.php'; class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { function testUpdatePropertiesPassthrough() { - $tree = array( + $tree = [ new DAV\SimpleCollection('foo'), - ); + ]; $server = new DAV\Server($tree); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin(new Plugin()); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}foo' => 'bar', - )); + ]); - $expected = array( + $expected = [ '{DAV:}foo' => 403, - ); + ]; $this->assertEquals($expected, $result); @@ -32,35 +29,39 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { function testRemoveGroupMembers() { - $tree = array( - new MockPrincipal('foo','foo'), - ); + $tree = [ + new MockPrincipal('foo', 'foo'), + ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => null, - )); + ]); - $expected = array( + $expected = [ '{DAV:}group-member-set' => 204 - ); + ]; $this->assertEquals($expected, $result); - $this->assertEquals(array(),$tree[0]->getGroupMemberSet()); + $this->assertEquals([], $tree[0]->getGroupMemberSet()); } function testSetGroupMembers() { $tree = [ - new MockPrincipal('foo','foo'), + new MockPrincipal('foo', 'foo'), ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); $result = $server->updateProperties('foo', [ - '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar','/baz'], true), + '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], true), ]); $expected = [ @@ -68,7 +69,7 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - $this->assertEquals(['bar', 'baz'],$tree[0]->getGroupMemberSet()); + $this->assertEquals(['bar', 'baz'], $tree[0]->getGroupMemberSet()); } @@ -77,15 +78,17 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { */ function testSetBadValue() { - $tree = array( - new MockPrincipal('foo','foo'), - ); + $tree = [ + new MockPrincipal('foo', 'foo'), + ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => new \StdClass(), - )); + ]); } @@ -95,10 +98,12 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { new DAV\SimpleCollection('foo'), ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); $result = $server->updateProperties('foo', [ - '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar','/baz'],false), + '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], false), ]); $expected = [ diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php index 3814ebc0d..9fef3018d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php @@ -5,10 +5,24 @@ namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; use Sabre\HTTP; - abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - abstract function getPDO(); + use DAV\DbTestHelperTrait; + + function setUp() { + + $this->dropTables(['principals', 'groupmembers']); + $this->createSchema('principals'); + + $pdo = $this->getPDO(); + + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); + + $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)"); + + } + function testConstruct() { @@ -26,21 +40,26 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array( - array( - 'uri' => 'principals/user', + $expected = [ + [ + 'uri' => 'principals/admin', + '{http://sabredav.org/ns}email-address' => 'admin@example.org', + '{DAV:}displayname' => 'Administrator', + ], + [ + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', - ), - array( - 'uri' => 'principals/group', + '{DAV:}displayname' => 'User', + ], + [ + 'uri' => 'principals/group', '{http://sabredav.org/ns}email-address' => 'group@example.org', - '{DAV:}displayname' => 'Group', - ), - ); + '{DAV:}displayname' => 'Group', + ], + ]; $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); - $this->assertEquals(array(), $backend->getPrincipalsByPrefix('foo')); + $this->assertEquals([], $backend->getPrincipalsByPrefix('foo')); } @@ -52,12 +71,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array( - 'id' => 1, - 'uri' => 'principals/user', + $expected = [ + 'id' => 4, + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', - ); + '{DAV:}displayname' => 'User', + ]; $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); $this->assertEquals(null, $backend->getPrincipalByPath('foo')); @@ -68,9 +87,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array('principals/user'); + $expected = ['principals/user']; - $this->assertEquals($expected,$backend->getGroupMemberSet('principals/group')); + $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group')); } @@ -78,9 +97,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array('principals/group'); + $expected = ['principals/group']; - $this->assertEquals($expected,$backend->getGroupMembership('principals/user')); + $this->assertEquals($expected, $backend->getGroupMembership('principals/user')); } @@ -90,15 +109,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Start situation $backend = new PDO($pdo); - $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); // Removing all principals - $backend->setGroupMemberSet('principals/group', array()); - $this->assertEquals(array(), $backend->getGroupMemberSet('principals/group')); + $backend->setGroupMemberSet('principals/group', []); + $this->assertEquals([], $backend->getGroupMemberSet('principals/group')); // Adding principals again - $backend->setGroupMemberSet('principals/group', array('principals/user')); - $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + $backend->setGroupMemberSet('principals/group', ['principals/user']); + $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); } @@ -109,17 +128,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend = new PDO($pdo); - $result = $backend->searchPrincipals('principals', array('{DAV:}blabla' => 'foo')); - $this->assertEquals(array(), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}blabla' => 'foo']); + $this->assertEquals([], $result); - $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'ou')); - $this->assertEquals(array('principals/group'), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'ou']); + $this->assertEquals(['principals/group'], $result); - $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE')); - $this->assertEquals(array('principals/user'), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); + $this->assertEquals(['principals/user'], $result); - $result = $backend->searchPrincipals('mom', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE')); - $this->assertEquals(array(), $result); + $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); + $this->assertEquals([], $result); } @@ -137,12 +156,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($result); - $this->assertEquals(array( - 'id' => 1, - 'uri' => 'principals/user', - '{DAV:}displayname' => 'pietje', + $this->assertEquals([ + 'id' => 4, + 'uri' => 'principals/user', + '{DAV:}displayname' => 'pietje', '{http://sabredav.org/ns}email-address' => 'user@example.org', - ), $backend->getPrincipalByPath('principals/user')); + ], $backend->getPrincipalByPath('principals/user')); } @@ -153,7 +172,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $propPatch = new DAV\PropPatch([ '{DAV:}displayname' => 'pietje', - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updatePrincipal('principals/user', $propPatch); @@ -161,17 +180,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($result); - $this->assertEquals(array( + $this->assertEquals([ '{DAV:}displayname' => 424, - '{DAV:}unknown' => 403 - ), $propPatch->getResult()); + '{DAV:}unknown' => 403 + ], $propPatch->getResult()); - $this->assertEquals(array( - 'id' => '1', - 'uri' => 'principals/user', - '{DAV:}displayname' => 'User', + $this->assertEquals([ + 'id' => '4', + 'uri' => 'principals/user', + '{DAV:}displayname' => 'User', '{http://sabredav.org/ns}email-address' => 'user@example.org', - ), $backend->getPrincipalByPath('principals/user')); + ], $backend->getPrincipalByPath('principals/user')); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php index 83353c86c..8779eb69f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php @@ -2,49 +2,8 @@ namespace Sabre\DAVACL\PrincipalBackend; -use Sabre\DAV; -use Sabre\HTTP; - - -require_once 'Sabre/TestUtil.php'; - class PDOMySQLTest extends AbstractPDOTest { - function getPDO() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - $pdo->query("DROP TABLE IF EXISTS principals"); - $pdo->query(<<<SQL -create table principals ( - id integer unsigned not null primary key auto_increment, - uri varchar(50), - email varchar(80), - displayname VARCHAR(80), - vcardurl VARCHAR(80), - unique(uri) -) -SQL - ); - - $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); - $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); - $pdo->query("DROP TABLE IF EXISTS groupmembers"); - $pdo->query(<<<SQL -CREATE TABLE groupmembers ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principal_id INTEGER UNSIGNED NOT NULL, - member_id INTEGER UNSIGNED NOT NULL, - UNIQUE(principal_id, member_id) -) -SQL - ); - - $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); - - return $pdo; - - } + public $driver = 'mysql'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php index f335ed51f..48454981d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php @@ -2,44 +2,8 @@ namespace Sabre\DAVACL\PrincipalBackend; -use Sabre\DAV; -use Sabre\HTTP; +class PDOSqliteTest extends AbstractPDOTest { - -require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php'; - -class PDOSQLiteTest extends AbstractPDOTest { - - function tearDown() { - - if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend'); - if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2'); - - } - - function getPDO() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - $pdo->query('CREATE TABLE principals (id INTEGER PRIMARY KEY ASC, uri TEXT, email VARCHAR(80), displayname VARCHAR(80))'); - $pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User")'); - $pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group")'); - - $pdo->query(<<<SQL -CREATE TABLE groupmembers ( - id INTEGER PRIMARY KEY ASC, - principal_id INT, - member_id INT, - UNIQUE(principal_id, member_id) -) -SQL - ); - - $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); - - return $pdo; - - } + public $driver = 'sqlite'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php index f51d2dcce..bcf78821b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php @@ -2,26 +2,22 @@ namespace Sabre\DAVACL; -use Sabre\DAV; -use Sabre\HTTP; - - class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { - public function testBasic() { + function testBasic() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertTrue($pc instanceof PrincipalCollection); - $this->assertEquals('principals',$pc->getName()); + $this->assertEquals('principals', $pc->getName()); } /** * @depends testBasic */ - public function testGetChildren() { + function testGetChildren() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -29,7 +25,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { $children = $pc->getChildren(); $this->assertTrue(is_array($children)); - foreach($children as $child) { + foreach ($children as $child) { $this->assertTrue($child instanceof IPrincipal); } @@ -39,7 +35,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { * @depends testBasic * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ - public function testGetChildrenDisable() { + function testGetChildrenDisable() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -49,7 +45,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { } - public function testFindByUri() { + function testFindByUri() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php index 8e4c86782..60e156d9a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php @@ -23,6 +23,7 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $fakeServer->debugExceptions = true; $plugin = new MockPlugin(); $plugin->allowAccessToNodesWithoutACL = true; + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); @@ -48,11 +49,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '1', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -63,10 +64,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString()); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -87,11 +88,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -102,11 +103,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString()); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); } @@ -127,11 +128,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -142,36 +143,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 4, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -200,11 +201,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -215,36 +216,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 0, - '/d:multistatus/d:response/d:href' => 0, - '/d:multistatus/d:response/d:propstat' => 0, - '/d:multistatus/d:response/d:propstat/d:prop' => 0, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, + '/d:multistatus/d:response' => 0, + '/d:multistatus/d:response/d:href' => 0, + '/d:multistatus/d:response/d:propstat' => 0, + '/d:multistatus/d:response/d:propstat/d:prop' => 0, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0, - '/d:multistatus/d:response/d:propstat/d:status' => 0, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 0, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -272,11 +273,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -287,36 +288,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 4, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -337,11 +338,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { </d:prop> </d:principal-property-search>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -352,30 +353,30 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', '/d:multistatus/d:response' => 0, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -386,10 +387,10 @@ class MockPlugin extends Plugin { function getCurrentUserPrivilegeSet($node) { - return array( + return [ '{DAV:}read', '{DAV:}write', - ); + ]; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php index 952dc174a..fa1314d10 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -21,6 +21,7 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); @@ -34,11 +35,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:" />'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '1', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -49,10 +50,10 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -61,11 +62,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -76,10 +77,10 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -88,11 +89,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"/>'; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -103,34 +104,34 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/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' => 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, - ); + '/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) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php index 03fd9d64d..20622ad17 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php @@ -7,10 +7,10 @@ use Sabre\HTTP; class PrincipalTest extends \PHPUnit_Framework_TestCase { - public function testConstruct() { + function testConstruct() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertTrue($principal instanceof Principal); } @@ -18,65 +18,65 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception */ - public function testConstructNoUri() { + function testConstructNoUri() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array()); + $principal = new Principal($principalBackend, []); } - public function testGetName() { + function testGetName() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('admin',$principal->getName()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('admin', $principal->getName()); } - public function testGetDisplayName() { + function testGetDisplayName() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('admin',$principal->getDisplayname()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('admin', $principal->getDisplayname()); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', '{DAV:}displayname' => 'Mr. Admin' - )); - $this->assertEquals('Mr. Admin',$principal->getDisplayname()); + ]); + $this->assertEquals('Mr. Admin', $principal->getDisplayname()); } - public function testGetProperties() { + function testGetProperties() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - )); + ]); - $keys = array( + $keys = [ '{DAV:}displayname', '{http://www.example.org/custom}custom', '{http://sabredav.org/ns}email-address', - ); + ]; $props = $principal->getProperties($keys); - foreach($keys as $key) $this->assertArrayHasKey($key,$props); + foreach ($keys as $key) $this->assertArrayHasKey($key, $props); - $this->assertEquals('Mr. Admin',$props['{DAV:}displayname']); + $this->assertEquals('Mr. Admin', $props['{DAV:}displayname']); $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']); } - public function testUpdateProperties() { + function testUpdateProperties() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); - $propPatch = new DAV\PropPatch(array('{DAV:}yourmom' => 'test')); + $propPatch = new DAV\PropPatch(['{DAV:}yourmom' => 'test']); $result = $principal->propPatch($propPatch); $result = $propPatch->commit(); @@ -84,123 +84,123 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { } - public function testGetPrincipalUrl() { + function testGetPrincipalUrl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('principals/admin',$principal->getPrincipalUrl()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('principals/admin', $principal->getPrincipalUrl()); } - public function testGetAlternateUriSet() { + function testGetAlternateUriSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}alternate-URI-set' => array( + '{DAV:}alternate-URI-set' => [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', - ), - )); + ], + ]); - $expected = array( + $expected = [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', - ); + ]; - $this->assertEquals($expected,$principal->getAlternateUriSet()); + $this->assertEquals($expected, $principal->getAlternateUriSet()); } - public function testGetAlternateUriSetEmpty() { + function testGetAlternateUriSetEmpty() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( + $principal = new Principal($principalBackend, [ 'uri' => 'principals/admin', - )); + ]); - $expected = array(); + $expected = []; - $this->assertEquals($expected,$principal->getAlternateUriSet()); + $this->assertEquals($expected, $principal->getAlternateUriSet()); } - public function testGetGroupMemberSet() { + function testGetGroupMemberSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array(),$principal->getGroupMemberSet()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([], $principal->getGroupMemberSet()); } - public function testGetGroupMembership() { + function testGetGroupMembership() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array(),$principal->getGroupMembership()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([], $principal->getGroupMembership()); } - public function testSetGroupMemberSet() { + function testSetGroupMemberSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $principal->setGroupMemberSet(array('principals/foo')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $principal->setGroupMemberSet(['principals/foo']); - $this->assertEquals(array( - 'principals/admin' => array('principals/foo'), - ), $principalBackend->groupMembers); + $this->assertEquals([ + 'principals/admin' => ['principals/foo'], + ], $principalBackend->groupMembers); } - public function testGetOwner() { + function testGetOwner() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('principals/admin',$principal->getOwner()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('principals/admin', $principal->getOwner()); } - public function testGetGroup() { + function testGetGroup() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getGroup()); } - public function testGetACl() { + function testGetACl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array( - array( - 'privilege' => '{DAV:}read', - 'principal' => '{DAV:}authenticated', + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ) - ),$principal->getACL()); + ] + ], $principal->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\Forbidden */ - public function testSetACl() { + function testSetACl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $principal->setACL(array()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $principal->setACL([]); } - public function testGetSupportedPrivilegeSet() { + function testGetSupportedPrivilegeSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getSupportedPrivilegeSet()); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php index fb73cc16a..2de0ba6a8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php @@ -5,7 +5,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; - require_once 'Sabre/DAVACL/MockPrincipal.php'; require_once 'Sabre/DAVACL/MockACLNode.php'; @@ -14,21 +13,22 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testValues() { $aclPlugin = new Plugin(); - $this->assertEquals('acl',$aclPlugin->getPluginName()); + $this->assertEquals('acl', $aclPlugin->getPluginName()); $this->assertEquals( - array('access-control', 'calendarserver-principal-property-search'), + ['access-control', 'calendarserver-principal-property-search'], $aclPlugin->getFeatures() ); $this->assertEquals( - array( + [ '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set' - ), + ], $aclPlugin->getSupportedReportSet('')); - $this->assertEquals(array('ACL'), $aclPlugin->getMethods('')); + $this->assertEquals(['ACL'], $aclPlugin->getMethods('')); $this->assertEquals( @@ -39,90 +39,84 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testGetFlatPrivilegeSet() { - $expected = array( - '{DAV:}all' => array( - 'privilege' => '{DAV:}all', - 'abstract' => true, - 'aggregates' => array( + $expected = [ + '{DAV:}all' => [ + 'privilege' => '{DAV:}all', + 'abstract' => false, + 'aggregates' => [ '{DAV:}read', '{DAV:}write', - ), - 'concrete' => null, - ), - '{DAV:}read' => array( - 'privilege' => '{DAV:}read', - 'abstract' => false, - 'aggregates' => array( + ], + 'concrete' => '{DAV:}all', + ], + '{DAV:}read' => [ + 'privilege' => '{DAV:}read', + 'abstract' => false, + 'aggregates' => [ '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', - ), + ], 'concrete' => '{DAV:}read', - ), - '{DAV:}read-acl' => array( - 'privilege' => '{DAV:}read-acl', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}read-acl', - ), - '{DAV:}read-current-user-privilege-set' => array( - 'privilege' => '{DAV:}read-current-user-privilege-set', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}read-current-user-privilege-set', - ), - '{DAV:}write' => array( - 'privilege' => '{DAV:}write', - 'abstract' => false, - 'aggregates' => array( - '{DAV:}write-acl', + ], + '{DAV:}read-acl' => [ + 'privilege' => '{DAV:}read-acl', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}read-acl', + ], + '{DAV:}read-current-user-privilege-set' => [ + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}read-current-user-privilege-set', + ], + '{DAV:}write' => [ + 'privilege' => '{DAV:}write', + 'abstract' => false, + 'aggregates' => [ '{DAV:}write-properties', '{DAV:}write-content', + '{DAV:}unlock', '{DAV:}bind', '{DAV:}unbind', - '{DAV:}unlock', - ), + ], 'concrete' => '{DAV:}write', - ), - '{DAV:}write-acl' => array( - 'privilege' => '{DAV:}write-acl', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-acl', - ), - '{DAV:}write-properties' => array( - 'privilege' => '{DAV:}write-properties', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-properties', - ), - '{DAV:}write-content' => array( - 'privilege' => '{DAV:}write-content', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-content', - ), - '{DAV:}unlock' => array( - 'privilege' => '{DAV:}unlock', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}unlock', - ), - '{DAV:}bind' => array( - 'privilege' => '{DAV:}bind', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}bind', - ), - '{DAV:}unbind' => array( - 'privilege' => '{DAV:}unbind', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}unbind', - ), - - ); + ], + '{DAV:}write-properties' => [ + 'privilege' => '{DAV:}write-properties', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}write-properties', + ], + '{DAV:}write-content' => [ + 'privilege' => '{DAV:}write-content', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}write-content', + ], + '{DAV:}unlock' => [ + 'privilege' => '{DAV:}unlock', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}unlock', + ], + '{DAV:}bind' => [ + 'privilege' => '{DAV:}bind', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}bind', + ], + '{DAV:}unbind' => [ + 'privilege' => '{DAV:}unbind', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}unbind', + ], + + ]; $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($plugin); $this->assertEquals($expected, $plugin->getFlatPrivilegeSet('')); @@ -132,24 +126,26 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testCurrentUserPrincipalsNotLoggedIn() { $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($acl); - $this->assertEquals(array(),$acl->getCurrentUserPrincipals()); + $this->assertEquals([], $acl->getCurrentUserPrincipals()); } function testCurrentUserPrincipalsSimple() { - $tree = array( + $tree = [ - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )) + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]) - ); + ]; $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server($tree); $server->addPlugin($acl); @@ -159,24 +155,25 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $this->assertEquals(array('principals/admin'),$acl->getCurrentUserPrincipals()); + $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals()); } function testCurrentUserPrincipalsGroups() { - $tree = array( + $tree = [ - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin',array('principals/administrators', 'principals/everyone')), - new MockPrincipal('administrators','principals/administrators',array('principals/groups'), array('principals/admin')), - new MockPrincipal('everyone','principals/everyone',array(), array('principals/admin')), - new MockPrincipal('groups','principals/groups',array(), array('principals/administrators')), - )) + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']), + new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']), + new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']), + new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']), + ]) - ); + ]; $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server($tree); $server->addPlugin($acl); @@ -186,75 +183,77 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $expected = array( + $expected = [ 'principals/admin', 'principals/administrators', 'principals/everyone', 'principals/groups', - ); + ]; - $this->assertEquals($expected,$acl->getCurrentUserPrincipals()); + $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); // The second one should trigger the cache and be identical - $this->assertEquals($expected,$acl->getCurrentUserPrincipals()); + $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); } function testGetACL() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), - ); + $tree = [ + new MockACLNode('foo', $acl), + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); - $this->assertEquals($acl,$aclPlugin->getACL('foo')); + $this->assertEquals($acl, $aclPlugin->getACL('foo')); } function testGetCurrentUserPrivilegeSet() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/user1', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), + $tree = [ + new MockACLNode('foo', $acl), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]), - ); + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); @@ -263,52 +262,51 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $expected = array( + $expected = [ '{DAV:}write', - '{DAV:}write-acl', '{DAV:}write-properties', '{DAV:}write-content', - '{DAV:}bind', - '{DAV:}unbind', '{DAV:}unlock', + '{DAV:}write-acl', '{DAV:}read', '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', - ); + ]; - $this->assertEquals($expected,$aclPlugin->getCurrentUserPrivilegeSet('foo')); + $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo')); } function testCheckPrivileges() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/user1', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), + $tree = [ + new MockACLNode('foo', $acl), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]), - ); + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); @@ -317,11 +315,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login //$auth->beforeMethod('GET','/'); - $this->assertFalse($aclPlugin->checkPrivileges('foo', array('{DAV:}read'), Plugin::R_PARENT, false)); + $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false)); } } - - - - diff --git a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php index d329b5b05..35f240d23 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php @@ -27,6 +27,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { protected $setupCalDAVICSExport = false; protected $setupLocks = false; protected $setupFiles = false; + protected $setupSharing = false; protected $setupPropertyStorage = false; /** @@ -90,6 +91,13 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { protected $locksPlugin; /** + * Sharing plugin. + * + * @var \Sabre\DAV\Sharing\Plugin + */ + protected $sharingPlugin; + + /* * @var Sabre\DAV\PropertyStorage\Plugin */ protected $propertyStoragePlugin; @@ -102,6 +110,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { function setUp() { + $this->initializeEverything(); + + } + + function initializeEverything() { + $this->setUpBackends(); $this->setUpTree(); @@ -113,6 +127,10 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->caldavPlugin = new CalDAV\Plugin(); $this->server->addPlugin($this->caldavPlugin); } + if ($this->setupCalDAVSharing || $this->setupSharing) { + $this->sharingPlugin = new DAV\Sharing\Plugin(); + $this->server->addPlugin($this->sharingPlugin); + } if ($this->setupCalDAVSharing) { $this->caldavSharingPlugin = new CalDAV\SharingPlugin(); $this->server->addPlugin($this->caldavSharingPlugin); @@ -132,10 +150,6 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->carddavPlugin = new CardDAV\Plugin(); $this->server->addPlugin($this->carddavPlugin); } - if ($this->setupACL) { - $this->aclPlugin = new DAVACL\Plugin(); - $this->server->addPlugin($this->aclPlugin); - } if ($this->setupLocks) { $this->locksPlugin = new DAV\Locks\Plugin( $this->locksBackend @@ -149,13 +163,15 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($this->propertyStoragePlugin); } if ($this->autoLogin) { - $authBackend = new DAV\Auth\Backend\Mock(); - $authBackend->setPrincipal('principals/' . $this->autoLogin); - $this->authPlugin = new DAV\Auth\Plugin($authBackend); - $this->server->addPlugin($this->authPlugin); - - // This will trigger the actual login procedure - $this->authPlugin->beforeMethod(new Request(), new Response()); + $this->autoLogin($this->autoLogin); + } + if ($this->setupACL) { + $this->aclPlugin = new DAVACL\Plugin(); + if (!$this->autoLogin) { + $this->aclPlugin->allowUnauthenticatedAccess = false; + } + $this->aclPlugin->adminPrincipals = ['principals/admin']; + $this->server->addPlugin($this->aclPlugin); } } @@ -166,23 +182,55 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { * You can either pass an instance of Sabre\HTTP\Request, or an array, * which will then be used as the _SERVER array. * + * If $expectedStatus is set, we'll compare it with the HTTP status of + * the returned response. If it doesn't match, we'll immediately fail + * the test. + * * @param array|\Sabre\HTTP\Request $request + * @param int $expectedStatus * @return \Sabre\HTTP\Response */ - function request($request) { + function request($request, $expectedStatus = null) { if (is_array($request)) { $request = HTTP\Request::createFromServerArray($request); } + $response = new HTTP\ResponseMock(); + $this->server->httpRequest = $request; - $this->server->httpResponse = new HTTP\ResponseMock(); + $this->server->httpResponse = $response; $this->server->exec(); + if ($expectedStatus) { + $responseBody = $expectedStatus !== $response->getStatus() ? $response->getBodyAsString() : ''; + $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: ' . $responseBody); + } return $this->server->httpResponse; } /** + * This function takes a username and sets the server in a state where + * this user is logged in, and no longer requires an authentication check. + * + * @param string $userName + */ + function autoLogin($userName) { + $authBackend = new DAV\Auth\Backend\Mock(); + $authBackend->setPrincipal('principals/' . $userName); + $this->authPlugin = new DAV\Auth\Plugin($authBackend); + + // If the auth plugin already exists, we're removing its hooks: + if ($oldAuth = $this->server->getPlugin('auth')) { + $this->server->removeListener('beforeMethod', [$oldAuth, 'beforeMethod']); + } + $this->server->addPlugin($this->authPlugin); + + // This will trigger the actual login procedure + $this->authPlugin->beforeMethod(new Request(), new Response()); + } + + /** * Override this to provide your own Tree for your test-case. */ function setUpTree() { @@ -200,10 +248,14 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { ); } - if ($this->setupCardDAV || $this->setupCalDAV) { + if ($this->setupCalDAV) { $this->tree[] = new CalDAV\Principal\Collection( $this->principalBackend ); + } elseif ($this->setupCardDAV || $this->setupACL) { + $this->tree[] = new DAVACL\PrincipalCollection( + $this->principalBackend + ); } if ($this->setupFiles) { @@ -231,7 +283,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { if ($this->setupCardDAV && is_null($this->carddavBackend)) { $this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards); } - if ($this->setupCardDAV || $this->setupCalDAV) { + if ($this->setupCardDAV || $this->setupCalDAV || $this->setupACL) { $this->principalBackend = new DAVACL\PrincipalBackend\Mock(); } if ($this->setupLocks) { @@ -244,7 +296,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { } - function assertHTTPStatus($expectedStatus, HTTP\Request $req) { + function assertHttpStatus($expectedStatus, HTTP\Request $req) { $resp = $this->request($req); $this->assertEquals((int)$expectedStatus, (int)$resp->status, 'Incorrect HTTP status received: ' . $resp->body); diff --git a/vendor/sabre/dav/tests/Sabre/TestUtil.php b/vendor/sabre/dav/tests/Sabre/TestUtil.php index 20bce1ea0..9df94915f 100644 --- a/vendor/sabre/dav/tests/Sabre/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/TestUtil.php @@ -11,17 +11,17 @@ class TestUtil { */ static function clearTempDir() { - self::deleteTree(SABRE_TEMPDIR,false); + self::deleteTree(SABRE_TEMPDIR, false); } - static private function deleteTree($path,$deleteRoot = true) { + private static function deleteTree($path, $deleteRoot = true) { - foreach(scandir($path) as $node) { + foreach (scandir($path) as $node) { - if ($node=='.' || $node=='..') continue; - $myPath = $path.'/'. $node; + if ($node == '.' || $node == '..') continue; + $myPath = $path . '/' . $node; if (is_file($myPath)) { unlink($myPath); } else { @@ -38,8 +38,8 @@ class TestUtil { static function getMySQLDB() { try { - $pdo = new \PDO(SABRE_MYSQLDSN,SABRE_MYSQLUSER,SABRE_MYSQLPASS); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); + $pdo = new \PDO(SABRE_MYSQLDSN, SABRE_MYSQLUSER, SABRE_MYSQLPASS); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $pdo; } catch (\PDOException $e) { return null; @@ -49,10 +49,23 @@ class TestUtil { static function getSQLiteDB() { - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); + $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/pdobackend'); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $pdo; } + static function getPgSqlDB() { + + //try { + $pdo = new \PDO(SABRE_PGSQLDSN); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + return $pdo; + //} catch (\PDOException $e) { + // return null; + //} + + } + + } diff --git a/vendor/sabre/dav/tests/bootstrap.php b/vendor/sabre/dav/tests/bootstrap.php index 325ccd3c7..26eb32aa2 100644 --- a/vendor/sabre/dav/tests/bootstrap.php +++ b/vendor/sabre/dav/tests/bootstrap.php @@ -7,28 +7,30 @@ $autoLoader = include __DIR__ . '/../vendor/autoload.php'; // SabreDAV tests auto loading $autoLoader->add('Sabre\\', __DIR__); // VObject tests auto loading -$autoLoader->addPsr4('Sabre\\VObject\\',__DIR__ . '/../vendor/sabre/vobject/tests/VObject'); -$autoLoader->addPsr4('Sabre\\Xml\\',__DIR__ . '/../vendor/sabre/xml/tests/Sabre/Xml'); +$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__ . '/../vendor/sabre/vobject/tests/VObject'); +$autoLoader->addPsr4('Sabre\\Xml\\', __DIR__ . '/../vendor/sabre/xml/tests/Sabre/Xml'); date_default_timezone_set('UTC'); $config = [ 'SABRE_TEMPDIR' => dirname(__FILE__) . '/temp/', - 'SABRE_HASSQLITE' => in_array('sqlite',PDO::getAvailableDrivers()), - 'SABRE_HASMYSQL' => in_array('mysql',PDO::getAvailableDrivers()), - 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav', - 'SABRE_MYSQLUSER' => 'root', + 'SABRE_HASSQLITE' => in_array('sqlite', PDO::getAvailableDrivers()), + 'SABRE_HASMYSQL' => in_array('mysql', PDO::getAvailableDrivers()), + 'SABRE_HASPGSQL' => in_array('pgsql', PDO::getAvailableDrivers()), + 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav_test', + 'SABRE_MYSQLUSER' => 'sabredav', 'SABRE_MYSQLPASS' => '', + 'SABRE_PGSQLDSN' => 'pgsql:host=localhost;dbname=sabredav_test;user=sabredav;password=sabredav', ]; if (file_exists(__DIR__ . '/config.user.php')) { include __DIR__ . '/config.user.php'; - foreach($userConfig as $key=>$value) { + foreach ($userConfig as $key => $value) { $config[$key] = $value; } } -foreach($config as $key=>$value) { +foreach ($config as $key => $value) { if (!defined($key)) define($key, $value); } diff --git a/vendor/sabre/dav/tests/phpunit.xml b/vendor/sabre/dav/tests/phpunit.xml index db475f12b..e16ec38b5 100644 --- a/vendor/sabre/dav/tests/phpunit.xml +++ b/vendor/sabre/dav/tests/phpunit.xml @@ -6,22 +6,15 @@ convertWarningsToExceptions="true" strict="true" > + <testsuite name="sabre-vobject"> + <directory>../vendor/sabre/vobject/tests/VObject</directory> + </testsuite> <testsuite name="sabre-event"> <directory>../vendor/sabre/event/tests/</directory> </testsuite> - <testsuite name="sabre-uri"> - <directory>../vendor/sabre/uri/tests/</directory> - </testsuite> - <testsuite name="sabre-xml"> - <directory>../vendor/sabre/xml/tests/Sabre/Xml/</directory> - </testsuite> <testsuite name="sabre-http"> <directory>../vendor/sabre/http/tests/HTTP</directory> </testsuite> - <testsuite name="sabre-vobject"> - <directory>../vendor/sabre/vobject/tests/VObject</directory> - </testsuite> - <testsuite name="sabre-dav"> <directory>Sabre/DAV</directory> </testsuite> diff --git a/vendor/sabre/vobject/ChangeLog.md b/vendor/sabre/vobject/ChangeLog.md new file mode 100644 index 000000000..60501f930 --- /dev/null +++ b/vendor/sabre/vobject/ChangeLog.md @@ -0,0 +1,563 @@ +ChangeLog +========= + +3.4.5 (2015-06-02) +------------------ + +* #229: Converting vcards from 3.0 to 4.0 that contained a `LANG` property + would throw an error. + + +3.4.4 (2015-05-27) +------------------ + +* #228: Fixed a 'party crasher' bug in the iTip broker. This would break + scheduling in some cases. + + +3.4.3 (2015-05-19) +------------------ + +* #219: Corrected validation of `EXDATE` properties with more than one value. +* #212: `BYSETPOS` with values below `-1` was broken and could cause infinite + loops. +* #211: Fix `BYDAY=-5TH` in recurrence iterator. (@lindquist) +* #216: `ENCODING` parameter is now validated for all document types. +* #217: Initializing vCard `DATE` objects with a PHP DateTime object will now + work correctly. (@thomascube) + + +3.4.2 (2015-02-25) +------------------ + +* #210: iTip: Replying to an event without a master event was broken. + + +3.4.1 (2015-02-24) +------------------ + +* A minor change to ensure that unittests work correctly in the sabre/dav + test-suite. + + +3.4.0 (2015-02-23) +------------------ + +* #196: Made parsing recurrence rules a lot faster on big calendars. +* Updated windows timezone mappings to latest unicode version. +* #202: Support for parsing and validating `VAVAILABILITY` components. (@Hywan) +* #195: PHP 5.3 compatibility in 'generatevcards' script. (@rickdenhaan) +* #205: Improving handling of multiple `EXDATE` when processing iTip changes. + (@armin-hackmann) +* #187: Fixed validator rules for `LAST-MODIFIED` properties. +* #188: Retain floating times when generating instances using + `Recur\EventIterator`. +* #203: Skip tests for timezones that are not supported on older PHP versions, + instead of a hard fail. +* #204: Dealing a bit better with vCard date-time values that contained + milliseconds. (which is normally invalid). (@armin-hackmann) + + +3.3.5 (2015-01-09) +------------------ + +* #168: Expanding calendars now removes objects with recurrence rules that + don't have a valid recurrence instance. +* #177: SCHEDULE-STATUS should not contain a reason phrase, only a status + code. +* #175: Parser can now read and skip the UTF-8 BOM. +* #179: Added `isFloating` to `DATE-TIME` properties. +* #179: Fixed jCal serialization of floating `DATE-TIME` properties. +* #173: vCard converter failed for `X-ABDATE` properties that had no + `X-ABLABEL`. +* #180: Added `PROFILE_CALDAV` and `PROFILE_CARDDAV` to enable validation rules + specific for CalDAV/CardDAV servers. +* #176: A missing `UID` is no longer an error, but a warning for the vCard + validator, unless `PROFILE_CARDDAV` is specified. + + +3.3.4 (2014-11-19) +------------------ + +* #154: Converting `ANNIVERSARY` to `X-ANNIVERSARY` and `X-ABDATE` and + vice-versa when converting to/from vCard 4. +* #154: It's now possible to easily select all vCard properties belonging to + a single group with `$vcard->{'ITEM1.'}` syntax. (@armin-hackmann) +* #156: Simpler way to check if a string is UTF-8. (@Hywan) +* Unittest improvements. +* #159: The recurrence iterator, freebusy generator and iCalendar DATE and + DATE-TIME properties can now all accept a reference timezone when working + floating times or all-day events. +* #159: Master events will no longer get a `RECURRENCE-ID` when expanding. +* #159: `RECURRENCE-ID` for all-day events will now be correct when expanding. +* #163: Added a `getTimeZone()` method to `VTIMEZONE` components. + + +3.3.3 (2014-10-09) +------------------ + +* #142: `CANCEL` and `REPLY` messages now include the `DTSTART` from the + original event. +* #143: `SCHEDULE-AGENT` on the `ORGANIZER` property is respected. +* #144: `PARTSTAT=NEEDS-ACTION` is now set for new invites, if no `PARTSTAT` is + set to support the inbox feature of iOS. +* #147: Bugs related to scheduling all-day events. +* #148: Ignore events that have attendees but no organizer. +* #149: Avoiding logging errors during timezone detection. This is a workaround + for a PHP bug. +* Support for "Line Islands Standard Time" windows timezone. +* #154: Correctly work around vCard parameters that have a value but no name. + + +3.3.2 (2014-09-19) +------------------ + +* Changed: iTip broker now sets RSVP status to false when replies are received. +* #118: iTip Message now has a `getScheduleStatus()` method. +* #119: Support for detecting 'significant changes'. +* #120: Support for `SCHEDULE-FORCE-SEND`. +* #121: iCal demands parameters containing the + sign to be quoted. +* #122: Don't generate REPLY messages for events that have been cancelled. +* #123: Added `SUMMARY` to iTip messages. +* #130: Incorrect validation rules for `RELATED` (should be `RELATED-TO`). +* #128: `ATTACH` in iCalendar is `URI` by default, not `BINARY`. +* #131: RRULE that doesn't provide a single valid instance now throws an + exception. +* #136: Validator rejects *all* control characters. We were missing a few. +* #133: Splitter objects will throw exceptions when receiving incompatible + objects. +* #127: Attendees who delete recurring event instances events they had already + declined earlier will no longer generate another reply. +* #125: Send CANCEL messages when ORGANIZER property gets deleted. + + +3.3.1 (2014-08-18) +------------------ + +* Changed: It's now possible to pass DateTime objects when using the magic + setters on properties. (`$event->DTSTART = new DateTime('now')`). +* #111: iTip Broker does not process attendee adding events to EXDATE. +* #112: EventIterator now sets TZID on RECURRENCE-ID. +* #113: Timezone support during creation of iTip REPLY messages. +* #114: VTIMEZONE is retained when generating new REQUEST objects. +* #114: Support for 'MAILTO:' style email addresses (in uppercase) in the iTip + broker. This improves evolution support. +* #115: Using REQUEST-STATUS from REPLY messages and now propegating that into + SCHEDULE-STATUS. + + +3.3.0 (2014-08-07) +------------------ + +* We now use PSR-4 for the directory structure. This means that everything + that was used to be in the `lib/Sabre/VObject` directory is now moved to + `lib/`. If you use composer to load this library, you shouldn't have to do + anything about that though. +* VEVENT now get populated with a DTSTAMP and UID property by default. +* BC Break: Removed the 'includes.php' file. Use composer instead. +* #103: Added support for processing [iTip][iTip] messages. This allows a user + to parse incoming iTip messages and apply the result on existing calendars, + or automatically generate invites/replies/cancellations based on changes that + a user made on objects. +* #75, #58, #18: Fixes related to overriding the first event in recurrences. +* Added: VCalendar::getBaseComponent to find the 'master' component in a + calendar. +* #51: Support for iterating RDATE properties. +* Fixed: Issue #101: RecurrenceIterator::nextMonthly() shows events that are + excluded events with wrong time + + +3.2.4 (2014-07-14) +------------------ + +* Added: Issue #98. The VCardConverter now takes `X-APPLE-OMIT-YEAR` into + consideration when converting between vCard 3 and 4. +* Fixed: Issue #96. Some support for Yahoo's broken vcards. +* Fixed: PHP 5.3 support was broken in the cli tool. + + +3.2.3 (2014-06-12) +------------------ + +* Validator now checks if DUE and DTSTART are of the same type in VTODO, and + ensures that DUE is always after DTSTART. +* Removed documentation from source repository, to http://sabre.io/vobject/ +* Expanded the vobject cli tool validation output to make it easier to find + issues. +* Fixed: vobject repair. It was not working for iCalendar objects. + + +3.2.2 (2014-05-07) +------------------ + +* Minor tweak in unittests to make it run on PHP 5.5.12. Json-prettifying + slightly changed which caused the test to fail. + + +3.2.1 (2014-05-03) +------------------ + +* Minor tweak to make the unittests run with the latest hhvm on travis. +* Updated timezone definitions. +* Updated copyright links to point to http://sabre.io/ + + +3.2.0 (2014-04-02) +------------------ + +* Now hhvm compatible! +* The validator can now detect a _lot_ more problems. Many rules for both + iCalendar and vCard were added. +* Added: bin/generate_vcards, a utility to generate random vcards for testing + purposes. Patches are welcome to add more data. +* Updated: Windows timezone mapping to latest version from unicode.org +* Changed: The timezone maps are now loaded in from external files, in + lib/Sabre/VObject/timezonedata. +* Added: Fixing badly encoded URL's from google contacts vcards. +* Fixed: Issue #68. Couldn't decode properties ending in a colon. +* Fixed: Issue #72. RecurrenceIterator should respect timezone in the UNTIL + clause. +* Fixed: Issue #67. BYMONTH limit on DAILY recurrences. +* Fixed: Issue #26. Return a more descriptive error when coming across broken + BYDAY rules. +* Fixed: Issue #28. Incorrect timezone detection for some timezones. +* Fixed: Issue #70. Casting a parameter with a null value to string would fail. +* Added: Support for rfc6715 and rfc6474. +* Added: Support for DateTime objects in the VCard DATE-AND-OR-TIME property. +* Added: UUIDUtil, for easily creating unique identifiers. +* Fixed: Issue #83. Creating new VALUE=DATE objects using php's DateTime. +* Fixed: Issue #86. Don't go into an infinite loop when php errors are + disabled and an invalid file is read. + + +3.1.4 (2014-03-30) +------------------ + +* Fixed: Issue #87: Several compatibility fixes related to timezone handling + changes in PHP 5.5.10. + + +3.1.3 (2013-10-02) +------------------ + +* Fixed: Support from properties from draft-daboo-valarm-extensions-04. Issue + #56. +* Fixed: Issue #54. Parsing a stream of multiple vcards separated by more than + one newline. Thanks @Vedmak for the patch. +* Fixed: Serializing vcard 2.1 parameters with no name caused a literal '1' to + be inserted. +* Added: VCardConverter removed properties that are no longer supported in vCard + 4.0. +* Added: vCards with a minimum number of values (such as N), but don't have that + many, are now automatically padded with empty components. +* Added: The vCard validator now also checks for a minimum number of components, + and has the ability to repair these. +* Added: Some support for vCard 2.1 in the VCard converter, to upgrade to vCard + 3.0 or 4.0. +* Fixed: Issue 60 Use Document::$componentMap when instantiating the top-level + VCalendar and VCard components. +* Fixed: Issue 62: Parsing iCalendar parameters with no value. +* Added: --forgiving option to vobject utility. +* Fixed: Compound properties such as ADR were not correctly split up in vCard + 2.1 quoted printable-encoded properties. +* Fixed: Issue 64: Encoding of binary properties of converted vCards. Thanks + @DominikTo for the patch. + + +3.1.2 (2013-08-13) +------------------ + +* Fixed: Setting correct property group on VCard conversion + + +3.1.1 (2013-08-02) +------------------ + +* Fixed: Issue #53. A regression in RecurrenceIterator. + + +3.1.0 (2013-07-27) +------------------ + +* Added: bad-ass new cli debugging utility (in bin/vobject). +* Added: jCal and jCard parser. +* Fixed: URI properties should not escape ; and ,. +* Fixed: VCard 4 documents now correctly use URI as a default value-type for + PHOTO and others. BINARY no longer exists in vCard 4. +* Added: Utility to convert between 2.1, 3.0 and 4.0 vCards. +* Added: You can now add() multiple parameters to a property in one call. +* Added: Parameter::has() for easily checking if a parameter value exists. +* Added: VCard::preferred() to find a preferred email, phone number, etc for a + contact. +* Changed: All $duration properties are now public. +* Added: A few validators for iCalendar documents. +* Fixed: Issue #50. RecurrenceIterator gives incorrect result when exception + events are out of order in the iCalendar file. +* Fixed: Issue #48. Overridden events in the recurrence iterator that were past + the UNTIL date were ignored. +* Added: getDuration for DURATION values such as TRIGGER. Thanks to + @SimonSimCity. +* Fixed: Issue #52. vCard 2.1 parameters with no name may lose values if there's + more than 1. Thanks to @Vedmak. + + +3.0.0 (2013-06-21) +------------------ + +* Fixed: includes.php file was still broken. Our tool to generate it had some + bugs. + + +3.0.0-beta4 (2013-06-21) +------------------------ + +* Fixed: includes.php was no longer up to date. + + +3.0.0-beta3 (2013-06-17) +------------------------ + +* Added: OPTION_FORGIVING now also allows slashes in property names. +* Fixed: DateTimeParser no longer fails on dates with years < 1000 & > 4999 +* Fixed: Issue 36: Workaround for the recurrenceiterator and caldav events with + a missing base event. +* Fixed: jCard encoding of TIME properties. +* Fixed: jCal encoding of REQUEST-STATUS, GEO and PERIOD values. + + +3.0.0-beta2 (2013-06-10) +------------------------ + +* Fixed: Corrected includes.php file. +* Fixed: vCard date-time parser supported extended-format dates as well. +* Changed: Properties have been moved to an ICalendar or VCard directory. +* Fixed: Couldn't parse vCard 3 extended format dates and times. +* Fixed: Couldn't export jCard DATE values correctly. +* Fixed: Recursive loop in ICalendar\DateTime property. + + +3.0.0-beta1 (2013-06-07) +------------------------ + +* Added: jsonSerialize() for creating jCal and jCard documents. +* Added: helper method to parse vCard dates and times. +* Added: Specialized classes for FLOAT, LANGUAGE-TAG, TIME, TIMESTAMP, + DATE-AND-OR-TIME, CAL-ADDRESS, UNKNOWN and UTC-OFFSET properties. +* Removed: CommaSeparatedText property. Now included into Text. +* Fixed: Multiple parameters with the same name are now correctly encoded. +* Fixed: Parameter values containing a comma are now enclosed in double-quotes. +* Fixed: Iterating parameter values should now fully work as expected. +* Fixed: Support for vCard 2.1 nameless parameters. +* Changed: $valueMap, $componentMap and $propertyMap now all use fully-qualified + class names, so they are actually overridable. +* Fixed: Updating DATE-TIME to DATE values now behaves like expected. + + +3.0.0-alpha4 (2013-05-31) +------------------------- + +* Added: It's now possible to send parser options to the splitter classes. +* Added: A few tweaks to improve component and property creation. + + +3.0.0-alpha3 (2013-05-13) +------------------------- + +* Changed: propertyMap, valueMap and componentMap are now static properties. +* Changed: Component::remove() will throw an exception when trying to a node + that's not a child of said component. +* Added: Splitter objects are now faster, line numbers are accurately reported + and use less memory. +* Added: MimeDir parser can now continue parsing with the same stream buffer. +* Fixed: vobjectvalidate.php is operational again. +* Fixed: \r is properly stripped in text values. +* Fixed: QUOTED-PRINTABLE is now correctly encoded as well as encoded, for + vCards 2.1. +* Fixed: Parser assumes vCard 2.1, if no version was supplied. + + +3.0.0-alpha2 (2013-05-22) +------------------------- + +* Fixed: vCard URL properties were referencing a non-existant class. + + +3.0.0-alpha1 (2013-05-21) +------------------------- + +* Fixed: Now correctly dealing with escaping of properties. This solves the + problem with double-backslashes where they don't belong. +* Added: Easy support for properties with more than one value, using setParts + and getParts. +* Added: Support for broken 2.1 vCards produced by microsoft. +* Added: Automatically decoding quoted-printable values. +* Added: Automatically decoding base64 values. +* Added: Decoding RFC6868 parameter values (uses ^ as an escape character). +* Added: Fancy new MimeDir parser that can also parse streams. +* Added: Automatically mapping many, many properties to a property-class with + specialized API's. +* Added: remove() method for easily removing properties and sub-components + components. +* Changed: Components, Properties and Parameters can no longer be created with + Component::create, Property::create and Parameter::create. They must instead + be created through the root component. (A VCalendar or VCard object). +* Changed: API for DateTime properties has slightly changed. +* Changed: the ->value property is now protected everywhere. Use getParts() and + getValue() instead. +* BC Break: No support for mac newlines (\r). Never came across these anyway. +* Added: add() method to the Property class. +* Added: It's now possible to easy set multi-value properties as arrays. +* Added: When setting date-time properties you can just pass PHP's DateTime + object. +* Added: New components automatically get a bunch of default properties, such as + VERSION and CALSCALE. +* Added: You can add new sub-components much quicker with the magic setters, and + add() method. + + +2.1.7 (2015-01-21) +------------------ + +* Fixed: Issue #94, a workaround for bad escaping of ; and , in compound + properties. It's not a full solution, but it's an improvement for those + stuck in the 2.1 versions. + + +2.1.6 (2014-12-10) +------------------ + +* Fixed: Minor change to make sure that unittests succeed on every PHP version. + + +2.1.5 (2014-06-03) +------------------ + +* Fixed: #94: Better parameter escaping. +* Changed: Documentation cleanups. + + +2.1.4 (2014-03-30) +------------------ + +* Fixed: Issue #87: Several compatibility fixes related to timezone handling + changes in PHP 5.5.10. + + +2.1.3 (2013-10-02) +------------------ + +* Fixed: Issue #55. \r must be stripped from property values. +* Fixed: Issue #65. Putting quotes around parameter values that contain a colon. + + +2.1.2 (2013-08-02) +------------------ + +* Fixed: Issue #53. A regression in RecurrenceIterator. + + +2.1.1 (2013-07-27) +------------------ + +* Fixed: Issue #50. RecurrenceIterator gives incorrect result when exception + events are out of order in the iCalendar file. +* Fixed: Issue #48. Overridden events in the recurrence iterator that were past + the UNTIL date were ignored. + + +2.1.0 (2013-06-17) +------------------ + +* This version is fully backwards compatible with 2.0.\*. However, it contains a + few new API's that mimic the VObject 3 API. This allows it to be used a + 'bridge' version. Specifically, this new version exists so SabreDAV 1.7 and + 1.8 can run with both the 2 and 3 versions of this library. +* Added: Property\DateTime::hasTime(). +* Added: Property\MultiDateTime::hasTime(). +* Added: Property::getValue(). +* Added: Document class. +* Added: Document::createComponent and Document::createProperty. +* Added: Parameter::getValue(). + + +2.0.7 (2013-03-05) +------------------ + +* Fixed: Microsoft re-uses their magic numbers for different timezones, + specifically id 2 for both Sarajevo and Lisbon). A workaround was added to + deal with this. + + +2.0.6 (2013-02-17) +------------------ + +* Fixed: The reader now properly parses parameters without a value. + + +2.0.5 (2012-11-05) +------------------ + +* Fixed: The FreeBusyGenerator is now properly using the factory methods for + creation of components and properties. + + +2.0.4 (2012-11-02) +------------------ + +* Added: Known Lotus Notes / Domino timezone id's. + + +2.0.3 (2012-10-29) +------------------ + +* Added: Support for 'GMT+????' format in TZID's. +* Added: Support for formats like SystemV/EST5EDT in TZID's. +* Fixed: RecurrenceIterator now repairs recurrence rules where UNTIL < DTSTART. +* Added: Support for BYHOUR in FREQ=DAILY (@hollodk). +* Added: Support for BYHOUR and BYDAY in FREQ=WEEKLY. + + +2.0.2 (2012-10-06) +------------------ + +* Added: includes.php file, to load the entire library in one go. +* Fixed: A problem with determining alarm triggers for TODO's. + + +2.0.1 (2012-09-22) +------------------ + +* Removed: Element class. It wasn't used. +* Added: Basic validation and repair methods for broken input data. +* Fixed: RecurrenceIterator could infinitely loop when an INTERVAL of 0 was + specified. +* Added: A cli script that can validate and automatically repair vcards and + iCalendar objects. +* Added: A new 'Compound' property, that can automatically split up parts for + properties such as N, ADR, ORG and CATEGORIES. +* Added: Splitter classes, that can split up large objects (such as exports) + into individual objects (thanks @DominikTO and @armin-hackmann). +* Added: VFREEBUSY component, which allows easily checking wether timeslots are + available. +* Added: The Reader class now has a 'FORGIVING' option, which allows it to parse + properties with incorrect characters in the name (at this time, it just allows + underscores). +* Added: Also added the 'IGNORE_INVALID_LINES' option, to completely disregard + any invalid lines. +* Fixed: A bug in Windows timezone-id mappings for times created in Greenlands + timezone (sorry Greenlanders! I do care!). +* Fixed: DTEND was not generated correctly for VFREEBUSY reports. +* Fixed: Parser is at least 25% faster with real-world data. + + +2.0.0 (2012-08-08) +------------------ + +* VObject is now a separate project from SabreDAV. See the SabreDAV changelog + for version information before 2.0. +* New: VObject library now uses PHP 5.3 namespaces. +* New: It's possible to specify lists of parameters when constructing + properties. +* New: made it easier to construct the FreeBusyGenerator. + +[iTip]: http://tools.ietf.org/html/rfc5546 diff --git a/vendor/sabre/vobject/lib/Property/Float.php b/vendor/sabre/vobject/lib/Property/Float.php new file mode 100644 index 000000000..25bcd3db2 --- /dev/null +++ b/vendor/sabre/vobject/lib/Property/Float.php @@ -0,0 +1,104 @@ +<?php + +namespace Sabre\VObject\Property; + +use + Sabre\VObject\Property; + +/** + * Float property + * + * This object represents FLOAT values. These can be 1 or more floating-point + * numbers. + * + * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class Float extends Property { + + /** + * In case this is a multi-value property. This string will be used as a + * delimiter. + * + * @var string|null + */ + public $delimiter = ';'; + + /** + * Sets a raw value coming from a mimedir (iCalendar/vCard) file. + * + * This has been 'unfolded', so only 1 line will be passed. Unescaping is + * not yet done, but parameters are not included. + * + * @param string $val + * @return void + */ + public function setRawMimeDirValue($val) { + + $val = explode($this->delimiter, $val); + foreach($val as &$item) { + $item = (float)$item; + } + $this->setParts($val); + + } + + /** + * Returns a raw mime-dir representation of the value. + * + * @return string + */ + public function getRawMimeDirValue() { + + return implode( + $this->delimiter, + $this->getParts() + ); + + } + + /** + * Returns the type of value. + * + * This corresponds to the VALUE= parameter. Every property also has a + * 'default' valueType. + * + * @return string + */ + public function getValueType() { + + return "FLOAT"; + + } + + /** + * Returns the value, in the format it should be encoded for json. + * + * This method must always return an array. + * + * @return array + */ + public function getJsonValue() { + + $val = array_map( + function($item) { + + return (float)$item; + + }, + $this->getParts() + ); + + // Special-casing the GEO property. + // + // See: + // http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-04#section-3.4.1.2 + if ($this->name==='GEO') { + return array($val); + } else { + return $val; + } + + } +} diff --git a/vendor/sabre/vobject/lib/Property/Integer.php b/vendor/sabre/vobject/lib/Property/Integer.php new file mode 100644 index 000000000..db000156f --- /dev/null +++ b/vendor/sabre/vobject/lib/Property/Integer.php @@ -0,0 +1,72 @@ +<?php + +namespace Sabre\VObject\Property; + +use + Sabre\VObject\Property; + +/** + * Integer property + * + * This object represents INTEGER values. These are always a single integer. + * They may be preceeded by either + or -. + * + * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class Integer extends Property { + + /** + * Sets a raw value coming from a mimedir (iCalendar/vCard) file. + * + * This has been 'unfolded', so only 1 line will be passed. Unescaping is + * not yet done, but parameters are not included. + * + * @param string $val + * @return void + */ + public function setRawMimeDirValue($val) { + + $this->setValue((int)$val); + + } + + /** + * Returns a raw mime-dir representation of the value. + * + * @return string + */ + public function getRawMimeDirValue() { + + return $this->value; + + } + + /** + * Returns the type of value. + * + * This corresponds to the VALUE= parameter. Every property also has a + * 'default' valueType. + * + * @return string + */ + public function getValueType() { + + return "INTEGER"; + + } + + /** + * Returns the value, in the format it should be encoded for json. + * + * This method must always return an array. + * + * @return array + */ + public function getJsonValue() { + + return array((int)$this->getValue()); + + } +} diff --git a/vendor/sabre/vobject/lib/RecurrenceIterator.php b/vendor/sabre/vobject/lib/RecurrenceIterator.php new file mode 100644 index 000000000..92ea03ffe --- /dev/null +++ b/vendor/sabre/vobject/lib/RecurrenceIterator.php @@ -0,0 +1,21 @@ +<?php + +namespace Sabre\VObject; + +use Sabre\VObject\Recur\EventIterator; + +/** + * RecurrenceIterator + * + * This class is deprecated. Use Sabre\VObject\Recur\EventIterator instead. + * This class will be removed from a future version. + * + * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @deprecated + * @license http://sabre.io/license Modified BSD License + */ +class RecurrenceIterator extends EventIterator { + + +} diff --git a/vendor/sabre/xml/.travis.yml b/vendor/sabre/xml/.travis.yml index 19a61a2c8..9bba4d451 100644 --- a/vendor/sabre/xml/.travis.yml +++ b/vendor/sabre/xml/.travis.yml @@ -4,6 +4,7 @@ php: - 5.5 - 5.6 - 7 + - nightly - hhvm matrix: @@ -11,10 +12,14 @@ matrix: sudo: false -cache: vendor +cache: + directories: + - $HOME/.composer/cache script: - ./bin/phpunit --configuration tests/phpunit.xml.dist - ./bin/sabre-cs-fixer fix . --dry-run --diff -before_script: composer install +before_script: + - phpenv config-rm xdebug.ini; true + - composer install diff --git a/vendor/sabre/xml/CHANGELOG.md b/vendor/sabre/xml/CHANGELOG.md index 3d8eb0fcb..a8085401b 100644 --- a/vendor/sabre/xml/CHANGELOG.md +++ b/vendor/sabre/xml/CHANGELOG.md @@ -1,6 +1,17 @@ ChangeLog ========= +1.4.2 (????-??-??) +------------------ + +* The `contextStack` in the Reader object is now correctly rolled back in + error conditions (@staabm). +* repeatingElements deserializer now still parses if a bare element name + without clark notation was given. +* `$elementMap` in the Reader now also supports bare element names. +* `Service::expect()` can now also work with bare element names. + + 1.4.1 (2016-03-12) ----------------- diff --git a/vendor/sabre/xml/lib/Deserializer/functions.php b/vendor/sabre/xml/lib/Deserializer/functions.php index fe88a6db8..2e5d877e9 100644 --- a/vendor/sabre/xml/lib/Deserializer/functions.php +++ b/vendor/sabre/xml/lib/Deserializer/functions.php @@ -14,7 +14,7 @@ use Sabre\Xml\Reader; * deserializer functions. */ -/* +/** * The 'keyValue' deserializer parses all child elements, and outputs them as * a "key=>value" array. * @@ -213,7 +213,7 @@ function valueObject(Reader $reader, $className, $namespace) { } -/* +/** * This deserializer helps you deserialize xml structures that look like * this: * @@ -240,6 +240,9 @@ function valueObject(Reader $reader, $className, $namespace) { */ function repeatingElements(Reader $reader, $childElementName) { + if ($childElementName[0] !== '{') { + $childElementName = '{}' . $childElementName; + } $result = []; foreach ($reader->parseGetElements() as $element) { diff --git a/vendor/sabre/xml/lib/Reader.php b/vendor/sabre/xml/lib/Reader.php index 7cba76c59..f35dc8537 100644 --- a/vendor/sabre/xml/lib/Reader.php +++ b/vendor/sabre/xml/lib/Reader.php @@ -142,7 +142,12 @@ class Reader extends XMLReader { // choice. See: // // https://bugs.php.net/bug.php?id=64230 - if (!@$this->read()) return false; + if (!@$this->read()) { + if (!is_null($elementMap)) { + $this->popContext(); + } + return false; + } while (true) { @@ -152,6 +157,9 @@ class Reader extends XMLReader { if ($errors) { libxml_clear_errors(); + if (!is_null($elementMap)) { + $this->popContext(); + } throw new LibXMLException($errors); } } @@ -170,6 +178,9 @@ class Reader extends XMLReader { $this->read(); break 2; case self::NONE : + if (!is_null($elementMap)) { + $this->popContext(); + } throw new ParseException('We hit the end of the document prematurely. This likely means that some parser "eats" too many elements. Do not attempt to continue parsing.'); default : // Advance to the next element @@ -282,8 +293,13 @@ class Reader extends XMLReader { */ function getDeserializerForElementName($name) { + if (!array_key_exists($name, $this->elementMap)) { - return ['Sabre\\Xml\\Element\\Base', 'xmlDeserialize']; + if (substr($name, 0, 2) == '{}' && array_key_exists(substr($name, 2), $this->elementMap)) { + $name = substr($name, 2); + } else { + return ['Sabre\\Xml\\Element\\Base', 'xmlDeserialize']; + } } $deserializer = $this->elementMap[$name]; diff --git a/vendor/sabre/xml/lib/Service.php b/vendor/sabre/xml/lib/Service.php index b2603a4c7..09ee341cf 100644 --- a/vendor/sabre/xml/lib/Service.php +++ b/vendor/sabre/xml/lib/Service.php @@ -151,8 +151,14 @@ class Service { $r->contextUri = $contextUri; $r->xml($input); + $rootElementName = (array)$rootElementName; + + foreach ($rootElementName as &$rEl) { + if ($rEl[0] !== '{') $rEl = '{}' . $rEl; + } + $result = $r->parse(); - if (!in_array($result['name'], (array)$rootElementName, true)) { + if (!in_array($result['name'], $rootElementName, true)) { throw new ParseException('Expected ' . implode(' or ', (array)$rootElementName) . ' but received ' . $result['name'] . ' as the root element'); } return $result['value']; |