Added tests for OPTIONS and HEAD requests for updated MsOffice support.
This commit is contained in:
parent
1ba6b3e7d5
commit
311eeb86d6
@ -54,6 +54,18 @@ class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
|
||||
check_headers_exist
|
||||
end
|
||||
|
||||
def test_head_responds_anonymous_msoffice_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}", nil, {:HTTP_USER_AGENT => "Microsoft Office Word 2014"}
|
||||
assert_response :success
|
||||
check_headers_exist
|
||||
end
|
||||
|
||||
def test_head_responds_anonymous_other_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}", nil, {:HTTP_USER_AGENT => "Other"}
|
||||
assert_response 401
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
# Note:
|
||||
# At present we use Rack to serve the file, this makes life easy however it removes the Etag
|
||||
# header and invalidates the test - where as a folder listing will always not include a last-modified
|
||||
@ -65,18 +77,54 @@ class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
|
||||
check_headers_exist # Note it'll allow 1 out of the 3 expected to fail
|
||||
end
|
||||
|
||||
def test_head_responds_to_file_anonymous_msoffice_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}/test.txt", nil, {:HTTP_USER_AGENT => "Microsoft Office Word 2014"}
|
||||
assert_response :success
|
||||
check_headers_exist # Note it'll allow 1 out of the 3 expected to fail
|
||||
end
|
||||
|
||||
def test_head_responds_to_file_anonymous_other_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}/test.txt", nil, {:HTTP_USER_AGENT => "Other"}
|
||||
assert_response 401
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_file_not_found
|
||||
head "/dmsf/webdav/#{@project1.identifier}/not_here.txt", nil, @admin
|
||||
assert_response :missing
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_file_not_found_anonymous_msoffice_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}/not_here.txt", nil, {:HTTP_USER_AGENT => "Microsoft Office Word 2014"}
|
||||
assert_response :missing
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_file_not_found_anonymous_other_user_agent
|
||||
head "/dmsf/webdav/#{@project1.identifier}/not_here.txt", nil, {:HTTP_USER_AGENT => "Other"}
|
||||
assert_response 401
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_folder_not_found
|
||||
head '/dmsf/webdav/folder_not_here', nil, @admin
|
||||
assert_response :missing
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_folder_not_found_anonymous_msoffice_user_agent
|
||||
head '/dmsf/webdav/folder_not_here', nil, {:HTTP_USER_AGENT => "Microsoft Office Word 2014"}
|
||||
assert_response :missing
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_folder_not_found_anonymous_other_user_agent
|
||||
head '/dmsf/webdav/folder_not_here', nil, {:HTTP_USER_AGENT => "Other"}
|
||||
assert_response 401
|
||||
check_headers_dont_exist
|
||||
end
|
||||
|
||||
def test_head_fails_when_project_is_not_enabled_for_dmsf
|
||||
head "/dmsf/webdav/#{@project2.identifier}/test.txt", nil, @jsmith
|
||||
assert_response :missing
|
||||
@ -116,4 +164,4 @@ class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@ -117,6 +117,26 @@ class DmsfWebdavOptionsTest < RedmineDmsf::Test::IntegrationTest
|
||||
assert response.headers['Ms-Author-Via'] == 'DAV', 'Ms-Author-Via header - expected: DAV'
|
||||
end
|
||||
|
||||
def test_un_authenticated_options_for_msoffice_user_agent
|
||||
xml_http_request :options, "/dmsf/webdav/#{@project1.identifier}", nil, {:HTTP_USER_AGENT => "Microsoft Office Word 2014"}
|
||||
assert_response 405
|
||||
end
|
||||
|
||||
def test_authenticated_options_for_msoffice_user_agent
|
||||
xml_http_request :options, "/dmsf/webdav/#{@project1.identifier}", nil, @admin.merge!({:HTTP_USER_AGENT => "Microsoft Office Word 2014"})
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_un_authenticated_options_for_other_user_agent
|
||||
xml_http_request :options, "/dmsf/webdav/#{@project1.identifier}", nil, {:HTTP_USER_AGENT => "Other"}
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
def test_authenticated_options_for_other_user_agent
|
||||
xml_http_request :options, "/dmsf/webdav/#{@project1.identifier}", nil, @admin.merge!({:HTTP_USER_AGENT => "Other"})
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
# TODO: It doesn't work
|
||||
# def test_authenticated_options_returns_401_for_non_dmsf_enabled_items
|
||||
# @project2.disable_module! :dmsf
|
||||
@ -129,4 +149,4 @@ class DmsfWebdavOptionsTest < RedmineDmsf::Test::IntegrationTest
|
||||
# assert_response 401 # refused
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user