diff --git a/webdav/prop.go b/webdav/prop.go index 502f80ef..1cd068ce 100644 --- a/webdav/prop.go +++ b/webdav/prop.go @@ -141,9 +141,13 @@ var liveProps = map[xml.Name]struct { dir: false, }, - // TODO(nigeltao) Lock properties will be defined later. + // TODO: The lockdiscovery property requires LockSystem to list the + // active locks on a resource. xml.Name{Space: "DAV:", Local: "lockdiscovery"}: {}, - xml.Name{Space: "DAV:", Local: "supportedlock"}: {}, + xml.Name{Space: "DAV:", Local: "supportedlock"}: { + findFn: findSupportedLock, + dir: true, + }, } // TODO(nigeltao) merge props and allprop? @@ -370,3 +374,11 @@ func findETag(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string // with nanosecond granularity. return fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size()), nil } + +func findSupportedLock(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { + return `` + + `` + + `` + + `` + + ``, nil +} diff --git a/webdav/prop_test.go b/webdav/prop_test.go index 4cd8755c..f588d4fc 100644 --- a/webdav/prop_test.go +++ b/webdav/prop_test.go @@ -70,6 +70,7 @@ func TestMemPS(t *testing.T) { xml.Name{Space: "DAV:", Local: "getcontentlength"}, xml.Name{Space: "DAV:", Local: "getlastmodified"}, xml.Name{Space: "DAV:", Local: "getcontenttype"}, + xml.Name{Space: "DAV:", Local: "supportedlock"}, }, }, { op: "propname", @@ -81,6 +82,7 @@ func TestMemPS(t *testing.T) { xml.Name{Space: "DAV:", Local: "getlastmodified"}, xml.Name{Space: "DAV:", Local: "getcontenttype"}, xml.Name{Space: "DAV:", Local: "getetag"}, + xml.Name{Space: "DAV:", Local: "supportedlock"}, }, }}, }, { @@ -106,6 +108,14 @@ func TestMemPS(t *testing.T) { }, { XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"}, InnerXML: []byte("text/plain; charset=utf-8"), + }, { + XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, + InnerXML: []byte(`` + + `` + + `` + + `` + + ``, + ), }}, }}, }, { @@ -131,6 +141,14 @@ func TestMemPS(t *testing.T) { }, { XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, InnerXML: nil, // Calculated during test. + }, { + XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, + InnerXML: []byte(`` + + `` + + `` + + `` + + ``, + ), }}, }}, }, { @@ -160,6 +178,14 @@ func TestMemPS(t *testing.T) { }, { XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, InnerXML: nil, // Calculated during test. + }, { + XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, + InnerXML: []byte(`` + + `` + + `` + + `` + + ``, + ), }}}, { Status: http.StatusNotFound, Props: []Property{{ @@ -449,6 +475,7 @@ func TestMemPS(t *testing.T) { xml.Name{Space: "DAV:", Local: "getlastmodified"}, xml.Name{Space: "DAV:", Local: "getcontenttype"}, xml.Name{Space: "DAV:", Local: "getetag"}, + xml.Name{Space: "DAV:", Local: "supportedlock"}, xml.Name{Space: "foo", Local: "bar"}, }, }},