1084 |
1084 |
1085 UCX_TEST_END; |
1085 UCX_TEST_END; |
1086 testutil_destroy_session(sn); |
1086 testutil_destroy_session(sn); |
1087 } |
1087 } |
1088 |
1088 |
1089 static void init_test_webdav_method( |
1089 void init_test_webdav_method( |
1090 Session **out_sn, |
1090 Session **out_sn, |
1091 Request **out_rq, |
1091 Request **out_rq, |
1092 TestIOStream **out_st, |
1092 TestIOStream **out_st, |
1093 pblock **out_pb, |
1093 pblock **out_pb, |
1094 const char *method, |
1094 const char *method, |
|
1095 const char *path, |
1095 const char *request_body) |
1096 const char *request_body) |
1096 { |
1097 { |
1097 Session *sn; |
1098 Session *sn; |
1098 Request *rq; |
1099 Request *rq; |
1099 TestIOStream *st; |
1100 TestIOStream *st; |
1100 pblock *pb; |
1101 pblock *pb; |
1101 |
1102 |
1102 sn = testutil_session(); |
1103 sn = testutil_session(); |
1103 rq = testutil_request(sn->pool, method, "/"); |
1104 rq = testutil_request(sn->pool, method, "/"); |
1104 |
1105 |
1105 pblock_nvinsert("path", "/", rq->vars); |
1106 pblock_nvinsert("path", path, rq->vars); |
1106 pblock_nvinsert("uri", "/", rq->reqpb); |
1107 pblock_nvinsert("uri", path, rq->reqpb); |
1107 |
1108 |
1108 st = testutil_iostream(2048, TRUE); |
1109 st = testutil_iostream(2048, TRUE); |
1109 sn->csd = (IOStream*)st; |
1110 sn->csd = (IOStream*)st; |
1110 |
1111 |
1111 if(request_body) { |
1112 if(request_body) { |
1128 |
1129 |
1129 UCX_TEST_BEGIN; |
1130 UCX_TEST_BEGIN; |
1130 |
1131 |
1131 int ret; |
1132 int ret; |
1132 // Test 1 |
1133 // Test 1 |
1133 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", TEST_PROPFIND1); |
1134 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND1); |
1134 |
1135 |
1135 ret = webdav_propfind(pb, sn, rq); |
1136 ret = webdav_propfind(pb, sn, rq); |
1136 |
1137 |
1137 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
1138 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
1138 |
1139 |
1145 testutil_destroy_session(sn); |
1146 testutil_destroy_session(sn); |
1146 xmlFreeDoc(doc); |
1147 xmlFreeDoc(doc); |
1147 testutil_iostream_destroy(st); |
1148 testutil_iostream_destroy(st); |
1148 |
1149 |
1149 // Test2 |
1150 // Test2 |
1150 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", TEST_PROPFIND2); |
1151 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND2); |
1151 |
1152 |
1152 ret = webdav_propfind(pb, sn, rq); |
1153 ret = webdav_propfind(pb, sn, rq); |
1153 |
1154 |
1154 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
1155 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
1155 |
1156 |
1418 |
1419 |
1419 UCX_TEST_BEGIN; |
1420 UCX_TEST_BEGIN; |
1420 |
1421 |
1421 int ret; |
1422 int ret; |
1422 // Test 1 |
1423 // Test 1 |
1423 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", TEST_PROPPATCH2); |
1424 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/", TEST_PROPPATCH2); |
1424 rq->davCollection = &backend1; |
1425 rq->davCollection = &backend1; |
1425 ret = webdav_proppatch(pb, sn, rq); |
1426 ret = webdav_proppatch(pb, sn, rq); |
1426 |
1427 |
1427 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed"); |
1428 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed"); |
1428 |
1429 |
1582 |
1583 |
1583 // Tests performed primarily with MKCOL, because webdav_vfs_op_do |
1584 // Tests performed primarily with MKCOL, because webdav_vfs_op_do |
1584 // behaves the same for both operations |
1585 // behaves the same for both operations |
1585 // the only difference are the callbacks |
1586 // the only difference are the callbacks |
1586 |
1587 |
1587 init_test_webdav_method(&sn, &rq, &st, &pb, "MKCOL", NULL); |
1588 init_test_webdav_method(&sn, &rq, &st, &pb, "MKCOL", "/", NULL); |
1588 VFS *testvfs = testvfs_create(sn); |
1589 VFS *testvfs = testvfs_create(sn); |
1589 rq->vfs = testvfs; |
1590 rq->vfs = testvfs; |
1590 |
1591 |
1591 WebdavBackend dav1; |
1592 WebdavBackend dav1; |
1592 ZERO(&dav1, sizeof(WebdavBackend)); |
1593 ZERO(&dav1, sizeof(WebdavBackend)); |
1665 Session *sn; |
1666 Session *sn; |
1666 Request *rq; |
1667 Request *rq; |
1667 TestIOStream *st; |
1668 TestIOStream *st; |
1668 pblock *pb; |
1669 pblock *pb; |
1669 |
1670 |
1670 init_test_webdav_method(&sn, &rq, &st, &pb, "DELETE", NULL); |
1671 init_test_webdav_method(&sn, &rq, &st, &pb, "DELETE", "/", NULL); |
1671 rq->vfs = testvfs_create(sn); |
1672 rq->vfs = testvfs_create(sn); |
1672 |
1673 |
1673 WebdavBackend dav1; |
1674 WebdavBackend dav1; |
1674 ZERO(&dav1, sizeof(WebdavBackend)); |
1675 ZERO(&dav1, sizeof(WebdavBackend)); |
1675 dav1.opt_delete = test_backend_webdav_delete; |
1676 dav1.opt_delete = test_backend_webdav_delete; |
1733 TestIOStream *st; |
1734 TestIOStream *st; |
1734 pblock *pb; |
1735 pblock *pb; |
1735 |
1736 |
1736 const char *content_const = "Hello World"; |
1737 const char *content_const = "Hello World"; |
1737 |
1738 |
1738 init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", content_const); |
1739 init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", "/", content_const); |
1739 rq->vfs = testvfs_create(sn); |
1740 rq->vfs = testvfs_create(sn); |
1740 |
1741 |
1741 UCX_TEST_BEGIN; |
1742 UCX_TEST_BEGIN; |
1742 |
1743 |
1743 int err; |
1744 int err; |