mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-27 18:34:27 +00:00
Locking unmapped URLs results in creation of that resource now, as specified in http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.4
This commit is contained in:
+38
@@ -45,9 +45,13 @@ import org.apache.jackrabbit.webdav.MultiStatus;
|
||||
import org.apache.jackrabbit.webdav.MultiStatusResponse;
|
||||
import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
|
||||
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
|
||||
import org.apache.jackrabbit.webdav.client.methods.LockMethod;
|
||||
import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
|
||||
import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
|
||||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||
import org.apache.jackrabbit.webdav.lock.LockInfo;
|
||||
import org.apache.jackrabbit.webdav.lock.Scope;
|
||||
import org.apache.jackrabbit.webdav.lock.Type;
|
||||
import org.cryptomator.filesystem.FileSystem;
|
||||
import org.cryptomator.filesystem.ReadableFile;
|
||||
import org.cryptomator.filesystem.WritableFile;
|
||||
@@ -173,6 +177,40 @@ public class WebDavServerTest {
|
||||
Assert.assertTrue(CollectionUtils.containsAll(hrefs, Arrays.asList(servletRoot + "/folder1/", servletRoot + "/folder2/", servletRoot + "/file1")));
|
||||
}
|
||||
|
||||
/* LOCK */
|
||||
|
||||
@Test
|
||||
public void testLockExisting() throws IOException, DavException {
|
||||
final HttpClient client = new HttpClient();
|
||||
|
||||
// create file:
|
||||
try (WritableFile writable = fs.file("foo.txt").openWritable()) {
|
||||
writable.write(ByteBuffer.allocate(0));
|
||||
}
|
||||
|
||||
// lock existing file:
|
||||
LockInfo lockInfo = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "le me", 3600, false);
|
||||
final DavMethodBase lockMethod = new LockMethod(servletRoot + "/foo.txt", lockInfo);
|
||||
final int lockResponse = client.executeMethod(lockMethod);
|
||||
Assert.assertEquals(200, lockResponse);
|
||||
|
||||
lockMethod.releaseConnection();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockNonExisting() throws IOException, DavException {
|
||||
final HttpClient client = new HttpClient();
|
||||
|
||||
// lock nonexisting file:
|
||||
LockInfo lockInfo = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "le me", 3600, false);
|
||||
final DavMethodBase lockMethod = new LockMethod(servletRoot + "/foo.txt", lockInfo);
|
||||
final int lockResponse = client.executeMethod(lockMethod);
|
||||
Assert.assertEquals(201, lockResponse);
|
||||
Assert.assertTrue(fs.file("foo.txt").exists());
|
||||
|
||||
lockMethod.releaseConnection();
|
||||
}
|
||||
|
||||
/* MOVE */
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user