707 |
707 |
708 WebdavProperty p1; |
708 WebdavProperty p1; |
709 WebdavProperty p[16]; |
709 WebdavProperty p[16]; |
710 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; |
710 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; |
711 |
711 |
|
712 WSNamespace ns1; |
|
713 ZERO(&ns1, sizeof(WSNamespace)); |
|
714 WSNamespace ns2; |
|
715 ZERO(&ns2, sizeof(WSNamespace)); |
|
716 ns1.prefix = (xmlChar*)"x1"; |
|
717 ns1.href = (xmlChar*)"http://example.com/test/"; |
|
718 ns2.prefix = (xmlChar*)"x2"; |
|
719 ns2.href = (xmlChar*)"http://example.com/test/"; |
|
720 |
|
721 WebdavProperty dp1; |
|
722 ZERO(&dp1, sizeof(WebdavProperty)); |
|
723 dp1.name = "dup"; |
|
724 dp1.namespace = &ns1; |
|
725 dp1.value.text.str = "Hello"; |
|
726 dp1.value.text.length = 5; |
|
727 dp1.vtype = WS_VALUE_TEXT; |
|
728 |
|
729 WebdavProperty dp2; |
|
730 ZERO(&dp2, sizeof(WebdavProperty)); |
|
731 dp2.name = "dup"; |
|
732 dp2.namespace = &ns1; |
|
733 dp2.value.text.str = "Hello"; |
|
734 dp2.value.text.length = 5; |
|
735 dp2.vtype = WS_VALUE_TEXT; |
|
736 |
|
737 WebdavProperty dp3; |
|
738 ZERO(&dp3, sizeof(WebdavProperty)); |
|
739 dp3.name = "dup"; |
|
740 dp3.namespace = &ns2; |
|
741 dp3.value.text.str = "Hello"; |
|
742 dp3.value.text.length = 5; |
|
743 dp3.vtype = WS_VALUE_TEXT; |
|
744 |
712 // init test data |
745 // init test data |
713 p1.namespace = webdav_dav_namespace(); |
746 p1.namespace = webdav_dav_namespace(); |
714 p1.nsdef = NULL; |
|
715 p1.lang = NULL; |
747 p1.lang = NULL; |
716 p1.name = "test1"; |
748 p1.name = "test1"; |
717 p1.value.data = NULL; |
749 p1.value.data = NULL; |
718 p1.vtype = 0; |
750 p1.vtype = 0; |
719 |
751 |
720 for(int i=0;i<8;i++) { |
752 for(int i=0;i<8;i++) { |
721 p[i].namespace = webdav_dav_namespace(); |
753 p[i].namespace = webdav_dav_namespace(); |
722 p[i].nsdef = NULL; |
|
723 p[i].name = names[i]; |
754 p[i].name = names[i]; |
724 p[i].lang = NULL; |
755 p[i].lang = NULL; |
725 p[i].value.node = NULL; |
756 p[i].value.node = NULL; |
726 p[1].vtype = 0; |
757 p[1].vtype = 0; |
727 } |
758 } |
749 |
780 |
750 UCX_TEST_ASSERT(ucx_list_size(r->errors->begin) == 2, "404 list size != 2"); |
781 UCX_TEST_ASSERT(ucx_list_size(r->errors->begin) == 2, "404 list size != 2"); |
751 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->begin) == 4, "403 list size != 4"); |
782 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->begin) == 4, "403 list size != 4"); |
752 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->next->begin) == 1, "500 list size != 1"); |
783 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->next->begin) == 1, "500 list size != 1"); |
753 |
784 |
|
785 // new resource for prop duplication tests |
|
786 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test"); |
|
787 UCX_TEST_ASSERT(r, "cannot create second response"); |
|
788 |
|
789 r->resource.addproperty((WebdavResource*)r, &dp1, 200); |
|
790 UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed"); |
|
791 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: list size not 1"); |
|
792 |
|
793 r->resource.addproperty((WebdavResource*)r, &dp2, 200); |
|
794 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 should not work"); |
|
795 |
|
796 r->resource.addproperty((WebdavResource*)r, &dp2, 404); |
|
797 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 with different status should not work (1)"); |
|
798 if(r->errors) { |
|
799 UCX_TEST_ASSERT(ucx_list_size(r->errors->begin) == 0, "dp1: error list not empty"); |
|
800 } |
|
801 |
|
802 r->resource.addproperty((WebdavResource*)r, &dp3, 200); |
|
803 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp3 should not work"); |
|
804 |
754 UCX_TEST_END; |
805 UCX_TEST_END; |
755 } |
806 } |
756 |
807 |
757 UCX_TEST(test_webdav_propfind_init) { |
808 UCX_TEST(test_webdav_propfind_init) { |
758 reset_backends(); |
809 reset_backends(); |