Compare commits
6 Commits
acl
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
420b9ad7b7 | ||
|
|
d3c6c35b8a | ||
|
|
5e7fde423d | ||
|
|
f29b8b27e7 | ||
|
|
49b4573761 | ||
|
|
e25a887086 |
@@ -1,9 +1,8 @@
|
||||
language: ruby
|
||||
cache: bundler
|
||||
rvm:
|
||||
- 2.3
|
||||
- 2.4
|
||||
- 2.5
|
||||
- 2.6
|
||||
script:
|
||||
- bundle exec rake spec
|
||||
- bundle exec rake litmus:run
|
||||
|
||||
207
Gemfile.lock
207
Gemfile.lock
@@ -2,112 +2,135 @@ PATH
|
||||
remote: .
|
||||
specs:
|
||||
calligraphy (0.3.1)
|
||||
rails (~> 5.0, >= 5.0)
|
||||
rails (>= 5.1.6.2)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actioncable (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
actionpack (6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activerecord (5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.4)
|
||||
activemodel (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activerecord (6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activestorage (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (8.0.0)
|
||||
ast (2.3.0)
|
||||
zeitwerk (~> 2.1, >= 2.1.8)
|
||||
ast (2.4.0)
|
||||
builder (3.2.3)
|
||||
coderay (1.1.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.3)
|
||||
concurrent-ruby (1.1.5)
|
||||
crass (1.0.5)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.7.0)
|
||||
globalid (0.4.1)
|
||||
erubi (1.8.0)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (0.9.1)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
loofah (2.1.1)
|
||||
jaro_winkler (1.5.3)
|
||||
loofah (2.3.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
method_source (0.9.0)
|
||||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
nio4r (2.2.0)
|
||||
nokogiri (1.8.1)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
parallel (1.12.1)
|
||||
parser (2.4.0.2)
|
||||
ast (~> 2.3)
|
||||
powerpack (0.1.1)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
pry-nav (0.2.4)
|
||||
pry (>= 0.9.10, < 0.11.0)
|
||||
puma (3.11.0)
|
||||
rack (2.0.3)
|
||||
rack-test (0.8.2)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
method_source (0.9.2)
|
||||
mimemagic (0.3.3)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
nio4r (2.5.1)
|
||||
nokogiri (1.10.5)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
parallel (1.17.0)
|
||||
parser (2.6.4.0)
|
||||
ast (~> 2.4.0)
|
||||
pry (0.12.2)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.9.0)
|
||||
pry-nav (0.3.0)
|
||||
pry (>= 0.9.10, < 0.13.0)
|
||||
puma (4.1.0)
|
||||
nio4r (~> 2.0)
|
||||
rack (2.0.7)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.4)
|
||||
actioncable (= 5.1.4)
|
||||
actionmailer (= 5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activerecord (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails (6.0.0)
|
||||
actioncable (= 6.0.0)
|
||||
actionmailbox (= 6.0.0)
|
||||
actionmailer (= 6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actiontext (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.1.4)
|
||||
railties (= 6.0.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails-html-sanitizer (1.2.0)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (12.3.0)
|
||||
rspec-core (3.7.0)
|
||||
rake (12.3.3)
|
||||
rspec-core (3.7.1)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
@@ -123,32 +146,32 @@ GEM
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.0)
|
||||
rubocop (0.52.1)
|
||||
rspec-support (3.7.1)
|
||||
rubocop (0.74.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.4.0.2, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 2.6)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-progressbar (1.9.0)
|
||||
slop (3.6.0)
|
||||
sprockets (3.7.1)
|
||||
unicode-display_width (>= 1.4.0, < 1.7)
|
||||
ruby-progressbar (1.10.1)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.20.0)
|
||||
sqlite3 (1.4.1)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.4)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
unicode-display_width (1.3.0)
|
||||
websocket-driver (0.6.5)
|
||||
unicode-display_width (1.6.0)
|
||||
websocket-driver (0.7.1)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
websocket-extensions (0.1.4)
|
||||
zeitwerk (2.1.10)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -156,11 +179,11 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
calligraphy!
|
||||
pry-nav
|
||||
puma (~> 3.11.0, >= 3.11.0)
|
||||
rake (~> 12.3.0, >= 12.3.0)
|
||||
rspec-rails (~> 3.7.2, >= 3.7.2)
|
||||
rubocop (~> 0.52.1)
|
||||
sqlite3 (~> 1.3.13, >= 1.3.13)
|
||||
puma (~> 4.1.0)
|
||||
rake (~> 12.3.3)
|
||||
rspec-rails (~> 3.7.2)
|
||||
rubocop (~> 0.74.0)
|
||||
sqlite3 (~> 1.4.1)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
2.0.2
|
||||
|
||||
@@ -8,21 +8,21 @@ require 'calligraphy/version'
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'calligraphy'
|
||||
s.version = Calligraphy::VERSION
|
||||
s.summary = 'WebDAV framework and extension for Rails 5'
|
||||
s.summary = 'WebDAV framework and extension for Rails'
|
||||
s.author = 'Brandon Robins'
|
||||
s.email = 'brandon@onebnottwo.com'
|
||||
s.homepage = 'http://www.github.com/eanlain/calligraphy'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.required_ruby_version = '>= 2.3.0'
|
||||
s.required_ruby_version = '>= 2.5.0'
|
||||
|
||||
s.files = Dir['lib/**/*', 'LICENSE', 'README.md']
|
||||
|
||||
s.add_dependency 'rails', '~> 5.0', '>= 5.0'
|
||||
s.add_dependency 'rails', '>= 5.1.6.2'
|
||||
|
||||
s.add_development_dependency 'puma', '~> 3.11.0', '>= 3.11.0'
|
||||
s.add_development_dependency 'rake', '~> 12.3.0', '>= 12.3.0'
|
||||
s.add_development_dependency 'rspec-rails', '~> 3.7.2', '>= 3.7.2'
|
||||
s.add_development_dependency 'rubocop', '~> 0.52.1'
|
||||
s.add_development_dependency 'sqlite3', '~> 1.3.13', '>= 1.3.13'
|
||||
s.add_development_dependency 'puma', '~> 4.1.0'
|
||||
s.add_development_dependency 'rake', '~> 12.3.3'
|
||||
s.add_development_dependency 'rspec-rails', '~> 3.7.2'
|
||||
s.add_development_dependency 'rubocop', '~> 0.74.0'
|
||||
s.add_development_dependency 'sqlite3', '~> 1.4.1'
|
||||
end
|
||||
|
||||
@@ -24,7 +24,6 @@ require 'calligraphy/web_dav_request/propfind'
|
||||
require 'calligraphy/web_dav_request/proppatch'
|
||||
require 'calligraphy/web_dav_request/put'
|
||||
require 'calligraphy/web_dav_request/unlock'
|
||||
require 'calligraphy/web_dav_request/acl'
|
||||
|
||||
#:nodoc:
|
||||
module Calligraphy
|
||||
@@ -44,7 +43,7 @@ module Calligraphy
|
||||
mattr_accessor :allowed_http_methods
|
||||
@@allowed_http_methods = %w[
|
||||
options get put delete copy move
|
||||
mkcol propfind proppatch lock unlock acl
|
||||
mkcol propfind proppatch lock unlock
|
||||
]
|
||||
|
||||
# Proc responsible for returning the user's password, API key,
|
||||
@@ -71,7 +70,7 @@ module Calligraphy
|
||||
mattr_accessor :web_dav_actions
|
||||
@@web_dav_actions = %i[
|
||||
options get put delete copy move
|
||||
mkcol propfind proppatch lock unlock acl
|
||||
mkcol propfind proppatch lock unlock
|
||||
]
|
||||
|
||||
# Default way to set up Calligraphy.
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Calligraphy
|
||||
module AclUtils
|
||||
def parse_acl(xml)
|
||||
[].tap do |ace|
|
||||
xml.each do |node|
|
||||
next unless node.is_a? Nokogiri::XML::Element
|
||||
|
||||
ace << node
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,13 +5,6 @@ module ActionDispatch
|
||||
class Mapper
|
||||
#:nodoc:
|
||||
module HttpHelpers
|
||||
# Define a Calligraphy route that only recognizes HTTP ACL.
|
||||
# acl 'bacon', to: 'food#bacon'
|
||||
def acl(*args, &block)
|
||||
args = web_dav_args args
|
||||
map_method :acl, args, &block
|
||||
end
|
||||
|
||||
# Define a Calligraphy route that only recognizes HTTP COPY.
|
||||
# copy 'bacon', to: 'food#bacon'
|
||||
def copy(*args, &block)
|
||||
@@ -144,7 +137,6 @@ module ActionDispatch
|
||||
# PROPPATCH /photos/*resource
|
||||
# LOCK /photos/*resource
|
||||
# UNLOCK /photos/*resource
|
||||
# ACL /photos/*resource
|
||||
def calligraphy_resource(*resources, &block)
|
||||
options = resources.extract_options!.dup
|
||||
|
||||
|
||||
@@ -67,10 +67,6 @@ module Calligraphy
|
||||
def unlock
|
||||
Calligraphy::Unlock.new(web_dav_request).execute
|
||||
end
|
||||
|
||||
def acl
|
||||
Calligraphy::Acl.new(web_dav_request).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -596,6 +596,11 @@ module Calligraphy
|
||||
prop
|
||||
end
|
||||
|
||||
# def include(prop)
|
||||
# # TODO: Implement
|
||||
# prop
|
||||
# end
|
||||
|
||||
def lockdiscovery(prop)
|
||||
prop.content = fetch_lock_info
|
||||
prop
|
||||
|
||||
@@ -71,7 +71,6 @@ module Calligraphy
|
||||
# Used in OPTIONS requests.
|
||||
def dav_compliance
|
||||
compliance_classes = %w[1 2 3]
|
||||
compliance_classes.push 'access-control' if enable_access_control?
|
||||
compliance_classes.push 'extended-mkcol' if enable_extended_mkcol?
|
||||
|
||||
compliance_classes.join ', '
|
||||
@@ -85,12 +84,6 @@ module Calligraphy
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
# Responsible for returning a boolean indicating whether the resource
|
||||
# supports Access Control Protocol (see RFC3744).
|
||||
def enable_access_control?
|
||||
false
|
||||
end
|
||||
|
||||
# Responsible for returning a boolean indicating whether the resource
|
||||
# supports Extended MKCOL (see RFC5689).
|
||||
def enable_extended_mkcol?
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Calligraphy
|
||||
# TODO: CHANGE DESCRIPTIONS
|
||||
# Responsible for processing instructions specified in the request body
|
||||
# to set and/or remove properties defined on the resource.
|
||||
class Acl < WebDavRequest
|
||||
include Calligraphy::XML::Utils
|
||||
# include Calligraphy::AclUtils
|
||||
|
||||
# Responsible for evaluating preconditions for the WebDAV request.
|
||||
def preconditions
|
||||
# conflict_preconditions
|
||||
# forbidden_preconditions
|
||||
end
|
||||
|
||||
# Executes the WebDAV request for a particular resource.
|
||||
def execute
|
||||
return :locked if @resource.locked_to_user? @headers
|
||||
|
||||
# The `acl` tag contains the request to modify the access control list
|
||||
# of a resource.
|
||||
xml = xml_for body: body, node: 'acl'
|
||||
return :bad_request if xml == :bad_request
|
||||
|
||||
ace = search_xml_for body: body, search: 'ace'
|
||||
|
||||
binding.pry
|
||||
@resource.acl ace
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Array with compact and first?
|
||||
def conflict_preconditions
|
||||
[
|
||||
no_ace_conflict,
|
||||
no_protected_ace_conflict,
|
||||
no_inherited_ace_conflict
|
||||
].compact.first
|
||||
end
|
||||
|
||||
def forbidden_preconditions
|
||||
[
|
||||
limited_number_of_aces,
|
||||
deny_before_grant,
|
||||
grant_only,
|
||||
no_invert,
|
||||
no_abstract,
|
||||
not_supported_priviledge,
|
||||
missing_required_principal,
|
||||
recognized_principal,
|
||||
allowed_principal
|
||||
].compact.first
|
||||
end
|
||||
|
||||
def build_error(response)
|
||||
{ error: response }
|
||||
end
|
||||
|
||||
def no_ace_conflict
|
||||
build_error 'no_ace_conflict'
|
||||
end
|
||||
|
||||
def no_protected_ace_conflict
|
||||
build_error 'no-protected-ace-conflict'
|
||||
end
|
||||
|
||||
def no_inherited_ace_conflict
|
||||
build_error 'no-inherited-ace-conflict'
|
||||
end
|
||||
|
||||
def limited_number_of_aces
|
||||
build_error 'limited-number-of-aces'
|
||||
end
|
||||
|
||||
def deny_before_grant
|
||||
build_error 'deny-before-grant'
|
||||
end
|
||||
|
||||
def grant_only
|
||||
build_error 'grant-only'
|
||||
end
|
||||
|
||||
def no_invert
|
||||
build_error 'no-invert'
|
||||
end
|
||||
|
||||
def no_abstract
|
||||
build_error 'no-abstract'
|
||||
end
|
||||
|
||||
def not_supported_privilege
|
||||
build_error 'not-supported-priviledge'
|
||||
end
|
||||
|
||||
def missing_required_principal
|
||||
build_error 'missing-required-principal'
|
||||
end
|
||||
|
||||
def recognized_principal
|
||||
build_error 'recognized-principal'
|
||||
end
|
||||
|
||||
def allowed_principal
|
||||
build_error 'allowed-principal'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,7 +5,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, :acl
|
||||
# :mkcol, :propfind, :proppatch, :lock, :unlock
|
||||
# ]
|
||||
|
||||
# HTTP methods allowed by the WebDavRequests controller.
|
||||
@@ -15,7 +15,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 acl
|
||||
# mkcol propfind proppatch lock unlock
|
||||
# )
|
||||
|
||||
# If Digest Authentication is enabled by default. False by default.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
//= link_tree ../images
|
||||
//= link_directory ../javascripts .js
|
||||
//= link_directory ../stylesheets .css
|
||||
@@ -1,13 +0,0 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require_tree .
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
||||
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||
* It is generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
||||
@@ -1,3 +0,0 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dummy</title>
|
||||
<%= csrf_meta_tags %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all' %>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
load Gem.bin_path('bundler', 'bundle')
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require_relative '../config/boot'
|
||||
require 'rake'
|
||||
Rake.application.run
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a starting point to setup your application.
|
||||
# Add necessary setup steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
# Install JavaScript dependencies if using Yarn
|
||||
# system('bin/yarn')
|
||||
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?('config/database.yml')
|
||||
# cp 'config/database.yml.sample', 'config/database.yml'
|
||||
# end
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system! 'bin/rails db:setup'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a way to update your development environment automatically.
|
||||
# Add necessary update steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
||||
@@ -19,7 +19,3 @@ development:
|
||||
test:
|
||||
<<: *default
|
||||
database: db/test.sqlite3
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both threaded web servers
|
||||
# and those relying on copy on write to perform better.
|
||||
# Rake tasks automatically ignore this option for performance.
|
||||
config.eager_load = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on.
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
|
||||
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
|
||||
# `config/secrets.yml.key`.
|
||||
config.read_encrypted_secrets = true
|
||||
|
||||
# Disable serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = false
|
||||
|
||||
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = 'http://assets.example.com'
|
||||
|
||||
# Specifies the header that your server uses for sending files.
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
||||
|
||||
# Mount Action Cable outside main process or domain
|
||||
# config.action_cable.mount_path = nil
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Use the lowest log level to ensure availability of diagnostic information
|
||||
# when problems arise.
|
||||
config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
config.log_tags = [ :request_id ]
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# config.active_job.queue_adapter = :resque
|
||||
# config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation cannot be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = ::Logger::Formatter.new
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# require 'syslog/logger'
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||
|
||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||
logger = ActiveSupport::Logger.new(STDOUT)
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
end
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
end
|
||||
@@ -40,3 +40,4 @@ Rails.application.configure do
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.0'
|
||||
|
||||
# Add additional assets to the asset load path.
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
# Add Yarn node_modules folder to the asset load path.
|
||||
# Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in the app/assets
|
||||
# folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
||||
@@ -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, :acl
|
||||
# :mkcol, :propfind, :proppatch, :lock, :unlock
|
||||
# ]
|
||||
|
||||
# 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 acl
|
||||
# mkcol propfind proppatch lock unlock
|
||||
# )
|
||||
|
||||
# If Digest Authentication is enabled by default. False by default.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Specify a serializer for the signed and encrypted cookie jars.
|
||||
# Valid options are :json, :marshal, and :hybrid.
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
||||
@@ -1,4 +0,0 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
||||
@@ -1,14 +0,0 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# end
|
||||
@@ -1,6 +1,4 @@
|
||||
Rails.application.routes.draw do
|
||||
calligraphy_resource :test
|
||||
calligraphy_resource :webdav,
|
||||
resource_class: Calligraphy::FileResource,
|
||||
resource_root_path: File.expand_path('../../../../tmp/webdav', __FILE__)
|
||||
calligraphy_resource :webdav, resource_class: Calligraphy::FileResource, resource_root_path: File.expand_path('../../../../tmp/webdav', __FILE__)
|
||||
end
|
||||
|
||||
@@ -22,11 +22,3 @@ development:
|
||||
|
||||
test:
|
||||
secret_key_base: 276136c8ffad50817d3e1dcc7a84dd129105108f1c8e920f46b9b98b74943298637e5261fa66868baa50c1a170fcfb99dfb56f5bd33ec1b4bfd8eb34edcedb16
|
||||
|
||||
# Do not keep production secrets in the unencrypted secrets file.
|
||||
# Instead, either read values from the environment.
|
||||
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
|
||||
# and move the `production:` environment over there.
|
||||
|
||||
production:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
%w(
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
||||
@@ -22,7 +22,7 @@ require 'rspec/rails'
|
||||
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
||||
# require only the support files necessary.
|
||||
#
|
||||
# Dir[Rails.root.join('../support/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('../support/**/*.rb')].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations and applies them before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
@@ -57,5 +57,3 @@ RSpec.configure do |config|
|
||||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
end
|
||||
|
||||
require 'support/resource_helpers'
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
# 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
|
||||
@@ -5,47 +5,47 @@ require 'support/request_helpers'
|
||||
require 'support/examples/ext_mkcol'
|
||||
|
||||
RSpec.describe 'mkcol', type: :request do
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
before(:all) do
|
||||
tmp_dir = Rails.root.join('../../tmp').to_path
|
||||
Dir.mkdir tmp_dir unless File.exist? tmp_dir
|
||||
|
||||
webdav_dir = Rails.root.join('../../tmp/webdav').to_path
|
||||
FileUtils.rm_r webdav_dir if File.exist? webdav_dir
|
||||
Dir.mkdir webdav_dir
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
skip_authentication
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
it 'creates a collection with additional properties' do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:valid_resourcetypes
|
||||
).and_return(%w[collection special-resource])
|
||||
|
||||
expect(Dir).to receive(:mkdir).and_call_original
|
||||
expect_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:proppatch
|
||||
)
|
||||
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.body.empty?).to eq(true)
|
||||
expect(response.status).to eq(201)
|
||||
end
|
||||
|
||||
context "for #{Calligraphy::FileResource}" do
|
||||
it 'creates a collection with additional properties' do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:valid_resourcetypes
|
||||
).and_return(%w[collection special-resource])
|
||||
|
||||
expect(Dir).to receive(:mkdir).and_call_original
|
||||
expect_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:proppatch
|
||||
)
|
||||
|
||||
context 'with an invalid resource type' do
|
||||
it 'returns an error response' do
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.body.empty?).to eq(true)
|
||||
expect(response.status).to eq(201)
|
||||
end
|
||||
|
||||
context 'with an invalid resource type' do
|
||||
it 'returns an error response' do
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.body).to include('mkcol-response')
|
||||
expect(response.body).to include('valid-resourcetype')
|
||||
end
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.body).to include('mkcol-response')
|
||||
expect(response.body).to include('valid-resourcetype')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,97 +4,48 @@ require 'rails_helper'
|
||||
require 'support/request_helpers'
|
||||
|
||||
RSpec.describe 'OPTIONS', type: :request do
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
skip_authentication
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
context 'when not using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).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 extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to_not include('extended-mkcol')
|
||||
end
|
||||
end
|
||||
|
||||
context "for #{Calligraphy::FileResource}" do
|
||||
context 'when not using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).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 extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to_not include('extended-mkcol')
|
||||
end
|
||||
context 'when using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(true)
|
||||
end
|
||||
|
||||
context 'when using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(true)
|
||||
end
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
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 extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to include('extended-mkcol')
|
||||
end
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
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 extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
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
|
||||
expect(response.headers['DAV']).to include('extended-mkcol')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,22 +6,25 @@ require 'support/examples/propfind'
|
||||
require 'support/examples/proppatch'
|
||||
|
||||
RSpec.describe 'PROPFIND', type: :request do
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
before(:all) do
|
||||
tmp_dir = Rails.root.join('../../tmp').to_path
|
||||
Dir.mkdir tmp_dir unless File.exist? tmp_dir
|
||||
|
||||
webdav_dir = Rails.root.join('../../tmp/webdav').to_path
|
||||
FileUtils.rm_r webdav_dir if File.exist? webdav_dir
|
||||
Dir.mkdir webdav_dir
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
skip_authentication
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
end
|
||||
|
||||
context 'with xml defintiion' do
|
||||
before(:each) do
|
||||
Calligraphy::FileResource.create resource: 'bar.html'
|
||||
|
||||
put '/webdav/bar.html', headers: {
|
||||
RAW_POST_DATA: 'hello world'
|
||||
}
|
||||
proppatch '/webdav/bar.html', headers: {
|
||||
RAW_POST_DATA: Support::Examples::Proppatch.rfc4918_9_2_2
|
||||
}
|
||||
|
||||
@@ -46,26 +46,5 @@ RSpec.describe 'Resource' do
|
||||
expect(resource.dav_compliance).to eq('1, 2, 3')
|
||||
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
|
||||
expect(resource.enable_extended_mkcol?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#valid_resourcetypes' do
|
||||
it 'returns only a collection resourcetype by default' do
|
||||
resource = Calligraphy::Resource.new
|
||||
expect(resource.valid_resourcetypes).to match_array(['collection'])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -113,25 +113,5 @@ RSpec.describe 'calligraphy_resource', type: :routing do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'for HEAD requests' do
|
||||
it do
|
||||
expect(head: '/test/twelve').to route_to(
|
||||
controller: 'calligraphy/rails/web_dav_requests',
|
||||
action: 'invoke_method',
|
||||
resource: 'twelve'
|
||||
)
|
||||
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
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# 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 acl
|
||||
copy move mkcol options propfind proppatch lock unlock
|
||||
]
|
||||
|
||||
request_methods.each do |method|
|
||||
@@ -15,7 +15,3 @@ module ActionDispatch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def skip_authentication
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication).and_return(false)
|
||||
end
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RESOURCES_TO_TEST_AGAINST = [
|
||||
Calligraphy::FileResource
|
||||
].freeze
|
||||
|
||||
module RSpecMethods
|
||||
def setup; end
|
||||
|
||||
def cleanup; end
|
||||
|
||||
def create(resource:, content: 'Hi hi!'); end
|
||||
end
|
||||
|
||||
module FileResourceHelpers
|
||||
def setup
|
||||
tmp_dir = Rails.root.join('../../tmp').to_path
|
||||
Dir.mkdir tmp_dir unless File.exist? tmp_dir
|
||||
|
||||
FileUtils.rm_r resource_root if File.exist? resource_root
|
||||
Dir.mkdir resource_root
|
||||
end
|
||||
|
||||
def cleanup
|
||||
FileUtils.rm_r resource_root if File.exist? resource_root
|
||||
end
|
||||
|
||||
def create(resource:, content: 'Hello world')
|
||||
resource = Calligraphy::FileResource.new(
|
||||
resource: resource,
|
||||
root_dir: resource_root
|
||||
)
|
||||
resource.write content
|
||||
end
|
||||
|
||||
def resource_root
|
||||
Rails.root.join('../../tmp/webdav').to_path
|
||||
end
|
||||
end
|
||||
|
||||
RESOURCES_TO_TEST_AGAINST.each do |resource_class|
|
||||
resource_class.send :extend, RSpecMethods
|
||||
end
|
||||
|
||||
module Calligraphy
|
||||
class FileResource
|
||||
extend FileResourceHelpers
|
||||
end
|
||||
end
|
||||
@@ -1,37 +0,0 @@
|
||||
Description
|
||||
activelock
|
||||
collection
|
||||
depth
|
||||
error
|
||||
exclusive
|
||||
href
|
||||
location
|
||||
lockentry
|
||||
lockinfo
|
||||
lockroot
|
||||
lockscope
|
||||
locktoken
|
||||
locktype
|
||||
multistatus
|
||||
owner
|
||||
prop
|
||||
propstat
|
||||
response
|
||||
responsedescription
|
||||
shared
|
||||
status
|
||||
timeout
|
||||
write
|
||||
|
||||
|
||||
Input
|
||||
allprop
|
||||
# include
|
||||
prop
|
||||
propertyupdate
|
||||
propfind
|
||||
propname
|
||||
remove
|
||||
set
|
||||
|
||||
|
||||
Reference in New Issue
Block a user