src/server/test/webdav.c

Sun, 01 May 2022 10:48:20 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 01 May 2022 10:48:20 +0200
branch
webdav
changeset 319
a9b9344875aa
parent 307
8787cb5ebab3
child 320
a40f7af1b670
permissions
-rw-r--r--

add WebdavNSList <-> string converting functions

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
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
315 UcxList *requests = NULL;
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
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
706 UcxBuffer *b1 = rqbody2buffer(sn, rq);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
707 UCX_TEST_ASSERT(b1->size == 12, "b1: wrong size");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
708 UCX_TEST_ASSERT(!memcmp(b1->space,"Hello World!",12), "b1: wrong content");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
709
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
710 ucx_buffer_free(b1);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
711 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
712
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 // TEST 2
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
715 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
716 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
717 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
718 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
719 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
720 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
721 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
722 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
723
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
724 UcxBuffer *b2 = rqbody2buffer(sn, rq);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
725 UCX_TEST_ASSERT(b2->size == len1, "b2: wrong size");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
726 UCX_TEST_ASSERT(!memcmp(b2->space, body1, len1), "b2: wrong content");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
727
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
728 ucx_buffer_free(b2);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
729 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
730
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
731 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
732 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
733
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
734 UCX_TEST(test_webdav_plist_iterator) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
735 Session *sn;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
736 Request *rq;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
737 WebdavPropfindRequest *propfind;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
738
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
739 UCX_TEST_BEGIN;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
740 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
741
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
742 WebdavPList *properties = propfind->properties;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
743 size_t count = 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
744
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
745 WebdavPListIterator i = webdav_plist_iterator(&properties);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
746 WebdavPList *cur;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
747 while(webdav_plist_iterator_next(&i, &cur)) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
748 switch(i.index) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
749 case 0: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
750 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
751 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
752 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
753 case 1: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
754 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
755 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
756 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
757 case 2: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
758 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
759 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
760 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
761 case 3: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
762 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
763 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
764 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
765 case 4: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
766 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
767 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
768 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
769 case 5: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
770 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
771 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
772 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
773 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
774 count++;
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
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
777 UCX_TEST_ASSERT(count == propfind->propcount, "wrong count");
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
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
780 UCX_TEST_END;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
781 testutil_destroy_session(sn);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
782 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
783
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
784 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
785 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
786 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
787 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
788
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 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
790 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
791
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 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
793 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
794 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
795 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
796
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 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
798 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
799
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 // 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
801 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
802 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
803 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
804 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
805 }
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 }
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 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
809 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
810 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
811 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
812
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 // 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
814 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
815 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
816 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
817 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
818 }
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 }
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 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
822 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
823 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
824
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 // 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
826 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
827 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
828 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
829 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
830 }
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 }
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 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
834 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
835
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 // 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 }
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 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
847 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
848 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
849 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
850 }
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 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
852 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
853 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
854 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
855 }
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 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
857 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
858 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
859 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
860 }
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 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
862 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
863 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
864 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
865 }
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 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
867 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
868 }
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 }
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 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
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_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
875 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
876 }
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
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
878 UCX_TEST(test_msresponse_addproperty) {
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
879 Session *sn;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
880 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
881
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
882 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
883
223
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
884 WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1);
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
885 UCX_TEST_ASSERT(op, "init failed");
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
886 UCX_TEST_ASSERT(op->response, "no response");
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
887
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
888 Multistatus *ms = (Multistatus*)op->response;
bbaec8415c10 add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 222
diff changeset
889 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
890
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
891 WebdavProperty p1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
892 WebdavProperty p[16];
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
893 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
894
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
895 WSNamespace ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
896 ZERO(&ns1, sizeof(WSNamespace));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
897 WSNamespace ns2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
898 ZERO(&ns2, sizeof(WSNamespace));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
899 ns1.prefix = (xmlChar*)"x1";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
900 ns1.href = (xmlChar*)"http://example.com/test/";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
901 ns2.prefix = (xmlChar*)"x2";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
902 ns2.href = (xmlChar*)"http://example.com/test/";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
903
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
904 WebdavProperty dp1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
905 ZERO(&dp1, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
906 dp1.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
907 dp1.namespace = &ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
908 dp1.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
909 dp1.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
910 dp1.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
911
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
912 WebdavProperty dp2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
913 ZERO(&dp2, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
914 dp2.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
915 dp2.namespace = &ns1;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
916 dp2.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
917 dp2.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
918 dp2.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
919
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
920 WebdavProperty dp3;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
921 ZERO(&dp3, sizeof(WebdavProperty));
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
922 dp3.name = "dup";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
923 dp3.namespace = &ns2;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
924 dp3.value.text.str = "Hello";
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
925 dp3.value.text.length = 5;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
926 dp3.vtype = WS_VALUE_TEXT;
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
927
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
928 // init test data
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
929 p1.namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
930 p1.lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
931 p1.name = "test1";
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
932 p1.value.data = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
933 p1.vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
934
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
935 for(int i=0;i<8;i++) {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
936 p[i].namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
937 p[i].name = names[i];
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
938 p[i].lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
939 p[i].value.node = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
940 p[1].vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
941 }
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
942
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
943 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
944
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
945 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
946 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
947 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
948
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
949 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
950 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
951 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
952 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
953 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
954 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
955 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
956
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
957 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
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->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
960 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
961 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
962 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
963
229
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
964 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
965 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
966 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
967
227
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
968 // new resource for prop duplication tests
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
969 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
970 UCX_TEST_ASSERT(r, "cannot create second response");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
971
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
972 r->resource.addproperty((WebdavResource*)r, &dp1, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
973 UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed");
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
974 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
975
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
976 r->resource.addproperty((WebdavResource*)r, &dp2, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
977 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
978
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
979 r->resource.addproperty((WebdavResource*)r, &dp2, 404);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
980 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
981 if(r->errors) {
229
73cb1c98ef7d replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 228
diff changeset
982 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
983 }
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
984
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
985 r->resource.addproperty((WebdavResource*)r, &dp3, 200);
3c23855f7b46 remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 223
diff changeset
986 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
987
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
988 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
989 }
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
990
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
991 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
992 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
993
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
994 Session *sn;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
995 Request *rq;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
996 WebdavPropfindRequest *propfind;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
997 UCX_TEST_BEGIN;
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
998 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
999
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1000 UcxList *requests = NULL;
307
8787cb5ebab3 fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
1001 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
1002
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1003 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
1004 UCX_TEST_ASSERT(requests, "request list is empty");
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(ucx_list_size(requests), "request list has wrong size");
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1006
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1007 WebdavPropfindRequest *p1 = requests->data;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1008 WebdavPropfindRequest *p2 = requests->next->data;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1009
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1010 // backend1 removes the first property from the plist
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1011 // backend2 should have one property less
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
1012
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1013 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
1014 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
1015 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
1016 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
1017
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1018 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
1019 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
1020
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1021 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
1022
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
1023 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
1024 }
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1025
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1026 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
1027 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1028
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1029 Session *sn;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1030 Request *rq;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1031
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1032 UCX_TEST_BEGIN;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1033 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
1034 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
1035
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1036 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
1037 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
1038 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
1039 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
1040
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1041
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
1042 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1043 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
1044 }
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1045
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1046 UCX_TEST(test_webdav_op_propfind_children) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1047 reset_backends();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1048
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1049 Session *sn;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1050 Request *rq;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1051
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1052 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1053 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
1054 UCX_TEST_ASSERT(op, "WebdavOperation not created");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1055
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1056 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
1057 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
1058
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1059 // 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
1060 rq->vfs = testvfs_create(sn);
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1061 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
1062 UCX_TEST_ASSERT(vfs, "no vfs");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1063
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1064 err = vfs_mkdir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1065 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
1066
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1067 // add some test file to /dir
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1068 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
1069 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
1070 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
1071 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
1072
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1073 VFSDir *dir = vfs_opendir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1074 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
1075
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1076 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
1077 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
1078
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1079 // propfind for all children
221
ff5826fc6a6c add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 220
diff changeset
1080 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
1081 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
1082
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1083 // 1 dir + 4 children
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1084 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
1085 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
1086
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1087 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
1088 testutil_destroy_session(sn);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
1089 }
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
1090
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1091 void init_test_webdav_method(
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1092 Session **out_sn,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1093 Request **out_rq,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1094 TestIOStream **out_st,
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1095 pblock **out_pb,
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1096 const char *method,
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1097 const char *path,
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1098 const char *request_body)
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1099 {
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1100 Session *sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1101 Request *rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1102 TestIOStream *st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1103 pblock *pb;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1104
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1105 sn = testutil_session();
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1106 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
1107
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1108 pblock_nvinsert("path", path, rq->vars);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1109 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
1110
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1111 st = testutil_iostream(2048, TRUE);
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1112 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
1113
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
1114 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
1115 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
1116 }
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1117
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1118 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
1119
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1120 *out_sn = sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1121 *out_rq = rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1122 *out_st = st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1123 *out_pb = pb;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1124 }
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1125
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1126 UCX_TEST(test_webdav_propfind) {
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1127 Session *sn;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1128 Request *rq;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1129 TestIOStream *st;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1130 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
1131
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1132 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
1133
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1134 int ret;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1135 // Test 1
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1136 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
1137
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1138 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
1139
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1140 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
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 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
1143 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
1144 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
1145
c5985d2fc19a add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 229
diff changeset
1146 //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
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 testutil_destroy_session(sn);
238
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1149 xmlFreeDoc(doc);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1150 testutil_iostream_destroy(st);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1151
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1152 // Test2
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1153 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
1154
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1155 ret = webdav_propfind(pb, sn, rq);
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 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
1158
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1159 xmlDoc *doc2 = xmlReadMemory(
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1160 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
1161 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
1162
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1163 //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
1164
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1165 testutil_destroy_session(sn);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1166 xmlFreeDoc(doc2);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1167 testutil_iostream_destroy(st);
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1168
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1169 UCX_TEST_END;
e820d433f405 fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 237
diff changeset
1170
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
1171 }
239
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1172
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1173 /* -------------------------------------------------------------------------
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 * PROPPATCH TESTS
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 * ------------------------------------------------------------------------ */
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 static int test_proppatch_init(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1180 Session **out_sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1181 Request **out_rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1182 WebdavProppatchRequest **out_proppatch,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1183 const char *xml)
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1184 {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1185 if(!webdav_is_initialized) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1186 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
1187 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1188 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1189 webdav_is_initialized = 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
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1192 Session *sn = testutil_session();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1193 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
1194
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1195 int error = 0;
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 WebdavProppatchRequest *proppatch = proppatch_parse(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1198 sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1199 rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1200 xml,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1201 strlen(xml),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1202 &error);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1203
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1204 if(error) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1205 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1206 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1207
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1208 if(!proppatch || !(proppatch->set || proppatch->remove)) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1209 return 1;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1210 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1211
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1212 *out_sn = sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1213 *out_rq = rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1214 *out_proppatch = proppatch;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1215 return 0;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1216 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1217
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1218 static WebdavOperation* test_proppatch_op1(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1219 Session **out_sn,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1220 Request **out_rq,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1221 const char *xml)
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1222 {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1223 WebdavProppatchRequest *proppatch;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1224 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
1225 return NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1226 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1227
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1228 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
1229 if(!ms) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1230 return NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1231 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1232 // 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
1233 // for adding resources to the response
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1234 WebdavResponse *response = (WebdavResponse*)ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1235
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1236 return webdav_create_proppatch_operation(
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1237 (*out_sn),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1238 (*out_rq),
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1239 &backend1,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1240 proppatch,
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1241 response);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1242 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1243
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 UCX_TEST(test_proppatch_msresponse) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1246 Session *sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1247 Request *rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1248 WebdavOperation *op;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1249
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1250 Multistatus *ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1251 WebdavResource *res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1252
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1253 WebdavProperty p[16];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1254 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
1255 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
1256 p[i].namespace = webdav_dav_namespace();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1257 p[i].name = names[i];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1258 p[i].lang = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1259 p[i].value.node = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1260 p[1].vtype = 0;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1261 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1262
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1263 UCX_TEST_BEGIN;
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 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
1266 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
1267
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1268 ms = (Multistatus*)op->response;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1269 ms->proppatch = TRUE;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1270 res = ms->response.addresource(&ms->response, "/");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1271 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
1272
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1273 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
1274 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
1275 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
1276 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
1277
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1278 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
1279
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1280 MSResponse *msres = (MSResponse*)res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1281 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
1282 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
1283 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
1284 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
1285 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
1286 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
1287
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1288 UCX_TEST_END;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1289 testutil_destroy_session(sn);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1290 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1291
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1292 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
1293 Session *sn;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1294 Request *rq;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1295 WebdavOperation *op;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1296
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1297 Multistatus *ms;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1298 WebdavResource *res;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1299
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1300 WebdavProperty p[16];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1301 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
1302 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
1303 p[i].namespace = webdav_dav_namespace();
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1304 p[i].name = names[i];
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1305 p[i].lang = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1306 p[i].value.node = NULL;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1307 p[1].vtype = 0;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1308 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1309
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1310 UCX_TEST_BEGIN;
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 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
1313 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
1314
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1315 ms = (Multistatus*)op->response;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1316 ms->proppatch = TRUE;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1317 res = ms->response.addresource(&ms->response, "/");
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1318 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
1319
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1320 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
1321 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
1322 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
1323 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
1324
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1325 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
1326
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1327 // 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
1328 // 1 x 409, 3 x 424
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1329
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1330 MSResponse *msres = (MSResponse*)res;
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 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
1333 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
1334 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
1335 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
1336
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1337 // 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
1338 // 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
1339 // error lists, therefore check both variants
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1340 if(msres->errors->status == 409) {
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1341 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
1342 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
1343 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
1344 } else {
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->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
1346 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
1347 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
1348 }
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1349
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1350 UCX_TEST_END;
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1351 testutil_destroy_session(sn);
d5031c30022c make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 238
diff changeset
1352 }
241
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1353
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1354 UCX_TEST(test_webdav_op_proppatch) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1355 Session *sn;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1356 Request *rq;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1357 WebdavOperation *op;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1358
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1359 Multistatus *ms;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1360 WebdavResource *res;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1361
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1362 WebdavProperty p[16];
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1363 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
1364 for(int i=0;i<8;i++) {
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1365 p[i].namespace = webdav_dav_namespace();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1366 p[i].name = names[i];
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1367 p[i].lang = NULL;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1368 p[i].value.node = NULL;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1369 p[1].vtype = 0;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1370 }
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1371
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1372 UCX_TEST_BEGIN;
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 // TEST_PROPPATCH2 should succeed
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1375 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1376 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1377 UCX_TEST_ASSERT(op, "failed to create proppatch operation");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1378
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1379 int ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1380 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1381 UCX_TEST_ASSERT(backend1_proppatch_commit, "backend1 no commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1382 UCX_TEST_ASSERT(backend2_proppatch_commit, "backend2 no commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1383 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
1384 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
1385 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
1386 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
1387
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1388 // TEST_PROPPATCH3 should fail (commit == FALSE)
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1389 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1390 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH3);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1391 UCX_TEST_ASSERT(op, "failed to create proppatch operation 2");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1392
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1393 ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1394 UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed (2)");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1395 UCX_TEST_ASSERT(!backend1_proppatch_commit, "backend1 commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1396 UCX_TEST_ASSERT(!backend2_proppatch_commit, "backend2 commit");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1397
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1398 // TEST_PROPPATCH4 should abort
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1399 reset_backends();
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1400 op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH4);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1401 UCX_TEST_ASSERT(op, "failed to create proppatch operation 3");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1402
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1403 ret = webdav_op_proppatch(op, "/", "/");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1404 UCX_TEST_ASSERT(ret != 0, "webdav_op_proppatch should fail");
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1405 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
1406 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
1407 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
1408 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
1409
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1410 UCX_TEST_END;
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1411 testutil_destroy_session(sn);
4adad7faf452 add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 239
diff changeset
1412 }
242
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1413
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1414 #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
1415
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1416 UCX_TEST(test_webdav_proppatch) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1417 Session *sn;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1418 Request *rq;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1419 TestIOStream *st;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1420 pblock *pb;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1421
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1422 UCX_TEST_BEGIN;
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 int ret;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1425 // Test 1
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1426 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
1427 rq->davCollection = &backend1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1428 ret = webdav_proppatch(pb, sn, rq);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1429
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1430 UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed");
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 xmlDoc *doc = xmlReadMemory(
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1433 st->buf->space, st->buf->size, NULL, NULL, 0);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1434 UCX_TEST_ASSERT(doc, "proppatch1: response is not valid xml");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1435
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1436 //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
1437
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1438 xmlNode *root = xmlDocGetRootElement(doc);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1439 UCX_TEST_ASSERT(root, "proppatch1: no root");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1440
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1441 xmlNode *nodeC = NULL;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1442 xmlNode *node = root->children;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1443 int depth = 1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1444 while(node) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1445 const xmlChar *name = node->name;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1446 int nextNode = 1;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1447 if(node->type != XML_ELEMENT_NODE) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1448 // nothing
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1449 } else if(depth == 1) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1450 if(xstreq(name, "response")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1451 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1452 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1453 } else if(depth == 2) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1454 if(xstreq(name, "propstat")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1455 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1456 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1457 } else if(depth == 3) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1458 if(xstreq(name, "prop")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1459 nextNode = 0;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1460 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1461 } else if(depth == 4) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1462 if(xstreq(name, "c")) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1463 nodeC = node;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1464 break;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1465 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1466 }
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 if(nextNode) {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1469 node = node->next;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1470 } else {
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1471 node = node->children;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1472 depth++;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1473 }
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1474 }
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 UCX_TEST_ASSERT(nodeC, "prop c not in response");
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1477 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
1478
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1479 testutil_destroy_session(sn);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1480 xmlFreeDoc(doc);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1481 testutil_iostream_destroy(st);
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1482
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1483
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1484 UCX_TEST_END;
c337a7ac82a8 implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 241
diff changeset
1485 }
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
1486
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
1487
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 * 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
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 * ------------------------------------------------------------------------ */
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 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
1495 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
1496 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
1497 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
1498
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_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
1500 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
1501
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_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
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 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
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 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
1507 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
1508
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 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
1510 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
1511 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
1512 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
1513 }
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 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
1515 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
1516 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
1517 }
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 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
1519 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
1520 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
1521 }
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 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
1523 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
1524 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
1525 }
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 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
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
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 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
1530 *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
1531 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
1532 }
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
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 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
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
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 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
1538 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
1539
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 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
1541 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
1542 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
1543 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
1544 }
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 } 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
1546 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
1547 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
1548 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
1549 }
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 } 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
1551 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
1552 // 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
1553 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
1554 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
1555 }
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 }
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 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
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
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 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
1562 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
1563 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
1564 }
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
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1566 static int delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1567 static int delete_finish_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1568
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1569 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
1570 delete_count++;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1571 return 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1572 }
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1573
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1574 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
1575 delete_finish_count++;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1576 return 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1577 }
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
1578
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
1579
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 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
1581 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
1582 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
1583 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
1584 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
1585
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1586 // 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
1587 // behaves the same for both operations
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1588 // the only difference are the callbacks
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1589
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1590 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
1591 VFS *testvfs = testvfs_create(sn);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1592 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
1593
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
1594 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
1595 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
1596 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
1597 dav1.opt_mkcol_finish = test_webdav_mkcol_finish;
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1598 dav1.opt_delete = test_backend_webdav_delete;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1599 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
1600
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
1601 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
1602 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
1603 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
1604
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 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
1606 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
1607 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
1608
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 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
1610 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
1611 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
1612 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
1613
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 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
1615 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
1616 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
1617
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 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
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 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
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 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
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 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
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 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
1627 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
1628 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
1629 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
1630
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 // 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
1632 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
1633 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
1634
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 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
1636 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
1637
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 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
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 // 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
1641 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
1642 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
1643 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
1644
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 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
1646 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
1647
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 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
1649 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
1650 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
1651
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1652 // 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
1653 pblock_replace("path", "/deltest", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1654 rq->vfs = testvfs;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1655 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
1656 vfs_open(op_del->vfs, "/deltest", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1657 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
1658
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1659 UCX_TEST_ASSERT(!ret, "op_del failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1660 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
1661 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
1662
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
1663
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
1664 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
1665 }
249
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1666
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1667 UCX_TEST(test_webdav_delete){
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1668 Session *sn;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1669 Request *rq;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1670 TestIOStream *st;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1671 pblock *pb;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1672
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1673 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
1674 rq->vfs = testvfs_create(sn);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1675
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1676 WebdavBackend dav1;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1677 ZERO(&dav1, sizeof(WebdavBackend));
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1678 dav1.opt_delete = test_backend_webdav_delete;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1679 dav1.opt_delete_finish = test_backend_webdav_delete_finish;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1680 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1681 delete_finish_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1682 rq->davCollection = &dav1;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1683
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1684 UCX_TEST_BEGIN;
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 // prepare
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1687 VFSContext *vfs = vfs_request_context(sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1688 int err;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1689 err = vfs_mkdir(vfs, "/dir1");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1690 UCX_TEST_ASSERT(err == 0, "mkdir dir1 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1691 err = vfs_mkdir(vfs, "/dir2");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1692 UCX_TEST_ASSERT(err == 0, "mkdir dir2 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1693 err = vfs_mkdir(vfs, "/dir2/dir3");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1694 UCX_TEST_ASSERT(err == 0, "mkdir dir3 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1695 err = vfs_mkdir(vfs, "/dir2/dir4");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1696 UCX_TEST_ASSERT(err == 0, "mkdir dir4 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1697 err = vfs_mkdir(vfs, "/dir2/dir4/dir5");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1698 UCX_TEST_ASSERT(err == 0, "mkdir dir5 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1699
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1700 SYS_FILE f0 = vfs_open(vfs, "/file0", O_CREAT);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1701 UCX_TEST_ASSERT(f0, "f0 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1702 // no f1
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1703 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
1704 UCX_TEST_ASSERT(f2, "f2 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1705 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
1706 UCX_TEST_ASSERT(f3, "f3 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1707 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
1708 UCX_TEST_ASSERT(f4, "f4 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1709 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
1710 UCX_TEST_ASSERT(f5, "f5 create failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1711
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1712 // delete single file
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1713 pblock_replace("path", "/file0", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1714 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1715 UCX_TEST_ASSERT(err == 0, "DELETE /file0 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1716 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
1717
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1718 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1719 pblock_replace("path", "/dir1", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1720 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1721 UCX_TEST_ASSERT(err == 0, "DELETE /dir1 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1722 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
1723
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1724 delete_count = 0;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1725 pblock_replace("path", "/dir2", rq->vars);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1726 err = webdav_delete(NULL, sn, rq);
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1727 UCX_TEST_ASSERT(err == 0, "DELETE /dir2 failed");
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1728 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
1729
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1730 UCX_TEST_END;
3b302093945c add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 245
diff changeset
1731 }
251
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1732
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1733 UCX_TEST(test_webdav_put) {
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1734 Session *sn;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1735 Request *rq;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1736 TestIOStream *st;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1737 pblock *pb;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1738
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1739 const char *content_const = "Hello World";
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1740
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 300
diff changeset
1741 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
1742 rq->vfs = testvfs_create(sn);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1743
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1744 UCX_TEST_BEGIN;
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 int err;
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 pblock_replace("path", "/file0", rq->vars);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1749 err = webdav_put(NULL, sn, rq);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1750
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1751 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
1752
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1753 VFSContext *vfs = vfs_request_context(sn, rq);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1754 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
1755 UCX_TEST_ASSERT(f0, "cannot open file0");
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1756
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1757 char buf[1024];
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1758 int r = system_fread(f0, buf, 1024);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1759
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1760 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
1761 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
1762
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1763 testutil_destroy_session(sn);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1764 testutil_iostream_destroy(st);
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1765
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1766 UCX_TEST_END;
f727a21497bb add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 249
diff changeset
1767 }

mercurial