Commit 84afb0af authored by Robert Stepanek's avatar Robert Stepanek Committed by Nigel Tao

webdav: Advertise exclusive write locks in supportedlock property.

Change-Id: I843c13b5a2f8e58c555ec3be09ca1d2d855126c7
Reviewed-on: https://go-review.googlesource.com/10631Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
parent 8d617020
......@@ -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 `` +
`<lockentry xmlns="DAV:">` +
`<lockscope><exclusive/></lockscope>` +
`<locktype><write/></locktype>` +
`</lockentry>`, nil
}
......@@ -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(`` +
`<lockentry xmlns="DAV:">` +
`<lockscope><exclusive/></lockscope>` +
`<locktype><write/></locktype>` +
`</lockentry>`,
),
}},
}},
}, {
......@@ -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(`` +
`<lockentry xmlns="DAV:">` +
`<lockscope><exclusive/></lockscope>` +
`<locktype><write/></locktype>` +
`</lockentry>`,
),
}},
}},
}, {
......@@ -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(`` +
`<lockentry xmlns="DAV:">` +
`<lockscope><exclusive/></lockscope>` +
`<locktype><write/></locktype>` +
`</lockentry>`,
),
}}}, {
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"},
},
}},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment