diff -r 09676b559091 -r 60870dbac94f src/server/plugins/postgresql/pgtest.c --- a/src/server/plugins/postgresql/pgtest.c Tue Apr 26 18:21:25 2022 +0200 +++ b/src/server/plugins/postgresql/pgtest.c Sat Apr 30 20:44:38 2022 +0200 @@ -94,6 +94,7 @@ ucx_test_register(suite, test_pg_prepare_tests); ucx_test_register(suite, test_pg_webdav_propfind); ucx_test_register(suite, test_pg_webdav_propfind_allprop); + ucx_test_register(suite, test_pg_webdav_proppatch_set); PGresult *result = PQexec(test_connection, "BEGIN"); PQclear(result); @@ -204,6 +205,7 @@ void test_multistatus_destroy(TestMultistatus *ms) { + if(!ms) return; xmlFreeDoc(ms->doc); ucx_mempool_destroy(ms->mp); } @@ -481,6 +483,7 @@ UCX_TEST_BEGIN; vfs_mkdir(vfs, "/propfind"); + vfs_mkdir(vfs, "/proppatch"); SYS_FILE f1; int64_t res1_id, res2_id; @@ -506,6 +509,10 @@ UCX_TEST_ASSERT(f1, "res4 create failed"); vfs_close(f1); + f1 = vfs_open(vfs, "/proppatch/pp1", O_WRONLY|O_CREAT); + UCX_TEST_ASSERT(f1, "pp1 create failed"); + vfs_close(f1); + // 2 properties for res1 char idstr[32]; snprintf(idstr, 32, "%" PRId64, res1_id); @@ -801,3 +808,42 @@ UCX_TEST_END; } +UCX_TEST(test_pg_webdav_proppatch_set) { + Session *sn; + Request *rq; + TestIOStream *st; + pblock *pb; + + UCX_TEST_BEGIN; + + // test data: + // + // /propfind/ + // /propfind/res1 (2 properties: test, prop2) + // /propfind/res2 (1 property: test) + // /propfind/res3 + // /propfind/sub + // /propfind/sub/res4 + + int ret; + TestResponse *r1; + TestProperty *p; + // Test 1 + init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/proppatch/pp1", PG_TEST_PROPPATCH1); + rq->davCollection = create_test_pgdav(sn, rq); + + ret = webdav_proppatch(pb, sn, rq); + UCX_TEST_ASSERT(ret == REQ_PROCEED, "proppatch1 failed"); + + printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); + + TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); + UCX_TEST_ASSERT(ms, "proppatch1 response is not valid xml"); + + testutil_destroy_session(sn); + test_multistatus_destroy(ms); + testutil_iostream_destroy(st); + + + UCX_TEST_END; +}