src/server/test/webdav.c

Wed, 27 Nov 2024 23:00:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 27 Nov 2024 23:00:07 +0100
changeset 563
6ca97c99173e
parent 415
d938228c382e
permissions
-rw-r--r--

add TODO to use a future ucx feature

211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2019 Olaf Wintermann. All rights reserved.
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "testutils.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include "../webdav/requestparser.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "../webdav/webdav.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../webdav/multistatus.h"
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
38 #include "../webdav/operation.h"
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
40 #include "vfs.h"
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include "webdav.h"
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
43 static int webdav_is_initialized = 0;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
44
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
45 /* ----------------------------- Test Backends --------------------------*/
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
46
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
47 static int backend2_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
48 static int backend2_propfind_do_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
49 static int backend2_propfind_finish_called = 0;
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
50 static int backend2_proppatch_commit = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
51 static int backend2_proppatch_do_count = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
52 static int backend2_proppatch_finish_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
53
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
54 // backend2
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
55 static int backend2_propfind_init(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
56 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
57 const char *path,
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
58 const char *href,
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
59 WebdavPList **outPList)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
60 {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
61 backend2_init_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
62 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
63 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
64
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
65 static int backend2_propfind_do(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
66 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
67 WebdavResponse *response,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
68 VFS_DIR parent,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
69 WebdavResource *resource,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
70 struct stat *s)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
71 {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
72 backend2_propfind_do_count++;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
73 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
74 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
75
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
76 static int backend2_propfind_finish(WebdavPropfindRequest *propfind) {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
77 backend2_propfind_finish_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
78 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
79 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
80
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
81 static int backend2_proppatch_do(
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
82 WebdavProppatchRequest *request,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
83 WebdavResource *response,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
84 VFSFile *file,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
85 WebdavPList **out_set,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
86 WebdavPList **out_remove)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
87 {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
88 backend2_proppatch_do_count++;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
89
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
90 if(*out_remove) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
91 return 1; // backend1 should remove all remove-props
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
92 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
93
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
94 WebdavPListIterator i = webdav_plist_iterator(out_set);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
95 WebdavPList *cur;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
96 while(webdav_plist_iterator_next(&i, &cur)) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
97 if(!strcmp(cur->property->name, "a")) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
98 // property 'a' should already be removed by backend1
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
99 return 1;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
100 } else if(!strcmp(cur->property->name, "abort")) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
101 return 1; // test abort
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
102 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
103 response->addproperty(response, cur->property, 200);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
104 webdav_plist_iterator_remove_current(&i);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
105 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
106
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
107 return 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
108 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
109
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
110 static int backend2_proppatch_finish(
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
111 WebdavProppatchRequest *request,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
112 WebdavResource *response,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
113 VFSFile *file,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
114 WSBool commit)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
115 {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
116 backend2_proppatch_finish_count++;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
117 backend2_proppatch_commit = commit;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
118 return 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
119 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
120
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
121 static WebdavBackend backend2 = {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
122 backend2_propfind_init,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
123 backend2_propfind_do,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
124 backend2_propfind_finish,
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
125 backend2_proppatch_do,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
126 backend2_proppatch_finish,
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
127 NULL, // opt_mkcol
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
128 NULL, // opt_mkcol_finish
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
129 NULL, // opt_delete
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
130 NULL, // opt_delete_finish
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
131 0,
300
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
132 NULL, // instance
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
133 NULL
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
134 };
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
135
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
136 // backend1
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
137
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
138 static int backend1_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
139 static int backend1_propfind_do_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
140 static int backend1_propfind_finish_called = 0;
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
141 static int backend1_proppatch_commit = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
142 static int backend1_proppatch_do_count = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
143 static int backend1_proppatch_finish_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
144
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
145
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
146 static int backend1_propfind_init(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
147 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
148 const char *path,
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
149 const char *href,
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
150 WebdavPList **outPList)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
151 {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
152 backend1_init_called = 1;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
153
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
154 WebdavPList *plist = *outPList;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
155 WebdavProperty *p = plist->property;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
156 if(!strcmp(p->name, "displayname")) {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
157 plist->next->prev = NULL;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
158 *outPList = plist->next; // remove first item from plist
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
159 } else {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
160 return 1;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
161 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
162
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
163 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
164 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
165
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
166 static int backend1_propfind_do(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
167 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
168 WebdavResponse *response,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
169 VFS_DIR parent,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
170 WebdavResource *resource,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
171 struct stat *s)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
172 {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
173 backend1_propfind_do_count++;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
174 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
175 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
176
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
177 static int backend1_propfind_finish(WebdavPropfindRequest *propfind) {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
178 backend1_propfind_finish_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
179 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
180 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
181
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
182 static int backend1_proppatch_do(
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
183 WebdavProppatchRequest *request,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
184 WebdavResource *response,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
185 VFSFile *file,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
186 WebdavPList **out_set,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
187 WebdavPList **out_remove)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
188 {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
189 backend1_proppatch_do_count++;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
190
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
191 // remove everything from out_remove
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
192 WebdavPListIterator i = webdav_plist_iterator(out_remove);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
193 WebdavPList *cur;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
194 while(webdav_plist_iterator_next(&i, &cur)) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
195 response->addproperty(response, cur->property, 200);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
196 webdav_plist_iterator_remove_current(&i);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
197 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
198
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
199 // remove property 'a' and fail at property 'fail'
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
200 i = webdav_plist_iterator(out_set);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
201 while(webdav_plist_iterator_next(&i, &cur)) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
202 if(!strcmp(cur->property->name, "fail")) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
203 response->addproperty(response, cur->property, 403);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
204 webdav_plist_iterator_remove_current(&i);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
205 } else if(!strcmp(cur->property->name, "a")) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
206 response->addproperty(response, cur->property, 200);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
207 webdav_plist_iterator_remove_current(&i);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
208 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
209 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
210
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
211 return 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
212 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
213
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
214 static int backend1_proppatch_finish(
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
215 WebdavProppatchRequest *request,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
216 WebdavResource *response,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
217 VFSFile *file,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
218 WSBool commit)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
219 {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
220 backend1_proppatch_finish_count++;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
221 backend1_proppatch_commit = commit;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
222 return 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
223 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
224
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
225 WebdavBackend backend1 = {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
226 backend1_propfind_init,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
227 backend1_propfind_do,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
228 backend1_propfind_finish,
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
229 backend1_proppatch_do,
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
230 backend1_proppatch_finish,
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
231 NULL, // opt_mkcol
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
232 NULL, // opt_mkcol_finish
244
e59abb210584 add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 242
diff changeset
233 NULL, // opt_delete
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
234 NULL, // opt_delete_finish
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
235 0,
300
0e3f275b2492 add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 251
diff changeset
236 NULL, // instance
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
237 &backend2
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
238 };
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
239
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
240 static void reset_backends(void) {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
241 backend1_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
242 backend1_propfind_do_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
243 backend1_propfind_finish_called = 0;
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
244 backend1_proppatch_commit = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
245 backend1_proppatch_do_count = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
246 backend1_proppatch_finish_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
247 backend2_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
248 backend2_propfind_do_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
249 backend2_propfind_finish_called = 0;
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
250 backend2_proppatch_commit = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
251 backend2_proppatch_do_count = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
252 backend2_proppatch_finish_count = 0;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
253 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
254
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
255 /* ----------------------------------------------------------------------*/
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
256
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
257
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
258 static int test_init(
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
259 Session **out_sn,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
260 Request **out_rq,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
261 WebdavPropfindRequest **out_propfind,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
262 const char *xml)
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
263 {
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
264 if(!webdav_is_initialized) {
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
265 if(webdav_init(NULL, NULL, NULL) != REQ_PROCEED) {
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
266 return 1;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
267 }
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
268 webdav_is_initialized = 1;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
269 }
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
270
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
271 Session *sn = testutil_session();
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
272 Request *rq = testutil_request(sn->pool, "PROPFIND", "/");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
273
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
274 int error = 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
275
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
276 WebdavPropfindRequest *propfind = propfind_parse(
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
277 sn,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
278 rq,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
279 xml,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
280 strlen(xml),
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
281 &error);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
282
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
283 if(error) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
284 return 1;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
285 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
286
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
287 if(!propfind || !propfind->properties) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
288 return 1;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
289 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
290
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
291 *out_sn = sn;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
292 *out_rq = rq;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
293 *out_propfind = propfind;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
294 return 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
295 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
296
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
297 static WebdavOperation* test_propfind_op(
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
298 Session **out_sn,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
299 Request **out_rq,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
300 const char *xml)
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
301 {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
302 WebdavPropfindRequest *propfind;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
303 if(test_init(out_sn, out_rq, &propfind, xml)) {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
304 return NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
305 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
306
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
307 Multistatus *ms = multistatus_response(*out_sn, *out_rq);
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
308 if(!ms) {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
309 return NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
310 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
311 // WebdavResponse is the public interface used by Backends
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
312 // for adding resources to the response
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
313 WebdavResponse *response = (WebdavResponse*)ms;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
314
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
315 WebdavPropfindRequestList *requests = NULL;
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
316
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
317 // Initialize all Webdav Backends
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
318 if(webdav_propfind_init(&backend1, propfind, "/", "/", &requests)) {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
319 return NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
320 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
321
239
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
322 return webdav_create_propfind_operation(
222
5f05e56cb8e2 create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
323 (*out_sn),
5f05e56cb8e2 create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 221
diff changeset
324 (*out_rq),
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
325 &backend1,
237
ee1680ef1ef2 handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 233
diff changeset
326 propfind->properties,
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
327 requests,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
328 response);
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
329 }
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
330
228
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
331
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
332 UCX_TEST(test_webdav_plist_add) {
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
333 Session *sn = testutil_session();
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
334
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
335 UCX_TEST_BEGIN;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
336
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
337 WebdavPList *begin = NULL;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
338 WebdavPList *end = NULL;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
339
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
340 WebdavProperty p1, p2, p3;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
341 ZERO(&p1, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
342 ZERO(&p2, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
343 ZERO(&p3, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
344 int r;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
345
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
346 r = webdav_plist_add(sn->pool, &begin, &end, &p1);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
347
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
348 UCX_TEST_ASSERT(r == 0, "add 1 failed");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
349 UCX_TEST_ASSERT(begin && end, "ptrs are NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
350 UCX_TEST_ASSERT(begin == end, "begin != end");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
351 UCX_TEST_ASSERT(begin->prev == NULL, "begin->prev not NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
352 UCX_TEST_ASSERT(begin->next == NULL, "begin->next not NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
353
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
354 r = webdav_plist_add(sn->pool, &begin, &end, &p2);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
355
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
356 UCX_TEST_ASSERT(r == 0, "add 2 failed");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
357 UCX_TEST_ASSERT(begin && end, "add2: ptrs are NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
358 UCX_TEST_ASSERT(begin->next, "begin->next is NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
359 UCX_TEST_ASSERT(begin->next == end, "begin->next != end");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
360 UCX_TEST_ASSERT(end->prev = begin, "end->prev != begin");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
361 UCX_TEST_ASSERT(begin->prev == NULL, "add2: begin->prev not NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
362 UCX_TEST_ASSERT(end->next == NULL, "add2: end->next not NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
363
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
364 r = webdav_plist_add(sn->pool, &begin, &end, &p3);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
365
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
366 UCX_TEST_ASSERT(r == 0, "add 3 failed");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
367 UCX_TEST_ASSERT(begin && end, "add3: ptrs are NULL");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
368 UCX_TEST_ASSERT(begin->next == end->prev, "begin->next != end->prev");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
369
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
370 UCX_TEST_END;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
371
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
372 testutil_destroy_session(sn);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
373 }
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
374
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
375 UCX_TEST(test_webdav_plist_size) {
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
376 Session *sn = testutil_session();
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
377
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
378 UCX_TEST_BEGIN;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
379
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
380 WebdavPList *begin = NULL;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
381 WebdavPList *end = NULL;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
382
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
383 WebdavProperty p1, p2, p3;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
384 ZERO(&p1, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
385 ZERO(&p2, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
386 ZERO(&p3, sizeof(WebdavProperty));
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
387 int r;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
388
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
389 UCX_TEST_ASSERT(webdav_plist_size(begin) == 0, "size != 0");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
390 r = webdav_plist_add(sn->pool, &begin, &end, &p1);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
391 UCX_TEST_ASSERT(webdav_plist_size(begin) == 1, "size != 1");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
392 r = webdav_plist_add(sn->pool, &begin, &end, &p2);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
393 UCX_TEST_ASSERT(webdav_plist_size(begin) == 2, "size != 2");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
394 r = webdav_plist_add(sn->pool, &begin, &end, &p3);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
395 UCX_TEST_ASSERT(webdav_plist_size(begin) == 3, "size != 3");
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
396
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
397 UCX_TEST_END;
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
398
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
399 testutil_destroy_session(sn);
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
400 }
c0afce708b1d add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 227
diff changeset
401
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 UCX_TEST(test_propfind_parse) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 Session *sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 Request *rq = testutil_request(sn->pool, "PROPFIND", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 UCX_TEST_BEGIN
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 // ----------------- TEST_PROPFIND1 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 // test basic propfind request
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 WebdavPropfindRequest *p1 = propfind_parse(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 sn,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 rq,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 TEST_PROPFIND1,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 strlen(TEST_PROPFIND1),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 UCX_TEST_ASSERT(p1, "p1 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 UCX_TEST_ASSERT(p1->properties, "p1: no props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 UCX_TEST_ASSERT(!p1->allprop, "p1: allprop is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 UCX_TEST_ASSERT(!p1->propname, "p1: propname is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 UCX_TEST_ASSERT(p1->propcount == 6, "p1: wrong propcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 // property 1: DAV:displayname
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 WebdavPList *elm = p1->properties;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 !strcmp(elm->property->name, "displayname"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 "p1: property 1 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 "p1: property 1 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 // property 2: DAV:getcontentlength
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437 UCX_TEST_ASSERT(elm, "p1: property 2 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 !strcmp(elm->property->name, "getcontentlength"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 "p1: property 2 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 "p1: property 2 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 UCX_TEST_ASSERT(elm, "p1: property 3 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 UCX_TEST_ASSERT(elm, "p1: property 4 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 UCX_TEST_ASSERT(elm, "p1: property 5 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 // property 6: DAV:getetag
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 UCX_TEST_ASSERT(elm, "p1: property 6 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 !strcmp(elm->property->name, "getetag"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 "p1: property 6 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 "p1: property 6 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 UCX_TEST_ASSERT(!elm->next, "p1: should not have property 7");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 // ----------------- TEST_PROPFIND2 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 // test with multiple namespaces
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 WebdavPropfindRequest *p2 = propfind_parse(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 sn,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 rq,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 TEST_PROPFIND2,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 strlen(TEST_PROPFIND2),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 UCX_TEST_ASSERT(p2, "p2 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 UCX_TEST_ASSERT(p2->properties, "p2: no props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 UCX_TEST_ASSERT(!p2->allprop, "p2: allprop is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 UCX_TEST_ASSERT(!p2->propname, "p2: propname is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 // property 1: DAV:resourcetype
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 elm = p2->properties;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481 !strcmp(elm->property->name, "resourcetype"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 "p2: property 1 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485 "p2: property 1 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 // property 2: X:testprop
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 UCX_TEST_ASSERT(elm, "p2: property 2 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 !strcmp(elm->property->name, "testprop"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492 "p2: property 2 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 !strcmp((char*)elm->property->namespace->href, "http://example.com/"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 "p2: property 2 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 // property 3: X:name
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499 UCX_TEST_ASSERT(elm, "p2: property 3 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
500 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 !strcmp(elm->property->name, "name"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 "p2: property 3 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 !strcmp((char*)elm->property->namespace->href, "http://example.com/"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 "p2: property 3 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 // property 4: Z:testprop
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 UCX_TEST_ASSERT(elm, "p2: property 4 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 !strcmp(elm->property->name, "testprop"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 "p2: property 4 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514 !strcmp((char*)elm->property->namespace->href, "testns"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 "p2: property 4 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 // ----------------- TEST_PROPFIND3 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 // test allprop
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 WebdavPropfindRequest *p3 = propfind_parse(sn, rq, TEST_PROPFIND3, strlen(TEST_PROPFIND3), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
523 UCX_TEST_ASSERT(p3, "p3 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
524 UCX_TEST_ASSERT(!p3->properties, "p2: has props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525 UCX_TEST_ASSERT(p3->allprop, "p2: allprop is FALSE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526 UCX_TEST_ASSERT(!p3->propname, "p2: propname is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 UCX_TEST_ASSERT(p3->propcount == 0, "p2: wrong propcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
529
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
530 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 // ----------------- TEST_PROPFIND4 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 // test propname
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533 WebdavPropfindRequest *p4 = propfind_parse(sn, rq, TEST_PROPFIND4, strlen(TEST_PROPFIND4), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
535 UCX_TEST_ASSERT(p4, "p4 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536 UCX_TEST_ASSERT(!p4->properties, "p2: has props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537 UCX_TEST_ASSERT(!p4->allprop, "p2: allprop is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 UCX_TEST_ASSERT(p4->propname, "p2: propname is FALSE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
541 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 // ----------------- TEST_PROPFIND5 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 // test duplicate check
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544 WebdavPropfindRequest *p5 = propfind_parse(sn, rq, TEST_PROPFIND5, strlen(TEST_PROPFIND5), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
546 UCX_TEST_ASSERT(p5, "p5 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547 UCX_TEST_ASSERT(p5->properties, "p5: no props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
548 UCX_TEST_ASSERT(!p5->allprop, "p5: allprop is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
549 UCX_TEST_ASSERT(!p5->propname, "p5: propname is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550 UCX_TEST_ASSERT(p5->propcount == 4, "p5: wrong propcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
551
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 // property 1: DAV:displayname
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 elm = p5->properties;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 UCX_TEST_ASSERT(elm, "p5: property 1 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 !strcmp(elm->property->name, "displayname"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 "p5: property 1 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 "p5: property 1 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 UCX_TEST_ASSERT(elm, "p5: property 2 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 UCX_TEST_ASSERT(elm, "p5: property 3 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 // property 4: DAV:resourcetype
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 elm = elm->next;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 UCX_TEST_ASSERT(elm, "p5: property 4 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 !strcmp(elm->property->name, "resourcetype"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 "p5: property 4 has wrong name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 !strcmp((char*)elm->property->namespace->href, "DAV:"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 "p5: property 4 has wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 // ----------------- TEST_PROPFIND6 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 // test prop/allprop mix
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 WebdavPropfindRequest *p6 = propfind_parse(sn, rq, TEST_PROPFIND6, strlen(TEST_PROPFIND6), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 UCX_TEST_ASSERT(p6, "p5 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 UCX_TEST_ASSERT(!p6->properties, "p5: has props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 UCX_TEST_ASSERT(p6->allprop, "p5: allprop is FALSE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 UCX_TEST_ASSERT(!p6->propname, "p5: propname is TRUE");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 UCX_TEST_ASSERT(p6->propcount == 0, "p5: wrong propcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 UCX_TEST_END
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 pool_destroy(sn->pool);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594 UCX_TEST(test_proppatch_parse) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
595 Session *sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 Request *rq = testutil_request(sn->pool, "PROPPATCH", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 UCX_TEST_BEGIN
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 WebdavProppatchRequest *p1 = proppatch_parse(sn, rq, TEST_PROPPATCH1, strlen(TEST_PROPPATCH1), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 UCX_TEST_ASSERT(p1->set, "p1: missing set props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 UCX_TEST_ASSERT(!p1->remove, "p1: has remove props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 UCX_TEST_ASSERT(p1->setcount == 2, "p1: wrong setcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 UCX_TEST_ASSERT(p1->set->next, "p1: set plist broken");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607 UCX_TEST_ASSERT(!p1->set->next->next, "p1: set plist has no end");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 UCX_TEST_ASSERT(p1->set->property, "p1: missing property ptr in plist");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
610 !strcmp(p1->set->property->name, "test"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 "p1: wrong property 1 name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 WebdavProppatchRequest *p2 = proppatch_parse(sn, rq, TEST_PROPPATCH2, strlen(TEST_PROPPATCH2), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
614
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
615 UCX_TEST_ASSERT(p2->set, "p2: missing set props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 UCX_TEST_ASSERT(p2->remove, "p2: missing remove props");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 UCX_TEST_ASSERT(p2->setcount == 4, "p2: wrong setcount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 UCX_TEST_ASSERT(p2->removecount == 1, "p2: wrong removecount");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
619
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
620 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 !strcmp((char*)p2->set->property->namespace->href, "http://example.com/"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 "p2: set property 1: wrong namespace");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
624 !strcmp(p2->set->property->name, "a"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
625 "p2: set property 1: wrong name");
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
626 WSXmlNode *p2set1 = p2->set->property->value.node;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
628 p2set1->type == WS_NODE_TEXT,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 "p2: set property 1: wrong type");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
630 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
631 p2set1->content,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
632 "p2: set property 1: no text");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 !strcmp((char*)p2set1->content, "test"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 "p2: set property 1: wrong value");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
637 WSXmlNode *p2set3 = p2->set->next->next->property->value.node;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 UCX_TEST_ASSERT(p2set3, "p2: set property 3 missing");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 p2set3->type == WS_NODE_TEXT,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 "p2: set property 3: wrong type");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 p2set3->next,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
644 "p2: set property 3: missing element X:name");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
645
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
646 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
647 xmlHasProp(p2set3->next, BAD_CAST"test"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
648 "p2: set property 3: missing attribute 'test'");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
649
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
650 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
651 xmlHasProp(p2set3->next, BAD_CAST"abc"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
652 "p2: set property 3: missing attribute 'abc");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
653
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
654 xmlChar *value1 = xmlGetProp(p2set3->next, BAD_CAST"test");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
655 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
656 !strcmp((char*) value1, "test1"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
657 "p2: set property 3: wrong attribute value 1");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
658 xmlFree(value1);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
659
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
660 xmlChar *value2 = xmlGetProp(p2set3->next, BAD_CAST"abc");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
661 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
662 !strcmp((char*) value2, "def"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
663 "p2: set property 3: wrong attribute value 2");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
664 xmlFree(value2);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
665
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
666 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
667 !strcmp(p2->remove->property->name, "e"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
668 "p2: wrong remove property");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
669
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
670 UCX_TEST_END
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
671
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
672 pool_destroy(sn->pool);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
673 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
674
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
675 UCX_TEST(test_lock_parse) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
676 Session *sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
677 Request *rq = testutil_request(sn->pool, "LOCK", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
678
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
679 UCX_TEST_BEGIN
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
680 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
681
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
682 WebdavLockRequest *l1 = lock_parse(sn, rq, TEST_LOCK1, strlen(TEST_LOCK1), &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
683
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
684 UCX_TEST_ASSERT(l1, "l1 is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
685 UCX_TEST_ASSERT(l1->type == WEBDAV_LOCK_WRITE, "l1: wrong type");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
686 UCX_TEST_ASSERT(l1->scope == WEBDAV_LOCK_SHARED, "l1: wrong scope");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
687 UCX_TEST_ASSERT(l1->owner, "l1: owner is NULL");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
688 UCX_TEST_ASSERT(!strcmp((char*)l1->owner->content, "User"), "l1: wrong owner");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
689
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
690 UCX_TEST_END
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
691
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
692 pool_destroy(sn->pool);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
693 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
694
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
695 UCX_TEST(test_rqbody2buffer) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
696 Session *sn;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
697 Request *rq;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
698
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
699 UCX_TEST_BEGIN;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
700 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
701 // TEST 1
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
702 sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
703 rq = testutil_request(sn->pool, "PUT", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
704 testutil_request_body(sn, rq, "Hello World!", 12);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
705
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
706 CxBuffer b1;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
707 rqbody2buffer(sn, rq, &b1);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
708 UCX_TEST_ASSERT(b1.size == 12, "b1: wrong size");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
709 UCX_TEST_ASSERT(!memcmp(b1.space,"Hello World!",12), "b1: wrong content");
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
710
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
711 cxBufferDestroy(&b1);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
712 testutil_destroy_session(sn);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
713
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
714 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
715 // TEST 2
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
716 size_t len1 = 25000;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
717 unsigned char *body1 = malloc(len1);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
718 for(int i=0;i<len1;i++) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
719 body1[i] = i;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
720 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
721 sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
722 rq = testutil_request(sn->pool, "PUT", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
723 testutil_request_body(sn, rq, (char*)body1, len1);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
724
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
725 CxBuffer b2;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
726 rqbody2buffer(sn, rq, &b2);
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
727 UCX_TEST_ASSERT(b2.size == len1, "b2: wrong size");
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
728 UCX_TEST_ASSERT(!memcmp(b2.space, body1, len1), "b2: wrong content");
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
729
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
730 cxBufferDestroy(&b2);
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
731 testutil_destroy_session(sn);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
732
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
733 UCX_TEST_END;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
734 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
735
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
736 UCX_TEST(test_webdav_plist_iterator) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
737 Session *sn;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
738 Request *rq;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
739 WebdavPropfindRequest *propfind;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
740
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
741 UCX_TEST_BEGIN;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
742 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
743
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
744 WebdavPList *properties = propfind->properties;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
745 size_t count = 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
746
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
747 WebdavPListIterator i = webdav_plist_iterator(&properties);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
748 WebdavPList *cur;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
749 while(webdav_plist_iterator_next(&i, &cur)) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
750 switch(i.index) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
751 case 0: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
752 UCX_TEST_ASSERT(!strcmp(cur->property->name, "displayname"), "wrong property 1");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
753 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
754 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
755 case 1: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
756 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontentlength"), "wrong property 2");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
757 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
758 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
759 case 2: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
760 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontenttype"), "wrong property 3");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
761 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
762 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
763 case 3: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
764 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getlastmodified"), "wrong property 4");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
765 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
766 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
767 case 4: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
768 UCX_TEST_ASSERT(!strcmp(cur->property->name, "resourcetype"), "wrong property 5");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
769 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
770 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
771 case 5: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
772 UCX_TEST_ASSERT(!strcmp(cur->property->name, "getetag"), "wrong property 6");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
773 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
774 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
775 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
776 count++;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
777 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
778
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
779 UCX_TEST_ASSERT(count == propfind->propcount, "wrong count");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
780
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
781
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
782 UCX_TEST_END;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
783 testutil_destroy_session(sn);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
784 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
785
216
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
786 UCX_TEST(test_webdav_plist_iterator_remove_current) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
787 Session *sn;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
788 Request *rq;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
789 WebdavPropfindRequest *propfind;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
790
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
791 UCX_TEST_BEGIN;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
792 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
793
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
794 WebdavPList *properties1 = webdav_plist_clone(sn->pool, propfind->properties);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
795 WebdavPList *properties2 = webdav_plist_clone(sn->pool, propfind->properties);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
796 WebdavPList *properties3 = webdav_plist_clone(sn->pool, propfind->properties);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
797 WebdavPList *properties4 = webdav_plist_clone(sn->pool, propfind->properties);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
798
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
799 WebdavPListIterator i;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
800 WebdavPList *cur;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
801
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
802 // test removal of first element
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
803 i = webdav_plist_iterator(&properties1);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
804 while(webdav_plist_iterator_next(&i, &cur)) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
805 if(i.index == 0) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
806 webdav_plist_iterator_remove_current(&i);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
807 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
808 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
809
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
810 UCX_TEST_ASSERT(!properties1->prev, "test1: prev not cleared");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
811 UCX_TEST_ASSERT(!strcmp(properties1->property->name, "getcontentlength"), "test1: wrong property");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
812 UCX_TEST_ASSERT(!strcmp(properties1->next->property->name, "getcontenttype"), "test1: wrong property 2");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
813 UCX_TEST_ASSERT(properties1->next->prev == properties1, "test1: wrong link");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
814
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
815 // test removal of second element
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
816 i = webdav_plist_iterator(&properties2);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
817 while(webdav_plist_iterator_next(&i, &cur)) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
818 if(i.index == 1) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
819 webdav_plist_iterator_remove_current(&i);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
820 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
821 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
822
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
823 UCX_TEST_ASSERT(!strcmp(properties2->next->property->name, "getcontenttype"), "test2: wrong property");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
824 UCX_TEST_ASSERT(properties2->next->prev == properties2, "test2: wrong link");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
825 UCX_TEST_ASSERT(webdav_plist_size(properties2) == 5, "test2: wrong size");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
826
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
827 // remove last element
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
828 i = webdav_plist_iterator(&properties3);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
829 while(webdav_plist_iterator_next(&i, &cur)) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
830 if(i.index == 5) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
831 webdav_plist_iterator_remove_current(&i);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
832 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
833 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
834
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
835 UCX_TEST_ASSERT(webdav_plist_size(properties3) == 5, "test3: wrong size");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
836 UCX_TEST_ASSERT(!strcmp(properties3->next->next->next->next->property->name, "resourcetype"), "test2: wrong property");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
837
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
838 // remove all elements
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
839 i = webdav_plist_iterator(&properties4);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
840 while(webdav_plist_iterator_next(&i, &cur)) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
841 webdav_plist_iterator_remove_current(&i);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
842 switch(i.index) {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
843 case 0: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
844 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontentlength"), "test4: wrong property 2");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
845 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (0)");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
846 break;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
847 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
848 case 1: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
849 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontenttype"), "test4: wrong property 3");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
850 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (1)");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
851 break;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
852 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
853 case 2: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
854 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getlastmodified"), "test4: wrong property 4");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
855 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (2)");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
856 break;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
857 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
858 case 3: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
859 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "resourcetype"), "test4: wrong property 5");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
860 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (3)");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
861 break;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
862 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
863 case 4: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
864 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getetag"), "test4: wrong property 6");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
865 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (4)");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
866 break;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
867 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
868 default: {
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
869 UCX_TEST_ASSERT(i.index <= 5, "fail");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
870 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
871 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
872 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
873
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
874 UCX_TEST_ASSERT(properties4 == NULL, "test4: list not NULL");
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
875
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
876 UCX_TEST_END;
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
877 testutil_destroy_session(sn);
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
878 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
879
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
880 UCX_TEST(test_msresponse_addproperty) {
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
881 Session *sn;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
882 Request *rq;
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
883
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
884 UCX_TEST_BEGIN;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
885
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
886 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
887 UCX_TEST_ASSERT(op, "init failed");
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
888 UCX_TEST_ASSERT(op->response, "no response");
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
889
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
890 Multistatus *ms = (Multistatus*)op->response;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
891 MSResponse *r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/");
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
892
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
893 WebdavProperty p1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
894 WebdavProperty p[16];
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
895 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"};
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
896
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
897 WSNamespace ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
898 ZERO(&ns1, sizeof(WSNamespace));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
899 WSNamespace ns2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
900 ZERO(&ns2, sizeof(WSNamespace));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
901 ns1.prefix = (xmlChar*)"x1";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
902 ns1.href = (xmlChar*)"http://example.com/test/";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
903 ns2.prefix = (xmlChar*)"x2";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
904 ns2.href = (xmlChar*)"http://example.com/test/";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
905
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
906 WebdavProperty dp1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
907 ZERO(&dp1, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
908 dp1.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
909 dp1.namespace = &ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
910 dp1.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
911 dp1.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
912 dp1.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
913
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
914 WebdavProperty dp2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
915 ZERO(&dp2, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
916 dp2.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
917 dp2.namespace = &ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
918 dp2.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
919 dp2.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
920 dp2.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
921
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
922 WebdavProperty dp3;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
923 ZERO(&dp3, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
924 dp3.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
925 dp3.namespace = &ns2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
926 dp3.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
927 dp3.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
928 dp3.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
929
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
930 // init test data
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
931 p1.namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
932 p1.lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
933 p1.name = "test1";
376
61d481d3c2e4 Add support for extended properties in pg propfind
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
934 p1.value.data = (WSXmlData){ NULL, NULL, 0};
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
935 p1.vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
936
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
937 for(int i=0;i<8;i++) {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
938 p[i].namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
939 p[i].name = names[i];
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
940 p[i].lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
941 p[i].value.node = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
942 p[1].vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
943 }
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
944
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
945 UCX_TEST_ASSERT(!r->plist_begin && !r->plist_end, "plist not empty");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
946
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
947 r->resource.addproperty((WebdavResource*)r, &p1, 200);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
948 UCX_TEST_ASSERT(r->plist_begin, "!plist_begin");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
949 UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
950
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
951 r->resource.addproperty((WebdavResource*)r, &p[0], 404);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
952 r->resource.addproperty((WebdavResource*)r, &p[1], 404);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
953 r->resource.addproperty((WebdavResource*)r, &p[2], 403);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
954 r->resource.addproperty((WebdavResource*)r, &p[3], 403);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
955 r->resource.addproperty((WebdavResource*)r, &p[4], 403);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
956 r->resource.addproperty((WebdavResource*)r, &p[5], 403);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
957 r->resource.addproperty((WebdavResource*)r, &p[6], 500);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
958
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
959 UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
960
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
961 UCX_TEST_ASSERT(r->errors, "no prop errors");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
962 UCX_TEST_ASSERT(r->errors->next, "no second error code");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
963 UCX_TEST_ASSERT(r->errors->next->next, "no third error code");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
964 UCX_TEST_ASSERT(!r->errors->next->next->next, "too many error codes");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
965
229
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
966 UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 2, "404 list size != 2");
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
967 UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->begin) == 4, "403 list size != 4");
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
968 UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->next->begin) == 1, "500 list size != 1");
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
969
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
970 // new resource for prop duplication tests
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
971 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
972 UCX_TEST_ASSERT(r, "cannot create second response");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
973
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
974 r->resource.addproperty((WebdavResource*)r, &dp1, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
975 UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
976 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: list size not 1");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
977
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
978 r->resource.addproperty((WebdavResource*)r, &dp2, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
979 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 should not work");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
980
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
981 r->resource.addproperty((WebdavResource*)r, &dp2, 404);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
982 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 with different status should not work (1)");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
983 if(r->errors) {
229
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
984 UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 0, "dp1: error list not empty");
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
985 }
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
986
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
987 r->resource.addproperty((WebdavResource*)r, &dp3, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
988 UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp3 should not work");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
989
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
990 UCX_TEST_END;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
991 }
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
992
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
993 UCX_TEST(test_webdav_propfind_init) {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
994 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
995
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
996 Session *sn;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
997 Request *rq;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
998 WebdavPropfindRequest *propfind;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
999 UCX_TEST_BEGIN;
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1000 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed");
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1001
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
1002 WebdavPropfindRequestList *requests = NULL;
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
1003 int err = webdav_propfind_init(&backend1, propfind, "/", "/", &requests);
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1004
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1005 UCX_TEST_ASSERT(!err, "webdav_propfind_init failed");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1006 UCX_TEST_ASSERT(requests, "request list is empty");
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
1007 UCX_TEST_ASSERT(cx_linked_list_size(requests, offsetof(WebdavPropfindRequestList, next)), "request list has wrong size");
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1008
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
1009 WebdavPropfindRequest *p1 = requests->propfind;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 376
diff changeset
1010 WebdavPropfindRequest *p2 = requests->next->propfind;
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1011
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1012 // backend1 removes the first property from the plist
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1013 // backend2 should have one property less
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1014
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1015 UCX_TEST_ASSERT(p1 && p2, "missing requests objects");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1016 UCX_TEST_ASSERT(p1 != p2, "request objects equal");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1017 UCX_TEST_ASSERT(p1->properties != p2->properties, "plists equal");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1018 UCX_TEST_ASSERT(p1->propcount == p2->propcount + 1, "first property not removed");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1019
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1020 UCX_TEST_ASSERT(backend1_init_called == 1, "backend1 init not called");
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1021 UCX_TEST_ASSERT(backend2_init_called == 1, "backend2 init not called");
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1022
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1023 UCX_TEST_END;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1024
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1025 pool_destroy(sn->pool);
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1026 }
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1027
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1028 UCX_TEST(test_webdav_op_propfind_begin) {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1029 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1030
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1031 Session *sn;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1032 Request *rq;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1033
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1034 UCX_TEST_BEGIN;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1035 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1036 UCX_TEST_ASSERT(op, "WebdavOperation not created");
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1037
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1038 int err = webdav_op_propfind_begin(op, "/", NULL, NULL);
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1039 UCX_TEST_ASSERT(err == 0, "err not 0");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1040 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1041 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend2 propfind_do not called");
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1042
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1043
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1044 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1045 testutil_destroy_session(sn);
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1046 }
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1047
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1048 UCX_TEST(test_webdav_op_propfind_children) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1049 reset_backends();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1050
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1051 Session *sn;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1052 Request *rq;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1053
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1054 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1055 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1056 UCX_TEST_ASSERT(op, "WebdavOperation not created");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1057
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1058 int err = webdav_op_propfind_begin(op, "/", NULL, NULL);
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1059 UCX_TEST_ASSERT(err == 0, "propfind_begin error");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1060
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1061 // create test vfs with some files (code from test_vfs_readdir)
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1062 rq->vfs = testvfs_create(sn);
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1063 VFSContext *vfs = vfs_request_context(sn, rq);
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1064 UCX_TEST_ASSERT(vfs, "no vfs");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1065
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1066 err = vfs_mkdir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1067 UCX_TEST_ASSERT(err == 0, "error not 0");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1068
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1069 // add some test file to /dir
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1070 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1071 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1072 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1073 UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1074
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1075 VFSDir *dir = vfs_opendir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1076 UCX_TEST_ASSERT(dir, "dir not opened");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1077
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1078 UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1079 UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend1 propfind_do not called")
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1080
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1081 // propfind for all children
221
ff5826fc6a6c add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
1082 err = webdav_op_propfind_children(op, vfs, "/", "/dir");
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1083 UCX_TEST_ASSERT(err == 0, "webdav_op_propfind_children failed");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1084
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1085 // 1 dir + 4 children
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1086 UCX_TEST_ASSERT(backend1_propfind_do_count == 5, "backend1 propfind_do wrong count");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1087 UCX_TEST_ASSERT(backend2_propfind_do_count == 5, "backend2 propfind_do wrong count");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1088
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1089 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1090 testutil_destroy_session(sn);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1091 }
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1092
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1093 void init_test_webdav_method(
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1094 Session **out_sn,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1095 Request **out_rq,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1096 TestIOStream **out_st,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1097 pblock **out_pb,
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1098 const char *method,
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1099 const char *path,
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1100 const char *request_body)
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1101 {
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1102 Session *sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1103 Request *rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1104 TestIOStream *st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1105 pblock *pb;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1106
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1107 sn = testutil_session();
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1108 rq = testutil_request(sn->pool, method, "/");
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1109
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1110 pblock_nvinsert("path", path, rq->vars);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1111 pblock_nvinsert("uri", path, rq->reqpb);
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1112
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1113 st = testutil_iostream(2048, TRUE);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1114 sn->csd = (IOStream*)st;
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1115
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1116 if(request_body) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1117 testutil_request_body(sn, rq, request_body, strlen(request_body));
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1118 }
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1119
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1120 pb = pblock_create_pool(sn->pool, 4);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1121
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1122 *out_sn = sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1123 *out_rq = rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1124 *out_st = st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1125 *out_pb = pb;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1126 }
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1127
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1128 UCX_TEST(test_webdav_propfind) {
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1129 Session *sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1130 Request *rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1131 TestIOStream *st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1132 pblock *pb;
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1133
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1134 UCX_TEST_BEGIN;
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1135
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1136 int ret;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1137 // Test 1
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1138 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND1);
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1139
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1140 ret = webdav_propfind(pb, sn, rq);
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1141
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1142 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed");
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1143
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1144 xmlDoc *doc = xmlReadMemory(
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1145 st->buf->space, st->buf->size, NULL, NULL, 0);
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1146 UCX_TEST_ASSERT(doc, "propfind1: response is not valid xml");
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1147
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1148 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1149
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1150 testutil_destroy_session(sn);
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1151 xmlFreeDoc(doc);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1152 testutil_iostream_destroy(st);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1153
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1154 // Test2
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1155 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/", TEST_PROPFIND2);
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1156
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1157 ret = webdav_propfind(pb, sn, rq);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1158
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1159 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed");
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1160
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1161 xmlDoc *doc2 = xmlReadMemory(
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1162 st->buf->space, st->buf->size, NULL, NULL, 0);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1163 UCX_TEST_ASSERT(doc, "propfind2: response is not valid xml");
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1164
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1165 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1166
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1167 testutil_destroy_session(sn);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1168 xmlFreeDoc(doc2);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1169 testutil_iostream_destroy(st);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1170
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1171 UCX_TEST_END;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1172
233
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1173 }
239
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1174
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1175 /* -------------------------------------------------------------------------
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1176 *
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1177 * PROPPATCH TESTS
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1178 *
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1179 * ------------------------------------------------------------------------ */
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1180
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1181 static int test_proppatch_init(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1182 Session **out_sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1183 Request **out_rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1184 WebdavProppatchRequest **out_proppatch,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1185 const char *xml)
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1186 {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1187 if(!webdav_is_initialized) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1188 if(webdav_init(NULL, NULL, NULL) != REQ_PROCEED) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1189 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1190 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1191 webdav_is_initialized = 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1192 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1193
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1194 Session *sn = testutil_session();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1195 Request *rq = testutil_request(sn->pool, "PROPPATCH", "/");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1196
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1197 int error = 0;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1198
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1199 WebdavProppatchRequest *proppatch = proppatch_parse(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1200 sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1201 rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1202 xml,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1203 strlen(xml),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1204 &error);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1205
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1206 if(error) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1207 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1208 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1209
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1210 if(!proppatch || !(proppatch->set || proppatch->remove)) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1211 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1212 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1213
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1214 *out_sn = sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1215 *out_rq = rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1216 *out_proppatch = proppatch;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1217 return 0;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1218 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1219
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1220 static WebdavOperation* test_proppatch_op1(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1221 Session **out_sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1222 Request **out_rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1223 const char *xml)
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1224 {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1225 WebdavProppatchRequest *proppatch;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1226 if(test_proppatch_init(out_sn, out_rq, &proppatch, xml)) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1227 return NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1228 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1229
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1230 Multistatus *ms = multistatus_response(*out_sn, *out_rq);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1231 if(!ms) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1232 return NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1233 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1234 // WebdavResponse is the public interface used by Backends
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1235 // for adding resources to the response
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1236 WebdavResponse *response = (WebdavResponse*)ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1237
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1238 return webdav_create_proppatch_operation(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1239 (*out_sn),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1240 (*out_rq),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1241 &backend1,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1242 proppatch,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1243 response);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1244 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1245
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1246
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1247 UCX_TEST(test_proppatch_msresponse) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1248 Session *sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1249 Request *rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1250 WebdavOperation *op;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1251
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1252 Multistatus *ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1253 WebdavResource *res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1254
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1255 WebdavProperty p[16];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1256 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"};
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1257 for(int i=0;i<8;i++) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1258 p[i].namespace = webdav_dav_namespace();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1259 p[i].name = names[i];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1260 p[i].lang = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1261 p[i].value.node = NULL;
320
a40f7af1b670 fix memory initialization for WebdavProperty in webdav tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1262 p[i].vtype = 0;
239
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1263 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1264
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1265 UCX_TEST_BEGIN;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1266
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1267 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1268 UCX_TEST_ASSERT(op, "failed to create proppatch operation");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1269
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1270 ms = (Multistatus*)op->response;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1271 ms->proppatch = TRUE;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1272 res = ms->response.addresource(&ms->response, "/");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1273 UCX_TEST_ASSERT(res, "cannot create resource 1");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1274
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1275 UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1276 UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1277 UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 200), "addproperty 3 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1278 UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1279
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1280 UCX_TEST_ASSERT(!res->close(res), "close failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1281
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1282 MSResponse *msres = (MSResponse*)res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1283 UCX_TEST_ASSERT(!msres->errors, "error list not NULL");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1284 UCX_TEST_ASSERT(msres->plist_begin, "elm1 missing");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1285 UCX_TEST_ASSERT(msres->plist_begin->next, "elm2 missing");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1286 UCX_TEST_ASSERT(msres->plist_begin->next->next, "elm3 missing");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1287 UCX_TEST_ASSERT(msres->plist_begin->next->next->next, "elm4 missing");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1288 UCX_TEST_ASSERT(!msres->plist_begin->next->next->next->next, "count != 4");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1289
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1290 UCX_TEST_END;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1291 testutil_destroy_session(sn);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1292 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1293
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1294 UCX_TEST(test_msresponse_addproperty_with_errors) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1295 Session *sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1296 Request *rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1297 WebdavOperation *op;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1298
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1299 Multistatus *ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1300 WebdavResource *res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1301
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1302 WebdavProperty p[16];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1303 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"};
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1304 for(int i=0;i<8;i++) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1305 p[i].namespace = webdav_dav_namespace();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1306 p[i].name = names[i];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1307 p[i].lang = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1308 p[i].value.node = NULL;
320
a40f7af1b670 fix memory initialization for WebdavProperty in webdav tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
1309 p[i].vtype = 0;
239
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1310 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1311
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1312 UCX_TEST_BEGIN;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1313
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1314 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1315 UCX_TEST_ASSERT(op, "failed to create proppatch operation");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1316
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1317 ms = (Multistatus*)op->response;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1318 ms->proppatch = TRUE;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1319 res = ms->response.addresource(&ms->response, "/");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1320 UCX_TEST_ASSERT(res, "cannot create resource 1");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1321
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1322 UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1323 UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1324 UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 409), "addproperty 3 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1325 UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1326
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1327 UCX_TEST_ASSERT(!res->close(res), "close failed");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1328
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1329 // all properties should have an error status code now
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1330 // 1 x 409, 3 x 424
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1331
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1332 MSResponse *msres = (MSResponse*)res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1333
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1334 UCX_TEST_ASSERT(!msres->plist_begin, "plist not NULL");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1335 UCX_TEST_ASSERT(msres->errors, "error list is NULL");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1336 UCX_TEST_ASSERT(msres->errors->next, "second error list is missing");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1337 UCX_TEST_ASSERT(!msres->errors->next->next, "wrong error list size");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1338
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1339 // We know that we have 2 error lists, one with status code 409 and
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1340 // the other must have 409. However we don't enforce the order of the
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1341 // error lists, therefore check both variants
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1342 if(msres->errors->status == 409) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1343 UCX_TEST_ASSERT(msres->errors->next->status == 424, "wrong status code in second err elm");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1344 UCX_TEST_ASSERT(msres->errors->begin, "missing 409 property");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1345 UCX_TEST_ASSERT(msres->errors->next->begin, "missing 424 properties");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1346 } else {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1347 UCX_TEST_ASSERT(msres->errors->next->status == 409, "wrong status code in second err elm");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1348 UCX_TEST_ASSERT(msres->errors->begin, "missing 424 properties");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1349 UCX_TEST_ASSERT(msres->errors->next->begin, "missing 409 property");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1350 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1351
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1352 UCX_TEST_END;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1353 testutil_destroy_session(sn);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1354 }
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1355
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1356 UCX_TEST(test_webdav_op_proppatch) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1357 Session *sn;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1358 Request *rq;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1359 WebdavOperation *op;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1360
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1361 Multistatus *ms;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1362 WebdavResource *res;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1363
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1364 WebdavProperty p[16];
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1365 const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"};
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1366 for(int i=0;i<8;i++) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1367 p[i].namespace = webdav_dav_namespace();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1368 p[i].name = names[i];
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1369 p[i].lang = NULL;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1370 p[i].value.node = NULL;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1371 p[1].vtype = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1372 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1373
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1374 UCX_TEST_BEGIN;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1375
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1376 // TEST_PROPPATCH2 should succeed
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1377 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1378 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1379 UCX_TEST_ASSERT(op, "failed to create proppatch operation");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1380
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1381 int ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1382 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1383 UCX_TEST_ASSERT(backend1_proppatch_commit, "backend1 no commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1384 UCX_TEST_ASSERT(backend2_proppatch_commit, "backend2 no commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1385 UCX_TEST_ASSERT(backend1_proppatch_do_count == 1, "backend1 wrong count (1)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1386 UCX_TEST_ASSERT(backend2_proppatch_do_count == 1, "backend1 wrong count (1)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1387 UCX_TEST_ASSERT(backend1_proppatch_finish_count == 1, "backend1 wrong finish count (1)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1388 UCX_TEST_ASSERT(backend2_proppatch_finish_count == 1, "backend1 wrong finish count (1)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1389
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1390 // TEST_PROPPATCH3 should fail (commit == FALSE)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1391 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1392 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH3);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1393 UCX_TEST_ASSERT(op, "failed to create proppatch operation 2");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1394
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1395 ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1396 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1397 UCX_TEST_ASSERT(!backend1_proppatch_commit, "backend1 commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1398 UCX_TEST_ASSERT(!backend2_proppatch_commit, "backend2 commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1399
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1400 // TEST_PROPPATCH4 should abort
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1401 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1402 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH4);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1403 UCX_TEST_ASSERT(op, "failed to create proppatch operation 3");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1404
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1405 ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1406 UCX_TEST_ASSERT(ret != 0, "webdav_op_proppatch should fail");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1407 UCX_TEST_ASSERT(backend1_proppatch_do_count == 1, "backend1 wrong count (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1408 UCX_TEST_ASSERT(backend2_proppatch_do_count == 1, "backend1 wrong count (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1409 UCX_TEST_ASSERT(backend1_proppatch_finish_count == 1, "backend1 wrong finish count (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1410 UCX_TEST_ASSERT(backend2_proppatch_finish_count == 0, "backend1 wrong finish count (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1411
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1412 UCX_TEST_END;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1413 testutil_destroy_session(sn);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1414 }
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1415
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1416 #define xstreq(a, b) (!strcmp((const char*)a, (const char*)b))
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1417
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1418 UCX_TEST(test_webdav_proppatch) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1419 Session *sn;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1420 Request *rq;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1421 TestIOStream *st;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1422 pblock *pb;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1423
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1424 UCX_TEST_BEGIN;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1425
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1426 int ret;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1427 // Test 1
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1428 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/", TEST_PROPPATCH2);
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1429 rq->davCollection = &backend1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1430 ret = webdav_proppatch(pb, sn, rq);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1431
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1432 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1433
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1434 xmlDoc *doc = xmlReadMemory(
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1435 st->buf->space, st->buf->size, NULL, NULL, 0);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1436 UCX_TEST_ASSERT(doc, "proppatch1: response is not valid xml");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1437
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1438 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1439
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1440 xmlNode *root = xmlDocGetRootElement(doc);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1441 UCX_TEST_ASSERT(root, "proppatch1: no root");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1442
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1443 xmlNode *nodeC = NULL;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1444 xmlNode *node = root->children;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1445 int depth = 1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1446 while(node) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1447 const xmlChar *name = node->name;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1448 int nextNode = 1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1449 if(node->type != XML_ELEMENT_NODE) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1450 // nothing
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1451 } else if(depth == 1) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1452 if(xstreq(name, "response")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1453 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1454 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1455 } else if(depth == 2) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1456 if(xstreq(name, "propstat")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1457 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1458 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1459 } else if(depth == 3) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1460 if(xstreq(name, "prop")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1461 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1462 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1463 } else if(depth == 4) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1464 if(xstreq(name, "c")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1465 nodeC = node;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1466 break;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1467 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1468 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1469
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1470 if(nextNode) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1471 node = node->next;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1472 } else {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1473 node = node->children;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1474 depth++;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1475 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1476 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1477
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1478 UCX_TEST_ASSERT(nodeC, "prop c not in response");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1479 UCX_TEST_ASSERT(!nodeC->children, "properties must not have a value");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1480
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1481 testutil_destroy_session(sn);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1482 xmlFreeDoc(doc);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1483 testutil_iostream_destroy(st);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1484
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1485
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1486 UCX_TEST_END;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1487 }
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1488
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1489
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1490 /* -------------------------------------------------------------------------
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1491 *
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1492 * WEBDAV VFS TESTS
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1493 *
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1494 * ------------------------------------------------------------------------ */
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1495
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1496 static int mkcol_data1 = 10;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1497 static int mkcol_data2 = 20;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1498 static int mkcol_data3 = 30;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1499 static int mkcol_data4 = 40;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1500
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1501 static int mkcol_count = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1502 static int mkcol_finish_count = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1503
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1504 static int mkcol_err = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1505
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1506 static int set_created = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1507
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1508 static int test_webdav_mkcol(WebdavVFSRequest *req, WSBool *created) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1509 mkcol_count++;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1510
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1511 switch(mkcol_count) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1512 case 1: {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1513 req->userdata = &mkcol_data1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1514 break;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1515 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1516 case 2: {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1517 req->userdata = &mkcol_data2;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1518 break;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1519 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1520 case 3: {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1521 req->userdata = &mkcol_data3;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1522 break;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1523 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1524 case 4: {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1525 req->userdata = &mkcol_data4;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1526 break;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1527 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1528 default: break;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1529 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1530
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1531 if(set_created) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1532 *created = TRUE;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1533 set_created = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1534 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1535
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1536 return 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1537 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1538
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1539 static int test_webdav_mkcol_finish(WebdavVFSRequest *req, WSBool success) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1540 mkcol_finish_count++;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1541
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1542 if(mkcol_finish_count == 1) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1543 int *data = req->userdata;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1544 if(data != &mkcol_data1) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1545 mkcol_err = 1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1546 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1547 } else if(mkcol_finish_count == 3) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1548 int *data = req->userdata;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1549 if(data != &mkcol_data3) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1550 mkcol_err = 1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1551 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1552 } else {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1553 int *data = req->userdata;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1554 // data4 should never be used
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1555 if(data == &mkcol_data4) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1556 mkcol_err = 1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1557 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1558 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1559
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1560 return 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1561 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1562
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1563 static int test_webdav_mkcol_fail(WebdavVFSRequest *req, WSBool *created) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1564 mkcol_count++;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1565 return 1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1566 }
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1567
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1568 static int delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1569 static int delete_finish_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1570
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1571 static int test_backend_webdav_delete(WebdavVFSRequest *req, WSBool *created) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1572 delete_count++;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1573 return 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1574 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1575
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1576 static int test_backend_webdav_delete_finish(WebdavVFSRequest *req, WSBool success) {
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1577 delete_finish_count++;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1578 return 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1579 }
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1580
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1581
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1582 UCX_TEST(test_webdav_vfs_op_do) {
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1583 Session *sn;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1584 Request *rq;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1585 TestIOStream *st;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1586 pblock *pb;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1587
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1588 // Tests performed primarily with MKCOL, because webdav_vfs_op_do
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1589 // behaves the same for both operations
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1590 // the only difference are the callbacks
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1591
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1592 init_test_webdav_method(&sn, &rq, &st, &pb, "MKCOL", "/", NULL);
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1593 VFS *testvfs = testvfs_create(sn);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1594 rq->vfs = testvfs;
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1595
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1596 WebdavBackend dav1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1597 ZERO(&dav1, sizeof(WebdavBackend));
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1598 dav1.opt_mkcol = test_webdav_mkcol;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1599 dav1.opt_mkcol_finish = test_webdav_mkcol_finish;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1600 dav1.opt_delete = test_backend_webdav_delete;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1601 dav1.opt_delete_finish = test_backend_webdav_delete_finish;
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1602
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1603 WebdavBackend dav2;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1604 ZERO(&dav2, sizeof(WebdavBackend));
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1605 dav2.opt_mkcol_finish = test_webdav_mkcol_finish;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1606
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1607 WebdavBackend dav3;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1608 ZERO(&dav3, sizeof(WebdavBackend));
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1609 dav3.opt_mkcol = test_webdav_mkcol;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1610
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1611 WebdavBackend dav4;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1612 ZERO(&dav4, sizeof(WebdavBackend));
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1613 dav4.opt_mkcol = test_webdav_mkcol;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1614 dav4.opt_mkcol_finish = test_webdav_mkcol_finish;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1615
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1616 dav1.next = &dav2;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1617 dav2.next = &dav3;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1618 dav3.next = &dav4;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1619
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1620 rq->davCollection = &dav1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1621
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1622 UCX_TEST_BEGIN;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1623
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1624 WebdavVFSOperation *op1 = webdav_vfs_op(sn, rq, &dav1, FALSE);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1625
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1626 int ret = webdav_vfs_op_do(op1, WEBDAV_VFS_MKDIR);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1627
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1628 UCX_TEST_ASSERT(!ret, "webdav_vfs_op_do failed");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1629 UCX_TEST_ASSERT(mkcol_count == 3, "wrong mkcol_count");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1630 UCX_TEST_ASSERT(mkcol_finish_count == 3, "wrong mkcol_finish_count");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1631 UCX_TEST_ASSERT(mkcol_err == 0, "mkcol_err");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1632
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1633 // test without VFS, but set *created to TRUE to skip VFS usage
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1634 rq->vfs = NULL;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1635 set_created = 1;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1636
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1637 WebdavVFSOperation *op2 = webdav_vfs_op(sn, rq, &dav1, FALSE);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1638 ret = webdav_vfs_op_do(op2, WEBDAV_VFS_MKDIR);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1639
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1640 UCX_TEST_ASSERT(!ret, "op2 failed");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1641
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1642 // test 3: abort after first backend
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1643 mkcol_count = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1644 mkcol_finish_count = 0;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1645 dav1.opt_mkcol = test_webdav_mkcol_fail;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1646
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1647 WebdavVFSOperation *op3 = webdav_vfs_op(sn, rq, &dav1, FALSE);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1648 ret = webdav_vfs_op_do(op3, WEBDAV_VFS_MKDIR);
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1649
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1650 UCX_TEST_ASSERT(ret, "op3 should fail");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1651 UCX_TEST_ASSERT(mkcol_count == 1, "op3: wrong mkcol_count");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1652 UCX_TEST_ASSERT(mkcol_finish_count == 1, "op3: wrong mkcol_finish_count");
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1653
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1654 // test DELETE to make sure, delete callbacks will be used
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1655 pblock_replace("path", "/deltest", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1656 rq->vfs = testvfs;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1657 WebdavVFSOperation *op_del = webdav_vfs_op(sn, rq, &dav1, FALSE);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1658 vfs_open(op_del->vfs, "/deltest", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1659 ret = webdav_vfs_op_do(op_del, WEBDAV_VFS_DELETE);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1660
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1661 UCX_TEST_ASSERT(!ret, "op_del failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1662 UCX_TEST_ASSERT(delete_count == 1, "op_del: wrong delete_count");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1663 UCX_TEST_ASSERT(delete_finish_count == 1, "op_del: wrong delete_finish_count");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1664
245
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1665
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1666 UCX_TEST_END;
a193c42fc809 add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 244
diff changeset
1667 }
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1668
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1669 UCX_TEST(test_webdav_delete){
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1670 Session *sn;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1671 Request *rq;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1672 TestIOStream *st;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1673 pblock *pb;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1674
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1675 init_test_webdav_method(&sn, &rq, &st, &pb, "DELETE", "/", NULL);
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1676 rq->vfs = testvfs_create(sn);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1677
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1678 WebdavBackend dav1;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1679 ZERO(&dav1, sizeof(WebdavBackend));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1680 dav1.opt_delete = test_backend_webdav_delete;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1681 dav1.opt_delete_finish = test_backend_webdav_delete_finish;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1682 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1683 delete_finish_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1684 rq->davCollection = &dav1;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1685
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1686 UCX_TEST_BEGIN;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1687
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1688 // prepare
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1689 VFSContext *vfs = vfs_request_context(sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1690 int err;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1691 err = vfs_mkdir(vfs, "/dir1");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1692 UCX_TEST_ASSERT(err == 0, "mkdir dir1 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1693 err = vfs_mkdir(vfs, "/dir2");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1694 UCX_TEST_ASSERT(err == 0, "mkdir dir2 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1695 err = vfs_mkdir(vfs, "/dir2/dir3");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1696 UCX_TEST_ASSERT(err == 0, "mkdir dir3 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1697 err = vfs_mkdir(vfs, "/dir2/dir4");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1698 UCX_TEST_ASSERT(err == 0, "mkdir dir4 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1699 err = vfs_mkdir(vfs, "/dir2/dir4/dir5");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1700 UCX_TEST_ASSERT(err == 0, "mkdir dir5 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1701
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1702 SYS_FILE f0 = vfs_open(vfs, "/file0", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1703 UCX_TEST_ASSERT(f0, "f0 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1704 // no f1
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1705 SYS_FILE f2 = vfs_open(vfs, "/dir2/file2", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1706 UCX_TEST_ASSERT(f2, "f2 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1707 SYS_FILE f3 = vfs_open(vfs, "/dir2/dir3/file3", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1708 UCX_TEST_ASSERT(f3, "f3 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1709 SYS_FILE f4 = vfs_open(vfs, "/dir2/dir4/file4", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1710 UCX_TEST_ASSERT(f4, "f4 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1711 SYS_FILE f5 = vfs_open(vfs, "/dir2/dir4/dir5/file5", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1712 UCX_TEST_ASSERT(f5, "f5 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1713
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1714 // delete single file
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1715 pblock_replace("path", "/file0", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1716 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1717 UCX_TEST_ASSERT(err == 0, "DELETE /file0 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1718 UCX_TEST_ASSERT(delete_count == 1, "del1: wrong delete count");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1719
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1720 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1721 pblock_replace("path", "/dir1", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1722 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1723 UCX_TEST_ASSERT(err == 0, "DELETE /dir1 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1724 UCX_TEST_ASSERT(delete_count == 1, "del1: wrong delete count");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1725
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1726 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1727 pblock_replace("path", "/dir2", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1728 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1729 UCX_TEST_ASSERT(err == 0, "DELETE /dir2 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1730 UCX_TEST_ASSERT(delete_count == 8, "del2: wrong delete count");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1731
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1732 UCX_TEST_END;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1733 }
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1734
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1735 UCX_TEST(test_webdav_put) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1736 Session *sn;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1737 Request *rq;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1738 TestIOStream *st;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1739 pblock *pb;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1740
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1741 const char *content_const = "Hello World";
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1742
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1743 init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", "/", content_const);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1744 rq->vfs = testvfs_create(sn);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1745
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1746 UCX_TEST_BEGIN;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1747
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1748 int err;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1749
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1750 pblock_replace("path", "/file0", rq->vars);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1751 err = webdav_put(NULL, sn, rq);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1752
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1753 UCX_TEST_ASSERT(err == REQ_PROCEED, "put failed");
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1754
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1755 VFSContext *vfs = vfs_request_context(sn, rq);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1756 SYS_FILE f0 = vfs_open(vfs, "/file0", 0);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1757 UCX_TEST_ASSERT(f0, "cannot open file0");
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1758
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1759 char buf[1024];
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1760 int r = system_fread(f0, buf, 1024);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1761
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1762 UCX_TEST_ASSERT(r == strlen(content_const), "wrong file size");
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1763 UCX_TEST_ASSERT(!memcmp(content_const, buf, r), "wrong file content");
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1764
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1765 testutil_destroy_session(sn);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1766 testutil_iostream_destroy(st);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1767
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1768 UCX_TEST_END;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1769 }

mercurial