src/server/test/webdav.c

branch
webdav
changeset 251
f727a21497bb
parent 249
3b302093945c
child 300
0e3f275b2492
--- a/src/server/test/webdav.c	Sun Jun 07 17:18:59 2020 +0200
+++ b/src/server/test/webdav.c	Sat Jul 11 17:58:00 2020 +0200
@@ -1104,7 +1104,7 @@
     pblock_nvinsert("uri", "/", rq->reqpb);
     
     st = testutil_iostream(2048, TRUE);
-    sn->csd = st;
+    sn->csd = (IOStream*)st;
     
     if(request_body) {
         testutil_request_body(sn, rq, request_body, strlen(request_body));
@@ -1724,3 +1724,39 @@
     
     UCX_TEST_END;
 }
+
+UCX_TEST(test_webdav_put) {
+    Session *sn;
+    Request *rq; 
+    TestIOStream *st;
+    pblock *pb;
+    
+    const char *content_const = "Hello World";
+    
+    init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", content_const);
+    rq->vfs = testvfs_create(sn);
+    
+    UCX_TEST_BEGIN;
+    
+    int err;
+    
+    pblock_replace("path", "/file0", rq->vars);
+    err = webdav_put(NULL, sn, rq);
+    
+    UCX_TEST_ASSERT(err == REQ_PROCEED, "put failed");
+    
+    VFSContext *vfs = vfs_request_context(sn, rq);
+    SYS_FILE f0 = vfs_open(vfs, "/file0", 0);
+    UCX_TEST_ASSERT(f0, "cannot open file0");
+    
+    char buf[1024];
+    int r = system_fread(f0, buf, 1024);
+    
+    UCX_TEST_ASSERT(r == strlen(content_const), "wrong file size");
+    UCX_TEST_ASSERT(!memcmp(content_const, buf, r), "wrong file content");
+    
+    testutil_destroy_session(sn);
+    testutil_iostream_destroy(st);
+    
+    UCX_TEST_END;
+}

mercurial