975 |
975 |
976 UCX_TEST_END; |
976 UCX_TEST_END; |
977 testutil_destroy_session(sn); |
977 testutil_destroy_session(sn); |
978 } |
978 } |
979 |
979 |
980 UCX_TEST(test_webdav_propfind) { |
980 static void init_test_webdav_propfind( |
981 Session *sn = testutil_session(); |
981 Session **out_sn, |
982 Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
982 Request **out_rq, |
|
983 TestIOStream **out_st, |
|
984 pblock **out_pb, |
|
985 const char *request_body) |
|
986 { |
|
987 Session *sn; |
|
988 Request *rq; |
|
989 TestIOStream *st; |
|
990 pblock *pb; |
|
991 |
|
992 sn = testutil_session(); |
|
993 rq = testutil_request(sn->pool, "PROPFIND", "/"); |
983 |
994 |
984 pblock_nvinsert("path", "/", rq->vars); |
995 pblock_nvinsert("path", "/", rq->vars); |
985 pblock_nvinsert("uri", "/", rq->reqpb); |
996 pblock_nvinsert("uri", "/", rq->reqpb); |
986 |
997 |
987 |
998 st = testutil_iostream(2048, TRUE); |
988 TestIOStream *st = testutil_iostream(2048, TRUE); |
|
989 sn->csd = st; |
999 sn->csd = st; |
990 |
1000 |
991 testutil_request_body(sn, rq, TEST_PROPFIND1, strlen(TEST_PROPFIND1)); |
1001 testutil_request_body(sn, rq, request_body, strlen(request_body)); |
|
1002 |
|
1003 pb = pblock_create_pool(sn->pool, 4); |
|
1004 |
|
1005 *out_sn = sn; |
|
1006 *out_rq = rq; |
|
1007 *out_st = st; |
|
1008 *out_pb = pb; |
|
1009 } |
|
1010 |
|
1011 UCX_TEST(test_webdav_propfind) { |
|
1012 Session *sn; |
|
1013 Request *rq; |
|
1014 TestIOStream *st; |
|
1015 pblock *pb; |
992 |
1016 |
993 UCX_TEST_BEGIN; |
1017 UCX_TEST_BEGIN; |
994 |
1018 |
995 pblock *pb = pblock_create_pool(sn->pool, 4); |
1019 int ret; |
996 |
1020 // Test 1 |
997 int ret = webdav_propfind(pb, sn, rq); |
1021 init_test_webdav_propfind(&sn, &rq, &st, &pb, TEST_PROPFIND1); |
|
1022 |
|
1023 ret = webdav_propfind(pb, sn, rq); |
998 |
1024 |
999 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
1025 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
1000 |
1026 |
1001 xmlDoc *doc = xmlReadMemory( |
1027 xmlDoc *doc = xmlReadMemory( |
1002 st->buf->space, st->buf->size, NULL, NULL, 0); |
1028 st->buf->space, st->buf->size, NULL, NULL, 0); |
1003 UCX_TEST_ASSERT(doc, "response is not valid xml"); |
1029 UCX_TEST_ASSERT(doc, "propfind1: response is not valid xml"); |
1004 |
1030 |
1005 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
1031 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
1006 |
1032 |
|
1033 testutil_destroy_session(sn); |
|
1034 xmlFreeDoc(doc); |
|
1035 testutil_iostream_destroy(st); |
|
1036 |
|
1037 // Test2 |
|
1038 init_test_webdav_propfind(&sn, &rq, &st, &pb, TEST_PROPFIND2); |
|
1039 |
|
1040 ret = webdav_propfind(pb, sn, rq); |
|
1041 |
|
1042 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
|
1043 |
|
1044 xmlDoc *doc2 = xmlReadMemory( |
|
1045 st->buf->space, st->buf->size, NULL, NULL, 0); |
|
1046 UCX_TEST_ASSERT(doc, "propfind2: response is not valid xml"); |
|
1047 |
|
1048 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
|
1049 |
|
1050 testutil_destroy_session(sn); |
|
1051 xmlFreeDoc(doc2); |
|
1052 testutil_iostream_destroy(st); |
|
1053 |
1007 UCX_TEST_END; |
1054 UCX_TEST_END; |
1008 testutil_destroy_session(sn); |
1055 |
1009 } |
1056 } |