Tue, 31 Dec 2019 14:53:13 +0100
add test for webdav_op_propfind_children
--- a/src/server/test/main.c Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/test/main.c Tue Dec 31 14:53:13 2019 +0100 @@ -66,7 +66,7 @@ ucx_test_register(suite, test_vfs_open); ucx_test_register(suite, test_vfs_mkdir); ucx_test_register(suite, test_vfs_opendir); - ucx_test_register(suite, test_readdir); + ucx_test_register(suite, test_vfs_readdir); // webdav tests ucx_test_register(suite, test_propfind_parse); @@ -78,6 +78,7 @@ ucx_test_register(suite, test_msresponse_addproperty); ucx_test_register(suite, test_webdav_propfind_init); ucx_test_register(suite, test_webdav_op_propfind_begin); + ucx_test_register(suite, test_webdav_op_propfind_children); // run tests ucx_test_run(suite, stdout);
--- a/src/server/test/vfs.c Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/test/vfs.c Tue Dec 31 14:53:13 2019 +0100 @@ -91,6 +91,7 @@ vfsdir->name = sstrdup_a( session_get_allocator(dir->ctx->sn), sstr(test_resource_name(file->path.ptr))); + ZERO(entry, sizeof(VFS_ENTRY)); entry->name = vfsdir->name.ptr; return 1; } else { @@ -308,7 +309,7 @@ testutil_destroy_session(sn); } -UCX_TEST(test_readdir) { +UCX_TEST(test_vfs_readdir) { Session *sn = testutil_session(); Request *rq = testutil_request(sn->pool, "PUT", "/"); rq->vfs = testvfs_create(sn);
--- a/src/server/test/vfs.h Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/test/vfs.h Tue Dec 31 14:53:13 2019 +0100 @@ -43,7 +43,7 @@ UCX_TEST(test_vfs_open); UCX_TEST(test_vfs_mkdir); UCX_TEST(test_vfs_opendir); -UCX_TEST(test_readdir); +UCX_TEST(test_vfs_readdir); #ifdef __cplusplus }
--- a/src/server/test/webdav.c Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/test/webdav.c Tue Dec 31 14:53:13 2019 +0100 @@ -37,6 +37,7 @@ #include "../webdav/multistatus.h" #include "../webdav/operation.h" +#include "vfs.h" #include "webdav.h" /* ----------------------------- Test Backends --------------------------*/ @@ -790,6 +791,7 @@ UCX_TEST_END; + testutil_destroy_session(sn); } UCX_TEST(test_webdav_op_propfind_children) { @@ -805,8 +807,34 @@ int err = webdav_op_propfind_begin(op, "/", NULL, NULL); UCX_TEST_ASSERT(err == 0, "propfind_begin error"); + // create test vfs with some files (code from test_vfs_readdir) + rq->vfs = testvfs_create(sn); + VFSContext *vfs = vfs_request_context(sn, rq); + UCX_TEST_ASSERT(vfs, "no vfs"); + err = vfs_mkdir(vfs, "/dir"); + UCX_TEST_ASSERT(err == 0, "error not 0"); + // add some test file to /dir + UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed"); + UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed"); + UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed"); + UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed"); + + VFSDir *dir = vfs_opendir(vfs, "/dir"); + UCX_TEST_ASSERT(dir, "dir not opened"); + + UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); + UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend1 propfind_do not called") + + // propfind for all children + err = webdav_op_propfind_children(op, vfs, "/dir"); + UCX_TEST_ASSERT(err == 0, "webdav_op_propfind_children failed"); + + // 1 dir + 4 children + UCX_TEST_ASSERT(backend1_propfind_do_count == 5, "backend1 propfind_do wrong count"); + UCX_TEST_ASSERT(backend2_propfind_do_count == 5, "backend2 propfind_do wrong count"); UCX_TEST_END; + testutil_destroy_session(sn); }
--- a/src/server/test/webdav.h Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/test/webdav.h Tue Dec 31 14:53:13 2019 +0100 @@ -51,6 +51,7 @@ UCX_TEST(test_webdav_propfind_init); UCX_TEST(test_webdav_op_propfind_begin); +UCX_TEST(test_webdav_op_propfind_children); /* --------------------------- PROPFIND --------------------------- */
--- a/src/server/webdav/operation.c Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/webdav/operation.c Tue Dec 31 14:53:13 2019 +0100 @@ -94,7 +94,6 @@ VFSContext *vfs, char *path) { - WebdavResponse *response = op->response; WebdavPropfindRequest *request = op->requests->data; UcxAllocator *a = session_get_allocator(request->sn);
--- a/src/server/webdav/webdav.c Tue Dec 31 14:07:42 2019 +0100 +++ b/src/server/webdav/webdav.c Tue Dec 31 14:53:13 2019 +0100 @@ -302,7 +302,7 @@ WebdavPropfindRequest *pReq = pool_malloc( pool, sizeof(WebdavPropfindRequest)); - memcpy(propfind, pReq, sizeof(WebdavPropfindRequest)); + memcpy(pReq, propfind, sizeof(WebdavPropfindRequest)); // use new plist after previous init (or orig. plist in the first run) pReq->properties = newProp; pReq->propcount = newPropCount;