WIP
This commit is contained in:
@@ -3,7 +3,7 @@ Calligraphy.configure do |config|
|
||||
# HTTP verbs and URLs and WebDAV controller actions.
|
||||
# config.web_dav_actions = [
|
||||
# :options, :get, :put, :delete, :copy, :move,
|
||||
# :mkcol, :propfind, :proppatch, :lock, :unlock
|
||||
# :mkcol, :propfind, :proppatch, :lock, :unlock, :acl
|
||||
# ]
|
||||
|
||||
# HTTP methods allowed by the WebDavRequests controller.
|
||||
@@ -13,7 +13,7 @@ Calligraphy.configure do |config|
|
||||
# HTTP 405 (Method Not Allowed) response.
|
||||
# config.allowed_http_methods = %w(
|
||||
# options get put delete copy move
|
||||
# mkcol propfind proppatch lock unlock
|
||||
# mkcol propfind proppatch lock unlock acl
|
||||
# )
|
||||
|
||||
# If Digest Authentication is enabled by default. False by default.
|
||||
|
||||
33
spec/requests/acl_spec.rb
Normal file
33
spec/requests/acl_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require 'support/request_helpers'
|
||||
require 'support/examples/acl'
|
||||
|
||||
RSpec.describe 'acl', type: :request do
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
skip_authentication
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
end
|
||||
|
||||
context "for #{Calligraphy::FileResource}" do
|
||||
describe 'acl' do
|
||||
before(:each) do
|
||||
Calligraphy::FileResource.create resource: 'top'
|
||||
end
|
||||
|
||||
it 'grants the proper privileges' do
|
||||
acl '/webdav/top', headers: {
|
||||
RAW_POST_DATA: Support::Examples::Acl.rfc3744_8_1_2
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,5 +56,45 @@ RSpec.describe 'OPTIONS', type: :request do
|
||||
expect(response.headers['DAV']).to include('extended-mkcol')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not using access control support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_access_control?
|
||||
).and_return(false)
|
||||
end
|
||||
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
|
||||
it 'does not advertise support for access control' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to_not include('access-control')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when using access control support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_access_control?
|
||||
).and_return(true)
|
||||
end
|
||||
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
|
||||
it 'advertises support for access control' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to include('access-control')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,6 +47,13 @@ RSpec.describe 'Resource' do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#enable_access_control?' do
|
||||
it 'is not enabled by default' do
|
||||
resource = Calligraphy::Resource.new
|
||||
expect(resource.enable_access_control?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#enable_extended_mkcol?' do
|
||||
it 'is not enabled by default' do
|
||||
resource = Calligraphy::Resource.new
|
||||
|
||||
@@ -123,5 +123,15 @@ RSpec.describe 'calligraphy_resource', type: :routing do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for ACL requests' do
|
||||
it do
|
||||
expect(acl: '/test/thirteen').to route_to(
|
||||
controller: 'calligraphy/rails/web_dav_requests',
|
||||
action: 'invoke_method',
|
||||
resource: 'thirteen'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
40
spec/support/examples/acl.rb
Normal file
40
spec/support/examples/acl.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
module Support
|
||||
module Examples
|
||||
module Acl
|
||||
# RFC3744: 8.1.2 The ACL method
|
||||
def self.rfc3744_8_1_2
|
||||
<<~XML
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<D:acl xmlns:D="DAV:">
|
||||
<D:ace>
|
||||
<D:principal>
|
||||
<D:href>http://www.example.com/users/esedlar</D:href>
|
||||
</D:principal>
|
||||
<D:grant>
|
||||
<D:privilege><D:read/></D:privilege>
|
||||
<D:privilege><D:write/></D:privilege>
|
||||
</D:grant>
|
||||
</D:ace>
|
||||
<D:ace>
|
||||
<D:principal>
|
||||
<D:property><D:owner/></D:property>
|
||||
</D:principal>
|
||||
<D:grant>
|
||||
<D:privilege><D:read-acl/></D:privilege>
|
||||
<D:privilege><D:write-acl/></D:privilege>
|
||||
</D:grant>
|
||||
</D:ace>
|
||||
<D:ace>
|
||||
<D:principal><D:all/></D:principal>
|
||||
<D:grant>
|
||||
<D:privilege><D:read/></D:privilege>
|
||||
</D:grant>
|
||||
</D:ace>
|
||||
</D:acl>
|
||||
XML
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,7 +4,7 @@ module ActionDispatch
|
||||
module Integration
|
||||
module RequestHelpers
|
||||
request_methods = %w[
|
||||
copy move mkcol options propfind proppatch lock unlock
|
||||
copy move mkcol options propfind proppatch lock unlock acl
|
||||
]
|
||||
|
||||
request_methods.each do |method|
|
||||
|
||||
Reference in New Issue
Block a user