tilia-dav 3.1.0.pre.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.database.travis.yml +6 -0
- data/.gitignore +25 -0
- data/.rubocop.yml +35 -0
- data/.simplecov +4 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.sabre.md +2084 -0
- data/CONTRIBUTING.md +25 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +103 -0
- data/LICENSE +27 -0
- data/LICENSE.sabre +27 -0
- data/README.md +40 -0
- data/Rakefile +18 -0
- data/database.sample.yml +6 -0
- data/examples/minimal.rb +25 -0
- data/lib/tilia/cal_dav.rb +27 -0
- data/lib/tilia/cal_dav/backend.rb +17 -0
- data/lib/tilia/cal_dav/backend/abstract_backend.rb +194 -0
- data/lib/tilia/cal_dav/backend/backend_interface.rb +250 -0
- data/lib/tilia/cal_dav/backend/notification_support.rb +38 -0
- data/lib/tilia/cal_dav/backend/scheduling_support.rb +57 -0
- data/lib/tilia/cal_dav/backend/sequel.rb +1118 -0
- data/lib/tilia/cal_dav/backend/sharing_support.rb +239 -0
- data/lib/tilia/cal_dav/backend/subscription_support.rb +79 -0
- data/lib/tilia/cal_dav/backend/sync_support.rb +75 -0
- data/lib/tilia/cal_dav/calendar.rb +426 -0
- data/lib/tilia/cal_dav/calendar_home.rb +335 -0
- data/lib/tilia/cal_dav/calendar_object.rb +219 -0
- data/lib/tilia/cal_dav/calendar_query_validator.rb +294 -0
- data/lib/tilia/cal_dav/calendar_root.rb +57 -0
- data/lib/tilia/cal_dav/exception.rb +7 -0
- data/lib/tilia/cal_dav/exception/invalid_component_type.rb +21 -0
- data/lib/tilia/cal_dav/i_calendar.rb +11 -0
- data/lib/tilia/cal_dav/i_calendar_object.rb +13 -0
- data/lib/tilia/cal_dav/i_calendar_object_container.rb +32 -0
- data/lib/tilia/cal_dav/i_shareable_calendar.rb +40 -0
- data/lib/tilia/cal_dav/i_shared_calendar.rb +28 -0
- data/lib/tilia/cal_dav/ics_export_plugin.rb +327 -0
- data/lib/tilia/cal_dav/notifications.rb +12 -0
- data/lib/tilia/cal_dav/notifications/collection.rb +131 -0
- data/lib/tilia/cal_dav/notifications/i_collection.rb +17 -0
- data/lib/tilia/cal_dav/notifications/i_node.rb +30 -0
- data/lib/tilia/cal_dav/notifications/node.rb +142 -0
- data/lib/tilia/cal_dav/notifications/plugin.rb +138 -0
- data/lib/tilia/cal_dav/plugin.rb +891 -0
- data/lib/tilia/cal_dav/principal.rb +12 -0
- data/lib/tilia/cal_dav/principal/collection.rb +21 -0
- data/lib/tilia/cal_dav/principal/i_proxy_read.rb +13 -0
- data/lib/tilia/cal_dav/principal/i_proxy_write.rb +13 -0
- data/lib/tilia/cal_dav/principal/proxy_read.rb +127 -0
- data/lib/tilia/cal_dav/principal/proxy_write.rb +127 -0
- data/lib/tilia/cal_dav/principal/user.rb +96 -0
- data/lib/tilia/cal_dav/schedule.rb +14 -0
- data/lib/tilia/cal_dav/schedule/i_inbox.rb +12 -0
- data/lib/tilia/cal_dav/schedule/i_mip_plugin.rb +156 -0
- data/lib/tilia/cal_dav/schedule/i_outbox.rb +12 -0
- data/lib/tilia/cal_dav/schedule/i_scheduling_object.rb +10 -0
- data/lib/tilia/cal_dav/schedule/inbox.rb +211 -0
- data/lib/tilia/cal_dav/schedule/outbox.rb +143 -0
- data/lib/tilia/cal_dav/schedule/plugin.rb +851 -0
- data/lib/tilia/cal_dav/schedule/scheduling_object.rb +126 -0
- data/lib/tilia/cal_dav/shareable_calendar.rb +54 -0
- data/lib/tilia/cal_dav/shared_calendar.rb +120 -0
- data/lib/tilia/cal_dav/sharing_plugin.rb +359 -0
- data/lib/tilia/cal_dav/subscriptions.rb +9 -0
- data/lib/tilia/cal_dav/subscriptions/i_subscription.rb +37 -0
- data/lib/tilia/cal_dav/subscriptions/plugin.rb +83 -0
- data/lib/tilia/cal_dav/subscriptions/subscription.rb +205 -0
- data/lib/tilia/cal_dav/xml.rb +10 -0
- data/lib/tilia/cal_dav/xml/filter.rb +12 -0
- data/lib/tilia/cal_dav/xml/filter/calendar_data.rb +64 -0
- data/lib/tilia/cal_dav/xml/filter/comp_filter.rb +79 -0
- data/lib/tilia/cal_dav/xml/filter/param_filter.rb +66 -0
- data/lib/tilia/cal_dav/xml/filter/prop_filter.rb +80 -0
- data/lib/tilia/cal_dav/xml/notification.rb +13 -0
- data/lib/tilia/cal_dav/xml/notification/invite.rb +253 -0
- data/lib/tilia/cal_dav/xml/notification/invite_reply.rb +167 -0
- data/lib/tilia/cal_dav/xml/notification/notification_interface.rb +41 -0
- data/lib/tilia/cal_dav/xml/notification/system_status.rb +139 -0
- data/lib/tilia/cal_dav/xml/property.rb +15 -0
- data/lib/tilia/cal_dav/xml/property/allowed_sharing_modes.rb +64 -0
- data/lib/tilia/cal_dav/xml/property/email_address_set.rb +60 -0
- data/lib/tilia/cal_dav/xml/property/invite.rb +207 -0
- data/lib/tilia/cal_dav/xml/property/schedule_calendar_transp.rb +108 -0
- data/lib/tilia/cal_dav/xml/property/supported_calendar_component_set.rb +100 -0
- data/lib/tilia/cal_dav/xml/property/supported_calendar_data.rb +50 -0
- data/lib/tilia/cal_dav/xml/property/supported_collation_set.rb +47 -0
- data/lib/tilia/cal_dav/xml/request.rb +14 -0
- data/lib/tilia/cal_dav/xml/request/calendar_multi_get_report.rb +99 -0
- data/lib/tilia/cal_dav/xml/request/calendar_query_report.rb +112 -0
- data/lib/tilia/cal_dav/xml/request/free_busy_query_report.rb +70 -0
- data/lib/tilia/cal_dav/xml/request/invite_reply.rb +110 -0
- data/lib/tilia/cal_dav/xml/request/mk_calendar.rb +67 -0
- data/lib/tilia/cal_dav/xml/request/share.rb +93 -0
- data/lib/tilia/card_dav.rb +17 -0
- data/lib/tilia/card_dav/address_book.rb +338 -0
- data/lib/tilia/card_dav/address_book_home.rb +192 -0
- data/lib/tilia/card_dav/address_book_root.rb +58 -0
- data/lib/tilia/card_dav/backend.rb +12 -0
- data/lib/tilia/card_dav/backend/abstract_backend.rb +30 -0
- data/lib/tilia/card_dav/backend/backend_interface.rb +175 -0
- data/lib/tilia/card_dav/backend/sequel.rb +476 -0
- data/lib/tilia/card_dav/backend/sync_support.rb +80 -0
- data/lib/tilia/card_dav/card.rb +193 -0
- data/lib/tilia/card_dav/i_address_book.rb +10 -0
- data/lib/tilia/card_dav/i_card.rb +11 -0
- data/lib/tilia/card_dav/i_directory.rb +14 -0
- data/lib/tilia/card_dav/plugin.rb +724 -0
- data/lib/tilia/card_dav/vcf_export_plugin.rb +122 -0
- data/lib/tilia/card_dav/xml.rb +9 -0
- data/lib/tilia/card_dav/xml/filter.rb +11 -0
- data/lib/tilia/card_dav/xml/filter/address_data.rb +50 -0
- data/lib/tilia/card_dav/xml/filter/param_filter.rb +71 -0
- data/lib/tilia/card_dav/xml/filter/prop_filter.rb +77 -0
- data/lib/tilia/card_dav/xml/property.rb +10 -0
- data/lib/tilia/card_dav/xml/property/supported_address_data.rb +67 -0
- data/lib/tilia/card_dav/xml/property/supported_collation_set.rb +38 -0
- data/lib/tilia/card_dav/xml/request.rb +10 -0
- data/lib/tilia/card_dav/xml/request/address_book_multi_get_report.rb +91 -0
- data/lib/tilia/card_dav/xml/request/address_book_query_report.rb +156 -0
- data/lib/tilia/dav.rb +94 -0
- data/lib/tilia/dav/auth.rb +8 -0
- data/lib/tilia/dav/auth/backend.rb +15 -0
- data/lib/tilia/dav/auth/backend/abstract_basic.rb +119 -0
- data/lib/tilia/dav/auth/backend/abstract_digest.rb +132 -0
- data/lib/tilia/dav/auth/backend/apache.rb +85 -0
- data/lib/tilia/dav/auth/backend/backend_interface.rb +61 -0
- data/lib/tilia/dav/auth/backend/basic_call_back.rb +46 -0
- data/lib/tilia/dav/auth/backend/file.rb +61 -0
- data/lib/tilia/dav/auth/backend/sequel.rb +46 -0
- data/lib/tilia/dav/auth/plugin.rb +157 -0
- data/lib/tilia/dav/browser.rb +12 -0
- data/lib/tilia/dav/browser/assets/favicon.ico +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/ICON-LICENSE +21 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.css +510 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.eot +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.otf +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.svg +543 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.ttf +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.woff +0 -0
- data/lib/tilia/dav/browser/assets/sabredav.css +228 -0
- data/lib/tilia/dav/browser/assets/sabredav.png +0 -0
- data/lib/tilia/dav/browser/guess_content_type.rb +80 -0
- data/lib/tilia/dav/browser/html_output.rb +27 -0
- data/lib/tilia/dav/browser/html_output_helper.rb +86 -0
- data/lib/tilia/dav/browser/map_get_to_prop_find.rb +41 -0
- data/lib/tilia/dav/browser/plugin.rb +693 -0
- data/lib/tilia/dav/browser/prop_find_all.rb +95 -0
- data/lib/tilia/dav/client.rb +341 -0
- data/lib/tilia/dav/collection.rb +79 -0
- data/lib/tilia/dav/core_plugin.rb +824 -0
- data/lib/tilia/dav/exception.rb +59 -0
- data/lib/tilia/dav/exception/bad_request.rb +18 -0
- data/lib/tilia/dav/exception/conflict.rb +18 -0
- data/lib/tilia/dav/exception/conflicting_lock.rb +26 -0
- data/lib/tilia/dav/exception/forbidden.rb +18 -0
- data/lib/tilia/dav/exception/insufficient_storage.rb +18 -0
- data/lib/tilia/dav/exception/invalid_resource_type.rb +23 -0
- data/lib/tilia/dav/exception/invalid_sync_token.rb +26 -0
- data/lib/tilia/dav/exception/length_required.rb +18 -0
- data/lib/tilia/dav/exception/lock_token_matches_request_uri.rb +25 -0
- data/lib/tilia/dav/exception/locked.rb +48 -0
- data/lib/tilia/dav/exception/method_not_allowed.rb +29 -0
- data/lib/tilia/dav/exception/not_authenticated.rb +18 -0
- data/lib/tilia/dav/exception/not_found.rb +18 -0
- data/lib/tilia/dav/exception/not_implemented.rb +18 -0
- data/lib/tilia/dav/exception/payment_required.rb +18 -0
- data/lib/tilia/dav/exception/precondition_failed.rb +47 -0
- data/lib/tilia/dav/exception/report_not_supported.rb +21 -0
- data/lib/tilia/dav/exception/requested_range_not_satisfiable.rb +18 -0
- data/lib/tilia/dav/exception/service_unavailable.rb +18 -0
- data/lib/tilia/dav/exception/too_many_matches.rb +21 -0
- data/lib/tilia/dav/exception/unsupported_media_type.rb +18 -0
- data/lib/tilia/dav/file.rb +58 -0
- data/lib/tilia/dav/fs.rb +9 -0
- data/lib/tilia/dav/fs/directory.rb +119 -0
- data/lib/tilia/dav/fs/file.rb +69 -0
- data/lib/tilia/dav/fs/node.rb +57 -0
- data/lib/tilia/dav/fs_ext.rb +8 -0
- data/lib/tilia/dav/fs_ext/directory.rb +175 -0
- data/lib/tilia/dav/fs_ext/file.rb +118 -0
- data/lib/tilia/dav/i_collection.rb +65 -0
- data/lib/tilia/dav/i_extended_collection.rb +36 -0
- data/lib/tilia/dav/i_file.rb +70 -0
- data/lib/tilia/dav/i_move_target.rb +37 -0
- data/lib/tilia/dav/i_multi_get.rb +29 -0
- data/lib/tilia/dav/i_node.rb +33 -0
- data/lib/tilia/dav/i_properties.rb +39 -0
- data/lib/tilia/dav/i_quota.rb +19 -0
- data/lib/tilia/dav/locks.rb +9 -0
- data/lib/tilia/dav/locks/backend.rb +12 -0
- data/lib/tilia/dav/locks/backend/abstract_backend.rb +16 -0
- data/lib/tilia/dav/locks/backend/backend_interface.rb +41 -0
- data/lib/tilia/dav/locks/backend/file.rb +146 -0
- data/lib/tilia/dav/locks/backend/sequel.rb +154 -0
- data/lib/tilia/dav/locks/lock_info.rb +60 -0
- data/lib/tilia/dav/locks/plugin.rb +467 -0
- data/lib/tilia/dav/mk_col.rb +47 -0
- data/lib/tilia/dav/mount.rb +7 -0
- data/lib/tilia/dav/mount/plugin.rb +62 -0
- data/lib/tilia/dav/node.rb +36 -0
- data/lib/tilia/dav/partial_update.rb +8 -0
- data/lib/tilia/dav/partial_update/i_patch_support.rb +40 -0
- data/lib/tilia/dav/partial_update/plugin.rb +179 -0
- data/lib/tilia/dav/prop_find.rb +262 -0
- data/lib/tilia/dav/prop_patch.rb +278 -0
- data/lib/tilia/dav/property_storage.rb +8 -0
- data/lib/tilia/dav/property_storage/backend.rb +10 -0
- data/lib/tilia/dav/property_storage/backend/backend_interface.rb +69 -0
- data/lib/tilia/dav/property_storage/backend/sequel.rb +192 -0
- data/lib/tilia/dav/property_storage/plugin.rb +131 -0
- data/lib/tilia/dav/server.rb +1388 -0
- data/lib/tilia/dav/server_plugin.rb +81 -0
- data/lib/tilia/dav/simple_collection.rb +71 -0
- data/lib/tilia/dav/simple_file.rb +82 -0
- data/lib/tilia/dav/string_util.rb +68 -0
- data/lib/tilia/dav/sync.rb +8 -0
- data/lib/tilia/dav/sync/i_sync_collection.rb +80 -0
- data/lib/tilia/dav/sync/plugin.rb +225 -0
- data/lib/tilia/dav/temporary_file_filter_plugin.rb +248 -0
- data/lib/tilia/dav/tree.rb +270 -0
- data/lib/tilia/dav/uuid_util.rb +45 -0
- data/lib/tilia/dav/version.rb +9 -0
- data/lib/tilia/dav/xml.rb +11 -0
- data/lib/tilia/dav/xml/element.rb +10 -0
- data/lib/tilia/dav/xml/element/prop.rb +92 -0
- data/lib/tilia/dav/xml/element/response.rb +188 -0
- data/lib/tilia/dav/xml/property.rb +16 -0
- data/lib/tilia/dav/xml/property/complex.rb +76 -0
- data/lib/tilia/dav/xml/property/get_last_modified.rb +79 -0
- data/lib/tilia/dav/xml/property/href.rb +137 -0
- data/lib/tilia/dav/xml/property/lock_discovery.rb +89 -0
- data/lib/tilia/dav/xml/property/resource_type.rb +96 -0
- data/lib/tilia/dav/xml/property/supported_lock.rb +48 -0
- data/lib/tilia/dav/xml/property/supported_method_set.rb +101 -0
- data/lib/tilia/dav/xml/property/supported_report_set.rb +118 -0
- data/lib/tilia/dav/xml/request.rb +13 -0
- data/lib/tilia/dav/xml/request/lock.rb +67 -0
- data/lib/tilia/dav/xml/request/mk_col.rb +69 -0
- data/lib/tilia/dav/xml/request/prop_find.rb +70 -0
- data/lib/tilia/dav/xml/request/prop_patch.rb +101 -0
- data/lib/tilia/dav/xml/request/sync_collection_report.rb +102 -0
- data/lib/tilia/dav/xml/response.rb +9 -0
- data/lib/tilia/dav/xml/response/multi_status.rb +108 -0
- data/lib/tilia/dav/xml/service.rb +42 -0
- data/lib/tilia/dav_acl.rb +16 -0
- data/lib/tilia/dav_acl/abstract_principal_collection.rb +143 -0
- data/lib/tilia/dav_acl/exception.rb +11 -0
- data/lib/tilia/dav_acl/exception/ace_conflict.rb +21 -0
- data/lib/tilia/dav_acl/exception/need_privileges.rb +65 -0
- data/lib/tilia/dav_acl/exception/no_abstract.rb +21 -0
- data/lib/tilia/dav_acl/exception/not_recognized_principal.rb +21 -0
- data/lib/tilia/dav_acl/exception/not_supported_privilege.rb +21 -0
- data/lib/tilia/dav_acl/fs.rb +9 -0
- data/lib/tilia/dav_acl/fs/collection.rb +108 -0
- data/lib/tilia/dav_acl/fs/file.rb +87 -0
- data/lib/tilia/dav_acl/fs/home_collection.rb +148 -0
- data/lib/tilia/dav_acl/i_acl.rb +61 -0
- data/lib/tilia/dav_acl/i_principal.rb +63 -0
- data/lib/tilia/dav_acl/i_principal_collection.rb +52 -0
- data/lib/tilia/dav_acl/plugin.rb +1109 -0
- data/lib/tilia/dav_acl/principal.rb +213 -0
- data/lib/tilia/dav_acl/principal_backend.rb +11 -0
- data/lib/tilia/dav_acl/principal_backend/abstract_backend.rb +42 -0
- data/lib/tilia/dav_acl/principal_backend/backend_interface.rb +127 -0
- data/lib/tilia/dav_acl/principal_backend/create_principal_support.rb +27 -0
- data/lib/tilia/dav_acl/principal_backend/sequel.rb +313 -0
- data/lib/tilia/dav_acl/principal_collection.rb +117 -0
- data/lib/tilia/dav_acl/xml.rb +8 -0
- data/lib/tilia/dav_acl/xml/property.rb +13 -0
- data/lib/tilia/dav_acl/xml/property/acl.rb +222 -0
- data/lib/tilia/dav_acl/xml/property/acl_restrictions.rb +40 -0
- data/lib/tilia/dav_acl/xml/property/current_user_privilege_set.rb +125 -0
- data/lib/tilia/dav_acl/xml/property/principal.rb +149 -0
- data/lib/tilia/dav_acl/xml/property/supported_privilege_set.rb +135 -0
- data/lib/tilia/dav_acl/xml/request.rb +11 -0
- data/lib/tilia/dav_acl/xml/request/expand_property_report.rb +86 -0
- data/lib/tilia/dav_acl/xml/request/principal_property_search_report.rb +111 -0
- data/lib/tilia/dav_acl/xml/request/principal_search_property_set_report.rb +49 -0
- data/test/cal_dav/backend/abstract_sequel_test.rb +817 -0
- data/test/cal_dav/backend/abstract_test.rb +163 -0
- data/test/cal_dav/backend/mock.rb +169 -0
- data/test/cal_dav/backend/mock_scheduling.rb +84 -0
- data/test/cal_dav/backend/mock_sharing.rb +124 -0
- data/test/cal_dav/backend/mock_subscription_support.rb +123 -0
- data/test/cal_dav/backend/sequel_my_sql_test.rb +102 -0
- data/test/cal_dav/backend/sequel_sqlite_test.rb +105 -0
- data/test/cal_dav/calendar_home_notifications_test.rb +41 -0
- data/test/cal_dav/calendar_home_shared_calendars_test.rb +64 -0
- data/test/cal_dav/calendar_home_subscriptions_test.rb +67 -0
- data/test/cal_dav/calendar_home_test.rb +144 -0
- data/test/cal_dav/calendar_object_test.rb +317 -0
- data/test/cal_dav/calendar_query_v_alarm_test.rb +114 -0
- data/test/cal_dav/calendar_query_validator_test.rb +820 -0
- data/test/cal_dav/calendar_test.rb +203 -0
- data/test/cal_dav/expand_events_double_events_test.rb +94 -0
- data/test/cal_dav/expand_events_dtstar_tand_dten_dby_day_test.rb +94 -0
- data/test/cal_dav/expand_events_dtstar_tand_dtend_test.rb +100 -0
- data/test/cal_dav/expand_events_floating_time_test.rb +211 -0
- data/test/cal_dav/free_busy_report_test.rb +156 -0
- data/test/cal_dav/get_events_by_timerange_test.rb +74 -0
- data/test/cal_dav/ics_export_plugin_test.rb +638 -0
- data/test/cal_dav/issue166_test.rb +59 -0
- data/test/cal_dav/issue172_test.rb +139 -0
- data/test/cal_dav/issue203_test.rb +130 -0
- data/test/cal_dav/issue205_test.rb +89 -0
- data/test/cal_dav/issue211_test.rb +84 -0
- data/test/cal_dav/issue220_test.rb +94 -0
- data/test/cal_dav/issue228_test.rb +74 -0
- data/test/cal_dav/j_cal_transform_test.rb +244 -0
- data/test/cal_dav/notifications/collection_test.rb +67 -0
- data/test/cal_dav/notifications/node_test.rb +73 -0
- data/test/cal_dav/notifications/plugin_test.rb +144 -0
- data/test/cal_dav/plugin_test.rb +1049 -0
- data/test/cal_dav/principal/collection_test.rb +19 -0
- data/test/cal_dav/principal/proxy_read_test.rb +67 -0
- data/test/cal_dav/principal/proxy_write_test.rb +29 -0
- data/test/cal_dav/principal/user_test.rb +91 -0
- data/test/cal_dav/schedule/deliver_new_event_test.rb +81 -0
- data/test/cal_dav/schedule/free_busy_request_test.rb +565 -0
- data/test/cal_dav/schedule/i_mip/mock_plugin.rb +40 -0
- data/test/cal_dav/schedule/i_mip_plugin_test.rb +196 -0
- data/test/cal_dav/schedule/inbox_test.rb +150 -0
- data/test/cal_dav/schedule/outbox_post_test.rb +124 -0
- data/test/cal_dav/schedule/outbox_test.rb +76 -0
- data/test/cal_dav/schedule/plugin_basic_test.rb +39 -0
- data/test/cal_dav/schedule/plugin_properties_test.rb +96 -0
- data/test/cal_dav/schedule/plugin_properties_with_shared_calendar_test.rb +69 -0
- data/test/cal_dav/schedule/schedule_deliver_test.rb +605 -0
- data/test/cal_dav/schedule/scheduling_object_test.rb +327 -0
- data/test/cal_dav/shareable_calendar_test.rb +58 -0
- data/test/cal_dav/shared_calendar_test.rb +189 -0
- data/test/cal_dav/sharing_plugin_test.rb +373 -0
- data/test/cal_dav/subscriptions/create_subscription_test.rb +115 -0
- data/test/cal_dav/subscriptions/plugin_test.rb +46 -0
- data/test/cal_dav/subscriptions/subscription_test.rb +119 -0
- data/test/cal_dav/test_util.rb +164 -0
- data/test/cal_dav/validate_i_cal_test.rb +219 -0
- data/test/cal_dav/xml/notification/invite_reply_test.rb +136 -0
- data/test/cal_dav/xml/notification/invite_test.rb +225 -0
- data/test/cal_dav/xml/notification/system_status_test.rb +63 -0
- data/test/cal_dav/xml/property/allowed_sharing_modes_test.rb +34 -0
- data/test/cal_dav/xml/property/email_address_set_test.rb +35 -0
- data/test/cal_dav/xml/property/invite_test.rb +173 -0
- data/test/cal_dav/xml/property/schedule_calendar_transp_test.rb +96 -0
- data/test/cal_dav/xml/property/supported_calendar_component_set_test.rb +76 -0
- data/test/cal_dav/xml/property/supported_calendar_data_test.rb +32 -0
- data/test/cal_dav/xml/property/supported_collation_set_test.rb +33 -0
- data/test/cal_dav/xml/request/calendar_query_report_test.rb +339 -0
- data/test/cal_dav/xml/request/invite_reply_test.rb +68 -0
- data/test/cal_dav/xml/request/share_test.rb +79 -0
- data/test/card_dav/abstract_plugin_test.rb +24 -0
- data/test/card_dav/address_book_home_test.rb +128 -0
- data/test/card_dav/address_book_query_test.rb +303 -0
- data/test/card_dav/address_book_root_test.rb +26 -0
- data/test/card_dav/address_book_test.rb +166 -0
- data/test/card_dav/backend/abstract_sequel_test.rb +302 -0
- data/test/card_dav/backend/mock.rb +122 -0
- data/test/card_dav/backend/sequel_my_sql_test.rb +56 -0
- data/test/card_dav/backend/sequel_sqlite_test.rb +59 -0
- data/test/card_dav/card_test.rb +164 -0
- data/test/card_dav/i_directory_test.rb +22 -0
- data/test/card_dav/multi_get_test.rb +97 -0
- data/test/card_dav/plugin_test.rb +87 -0
- data/test/card_dav/sogo_strip_content_type_test.rb +63 -0
- data/test/card_dav/test_util.rb +51 -0
- data/test/card_dav/validate_filter_test.rb +210 -0
- data/test/card_dav/validate_v_card_test.rb +143 -0
- data/test/card_dav/vcf_export_test.rb +66 -0
- data/test/card_dav/xml/property/supported_address_data_test.rb +34 -0
- data/test/card_dav/xml/property/supported_collation_set_test.rb +34 -0
- data/test/card_dav/xml/request/address_book_query_report_test.rb +276 -0
- data/test/dav/abstract_server.rb +36 -0
- data/test/dav/auth/backend/abstract_basic_test.rb +74 -0
- data/test/dav/auth/backend/abstract_digest_test.rb +114 -0
- data/test/dav/auth/backend/abstract_sequel_test.rb +25 -0
- data/test/dav/auth/backend/apache_test.rb +60 -0
- data/test/dav/auth/backend/basic_call_back_test.rb +33 -0
- data/test/dav/auth/backend/file_test.rb +43 -0
- data/test/dav/auth/backend/mock.rb +73 -0
- data/test/dav/auth/backend/sequel_my_sql_test.rb +32 -0
- data/test/dav/auth/backend/sequel_sqlite_test.rb +21 -0
- data/test/dav/auth/plugin_test.rb +92 -0
- data/test/dav/basic_node_test.rb +143 -0
- data/test/dav/browser/guess_content_type_test.rb +44 -0
- data/test/dav/browser/map_get_to_prop_find_test.rb +37 -0
- data/test/dav/browser/plugin_test.rb +165 -0
- data/test/dav/browser/prop_find_all_test.rb +59 -0
- data/test/dav/client_mock.rb +24 -0
- data/test/dav/client_test.rb +231 -0
- data/test/dav/copy_test.rb +33 -0
- data/test/dav/exception/locked_test.rb +61 -0
- data/test/dav/exception/payment_required_test.rb +14 -0
- data/test/dav/exception/service_unavailable_test.rb +14 -0
- data/test/dav/exception/too_many_matches_test.rb +31 -0
- data/test/dav/exception_test.rb +24 -0
- data/test/dav/fs_ext/file_test.rb +72 -0
- data/test/dav/fs_ext/server_test.rb +251 -0
- data/test/dav/get_if_conditions_test.rb +299 -0
- data/test/dav/http_delete_test.rb +110 -0
- data/test/dav/http_get_test.rb +130 -0
- data/test/dav/http_head_test.rb +80 -0
- data/test/dav/http_move_test.rb +105 -0
- data/test/dav/http_prefer_parsing_test.rb +186 -0
- data/test/dav/http_put_test.rb +271 -0
- data/test/dav/issue33_test.rb +90 -0
- data/test/dav/locks/backend/abstract_test.rb +160 -0
- data/test/dav/locks/backend/file_test.rb +24 -0
- data/test/dav/locks/backend/mock.rb +82 -0
- data/test/dav/locks/backend/sequel_my_sql_test.rb +32 -0
- data/test/dav/locks/backend/sequel_test.rb +19 -0
- data/test/dav/locks/ms_word_test.rb +119 -0
- data/test/dav/locks/plugin2_test.rb +61 -0
- data/test/dav/locks/plugin_test.rb +896 -0
- data/test/dav/mock/collection.rb +113 -0
- data/test/dav/mock/file.rb +100 -0
- data/test/dav/mock/properties_collection.rb +80 -0
- data/test/dav/mock/streaming_file.rb +66 -0
- data/test/dav/mount/plugin_test.rb +48 -0
- data/test/dav/object_tree_test.rb +65 -0
- data/test/dav/partial_update/file_mock.rb +92 -0
- data/test/dav/partial_update/plugin_test.rb +125 -0
- data/test/dav/partial_update/specification_test.rb +77 -0
- data/test/dav/prop_find_test.rb +87 -0
- data/test/dav/prop_patch_test.rb +367 -0
- data/test/dav/property_storage/backend/abstract_sequel_test.rb +147 -0
- data/test/dav/property_storage/backend/mock.rb +96 -0
- data/test/dav/property_storage/backend/sequel_mysql_test.rb +32 -0
- data/test/dav/property_storage/backend/sequel_sqlite_test.rb +31 -0
- data/test/dav/property_storage/plugin_test.rb +90 -0
- data/test/dav/server_copy_move_test.rb +164 -0
- data/test/dav/server_events_test.rb +105 -0
- data/test/dav/server_mkcol_test.rb +337 -0
- data/test/dav/server_mock.rb +10 -0
- data/test/dav/server_plugin_test.rb +85 -0
- data/test/dav/server_precondition_test.rb +253 -0
- data/test/dav/server_props_infinite_depth_test.rb +144 -0
- data/test/dav/server_props_test.rb +182 -0
- data/test/dav/server_range_test.rb +262 -0
- data/test/dav/server_simple_test.rb +388 -0
- data/test/dav/server_update_properties_test.rb +93 -0
- data/test/dav/simple_file_test.rb +17 -0
- data/test/dav/string_util_test.rb +92 -0
- data/test/dav/sync/mock_sync_collection.rb +141 -0
- data/test/dav/sync/plugin_test.rb +491 -0
- data/test/dav/sync_token_property_test.rb +105 -0
- data/test/dav/temporary_file_filter_test.rb +179 -0
- data/test/dav/test_plugin.rb +24 -0
- data/test/dav/tree_test.rb +201 -0
- data/test/dav/uuid_util_test.rb +14 -0
- data/test/dav/xml/element/prop_test.rb +121 -0
- data/test/dav/xml/element/response_test.rb +202 -0
- data/test/dav/xml/property/href_test.rb +112 -0
- data/test/dav/xml/property/last_modified_test.rb +52 -0
- data/test/dav/xml/property/lock_discovery_test.rb +79 -0
- data/test/dav/xml/property/supported_method_set_test.rb +54 -0
- data/test/dav/xml/property/supported_report_set_test.rb +109 -0
- data/test/dav/xml/request/prop_find_test.rb +45 -0
- data/test/dav/xml/request/prop_patch_test.rb +47 -0
- data/test/dav/xml/request/sync_collection_test.rb +89 -0
- data/test/dav/xml/xml_tester.rb +35 -0
- data/test/dav_acl/acl_method_test.rb +299 -0
- data/test/dav_acl/allow_access_test.rb +94 -0
- data/test/dav_acl/block_access_test.rb +161 -0
- data/test/dav_acl/exception/ace_conflict_test.rb +33 -0
- data/test/dav_acl/exception/need_privileges_exception_test.rb +43 -0
- data/test/dav_acl/exception/no_abstract_test.rb +33 -0
- data/test/dav_acl/exception/not_recognized_principal_test.rb +33 -0
- data/test/dav_acl/exception/not_supported_privilege_test.rb +33 -0
- data/test/dav_acl/expand_properties_test.rb +265 -0
- data/test/dav_acl/fs/collection_test.rb +39 -0
- data/test/dav_acl/fs/file_test.rb +47 -0
- data/test/dav_acl/fs/home_collection_test.rb +82 -0
- data/test/dav_acl/mock_acl_node.rb +27 -0
- data/test/dav_acl/mock_principal.rb +27 -0
- data/test/dav_acl/plugin_admin_test.rb +60 -0
- data/test/dav_acl/plugin_properties_test.rb +346 -0
- data/test/dav_acl/plugin_update_properties_test.rb +82 -0
- data/test/dav_acl/principal_backend/abstract_sequel_test.rb +159 -0
- data/test/dav_acl/principal_backend/mock.rb +150 -0
- data/test/dav_acl/principal_backend/sequel_my_sql_test.rb +43 -0
- data/test/dav_acl/principal_backend/sequel_sqlite_test.rb +31 -0
- data/test/dav_acl/principal_collection_test.rb +44 -0
- data/test/dav_acl/principal_property_search_test.rb +354 -0
- data/test/dav_acl/principal_search_property_set_test.rb +125 -0
- data/test/dav_acl/principal_test.rb +181 -0
- data/test/dav_acl/simple_plugin_test.rb +320 -0
- data/test/dav_acl/xml/property/acl_restrictions_test.rb +28 -0
- data/test/dav_acl/xml/property/acl_test.rb +325 -0
- data/test/dav_acl/xml/property/current_user_privilege_set_test.rb +77 -0
- data/test/dav_acl/xml/property/principal_test.rb +158 -0
- data/test/dav_acl/xml/property/supported_privilege_set_test.rb +109 -0
- data/test/dav_server_test.rb +225 -0
- data/test/http/response_mock.rb +16 -0
- data/test/http/sapi_mock.rb +29 -0
- data/test/test_helper.rb +176 -0
- data/tilia-dav.gemspec +28 -0
- metadata +726 -0
@@ -0,0 +1,824 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
module Tilia
|
4
|
+
module Dav
|
5
|
+
# The core plugin provides all the basic features for a WebDAV server.
|
6
|
+
class CorePlugin < ServerPlugin
|
7
|
+
# Reference to server object.
|
8
|
+
#
|
9
|
+
# @var Server
|
10
|
+
# RUBY: attr_accessor :server
|
11
|
+
|
12
|
+
# Sets up the plugin
|
13
|
+
#
|
14
|
+
# @param Server server
|
15
|
+
# @return void
|
16
|
+
def setup(server)
|
17
|
+
@server = server
|
18
|
+
server.on('method:GET', method(:http_get))
|
19
|
+
server.on('method:OPTIONS', method(:http_options))
|
20
|
+
server.on('method:HEAD', method(:http_head))
|
21
|
+
server.on('method:DELETE', method(:http_delete))
|
22
|
+
server.on('method:PROPFIND', method(:http_prop_find))
|
23
|
+
server.on('method:PROPPATCH', method(:http_prop_patch))
|
24
|
+
server.on('method:PUT', method(:http_put))
|
25
|
+
server.on('method:MKCOL', method(:http_mkcol))
|
26
|
+
server.on('method:MOVE', method(:http_move))
|
27
|
+
server.on('method:COPY', method(:http_copy))
|
28
|
+
server.on('method:REPORT', method(:http_report))
|
29
|
+
|
30
|
+
server.on('propPatch', method(:prop_patch_protected_property_check), 90)
|
31
|
+
server.on('propPatch', method(:prop_patch_node_update), 200)
|
32
|
+
server.on('propFind', method(:prop_find))
|
33
|
+
server.on('propFind', method(:prop_find_node), 120)
|
34
|
+
server.on('propFind', method(:prop_find_late), 200)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns a plugin name.
|
38
|
+
#
|
39
|
+
# Using this name other plugins will be able to access other plugins
|
40
|
+
# using DAV\Server::getPlugin
|
41
|
+
#
|
42
|
+
# @return string
|
43
|
+
def plugin_name
|
44
|
+
'core'
|
45
|
+
end
|
46
|
+
|
47
|
+
# This is the default implementation for the GET method.
|
48
|
+
#
|
49
|
+
# @param RequestInterface request
|
50
|
+
# @param ResponseInterface response
|
51
|
+
# @return bool
|
52
|
+
def http_get(request, response)
|
53
|
+
path = request.path
|
54
|
+
node = @server.tree.node_for_path(path)
|
55
|
+
|
56
|
+
return nil unless node.is_a?(IFile)
|
57
|
+
|
58
|
+
body = node.get
|
59
|
+
|
60
|
+
# Converting string into stream, if needed.
|
61
|
+
if body.is_a?(String)
|
62
|
+
stream = StringIO.new
|
63
|
+
stream.write(body)
|
64
|
+
stream.rewind
|
65
|
+
body = stream
|
66
|
+
end
|
67
|
+
|
68
|
+
# TODO: getetag, getlastmodified, getsize should also be used using
|
69
|
+
# this method
|
70
|
+
http_headers = @server.http_headers(path)
|
71
|
+
|
72
|
+
# ContentType needs to get a default, because many webservers will otherwise
|
73
|
+
# default to text/html, and we don't want this for security reasons.
|
74
|
+
unless http_headers.key?('Content-Type')
|
75
|
+
http_headers['Content-Type'] = 'application/octet-stream'
|
76
|
+
end
|
77
|
+
|
78
|
+
if http_headers.key?('Content-Length')
|
79
|
+
node_size = http_headers['Content-Length'].to_i
|
80
|
+
|
81
|
+
# Need to unset Content-Length, because we'll handle that during figuring out the range
|
82
|
+
http_headers.delete('Content-Length')
|
83
|
+
else
|
84
|
+
node_size = 0
|
85
|
+
end
|
86
|
+
|
87
|
+
response.add_headers(http_headers)
|
88
|
+
|
89
|
+
range = @server.http_range
|
90
|
+
if_range = request.header('If-Range')
|
91
|
+
ignore_range_header = false
|
92
|
+
|
93
|
+
# If ifRange is set, and range is specified, we first need to check
|
94
|
+
# the precondition.
|
95
|
+
if node_size > 0 && range && if_range
|
96
|
+
# if IfRange is parsable as a date we'll treat it as a DateTime
|
97
|
+
# otherwise, we must treat it as an etag.
|
98
|
+
|
99
|
+
if_range_date = Chronic.parse(if_range)
|
100
|
+
|
101
|
+
if if_range_date
|
102
|
+
# It's a date. We must check if the entity is modified since
|
103
|
+
# the specified date.
|
104
|
+
if !http_headers.key?('Last-Modified')
|
105
|
+
ignore_range_header = true
|
106
|
+
else
|
107
|
+
modified = Time.parse(http_headers['Last-Modified'])
|
108
|
+
ignore_range_header = true if modified > if_range_date
|
109
|
+
end
|
110
|
+
else
|
111
|
+
# It's an entity. We can do a simple comparison.
|
112
|
+
if !http_headers.key?('ETag')
|
113
|
+
ignore_range_header = true
|
114
|
+
elsif http_headers['ETag'] != if_range
|
115
|
+
ignore_range_header = true
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# We're only going to support HTTP ranges if the backend provided a filesize
|
121
|
+
if !ignore_range_header && node_size && range
|
122
|
+
# Determining the exact byte offsets
|
123
|
+
if range[0]
|
124
|
+
start = range[0]
|
125
|
+
ending = range[1] ? range[1] : node_size - 1
|
126
|
+
if start >= node_size
|
127
|
+
fail Exception::RequestedRangeNotSatisfiable, "The start offset (#{range[0]}) exceeded the size of the entity (#{node_size})"
|
128
|
+
end
|
129
|
+
|
130
|
+
if ending < start
|
131
|
+
fail Exception::RequestedRangeNotSatisfiable, "The end offset (#{range[1]}) is lower than the start offset (#{range[0]})"
|
132
|
+
end
|
133
|
+
|
134
|
+
ending = node_size - 1 if ending >= node_size
|
135
|
+
else
|
136
|
+
start = node_size - range[1]
|
137
|
+
ending = node_size - 1
|
138
|
+
|
139
|
+
start = 0 if start < 0
|
140
|
+
end
|
141
|
+
|
142
|
+
# for a seekable body stream we simply set the pointer
|
143
|
+
# for a non-seekable body stream we read and discard just the
|
144
|
+
# right amount of data
|
145
|
+
if body.respond_to?(:seek)
|
146
|
+
body.seek(start)
|
147
|
+
else
|
148
|
+
consume_block = 8192
|
149
|
+
consumed = 0
|
150
|
+
loop do
|
151
|
+
break unless start - consumed > 0
|
152
|
+
|
153
|
+
if body.eof?
|
154
|
+
fail Exception::RequestedRangeNotSatisfiable, "The start offset (#{start}) exceeded the size of the entity (#{consumed})"
|
155
|
+
end
|
156
|
+
|
157
|
+
consumed += body.read([start - consumed, consume_block].min)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
response.update_header('Content-Length', ending - start + 1)
|
162
|
+
response.update_header('Content-Range', "bytes #{start}-#{ending}/#{node_size}")
|
163
|
+
response.status = 206
|
164
|
+
response.body = body
|
165
|
+
else
|
166
|
+
response.update_header('Content-Length', node_size) if node_size > 0
|
167
|
+
response.status = 200
|
168
|
+
response.body = body
|
169
|
+
end
|
170
|
+
|
171
|
+
# Sending back false will interupt the event chain and tell the server
|
172
|
+
# we've handled this method.
|
173
|
+
false
|
174
|
+
end
|
175
|
+
|
176
|
+
# HTTP OPTIONS
|
177
|
+
#
|
178
|
+
# @param RequestInterface request
|
179
|
+
# @param ResponseInterface response
|
180
|
+
# @return bool
|
181
|
+
def http_options(request, response)
|
182
|
+
methods = @server.allowed_methods(request.path)
|
183
|
+
|
184
|
+
response.update_header('Allow', methods.join(', ').upcase)
|
185
|
+
features = ['1', '3', 'extended-mkcol']
|
186
|
+
|
187
|
+
@server.plugins.each do |_name, plugin|
|
188
|
+
features += plugin.features
|
189
|
+
end
|
190
|
+
|
191
|
+
response.update_header('DAV', features.join(', '))
|
192
|
+
response.update_header('MS-Author-Via', 'DAV')
|
193
|
+
response.update_header('Accept-Ranges', 'bytes')
|
194
|
+
response.update_header('Content-Length', '0')
|
195
|
+
response.status = 200
|
196
|
+
|
197
|
+
# Sending back false will interupt the event chain and tell the server
|
198
|
+
# we've handled this method.
|
199
|
+
false
|
200
|
+
end
|
201
|
+
|
202
|
+
# HTTP HEAD
|
203
|
+
#
|
204
|
+
# This method is normally used to take a peak at a url, and only get the
|
205
|
+
# HTTP response headers, without the body. This is used by clients to
|
206
|
+
# determine if a remote file was changed, so they can use a local cached
|
207
|
+
# version, instead of downloading it again
|
208
|
+
#
|
209
|
+
# @param RequestInterface request
|
210
|
+
# @param ResponseInterface response
|
211
|
+
# @return bool
|
212
|
+
def http_head(request, response)
|
213
|
+
# This is implemented by changing the HEAD request to a GET request,
|
214
|
+
# and dropping the response body.
|
215
|
+
sub_request = request.clone
|
216
|
+
sub_request.method = 'GET'
|
217
|
+
|
218
|
+
begin
|
219
|
+
@server.invoke_method(sub_request, response, false)
|
220
|
+
response.body = ''
|
221
|
+
rescue Exception::NotImplemented => e
|
222
|
+
# Some clients may do HEAD requests on collections, however, GET
|
223
|
+
# requests and HEAD requests _may_ not be defined on a collection,
|
224
|
+
# which would trigger a 501.
|
225
|
+
# This breaks some clients though, so we're transforming these
|
226
|
+
# 501s into 200s.
|
227
|
+
response.status = 200
|
228
|
+
response.body = ''
|
229
|
+
response.update_header('Content-Type', 'text/plain')
|
230
|
+
response.update_header('X-Sabre-Real-Status', e.http_code)
|
231
|
+
end
|
232
|
+
|
233
|
+
# Sending back false will interupt the event chain and tell the server
|
234
|
+
# we've handled this method.
|
235
|
+
false
|
236
|
+
end
|
237
|
+
|
238
|
+
# HTTP Delete
|
239
|
+
#
|
240
|
+
# The HTTP delete method, deletes a given uri
|
241
|
+
#
|
242
|
+
# @param RequestInterface request
|
243
|
+
# @param ResponseInterface response
|
244
|
+
# @return void
|
245
|
+
def http_delete(request, response)
|
246
|
+
path = request.path
|
247
|
+
|
248
|
+
return false unless @server.emit('beforeUnbind', [path])
|
249
|
+
|
250
|
+
@server.tree.delete(path)
|
251
|
+
|
252
|
+
@server.emit('afterUnbind', [path])
|
253
|
+
|
254
|
+
response.status = 204
|
255
|
+
response.update_header('Content-Length', '0')
|
256
|
+
|
257
|
+
# Sending back false will interupt the event chain and tell the server
|
258
|
+
# we've handled this method.
|
259
|
+
false
|
260
|
+
end
|
261
|
+
|
262
|
+
# WebDAV PROPFIND
|
263
|
+
#
|
264
|
+
# This WebDAV method requests information about an uri resource, or a list of resources
|
265
|
+
# If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value
|
266
|
+
# If the value is 1, it means that it also expects a list of sub-resources (e.g.: files in a directory)
|
267
|
+
#
|
268
|
+
# The request body contains an XML data structure that has a list of properties the client understands
|
269
|
+
# The response body is also an xml document, containing information about every uri resource and the requested properties
|
270
|
+
#
|
271
|
+
# It has to return a HTTP 207 Multi-status status code
|
272
|
+
#
|
273
|
+
# @param RequestInterface request
|
274
|
+
# @param ResponseInterface response
|
275
|
+
# @return void
|
276
|
+
def http_prop_find(request, response)
|
277
|
+
path = request.path
|
278
|
+
|
279
|
+
request_body = request.body_as_string
|
280
|
+
if request_body.size > 0
|
281
|
+
begin
|
282
|
+
prop_find_xml = @server.xml.expect('{DAV:}propfind', request_body)
|
283
|
+
rescue Tilia::Xml::ParseException => e
|
284
|
+
raise Exception::BadRequest, e.message, nil, e
|
285
|
+
end
|
286
|
+
else
|
287
|
+
prop_find_xml = Xml::Request::PropFind.new
|
288
|
+
prop_find_xml.all_prop = true
|
289
|
+
prop_find_xml.properties = []
|
290
|
+
end
|
291
|
+
|
292
|
+
depth = @server.http_depth(1)
|
293
|
+
# The only two options for the depth of a propfind is 0 or 1 - as long as depth infinity is not enabled
|
294
|
+
depth = 1 if !@server.enable_propfind_depth_infinity && depth != 0
|
295
|
+
|
296
|
+
new_properties = @server.properties_for_path(path, prop_find_xml.properties, depth)
|
297
|
+
|
298
|
+
# This is a multi-status response
|
299
|
+
response.status = 207
|
300
|
+
response.update_header('Content-Type', 'application/xml; charset=utf-8')
|
301
|
+
response.update_header('Vary', 'Brief,Prefer')
|
302
|
+
|
303
|
+
# Normally this header is only needed for OPTIONS responses, however..
|
304
|
+
# iCal seems to also depend on these being set for PROPFIND. Since
|
305
|
+
# this is not harmful, we'll add it.
|
306
|
+
features = ['1', '3', 'extended-mkcol']
|
307
|
+
@server.plugins.each do |_, plugin|
|
308
|
+
features += plugin.features
|
309
|
+
end
|
310
|
+
response.update_header('DAV', features.join(', '))
|
311
|
+
|
312
|
+
prefer = @server.http_prefer
|
313
|
+
minimal = prefer['return'] == 'minimal'
|
314
|
+
|
315
|
+
data = @server.generate_multi_status(new_properties, minimal)
|
316
|
+
response.body = data
|
317
|
+
|
318
|
+
# Sending back false will interupt the event chain and tell the server
|
319
|
+
# we've handled this method.
|
320
|
+
false
|
321
|
+
end
|
322
|
+
|
323
|
+
# WebDAV PROPPATCH
|
324
|
+
#
|
325
|
+
# This method is called to update properties on a Node. The request is an XML body with all the mutations.
|
326
|
+
# In this XML body it is specified which properties should be set/updated and/or deleted
|
327
|
+
#
|
328
|
+
# @param RequestInterface request
|
329
|
+
# @param ResponseInterface response
|
330
|
+
# @return bool
|
331
|
+
def http_prop_patch(request, response)
|
332
|
+
path = request.path
|
333
|
+
|
334
|
+
begin
|
335
|
+
prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)
|
336
|
+
rescue Tilia::Xml::ParseException => e
|
337
|
+
raise Exception::BadRequest, e.message, nil, e
|
338
|
+
end
|
339
|
+
|
340
|
+
new_properties = prop_patch.properties
|
341
|
+
|
342
|
+
result = @server.update_properties(path, new_properties)
|
343
|
+
|
344
|
+
prefer = @server.http_prefer
|
345
|
+
response.update_header('Vary', 'Brief,Prefer')
|
346
|
+
|
347
|
+
if prefer['return'] == 'minimal'
|
348
|
+
# If return-minimal is specified, we only have to check if the
|
349
|
+
# request was succesful, and don't need to return the
|
350
|
+
# multi-status.
|
351
|
+
ok = true
|
352
|
+
result.each do |_prop, code|
|
353
|
+
ok = false if code.to_i > 299
|
354
|
+
end
|
355
|
+
|
356
|
+
if ok
|
357
|
+
response.status = 204
|
358
|
+
return false
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
response.status = 207
|
363
|
+
response.update_header('Content-Type', 'application/xml; charset=utf-8')
|
364
|
+
|
365
|
+
# Reorganizing the result for generateMultiStatus
|
366
|
+
multi_status = {}
|
367
|
+
result.each do |property_name, code|
|
368
|
+
if multi_status.key?(code)
|
369
|
+
multi_status[code][property_name] = nil
|
370
|
+
else
|
371
|
+
multi_status[code] = { property_name => nil }
|
372
|
+
end
|
373
|
+
end
|
374
|
+
multi_status['href'] = path
|
375
|
+
|
376
|
+
response.body = @server.generate_multi_status([multi_status])
|
377
|
+
|
378
|
+
# Sending back false will interupt the event chain and tell the server
|
379
|
+
# we've handled this method.
|
380
|
+
false
|
381
|
+
end
|
382
|
+
|
383
|
+
# HTTP PUT method
|
384
|
+
#
|
385
|
+
# This HTTP method updates a file, or creates a new one.
|
386
|
+
#
|
387
|
+
# If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 204 No Content
|
388
|
+
#
|
389
|
+
# @param RequestInterface request
|
390
|
+
# @param ResponseInterface response
|
391
|
+
# @return bool
|
392
|
+
def http_put(request, response)
|
393
|
+
body = request.body_as_stream
|
394
|
+
path = request.path
|
395
|
+
|
396
|
+
# Intercepting Content-Range
|
397
|
+
if request.header('Content-Range')
|
398
|
+
# An origin server that allows PUT on a given target resource MUST send
|
399
|
+
# a 400 (Bad Request) response to a PUT request that contains a
|
400
|
+
# Content-Range header field.
|
401
|
+
#
|
402
|
+
# Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4
|
403
|
+
fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'
|
404
|
+
end
|
405
|
+
|
406
|
+
# Intercepting the Finder problem
|
407
|
+
expected = request.header('X-Expected-Entity-Length').to_i
|
408
|
+
if expected > 0
|
409
|
+
# Many webservers will not cooperate well with Finder PUT requests,
|
410
|
+
# because it uses 'Chunked' transfer encoding for the request body.
|
411
|
+
#
|
412
|
+
# The symptom of this problem is that Finder sends files to the
|
413
|
+
# server, but they arrive as 0-length files in PHP.
|
414
|
+
#
|
415
|
+
# If we don't do anything, the user might think they are uploading
|
416
|
+
# files successfully, but they end up empty on the server. Instead,
|
417
|
+
# we throw back an error if we detect this.
|
418
|
+
#
|
419
|
+
# The reason Finder uses Chunked, is because it thinks the files
|
420
|
+
# might change as it's being uploaded, and therefore the
|
421
|
+
# Content-Length can vary.
|
422
|
+
#
|
423
|
+
# Instead it sends the X-Expected-Entity-Length header with the size
|
424
|
+
# of the file at the very start of the request. If this header is set,
|
425
|
+
# but we don't get a request body we will fail the request to
|
426
|
+
# protect the end-user.
|
427
|
+
|
428
|
+
# Only reading first byte
|
429
|
+
first_byte = body.read(1)
|
430
|
+
unless first_byte
|
431
|
+
fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'
|
432
|
+
end
|
433
|
+
|
434
|
+
# The body needs to stay intact, so we copy everything to a
|
435
|
+
# temporary stream.
|
436
|
+
|
437
|
+
new_body = StringIO.new
|
438
|
+
new_body.write(first_byte)
|
439
|
+
IO.copy_stream(body, new_body)
|
440
|
+
new_body.rewind
|
441
|
+
|
442
|
+
body = new_body
|
443
|
+
end
|
444
|
+
|
445
|
+
if @server.tree.node_exists(path)
|
446
|
+
node = @server.tree.node_for_path(path)
|
447
|
+
|
448
|
+
# If the node is a collection, we'll deny it
|
449
|
+
unless node.is_a?(IFile)
|
450
|
+
fail Exception::Conflict, 'PUT is not allowed on non-files.'
|
451
|
+
end
|
452
|
+
|
453
|
+
etag = Box.new
|
454
|
+
return false unless @server.update_file(path, body, etag)
|
455
|
+
etag = etag.value
|
456
|
+
|
457
|
+
response.update_header('Content-Length', '0')
|
458
|
+
response.update_header('ETag', etag) if etag
|
459
|
+
response.status = 204
|
460
|
+
else
|
461
|
+
# If we got here, the resource didn't exist yet.
|
462
|
+
etag = Box.new
|
463
|
+
unless @server.create_file(path, body, etag)
|
464
|
+
# For one reason or another the file was not created.
|
465
|
+
return false
|
466
|
+
end
|
467
|
+
etag = etag.value
|
468
|
+
|
469
|
+
response.update_header('Content-Length', '0')
|
470
|
+
response.update_header('ETag', etag) if etag
|
471
|
+
response.status = 201
|
472
|
+
end
|
473
|
+
|
474
|
+
# Sending back false will interupt the event chain and tell the server
|
475
|
+
# we've handled this method.
|
476
|
+
false
|
477
|
+
end
|
478
|
+
|
479
|
+
# WebDAV MKCOL
|
480
|
+
#
|
481
|
+
# The MKCOL method is used to create a new collection (directory) on the server
|
482
|
+
#
|
483
|
+
# @param RequestInterface request
|
484
|
+
# @param ResponseInterface response
|
485
|
+
# @return bool
|
486
|
+
def http_mkcol(request, response)
|
487
|
+
request_body = request.body_as_string
|
488
|
+
path = request.path
|
489
|
+
|
490
|
+
if !request_body.blank?
|
491
|
+
content_type = request.header('Content-Type') || ''
|
492
|
+
if content_type.index('application/xml') != 0 && content_type.index('text/xml') != 0
|
493
|
+
# We must throw 415 for unsupported mkcol bodies
|
494
|
+
fail Exception::UnsupportedMediaType, 'The request body for the MKCOL request must have an xml Content-Type'
|
495
|
+
end
|
496
|
+
|
497
|
+
begin
|
498
|
+
mkcol = @server.xml.expect('{DAV:}mkcol', request_body)
|
499
|
+
rescue Tilia::Xml::ParseException => e
|
500
|
+
raise Exception::BadRequest, e.message
|
501
|
+
end
|
502
|
+
|
503
|
+
properties = mkcol.properties
|
504
|
+
|
505
|
+
unless properties.key?('{DAV:}resourcetype')
|
506
|
+
fail Exception::BadRequest, 'The mkcol request must include a {DAV:}resourcetype property'
|
507
|
+
end
|
508
|
+
|
509
|
+
resource_type = properties['{DAV:}resourcetype'].value
|
510
|
+
properties.delete('{DAV:}resourcetype')
|
511
|
+
else
|
512
|
+
properties = {}
|
513
|
+
resource_type = ['{DAV:}collection']
|
514
|
+
end
|
515
|
+
|
516
|
+
mkcol = MkCol.new(resource_type, properties)
|
517
|
+
|
518
|
+
result = @server.create_collection(path, mkcol)
|
519
|
+
|
520
|
+
if result.is_a?(Hash)
|
521
|
+
response.status = 207
|
522
|
+
response.update_header('Content-Type', 'application/xml; charset=utf-8')
|
523
|
+
|
524
|
+
response.body = @server.generate_multi_status([result])
|
525
|
+
else
|
526
|
+
response.update_header('Content-Length', '0')
|
527
|
+
response.status = 201
|
528
|
+
end
|
529
|
+
|
530
|
+
# Sending back false will interupt the event chain and tell the server
|
531
|
+
# we've handled this method.
|
532
|
+
false
|
533
|
+
end
|
534
|
+
|
535
|
+
# WebDAV HTTP MOVE method
|
536
|
+
#
|
537
|
+
# This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo
|
538
|
+
#
|
539
|
+
# @param RequestInterface request
|
540
|
+
# @param ResponseInterface response
|
541
|
+
# @return bool
|
542
|
+
def http_move(request, response)
|
543
|
+
path = request.path
|
544
|
+
|
545
|
+
move_info = @server.copy_and_move_info(request)
|
546
|
+
|
547
|
+
if move_info['destinationExists']
|
548
|
+
return false unless @server.emit('beforeUnbind', [move_info['destination']])
|
549
|
+
end
|
550
|
+
|
551
|
+
return false unless @server.emit('beforeUnbind', [path])
|
552
|
+
return false unless @server.emit('beforeBind', [move_info['destination']])
|
553
|
+
return false unless @server.emit('beforeMove', [path, move_info['destination']])
|
554
|
+
|
555
|
+
if move_info['destinationExists']
|
556
|
+
@server.tree.delete(move_info['destination'])
|
557
|
+
@server.emit('afterUnbind', [move_info['destination']])
|
558
|
+
end
|
559
|
+
|
560
|
+
@server.tree.move(path, move_info['destination'])
|
561
|
+
|
562
|
+
# Its important afterMove is called before afterUnbind, because it
|
563
|
+
# allows systems to transfer data from one path to another.
|
564
|
+
# PropertyStorage uses this. If afterUnbind was first, it would clean
|
565
|
+
# up all the properties before it has a chance.
|
566
|
+
@server.emit('afterMove', [path, move_info['destination']])
|
567
|
+
@server.emit('afterUnbind', [path])
|
568
|
+
@server.emit('afterBind', [move_info['destination']])
|
569
|
+
|
570
|
+
# If a resource was overwritten we should send a 204, otherwise a 201
|
571
|
+
response.update_header('Content-Length', '0')
|
572
|
+
response.status = move_info['destinationExists'] ? 204 : 201
|
573
|
+
|
574
|
+
# Sending back false will interupt the event chain and tell the server
|
575
|
+
# we've handled this method.
|
576
|
+
false
|
577
|
+
end
|
578
|
+
|
579
|
+
# WebDAV HTTP COPY method
|
580
|
+
#
|
581
|
+
# This method copies one uri to a different uri, and works much like the MOVE request
|
582
|
+
# A lot of the actual request processing is done in getCopyMoveInfo
|
583
|
+
#
|
584
|
+
# @param RequestInterface request
|
585
|
+
# @param ResponseInterface response
|
586
|
+
# @return bool
|
587
|
+
def http_copy(request, response)
|
588
|
+
path = request.path
|
589
|
+
|
590
|
+
copy_info = @server.copy_and_move_info(request)
|
591
|
+
|
592
|
+
if copy_info['destinationExists']
|
593
|
+
return false unless @server.emit('beforeUnbind', [copy_info['destination']])
|
594
|
+
@server.tree.delete(copy_info['destination'])
|
595
|
+
end
|
596
|
+
|
597
|
+
return false unless @server.emit('beforeBind', [copy_info['destination']])
|
598
|
+
|
599
|
+
@server.tree.copy(path, copy_info['destination'])
|
600
|
+
|
601
|
+
@server.emit('afterBind', [copy_info['destination']])
|
602
|
+
|
603
|
+
# If a resource was overwritten we should send a 204, otherwise a 201
|
604
|
+
response.update_header('Content-Length', '0')
|
605
|
+
response.status = copy_info['destinationExists'] ? 204 : 201
|
606
|
+
|
607
|
+
# Sending back false will interupt the event chain and tell the server
|
608
|
+
# we've handled this method.
|
609
|
+
false
|
610
|
+
end
|
611
|
+
|
612
|
+
# HTTP REPORT method implementation
|
613
|
+
#
|
614
|
+
# Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253)
|
615
|
+
# It's used in a lot of extensions, so it made sense to implement it into the core.
|
616
|
+
#
|
617
|
+
# @param RequestInterface request
|
618
|
+
# @param ResponseInterface response
|
619
|
+
# @return bool
|
620
|
+
def http_report(request, _response)
|
621
|
+
path = request.path
|
622
|
+
|
623
|
+
root_element_name = Box.new('')
|
624
|
+
result = @server.xml.parse(request.body, request.url, root_element_name)
|
625
|
+
root_element_name = root_element_name.value
|
626
|
+
|
627
|
+
if @server.emit('report', [root_element_name, result, path])
|
628
|
+
# If emit returned true, it means the report was not supported
|
629
|
+
fail Exception::ReportNotSupported
|
630
|
+
end
|
631
|
+
|
632
|
+
# Sending back false will interupt the event chain and tell the server
|
633
|
+
# we've handled this method.
|
634
|
+
false
|
635
|
+
end
|
636
|
+
|
637
|
+
# This method is called during property updates.
|
638
|
+
#
|
639
|
+
# Here we check if a user attempted to update a protected property and
|
640
|
+
# ensure that the process fails if this is the case.
|
641
|
+
#
|
642
|
+
# @param string path
|
643
|
+
# @param PropPatch prop_patch
|
644
|
+
# @return void
|
645
|
+
def prop_patch_protected_property_check(_path, prop_patch)
|
646
|
+
# Comparing the mutation list to the list of propetected properties.
|
647
|
+
mutations = prop_patch.mutations
|
648
|
+
|
649
|
+
protected_props = @server.protected_properties & mutations.keys
|
650
|
+
|
651
|
+
prop_patch.update_result_code(protected_props, 403) if protected_props.any?
|
652
|
+
end
|
653
|
+
|
654
|
+
# This method is called during property updates.
|
655
|
+
#
|
656
|
+
# Here we check if a node implements IProperties and let the node handle
|
657
|
+
# updating of (some) properties.
|
658
|
+
#
|
659
|
+
# @param string path
|
660
|
+
# @param PropPatch prop_patch
|
661
|
+
# @return void
|
662
|
+
def prop_patch_node_update(path, prop_patch)
|
663
|
+
# This should trigger a 404 if the node doesn't exist.
|
664
|
+
node = @server.tree.node_for_path(path)
|
665
|
+
|
666
|
+
node.prop_patch(prop_patch) if node.is_a?(IProperties)
|
667
|
+
end
|
668
|
+
|
669
|
+
# This method is called when properties are retrieved.
|
670
|
+
#
|
671
|
+
# Here we add all the default properties.
|
672
|
+
#
|
673
|
+
# @param PropFind prop_find
|
674
|
+
# @param INode node
|
675
|
+
# @return void
|
676
|
+
def prop_find(prop_find, node)
|
677
|
+
prop_find.handle(
|
678
|
+
'{DAV:}getlastmodified',
|
679
|
+
lambda do
|
680
|
+
lm = node.last_modified
|
681
|
+
return Xml::Property::GetLastModified.new(lm) if lm
|
682
|
+
return nil
|
683
|
+
end
|
684
|
+
)
|
685
|
+
|
686
|
+
if node.is_a?(IFile)
|
687
|
+
prop_find.handle('{DAV:}getcontentlength', node.method(:size))
|
688
|
+
prop_find.handle('{DAV:}getetag', node.method(:etag))
|
689
|
+
prop_find.handle('{DAV:}getcontenttype', node.method(:content_type))
|
690
|
+
end
|
691
|
+
|
692
|
+
if node.is_a?(IQuota)
|
693
|
+
quota_info = nil
|
694
|
+
prop_find.handle(
|
695
|
+
'{DAV:}quota-used-bytes',
|
696
|
+
lambda do
|
697
|
+
quota_info = node.quota_info
|
698
|
+
return quota_info[0]
|
699
|
+
end
|
700
|
+
)
|
701
|
+
prop_find.handle(
|
702
|
+
'{DAV:}quota-available-bytes',
|
703
|
+
lambda do
|
704
|
+
quota_info = node.quota_info unless quota_info
|
705
|
+
return quota_info[1]
|
706
|
+
end
|
707
|
+
)
|
708
|
+
end
|
709
|
+
|
710
|
+
prop_find.handle(
|
711
|
+
'{DAV:}supported-report-set',
|
712
|
+
lambda do
|
713
|
+
reports = []
|
714
|
+
@server.plugins.each do |_, plugin|
|
715
|
+
reports += plugin.supported_report_set(prop_find.path)
|
716
|
+
end
|
717
|
+
return Xml::Property::SupportedReportSet.new(reports)
|
718
|
+
end
|
719
|
+
)
|
720
|
+
prop_find.handle(
|
721
|
+
'{DAV:}resourcetype',
|
722
|
+
-> { return Xml::Property::ResourceType.new(@server.resource_type_for_node(node)) }
|
723
|
+
)
|
724
|
+
prop_find.handle(
|
725
|
+
'{DAV:}supported-method-set',
|
726
|
+
lambda do
|
727
|
+
return Xml::Property::SupportedMethodSet.new(
|
728
|
+
@server.allowed_methods(prop_find.path)
|
729
|
+
)
|
730
|
+
end
|
731
|
+
)
|
732
|
+
end
|
733
|
+
|
734
|
+
# Fetches properties for a node.
|
735
|
+
#
|
736
|
+
# This event is called a bit later, so plugins have a chance first to
|
737
|
+
# populate the result.
|
738
|
+
#
|
739
|
+
# @param PropFind prop_find
|
740
|
+
# @param INode node
|
741
|
+
# @return void
|
742
|
+
def prop_find_node(prop_find, node)
|
743
|
+
if node.is_a?(IProperties)
|
744
|
+
property_names = prop_find.load_404_properties
|
745
|
+
if property_names.any?
|
746
|
+
node_properties = node.properties(property_names)
|
747
|
+
property_names.each do |property_name|
|
748
|
+
if node_properties.include?(property_name)
|
749
|
+
prop_find.set(property_name, node_properties[property_name], 200)
|
750
|
+
end
|
751
|
+
end
|
752
|
+
end
|
753
|
+
end
|
754
|
+
end
|
755
|
+
|
756
|
+
# This method is called when properties are retrieved.
|
757
|
+
#
|
758
|
+
# This specific handler is called very late in the process, because we
|
759
|
+
# want other systems to first have a chance to handle the properties.
|
760
|
+
#
|
761
|
+
# @param PropFind prop_find
|
762
|
+
# @param INode node
|
763
|
+
# @return void
|
764
|
+
def prop_find_late(prop_find, _node)
|
765
|
+
prop_find.handle(
|
766
|
+
'{http://calendarserver.org/ns/}getctag',
|
767
|
+
lambda do
|
768
|
+
# If we already have a sync-token from the current propFind
|
769
|
+
# request, we can re-use that.
|
770
|
+
val = prop_find.get('{http://sabredav.org/ns}sync-token')
|
771
|
+
return val if val
|
772
|
+
|
773
|
+
val = prop_find.get('{DAV:}sync-token')
|
774
|
+
return val if val && val.scalar?
|
775
|
+
if val && val.is_a?(Xml::Property::Href)
|
776
|
+
length = Sync::Plugin::SYNCTOKEN_PREFIX.length
|
777
|
+
return val.href[length..-1]
|
778
|
+
end
|
779
|
+
|
780
|
+
# If we got here, the earlier two properties may simply not have
|
781
|
+
# been part of the earlier request. We're going to fetch them.
|
782
|
+
result = @server.properties(
|
783
|
+
prop_find.path,
|
784
|
+
[
|
785
|
+
'{http://sabredav.org/ns}sync-token',
|
786
|
+
'{DAV:}sync-token'
|
787
|
+
]
|
788
|
+
)
|
789
|
+
|
790
|
+
if result.key?('{http://sabredav.org/ns}sync-token')
|
791
|
+
return result['{http://sabredav.org/ns}sync-token']
|
792
|
+
end
|
793
|
+
if result.key?('{DAV:}sync-token')
|
794
|
+
val = result['{DAV:}sync-token']
|
795
|
+
if val.scalar?
|
796
|
+
return val
|
797
|
+
elsif val.is_a?(Xml::Property::Href)
|
798
|
+
length = Sync::Plugin::SYNCTOKEN_PREFIX.length
|
799
|
+
return val.href[length..-1]
|
800
|
+
end
|
801
|
+
end
|
802
|
+
end
|
803
|
+
)
|
804
|
+
end
|
805
|
+
|
806
|
+
# Returns a bunch of meta-data about the plugin.
|
807
|
+
#
|
808
|
+
# Providing this information is optional, and is mainly displayed by the
|
809
|
+
# Browser plugin.
|
810
|
+
#
|
811
|
+
# The description key in the returned array may contain html and will not
|
812
|
+
# be sanitized.
|
813
|
+
#
|
814
|
+
# @return array
|
815
|
+
def plugin_info
|
816
|
+
{
|
817
|
+
'name' => plugin_name,
|
818
|
+
'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.',
|
819
|
+
'link' => nil
|
820
|
+
}
|
821
|
+
end
|
822
|
+
end
|
823
|
+
end
|
824
|
+
end
|