From 42fdf2730321a65e5319eddb4984d73b8f29cf2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 4 Feb 2020 14:53:11 +0100 Subject: [PATCH] OPTION and PROPFIND request on the parent path --- config/routes.rb | 3 +++ lib/redmine_dmsf/webdav/custom_middleware.rb | 2 +- .../webdav/dmsf_webdav_custom_middleware_test.rb | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 7d6fdc75..27d0d495 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -165,5 +165,8 @@ if Redmine::Plugin.installed? :redmine_dmsf end end + # WebDAV + match '/', to: lambda { |env| [405, {}, [env.to_s]] }, via: [:propfind, :options] + match '/dmsf', to: lambda { |env| [405, {}, [env.to_s]] }, via: [:propfind, :options] end end diff --git a/lib/redmine_dmsf/webdav/custom_middleware.rb b/lib/redmine_dmsf/webdav/custom_middleware.rb index ec4b0bfd..7b3a9afe 100644 --- a/lib/redmine_dmsf/webdav/custom_middleware.rb +++ b/lib/redmine_dmsf/webdav/custom_middleware.rb @@ -57,7 +57,7 @@ module RedmineDmsf # If the URL map generated by Rack::Builder did not find a matching path, # it will return a 404 along with the X-Cascade header set to 'pass'. if (status == 404) && (headers['X-Cascade'] == 'pass') - @rails_app.call env # Let Rails handle the request + @rails_app.call env # let Rails handle the request else [status, headers, body] end diff --git a/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb b/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb index 359c4428..64a2db61 100644 --- a/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb +++ b/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb @@ -34,22 +34,22 @@ class DmsfWebdavCustomMiddlewareTest < RedmineDmsf::Test::IntegrationTest def test_options_for_root_path process :options, '/' - assert_response :not_found + assert_response :method_not_allowed end def test_options_for_dmsf_root_path process :options, '/dmsf' - assert_response :not_found + assert_response :method_not_allowed end def test_propfind_for_root_path process :propfind, '/' - assert_response :not_found + assert_response :method_not_allowed end def test_propfind_for_dmsf_root_path process :propfind, '/dmsf' - assert_response :not_found + assert_response :method_not_allowed end def test_webdav_not_enabled