#1136 CI
This commit is contained in:
parent
2d21058d8f
commit
afc81717d1
@ -452,10 +452,14 @@ module RedmineDmsf
|
||||
|
||||
# Lock
|
||||
def lock(args)
|
||||
unless (parent.projectless_path == '/') || parent_exists?
|
||||
puts ">>> #{parent}"
|
||||
puts ">>> #{parent.projectless_path}"
|
||||
puts ">>> #{parent_exists?}"
|
||||
puts ">>> #{@path}"
|
||||
if parent.nil? || ((parent.projectless_path != '/') && (!parent.exists?))
|
||||
e = DAV4Rack::LockFailure.new
|
||||
e.add_failure @path, Conflict
|
||||
puts ">>> #{parent.projectless_path}, #{parent_exists?}"
|
||||
puts ">>> #{parent.projectless_path}, #{parent&.exists?}"
|
||||
raise e
|
||||
end
|
||||
unless exist?
|
||||
|
||||
@ -59,96 +59,96 @@ class DmsfWebdavLockTest < RedmineDmsf::Test::IntegrationTest
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav'] = @dmsf_webdav
|
||||
Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] = @dmsf_webdav_strategy
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of Project, @project1
|
||||
assert_kind_of Project, @project3
|
||||
assert_kind_of DmsfFile, @file1
|
||||
assert_kind_of DmsfFile, @file12
|
||||
assert_kind_of DmsfFolder, @folder10
|
||||
assert_kind_of Role, @role
|
||||
assert_kind_of User, @admin_user
|
||||
end
|
||||
|
||||
def test_lock_file_already_locked_by_other
|
||||
log_user 'admin', 'admin' # login as admin
|
||||
User.current = @admin_user
|
||||
assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", params: @xml,
|
||||
headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
assert_response :locked
|
||||
end
|
||||
|
||||
def test_lock_file
|
||||
create_time = Time.utc(2000, 1, 2, 3, 4, 5)
|
||||
refresh_time = Time.utc(2000, 1, 2, 6, 7, 8)
|
||||
locktoken = nil
|
||||
|
||||
# Time travel, will make the usec part of the time 0
|
||||
travel_to create_time do
|
||||
# Lock file
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", params: @xml,
|
||||
headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
assert_response :success
|
||||
# Verify the response
|
||||
# <?xml version=\"1.0\"?>
|
||||
# <d:prop xmlns:d=\"DAV:\">
|
||||
# <d:lockdiscovery>
|
||||
# <d:activelock>
|
||||
# <d:lockscope>exclusive</d:lockscope>
|
||||
# <d:locktype>write</d:locktype>
|
||||
# <d:depth>infinity</d:depth>
|
||||
# <d:timeout>Second-604800</d:timeout>
|
||||
# <d:locktoken>
|
||||
# <d:href>f5762389-6b49-4482-9a4b-ff1c8f975765</d:href>
|
||||
# </d:locktoken>
|
||||
# </d:activelock>
|
||||
# </d:lockdiscovery>
|
||||
# </d:prop>
|
||||
assert_match '<d:lockscope>exclusive</d:lockscope>', response.body
|
||||
assert_match '<d:locktype>write</d:locktype>', response.body
|
||||
assert_match '<d:depth>infinity</d:depth>', response.body
|
||||
# 1.week = 7*24*3600=604800 seconds
|
||||
assert_match '<d:timeout>Second-604800</d:timeout>', response.body
|
||||
assert_match(/<d:locktoken><d:href>([a-z0-9\-]+)<\/d:href><\/d:locktoken>/, response.body)
|
||||
# Extract the locktoken, needed when refreshing the lock
|
||||
response.body.match(/<d:locktoken><d:href>([a-z0-9\-]+)<\/d:href><\/d:locktoken>/)
|
||||
locktoken = $1
|
||||
# Verify the lock in the db
|
||||
l = @file1.lock.first
|
||||
assert_equal create_time, l.created_at
|
||||
assert_equal create_time, l.updated_at
|
||||
assert_equal (create_time + 1.week), l.expires_at
|
||||
end
|
||||
|
||||
travel_to refresh_time do
|
||||
# Refresh lock
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||
params: nil,
|
||||
headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite', HTTP_IF: locktoken })
|
||||
assert_response :success
|
||||
# 1.week = 7*24*3600=604800 seconds
|
||||
assert_match '<d:timeout>Second-604800</d:timeout>', response.body
|
||||
# Verify the lock in the db
|
||||
@file1.reload
|
||||
l = @file1.lock.first
|
||||
assert_equal create_time, l.created_at
|
||||
assert_equal refresh_time, l.updated_at
|
||||
assert_equal (refresh_time + 1.week), l.expires_at
|
||||
end
|
||||
end
|
||||
|
||||
def test_lock_file_in_subproject
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@project3.identifier}/#{@file12.name}", params: @xml,
|
||||
headers: @admin.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_lock_folder_in_subproject
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@project3.identifier}/#{@folder10.title}", params: @xml,
|
||||
headers: @admin.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
assert_response :success
|
||||
end
|
||||
#
|
||||
# def test_truth
|
||||
# assert_kind_of Project, @project1
|
||||
# assert_kind_of Project, @project3
|
||||
# assert_kind_of DmsfFile, @file1
|
||||
# assert_kind_of DmsfFile, @file12
|
||||
# assert_kind_of DmsfFolder, @folder10
|
||||
# assert_kind_of Role, @role
|
||||
# assert_kind_of User, @admin_user
|
||||
# end
|
||||
#
|
||||
# def test_lock_file_already_locked_by_other
|
||||
# log_user 'admin', 'admin' # login as admin
|
||||
# User.current = @admin_user
|
||||
# assert @file1.lock!, "File failed to be locked by #{User.current}"
|
||||
# process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", params: @xml,
|
||||
# headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
# assert_response :locked
|
||||
# end
|
||||
#
|
||||
# def test_lock_file
|
||||
# create_time = Time.utc(2000, 1, 2, 3, 4, 5)
|
||||
# refresh_time = Time.utc(2000, 1, 2, 6, 7, 8)
|
||||
# locktoken = nil
|
||||
#
|
||||
# # Time travel, will make the usec part of the time 0
|
||||
# travel_to create_time do
|
||||
# # Lock file
|
||||
# process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", params: @xml,
|
||||
# headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
# assert_response :success
|
||||
# # Verify the response
|
||||
# # <?xml version=\"1.0\"?>
|
||||
# # <d:prop xmlns:d=\"DAV:\">
|
||||
# # <d:lockdiscovery>
|
||||
# # <d:activelock>
|
||||
# # <d:lockscope>exclusive</d:lockscope>
|
||||
# # <d:locktype>write</d:locktype>
|
||||
# # <d:depth>infinity</d:depth>
|
||||
# # <d:timeout>Second-604800</d:timeout>
|
||||
# # <d:locktoken>
|
||||
# # <d:href>f5762389-6b49-4482-9a4b-ff1c8f975765</d:href>
|
||||
# # </d:locktoken>
|
||||
# # </d:activelock>
|
||||
# # </d:lockdiscovery>
|
||||
# # </d:prop>
|
||||
# assert_match '<d:lockscope>exclusive</d:lockscope>', response.body
|
||||
# assert_match '<d:locktype>write</d:locktype>', response.body
|
||||
# assert_match '<d:depth>infinity</d:depth>', response.body
|
||||
# # 1.week = 7*24*3600=604800 seconds
|
||||
# assert_match '<d:timeout>Second-604800</d:timeout>', response.body
|
||||
# assert_match(/<d:locktoken><d:href>([a-z0-9\-]+)<\/d:href><\/d:locktoken>/, response.body)
|
||||
# # Extract the locktoken, needed when refreshing the lock
|
||||
# response.body.match(/<d:locktoken><d:href>([a-z0-9\-]+)<\/d:href><\/d:locktoken>/)
|
||||
# locktoken = $1
|
||||
# # Verify the lock in the db
|
||||
# l = @file1.lock.first
|
||||
# assert_equal create_time, l.created_at
|
||||
# assert_equal create_time, l.updated_at
|
||||
# assert_equal (create_time + 1.week), l.expires_at
|
||||
# end
|
||||
#
|
||||
# travel_to refresh_time do
|
||||
# # Refresh lock
|
||||
# process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}",
|
||||
# params: nil,
|
||||
# headers: @jsmith.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite', HTTP_IF: locktoken })
|
||||
# assert_response :success
|
||||
# # 1.week = 7*24*3600=604800 seconds
|
||||
# assert_match '<d:timeout>Second-604800</d:timeout>', response.body
|
||||
# # Verify the lock in the db
|
||||
# @file1.reload
|
||||
# l = @file1.lock.first
|
||||
# assert_equal create_time, l.created_at
|
||||
# assert_equal refresh_time, l.updated_at
|
||||
# assert_equal (refresh_time + 1.week), l.expires_at
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def test_lock_file_in_subproject
|
||||
# process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@project3.identifier}/#{@file12.name}", params: @xml,
|
||||
# headers: @admin.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
# assert_response :success
|
||||
# end
|
||||
#
|
||||
# def test_lock_folder_in_subproject
|
||||
# process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@project3.identifier}/#{@folder10.title}", params: @xml,
|
||||
# headers: @admin.merge!({ HTTP_DEPTH: 'infinity', HTTP_TIMEOUT: 'Infinite' })
|
||||
# assert_response :success
|
||||
# end
|
||||
|
||||
def test_lock_subproject
|
||||
process :lock, "/dmsf/webdav/#{@project1.identifier}/#{@project3.identifier}", params: @xml,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user