diff -r 6b1a6066ee43 -r b608b7aa43a6 src/server/plugins/postgresql/pgtest.c --- a/src/server/plugins/postgresql/pgtest.c Mon Apr 25 22:38:05 2022 +0200 +++ b/src/server/plugins/postgresql/pgtest.c Tue Apr 26 14:33:58 2022 +0200 @@ -203,7 +203,8 @@ void test_multistatus_destroy(TestMultistatus *ms) { - + xmlFreeDoc(ms->doc); + ucx_mempool_destroy(ms->mp); } @@ -497,6 +498,13 @@ UCX_TEST_ASSERT(f1, "res3 create failed"); vfs_close(f1); + int r = vfs_mkdir(vfs, "/propfind/sub"); + UCX_TEST_ASSERT(r == 0, "sub create failed"); + + f1 = vfs_open(vfs, "/propfind/sub/res4", O_WRONLY|O_CREAT); + UCX_TEST_ASSERT(f1, "res4 create failed"); + vfs_close(f1); + // 2 properties for res1 char idstr[32]; snprintf(idstr, 32, "%" PRId64, res1_id); @@ -566,6 +574,7 @@ // Test 1 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND1); rq->davCollection = create_test_pgdav(sn, rq); + pblock_nvinsert("depth", "0", rq->headers); ret = webdav_propfind(pb, sn, rq); @@ -577,16 +586,70 @@ TestResponse *r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); + UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); + TestProperty *p = ucx_map_cstr_get(r1->properties, "D:resourcetype"); UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'"); UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'"); p = ucx_map_cstr_get(r1->properties, "D:getlastmodified"); UCX_TEST_ASSERT(p, "propfind1: missing property 'getlastmodified'"); - UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'getlastmodified'"); + UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'getlastmodified'"); + + testutil_destroy_session(sn); + test_multistatus_destroy(ms); + testutil_iostream_destroy(st); + + + // Test 2 + init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2); + rq->davCollection = create_test_pgdav(sn, rq); + pblock_nvinsert("depth", "1", rq->headers); + + ret = webdav_propfind(pb, sn, rq); + + //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); + + UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); + + ms = test_parse_multistatus(st->buf->space, st->buf->size); + UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); + + r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); + UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); + + UCX_TEST_ASSERT(ms->responses->count == 5, "propfind2: wrong response count"); + + r1 = ucx_map_cstr_get(ms->responses, "/propfind/res2"); + UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res2 response"); + + testutil_destroy_session(sn); + test_multistatus_destroy(ms); + testutil_iostream_destroy(st); + + + + // Test 3 + init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2); + rq->davCollection = create_test_pgdav(sn, rq); + pblock_nvinsert("depth", "infinity", rq->headers); + + ret = webdav_propfind(pb, sn, rq); printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); + UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (3) failed"); + + ms = test_parse_multistatus(st->buf->space, st->buf->size); + UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); + + r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); + UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); + + UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); + + r1 = ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"); + UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res4 response"); testutil_destroy_session(sn); test_multistatus_destroy(ms);