1 # -*- encoding: binary -*-
2 # Copyright (C) 2012-2017 all contributors <omgdav-public@bogomips.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 require './test/integration'
8 # ensure everything works when we're using Rack::URLMap with builder
9 class TestUrlmap < Minitest::Test
10 include TestMogileFSIntegration
14 @app = Rack::Builder.new do
18 map "http://example.com/test" do
26 assert_equal 201, req("PUT", "/test/foo", input: StringIO.new("H"))[0].to_i
28 assert_equal "foo", @db[:paths].where { self.~(parent_id: 0) }.first[:name]
29 status, headers, body = req("PROPFIND", "/test", "HTTP_DEPTH" => "1")
30 xml = Nokogiri.XML(body)
31 hrefs = xml.search("//D:href").to_a.map { |x| x.text }
32 assert_equal 2, hrefs.size
33 assert hrefs.include?("/test/"), hrefs.inspect
34 assert hrefs.include?("/test/foo"), hrefs.inspect
36 assert_equal 200, req("HEAD", "/test/foo")[0].to_i
39 "HTTP_DESTINATION" => "http://example.com/test/bar",
40 "HTTP_HOST" => "example.com",
42 assert_equal 201, req("MOVE", "/test/foo", opts)[0].to_i
43 opts["HTTP_DESTINATION"] = "http://example.com/bar"
44 assert_equal 502, req("MOVE", "/test/bar", opts)[0].to_i
46 opts["HTTP_DESTINATION"] = "http://example.com/test/foo"
47 assert_equal 201, req("COPY", "/test/bar", opts)[0].to_i
49 assert_equal 201, req("MKCOL", "/test/col")[0].to_i
50 opts["HTTP_DESTINATION"] = "http://example.com/test/col/foo"
51 assert_equal 201, req("COPY", "/test/bar", opts)[0].to_i
53 opts["HTTP_DESTINATION"] = "http://example.com/zz"
54 assert_equal 502, req("MOVE", "/test/col/", opts)[0].to_i
56 opts["HTTP_DESTINATION"] = "http://example.com/test/COL"
57 assert_equal 201, req("MOVE", "/test/col/", opts)[0].to_i