586 TestResponse *r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
589 TestResponse *r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
587 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); |
590 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); |
588 |
591 |
589 UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); |
592 UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); |
590 |
593 |
591 TestProperty *p = ucx_map_cstr_get(r1->properties, "D:resourcetype"); |
594 TestProperty *p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
592 UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'"); |
595 UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'"); |
593 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'"); |
596 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'"); |
594 |
597 |
595 p = ucx_map_cstr_get(r1->properties, "D:getlastmodified"); |
598 p = ucx_map_cstr_get(r1->properties, "DAV:getlastmodified"); |
596 UCX_TEST_ASSERT(p, "propfind1: missing property 'getlastmodified'"); |
599 UCX_TEST_ASSERT(p, "propfind1: missing property 'getlastmodified'"); |
597 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'getlastmodified'"); |
600 UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'getlastmodified'"); |
598 |
601 |
599 testutil_destroy_session(sn); |
602 testutil_destroy_session(sn); |
600 test_multistatus_destroy(ms); |
603 test_multistatus_destroy(ms); |
601 testutil_iostream_destroy(st); |
604 testutil_iostream_destroy(st); |
602 |
605 |
646 r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
655 r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
647 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); |
656 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); |
648 |
657 |
649 UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); |
658 UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); |
650 |
659 |
|
660 |
|
661 r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
|
662 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res1 response"); |
|
663 |
|
664 p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
|
665 UCX_TEST_ASSERT(p, "propfind3: missing property 'test'"); |
|
666 UCX_TEST_ASSERT(p->status == 200, "propfind3: wrong status code for property 'test'"); |
|
667 UCX_TEST_ASSERT(!strcmp(p->value, "testvalue"), "propfind3: wrong property value"); |
|
668 |
|
669 p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
|
670 UCX_TEST_ASSERT(p, "propfind3: missing property 'prop2'"); |
|
671 UCX_TEST_ASSERT(p->status == 200, "propfind3: wrong status code for property 'prop2'"); |
|
672 UCX_TEST_ASSERT(!strcmp(p->value, "value2"), "propfind3: wrong property value"); |
|
673 |
|
674 |
651 r1 = ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"); |
675 r1 = ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"); |
652 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res4 response"); |
676 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res4 response"); |
653 |
677 |
654 testutil_destroy_session(sn); |
678 testutil_destroy_session(sn); |
655 test_multistatus_destroy(ms); |
679 test_multistatus_destroy(ms); |
656 testutil_iostream_destroy(st); |
680 testutil_iostream_destroy(st); |
657 |
681 |
658 UCX_TEST_END; |
682 UCX_TEST_END; |
659 } |
683 } |
|
684 |
|
685 |
|
686 UCX_TEST(test_pg_webdav_propfind_allprop) { |
|
687 Session *sn; |
|
688 Request *rq; |
|
689 TestIOStream *st; |
|
690 pblock *pb; |
|
691 |
|
692 UCX_TEST_BEGIN; |
|
693 |
|
694 // test data: |
|
695 // |
|
696 // /propfind/ |
|
697 // /propfind/res1 (2 properties: test, prop2) |
|
698 // /propfind/res2 (1 property: test) |
|
699 // /propfind/res3 |
|
700 // /propfind/sub |
|
701 // /propfind/sub/res4 |
|
702 |
|
703 int ret; |
|
704 TestResponse *r1; |
|
705 TestProperty *p; |
|
706 // Test 1 |
|
707 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
|
708 rq->davCollection = create_test_pgdav(sn, rq); |
|
709 pblock_nvinsert("depth", "0", rq->headers); |
|
710 |
|
711 ret = webdav_propfind(pb, sn, rq); |
|
712 |
|
713 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
|
714 |
|
715 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); |
|
716 UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml"); |
|
717 |
|
718 r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
|
719 UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); |
|
720 UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); |
|
721 |
|
722 p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
|
723 UCX_TEST_ASSERT(r1, "propfind1: missing resourcetype property"); |
|
724 |
|
725 testutil_destroy_session(sn); |
|
726 test_multistatus_destroy(ms); |
|
727 testutil_iostream_destroy(st); |
|
728 |
|
729 // Test 2 |
|
730 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
|
731 rq->davCollection = create_test_pgdav(sn, rq); |
|
732 pblock_nvinsert("depth", "1", rq->headers); |
|
733 |
|
734 ret = webdav_propfind(pb, sn, rq); |
|
735 |
|
736 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
|
737 |
|
738 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
|
739 |
|
740 ms = test_parse_multistatus(st->buf->space, st->buf->size); |
|
741 UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); |
|
742 |
|
743 r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
|
744 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); |
|
745 UCX_TEST_ASSERT(ms->responses->count == 5, "propfind2: wrong response count"); |
|
746 |
|
747 r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
|
748 UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res1 response"); |
|
749 |
|
750 p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
|
751 UCX_TEST_ASSERT(r1, "propfind2: missing resourcetype property"); |
|
752 p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
|
753 UCX_TEST_ASSERT(r1, "propfind2: missing test property"); |
|
754 p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
|
755 UCX_TEST_ASSERT(r1, "propfind2: missing prop2 property"); |
|
756 |
|
757 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res2"), "propfind2: missing /propfind/res2 response"); |
|
758 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res3"), "propfind2: missing /propfind/res3 response"); |
|
759 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/"), "propfind2: missing /propfind/sub response"); |
|
760 |
|
761 testutil_destroy_session(sn); |
|
762 test_multistatus_destroy(ms); |
|
763 testutil_iostream_destroy(st); |
|
764 |
|
765 // Test 3 |
|
766 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
|
767 rq->davCollection = create_test_pgdav(sn, rq); |
|
768 pblock_nvinsert("depth", "infinity", rq->headers); |
|
769 |
|
770 ret = webdav_propfind(pb, sn, rq); |
|
771 |
|
772 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
|
773 |
|
774 ms = test_parse_multistatus(st->buf->space, st->buf->size); |
|
775 UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); |
|
776 |
|
777 r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
|
778 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); |
|
779 UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); |
|
780 |
|
781 r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
|
782 UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/res1 response"); |
|
783 |
|
784 p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
|
785 UCX_TEST_ASSERT(r1, "propfind3: missing resourcetype property"); |
|
786 p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
|
787 UCX_TEST_ASSERT(r1, "propfind3: missing test property"); |
|
788 p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
|
789 UCX_TEST_ASSERT(r1, "propfind3: missing prop2 property"); |
|
790 |
|
791 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res2"), "propfind3: missing /propfind/res2 response"); |
|
792 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res3"), "propfind3: missing /propfind/res3 response"); |
|
793 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/"), "propfind3: missing /propfind/sub response"); |
|
794 UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"), "propfind3: missing /propfind/sub/res4 response"); |
|
795 |
|
796 testutil_destroy_session(sn); |
|
797 test_multistatus_destroy(ms); |
|
798 testutil_iostream_destroy(st); |
|
799 |
|
800 |
|
801 UCX_TEST_END; |
|
802 } |
|
803 |