Tue, 19 Apr 2022 19:14:49 +0200
add function for registering webdav backends
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, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
58 | WebdavPList **outPList) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
59 | { |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
60 | backend2_init_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
61 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
62 | } |
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 | static int backend2_propfind_do( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
65 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
66 | WebdavResponse *response, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
67 | VFS_DIR parent, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
68 | WebdavResource *resource, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
69 | struct stat *s) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
70 | { |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
71 | backend2_propfind_do_count++; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
72 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
73 | } |
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 | 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
|
76 | backend2_propfind_finish_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
77 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
78 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
79 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
80 | static int backend2_proppatch_do( |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
81 | WebdavProppatchRequest *request, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
82 | WebdavResource *response, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
83 | VFSFile *file, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
84 | WebdavPList **out_set, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
85 | WebdavPList **out_remove) |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
86 | { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
87 | backend2_proppatch_do_count++; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
88 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
89 | if(*out_remove) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
90 | return 1; // backend1 should remove all remove-props |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
91 | } |
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 | WebdavPListIterator i = webdav_plist_iterator(out_set); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
94 | WebdavPList *cur; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
95 | while(webdav_plist_iterator_next(&i, &cur)) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
96 | if(!strcmp(cur->property->name, "a")) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
97 | // property 'a' should already be removed by backend1 |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
98 | return 1; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
99 | } else if(!strcmp(cur->property->name, "abort")) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
100 | return 1; // test abort |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
101 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
102 | response->addproperty(response, cur->property, 200); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
103 | webdav_plist_iterator_remove_current(&i); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
104 | } |
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 | return 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
107 | } |
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 | static int backend2_proppatch_finish( |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
110 | WebdavProppatchRequest *request, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
111 | WebdavResource *response, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
112 | VFSFile *file, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
113 | WSBool commit) |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
114 | { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
115 | backend2_proppatch_finish_count++; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
116 | backend2_proppatch_commit = commit; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
117 | return 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
118 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
119 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
120 | static WebdavBackend backend2 = { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
121 | backend2_propfind_init, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
122 | backend2_propfind_do, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
123 | backend2_propfind_finish, |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
124 | backend2_proppatch_do, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
125 | backend2_proppatch_finish, |
244
e59abb210584
add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
126 | 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
|
127 | NULL, // opt_mkcol_finish |
244
e59abb210584
add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
128 | 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
|
129 | NULL, // opt_delete_finish |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
130 | 0, |
300
0e3f275b2492
add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
251
diff
changeset
|
131 | NULL, // instance |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
132 | NULL |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
133 | }; |
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 | // backend1 |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
136 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
137 | static int backend1_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
138 | 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
|
139 | static int backend1_propfind_finish_called = 0; |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
140 | static int backend1_proppatch_commit = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
141 | static int backend1_proppatch_do_count = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
142 | 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
|
143 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
144 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
145 | static int backend1_propfind_init( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
146 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
147 | const char *path, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
148 | WebdavPList **outPList) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
149 | { |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
150 | 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
|
151 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
152 | WebdavPList *plist = *outPList; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
153 | WebdavProperty *p = plist->property; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
154 | if(!strcmp(p->name, "displayname")) { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
155 | plist->next->prev = NULL; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
156 | *outPList = plist->next; // remove first item from plist |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
157 | } else { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
158 | return 1; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
159 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
160 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
161 | return 0; |
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 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
164 | static int backend1_propfind_do( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
165 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
166 | WebdavResponse *response, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
167 | VFS_DIR parent, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
168 | WebdavResource *resource, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
169 | struct stat *s) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
170 | { |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
171 | backend1_propfind_do_count++; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
172 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
173 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
174 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
175 | 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
|
176 | backend1_propfind_finish_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
177 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
178 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
179 | |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
180 | static int backend1_proppatch_do( |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
181 | WebdavProppatchRequest *request, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
182 | WebdavResource *response, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
183 | VFSFile *file, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
184 | WebdavPList **out_set, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
185 | WebdavPList **out_remove) |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
186 | { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
187 | backend1_proppatch_do_count++; |
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 | // remove everything from out_remove |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
190 | WebdavPListIterator i = webdav_plist_iterator(out_remove); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
191 | WebdavPList *cur; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
192 | while(webdav_plist_iterator_next(&i, &cur)) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
193 | response->addproperty(response, cur->property, 200); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
194 | webdav_plist_iterator_remove_current(&i); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
195 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
196 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
197 | // remove property 'a' and fail at property 'fail' |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
198 | i = webdav_plist_iterator(out_set); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
199 | while(webdav_plist_iterator_next(&i, &cur)) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
200 | if(!strcmp(cur->property->name, "fail")) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
201 | response->addproperty(response, cur->property, 403); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
202 | webdav_plist_iterator_remove_current(&i); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
203 | } else if(!strcmp(cur->property->name, "a")) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
204 | response->addproperty(response, cur->property, 200); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
205 | webdav_plist_iterator_remove_current(&i); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
206 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
207 | } |
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 | return 0; |
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 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
212 | static int backend1_proppatch_finish( |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
213 | WebdavProppatchRequest *request, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
214 | WebdavResource *response, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
215 | VFSFile *file, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
216 | WSBool commit) |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
217 | { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
218 | backend1_proppatch_finish_count++; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
219 | backend1_proppatch_commit = commit; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
220 | return 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
221 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
222 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
223 | WebdavBackend backend1 = { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
224 | backend1_propfind_init, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
225 | backend1_propfind_do, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
226 | backend1_propfind_finish, |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
227 | backend1_proppatch_do, |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
228 | backend1_proppatch_finish, |
244
e59abb210584
add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
229 | 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
|
230 | NULL, // opt_mkcol_finish |
244
e59abb210584
add minimal mkcol implementation and prepare delete
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
242
diff
changeset
|
231 | 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
|
232 | NULL, // opt_delete_finish |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
233 | 0, |
300
0e3f275b2492
add instance field to webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
251
diff
changeset
|
234 | NULL, // instance |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
235 | &backend2 |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
236 | }; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
237 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
238 | 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
|
239 | backend1_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
240 | 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
|
241 | backend1_propfind_finish_called = 0; |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
242 | backend1_proppatch_commit = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
243 | backend1_proppatch_do_count = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
244 | 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
|
245 | backend2_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
246 | 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
|
247 | backend2_propfind_finish_called = 0; |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
248 | backend2_proppatch_commit = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
249 | backend2_proppatch_do_count = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
250 | 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
|
251 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
252 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
253 | /* ----------------------------------------------------------------------*/ |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
254 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
255 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
256 | static int test_init( |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
257 | Session **out_sn, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
258 | Request **out_rq, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
259 | WebdavPropfindRequest **out_propfind, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
260 | const char *xml) |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
261 | { |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
262 | if(!webdav_is_initialized) { |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
263 | if(webdav_init(NULL, NULL, NULL) != REQ_PROCEED) { |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
264 | return 1; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
265 | } |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
266 | webdav_is_initialized = 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 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
269 | Session *sn = testutil_session(); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
270 | Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
271 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
272 | int error = 0; |
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 | WebdavPropfindRequest *propfind = propfind_parse( |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
275 | sn, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
276 | rq, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
277 | xml, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
278 | strlen(xml), |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
279 | &error); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
280 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
281 | if(error) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
282 | return 1; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
283 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
284 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
285 | if(!propfind || !propfind->properties) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
286 | return 1; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
287 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
288 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
289 | *out_sn = sn; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
290 | *out_rq = rq; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
291 | *out_propfind = propfind; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
292 | return 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
293 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
294 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
295 | 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
|
296 | Session **out_sn, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
297 | Request **out_rq, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
298 | const char *xml) |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
299 | { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
300 | WebdavPropfindRequest *propfind; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
301 | 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
|
302 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
303 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
304 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
305 | 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
|
306 | if(!ms) { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
307 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
308 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
309 | // 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
|
310 | // 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
|
311 | 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
|
312 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
313 | UcxList *requests = NULL; |
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 | // Initialize all Webdav Backends |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
316 | if(webdav_propfind_init(&backend1, propfind, "/", &requests)) { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
317 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
318 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
319 | |
239
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
320 | 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
|
321 | (*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
|
322 | (*out_rq), |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
323 | &backend1, |
237
ee1680ef1ef2
handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
233
diff
changeset
|
324 | propfind->properties, |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
325 | requests, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
326 | response); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
327 | } |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
328 | |
228
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
329 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
330 | 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
|
331 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
332 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
333 | UCX_TEST_BEGIN; |
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 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
336 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
337 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
338 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
339 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
340 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
341 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
342 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
343 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
344 | 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
|
345 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
346 | 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
|
347 | 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
|
348 | 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
|
349 | 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
|
350 | 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
|
351 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
352 | 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
|
353 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
354 | 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
|
355 | 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
|
356 | 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
|
357 | 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
|
358 | 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
|
359 | 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
|
360 | 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
|
361 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
362 | 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
|
363 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
364 | 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
|
365 | 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
|
366 | 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
|
367 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
368 | UCX_TEST_END; |
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 | testutil_destroy_session(sn); |
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 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
373 | 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
|
374 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
375 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
376 | UCX_TEST_BEGIN; |
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 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
379 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
380 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
381 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
382 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
383 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
384 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
385 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
386 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
395 | UCX_TEST_END; |
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 | testutil_destroy_session(sn); |
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 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
400 | 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
|
401 | 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
|
402 | 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
|
403 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
404 | 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
|
405 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
406 | 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
|
407 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
408 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
409 | // ----------------- TEST_PROPFIND1 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
410 | // 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
|
411 | 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
|
412 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
413 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
414 | TEST_PROPFIND1, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
415 | 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
|
416 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
417 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
418 | 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
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
424 | // 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
|
425 | 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
|
426 | 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
|
427 | !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
|
428 | "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
|
429 | 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
|
430 | !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
|
431 | "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
|
432 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
433 | // 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
|
434 | 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
|
435 | 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
|
436 | 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
|
437 | !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
|
438 | "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
|
439 | 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
|
440 | !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
|
441 | "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
|
442 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
443 | 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
|
444 | 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
|
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 4 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 5 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
449 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
450 | // 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
|
451 | 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
|
452 | 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
|
453 | 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
|
454 | !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
|
455 | "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
|
456 | 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
|
457 | !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
|
458 | "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
|
459 | 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
|
460 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
461 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
462 | // ----------------- TEST_PROPFIND2 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | // 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
|
464 | 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
|
465 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
466 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
467 | TEST_PROPFIND2, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
468 | 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
|
469 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
470 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
471 | 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
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
476 | // 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
|
477 | 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
|
478 | 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
|
479 | !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
|
480 | "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
|
481 | 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
|
482 | !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
|
483 | "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
|
484 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
485 | // 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | !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
|
490 | "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
|
491 | 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
|
492 | !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
|
493 | "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
|
494 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
495 | // 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
|
496 | 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
|
497 | 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
|
498 | 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
|
499 | !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
|
500 | "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
|
501 | 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
|
502 | !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
|
503 | "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
|
504 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
505 | // 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
|
506 | 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
|
507 | 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
|
508 | 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
|
509 | !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
|
510 | "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
|
511 | 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
|
512 | !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
|
513 | "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
|
514 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
515 | |
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 | // ----------------- TEST_PROPFIND3 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
518 | // test allprop |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
519 | 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
|
520 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
521 | 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
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
527 | |
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 | // ----------------- TEST_PROPFIND4 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
530 | // test propname |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
531 | 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
|
532 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
533 | 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
|
534 | 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
|
535 | 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
|
536 | 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
|
537 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
538 | |
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 | // ----------------- TEST_PROPFIND5 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
541 | // 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
|
542 | 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
|
543 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | 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
|
549 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
550 | // 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
|
551 | 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
|
552 | 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
|
553 | 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
|
554 | !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
|
555 | "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
|
556 | 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
|
557 | !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
|
558 | "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
|
559 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
560 | 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
|
561 | 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
|
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 3 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
564 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
565 | // 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
|
566 | 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
|
567 | 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
|
568 | 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
|
569 | !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
|
570 | "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
|
571 | 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
|
572 | !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
|
573 | "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
|
574 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
575 | |
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 | // ----------------- TEST_PROPFIND6 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
578 | // 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
|
579 | 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
|
580 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
581 | 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
|
582 | 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
|
583 | 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
|
584 | 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
|
585 | 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
|
586 | |
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_END |
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 | 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
|
590 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
591 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
592 | 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
|
593 | 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
|
594 | 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
|
595 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
596 | 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
|
597 | 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
|
598 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
599 | 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
|
600 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | 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
|
605 | 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
|
606 | 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
|
607 | 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
|
608 | !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
|
609 | "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
|
610 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
611 | 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
|
612 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
613 | 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
|
614 | 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
|
615 | 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
|
616 | 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
|
617 | |
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( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
619 | !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
|
620 | "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
|
621 | 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
|
622 | !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
|
623 | "p2: set property 1: wrong name"); |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
624 | 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
|
625 | 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
|
626 | 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
|
627 | "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
|
628 | 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
|
629 | p2set1->content, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
630 | "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
|
631 | 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
|
632 | !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
|
633 | "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
|
634 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
635 | 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
|
636 | 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
|
637 | 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
|
638 | 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
|
639 | "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
|
640 | 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
|
641 | p2set3->next, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
642 | "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
|
643 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
644 | 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
|
645 | 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
|
646 | "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
|
647 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
648 | 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
|
649 | 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
|
650 | "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
|
651 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
652 | 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
|
653 | 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
|
654 | !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
|
655 | "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
|
656 | xmlFree(value1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
657 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
658 | 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
|
659 | 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
|
660 | !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
|
661 | "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
|
662 | xmlFree(value2); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
663 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
664 | 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
|
665 | !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
|
666 | "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
|
667 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
668 | 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
|
669 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
670 | 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
|
671 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
672 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
673 | 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
|
674 | 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
|
675 | 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
|
676 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
677 | 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
|
678 | 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
|
679 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
680 | 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
|
681 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
682 | 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
|
683 | 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
|
684 | 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
|
685 | 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
|
686 | 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
|
687 | |
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_END |
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 | 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
|
691 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
692 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
693 | 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
|
694 | Session *sn; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
695 | Request *rq; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
696 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
697 | 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
|
698 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
699 | // TEST 1 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
700 | 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
|
701 | 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
|
702 | 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
|
703 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
704 | 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
|
705 | 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
|
706 | 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
|
707 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
708 | 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
|
709 | 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
|
710 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
711 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
712 | // TEST 2 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
713 | 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
|
714 | 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
|
715 | 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
|
716 | 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
|
717 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
718 | 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
|
719 | 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
|
720 | 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
|
721 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
722 | 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
|
723 | 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
|
724 | 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
|
725 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
726 | 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
|
727 | 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
|
728 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
729 | 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
|
730 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
731 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
732 | UCX_TEST(test_webdav_plist_iterator) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
733 | Session *sn; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
734 | Request *rq; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
735 | WebdavPropfindRequest *propfind; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
736 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
737 | UCX_TEST_BEGIN; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
738 | 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
|
739 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
740 | WebdavPList *properties = propfind->properties; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
741 | size_t count = 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
742 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
743 | WebdavPListIterator i = webdav_plist_iterator(&properties); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
744 | WebdavPList *cur; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
745 | while(webdav_plist_iterator_next(&i, &cur)) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
746 | switch(i.index) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
747 | case 0: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
748 | 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
|
749 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
750 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
751 | case 1: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
752 | 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
|
753 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
754 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
755 | case 2: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
756 | 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
|
757 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
758 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
759 | case 3: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
760 | 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
|
761 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
762 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
763 | case 4: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
764 | 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
|
765 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
766 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
767 | case 5: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
768 | 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
|
769 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
770 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
771 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
772 | count++; |
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 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
775 | UCX_TEST_ASSERT(count == propfind->propcount, "wrong count"); |
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 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
778 | UCX_TEST_END; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
779 | testutil_destroy_session(sn); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
780 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
781 | |
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
|
782 | 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
|
783 | 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
|
784 | 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
|
785 | 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
|
786 | |
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 | 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
|
788 | 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
|
789 | |
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 | 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
|
791 | 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
|
792 | 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
|
793 | 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
|
794 | |
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 | 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
|
796 | 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
|
797 | |
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 | // 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
|
799 | 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
|
800 | 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
|
801 | 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
|
802 | 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
|
803 | } |
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 | } |
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 | 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
|
807 | 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
|
808 | 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
|
809 | 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
|
810 | |
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 | // 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
|
812 | 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
|
813 | 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
|
814 | 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
|
815 | 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
|
816 | } |
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 | } |
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 | 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
|
820 | 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
|
821 | 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
|
822 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
823 | // 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
|
824 | 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
|
825 | 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
|
826 | 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
|
827 | 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
|
828 | } |
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 | } |
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 | 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
|
832 | 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
|
833 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
834 | // 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
|
835 | 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
|
836 | 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
|
837 | 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
|
838 | 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
|
839 | 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
|
840 | 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
|
841 | 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
|
842 | 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
|
843 | } |
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 | 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
|
845 | 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
|
846 | 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
|
847 | 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
|
848 | } |
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 | 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
|
850 | 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
|
851 | 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
|
852 | 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
|
853 | } |
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 | 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
|
855 | 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
|
856 | 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
|
857 | 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
|
858 | } |
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 | 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
|
860 | 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
|
861 | 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
|
862 | 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
|
863 | } |
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 | 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
|
865 | 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
|
866 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
867 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
868 | } |
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 | 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
|
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_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
|
873 | 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
|
874 | } |
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 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
876 | UCX_TEST(test_msresponse_addproperty) { |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
877 | Session *sn; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
878 | 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
|
879 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
880 | UCX_TEST_BEGIN; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
881 | |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
882 | WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
883 | UCX_TEST_ASSERT(op, "init failed"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
884 | UCX_TEST_ASSERT(op->response, "no response"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
885 | |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
886 | Multistatus *ms = (Multistatus*)op->response; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
887 | 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
|
888 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
889 | WebdavProperty p1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
890 | WebdavProperty p[16]; |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
891 | 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
|
892 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
893 | WSNamespace ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
894 | ZERO(&ns1, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
895 | WSNamespace ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
896 | ZERO(&ns2, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
897 | ns1.prefix = (xmlChar*)"x1"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
898 | ns1.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
899 | ns2.prefix = (xmlChar*)"x2"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
900 | ns2.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
901 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
902 | WebdavProperty dp1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
903 | ZERO(&dp1, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
904 | dp1.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
905 | dp1.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
906 | dp1.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
907 | dp1.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
908 | dp1.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
909 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
910 | WebdavProperty dp2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
911 | ZERO(&dp2, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
912 | dp2.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
913 | dp2.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
914 | dp2.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
915 | dp2.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
916 | dp2.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
917 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
918 | WebdavProperty dp3; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
919 | ZERO(&dp3, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
920 | dp3.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
921 | dp3.namespace = &ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
922 | dp3.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
923 | dp3.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
924 | dp3.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
925 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
926 | // init test data |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
927 | p1.namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
928 | p1.lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
929 | p1.name = "test1"; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
930 | p1.value.data = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
931 | p1.vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
932 | |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
933 | for(int i=0;i<8;i++) { |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
934 | p[i].namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
935 | p[i].name = names[i]; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
936 | p[i].lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
937 | p[i].value.node = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
938 | p[1].vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
939 | } |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
940 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
941 | 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
|
942 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
943 | 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
|
944 | 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
|
945 | 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
|
946 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
947 | r->resource.addproperty((WebdavResource*)r, &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
|
948 | 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
|
949 | 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
|
950 | 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
|
951 | 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
|
952 | 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
|
953 | 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
|
954 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
955 | 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
|
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->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
|
958 | 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
|
959 | 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
|
960 | 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
|
961 | |
229
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
962 | 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
|
963 | 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
|
964 | 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
|
965 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
966 | // new resource for prop duplication tests |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
967 | r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
968 | UCX_TEST_ASSERT(r, "cannot create second response"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
969 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
970 | r->resource.addproperty((WebdavResource*)r, &dp1, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
971 | UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
972 | 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
|
973 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
974 | r->resource.addproperty((WebdavResource*)r, &dp2, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
975 | 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
|
976 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
977 | r->resource.addproperty((WebdavResource*)r, &dp2, 404); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
978 | 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
|
979 | if(r->errors) { |
229
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
980 | 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
|
981 | } |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
982 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
983 | r->resource.addproperty((WebdavResource*)r, &dp3, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
984 | 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
|
985 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
986 | 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
|
987 | } |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
988 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
989 | 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
|
990 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
991 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
992 | Session *sn; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
993 | Request *rq; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
994 | WebdavPropfindRequest *propfind; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
995 | UCX_TEST_BEGIN; |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
996 | 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
|
997 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
998 | UcxList *requests = NULL; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
999 | int err = webdav_propfind_init(&backend1, propfind, "/", &requests); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1000 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1001 | 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
|
1002 | 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
|
1003 | 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
|
1004 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1005 | 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
|
1006 | 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
|
1007 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
1008 | // backend1 removes the first property from the plist |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
1009 | // backend2 should have one property less |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
1010 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1011 | 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
|
1012 | 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
|
1013 | 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
|
1014 | 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
|
1015 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1016 | 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
|
1017 | 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
|
1018 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1019 | 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
|
1020 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
1021 | 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
|
1022 | } |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1023 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1024 | 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
|
1025 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1026 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1027 | Session *sn; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1028 | Request *rq; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1029 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1030 | UCX_TEST_BEGIN; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1031 | 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
|
1032 | 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
|
1033 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1034 | 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
|
1035 | 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
|
1036 | 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
|
1037 | 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
|
1038 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1039 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
1040 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1041 | 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
|
1042 | } |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1043 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1044 | UCX_TEST(test_webdav_op_propfind_children) { |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1045 | reset_backends(); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1046 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1047 | Session *sn; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1048 | Request *rq; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1049 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1050 | UCX_TEST_BEGIN; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1051 | 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
|
1052 | UCX_TEST_ASSERT(op, "WebdavOperation not created"); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1053 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1054 | 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
|
1055 | 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
|
1056 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1057 | // 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
|
1058 | rq->vfs = testvfs_create(sn); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1059 | 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
|
1060 | UCX_TEST_ASSERT(vfs, "no vfs"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1061 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1062 | err = vfs_mkdir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1063 | 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
|
1064 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1065 | // add some test file to /dir |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1066 | 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
|
1067 | 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
|
1068 | 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
|
1069 | 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
|
1070 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1071 | VFSDir *dir = vfs_opendir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1072 | 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
|
1073 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1074 | 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
|
1075 | 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
|
1076 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1077 | // propfind for all children |
221
ff5826fc6a6c
add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
220
diff
changeset
|
1078 | 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
|
1079 | 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
|
1080 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1081 | // 1 dir + 4 children |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1082 | 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
|
1083 | 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
|
1084 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1085 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
1086 | testutil_destroy_session(sn); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
1087 | } |
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
|
1088 | |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1089 | static void init_test_webdav_method( |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1090 | Session **out_sn, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1091 | Request **out_rq, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1092 | TestIOStream **out_st, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1093 | pblock **out_pb, |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1094 | const char *method, |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1095 | const char *request_body) |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1096 | { |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1097 | Session *sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1098 | Request *rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1099 | TestIOStream *st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1100 | pblock *pb; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1101 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1102 | sn = testutil_session(); |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1103 | 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
|
1104 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1105 | pblock_nvinsert("path", "/", rq->vars); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1106 | pblock_nvinsert("uri", "/", rq->reqpb); |
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 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1108 | st = testutil_iostream(2048, TRUE); |
251
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1109 | 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
|
1110 | |
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
|
1111 | 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
|
1112 | 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
|
1113 | } |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1114 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1115 | 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
|
1116 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1117 | *out_sn = sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1118 | *out_rq = rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1119 | *out_st = st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1120 | *out_pb = pb; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1121 | } |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1122 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1123 | UCX_TEST(test_webdav_propfind) { |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1124 | Session *sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1125 | Request *rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1126 | TestIOStream *st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1127 | 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
|
1128 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1129 | 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
|
1130 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1131 | int ret; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1132 | // Test 1 |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1133 | 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
|
1134 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1135 | 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
|
1136 | |
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 | 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
|
1138 | |
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 | 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
|
1140 | 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
|
1141 | 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
|
1142 | |
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 | //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
|
1144 | |
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 | testutil_destroy_session(sn); |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1146 | xmlFreeDoc(doc); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1147 | testutil_iostream_destroy(st); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1148 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1149 | // Test2 |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1150 | 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
|
1151 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1152 | ret = webdav_propfind(pb, sn, rq); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1153 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1154 | 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
|
1155 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1156 | xmlDoc *doc2 = xmlReadMemory( |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1157 | 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
|
1158 | 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
|
1159 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1160 | //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
|
1161 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1162 | testutil_destroy_session(sn); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1163 | xmlFreeDoc(doc2); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1164 | testutil_iostream_destroy(st); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1165 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1166 | UCX_TEST_END; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1167 | |
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
|
1168 | } |
239
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1169 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1170 | /* ------------------------------------------------------------------------- |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1171 | * |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1172 | * PROPPATCH TESTS |
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 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1176 | static int test_proppatch_init( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1177 | Session **out_sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1178 | Request **out_rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1179 | WebdavProppatchRequest **out_proppatch, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1180 | const char *xml) |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1181 | { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1182 | if(!webdav_is_initialized) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1183 | 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
|
1184 | return 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1185 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1186 | webdav_is_initialized = 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1187 | } |
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 | Session *sn = testutil_session(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1190 | 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
|
1191 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1192 | int error = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1193 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1194 | WebdavProppatchRequest *proppatch = proppatch_parse( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1195 | sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1196 | rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1197 | xml, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1198 | strlen(xml), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1199 | &error); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1200 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1201 | if(error) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1202 | return 1; |
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 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1205 | if(!proppatch || !(proppatch->set || proppatch->remove)) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1206 | return 1; |
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 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1209 | *out_sn = sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1210 | *out_rq = rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1211 | *out_proppatch = proppatch; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1212 | return 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1213 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1214 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1215 | static WebdavOperation* test_proppatch_op1( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1216 | Session **out_sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1217 | Request **out_rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1218 | const char *xml) |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1219 | { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1220 | WebdavProppatchRequest *proppatch; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1221 | 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
|
1222 | return NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1223 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1224 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1225 | 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
|
1226 | if(!ms) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1227 | return NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1228 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1229 | // 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
|
1230 | // for adding resources to the response |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1231 | WebdavResponse *response = (WebdavResponse*)ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1232 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1233 | return webdav_create_proppatch_operation( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1234 | (*out_sn), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1235 | (*out_rq), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1236 | &backend1, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1237 | proppatch, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1238 | response); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1239 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1240 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1241 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1242 | UCX_TEST(test_proppatch_msresponse) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1243 | Session *sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1244 | Request *rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1245 | WebdavOperation *op; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1246 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1247 | Multistatus *ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1248 | WebdavResource *res; |
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 | WebdavProperty p[16]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1251 | 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
|
1252 | 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
|
1253 | p[i].namespace = webdav_dav_namespace(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1254 | p[i].name = names[i]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1255 | p[i].lang = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1256 | p[i].value.node = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1257 | p[1].vtype = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1258 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1259 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1260 | UCX_TEST_BEGIN; |
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 | 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
|
1263 | 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
|
1264 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1265 | ms = (Multistatus*)op->response; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1266 | ms->proppatch = TRUE; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1267 | res = ms->response.addresource(&ms->response, "/"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1268 | 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
|
1269 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1270 | 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
|
1271 | 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
|
1272 | 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
|
1273 | 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
|
1274 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1275 | 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
|
1276 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1277 | MSResponse *msres = (MSResponse*)res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1278 | 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
|
1279 | 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
|
1280 | 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
|
1281 | 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
|
1282 | 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
|
1283 | 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
|
1284 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1285 | UCX_TEST_END; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1286 | testutil_destroy_session(sn); |
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 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1289 | 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
|
1290 | Session *sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1291 | Request *rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1292 | WebdavOperation *op; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1293 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1294 | Multistatus *ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1295 | WebdavResource *res; |
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 | WebdavProperty p[16]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1298 | 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
|
1299 | 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
|
1300 | p[i].namespace = webdav_dav_namespace(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1301 | p[i].name = names[i]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1302 | p[i].lang = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1303 | p[i].value.node = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1304 | p[1].vtype = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1305 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1306 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1307 | UCX_TEST_BEGIN; |
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 | 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
|
1310 | 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
|
1311 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1312 | ms = (Multistatus*)op->response; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1313 | ms->proppatch = TRUE; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1314 | res = ms->response.addresource(&ms->response, "/"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1315 | 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
|
1316 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1317 | 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
|
1318 | 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
|
1319 | 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
|
1320 | 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
|
1321 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1322 | 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
|
1323 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1324 | // 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
|
1325 | // 1 x 409, 3 x 424 |
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 | MSResponse *msres = (MSResponse*)res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1328 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1329 | 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
|
1330 | 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
|
1331 | 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
|
1332 | 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
|
1333 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1334 | // 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
|
1335 | // 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
|
1336 | // error lists, therefore check both variants |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1337 | if(msres->errors->status == 409) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1338 | 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
|
1339 | 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
|
1340 | 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
|
1341 | } else { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1342 | 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
|
1343 | 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
|
1344 | 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
|
1345 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1346 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1347 | UCX_TEST_END; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1348 | testutil_destroy_session(sn); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1349 | } |
241
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1350 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1351 | UCX_TEST(test_webdav_op_proppatch) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1352 | Session *sn; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1353 | Request *rq; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1354 | WebdavOperation *op; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1355 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1356 | Multistatus *ms; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1357 | WebdavResource *res; |
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 | WebdavProperty p[16]; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1360 | 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
|
1361 | for(int i=0;i<8;i++) { |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1362 | p[i].namespace = webdav_dav_namespace(); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1363 | p[i].name = names[i]; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1364 | p[i].lang = NULL; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1365 | p[i].value.node = NULL; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1366 | p[1].vtype = 0; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1367 | } |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1368 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1369 | UCX_TEST_BEGIN; |
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 | // TEST_PROPPATCH2 should succeed |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1372 | reset_backends(); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1373 | op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1374 | UCX_TEST_ASSERT(op, "failed to create proppatch operation"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1375 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1376 | int ret = webdav_op_proppatch(op, "/", "/"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1377 | UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1378 | UCX_TEST_ASSERT(backend1_proppatch_commit, "backend1 no commit"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1379 | UCX_TEST_ASSERT(backend2_proppatch_commit, "backend2 no commit"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1380 | 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
|
1381 | 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
|
1382 | 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
|
1383 | 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
|
1384 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1385 | // TEST_PROPPATCH3 should fail (commit == FALSE) |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1386 | reset_backends(); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1387 | op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH3); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1388 | UCX_TEST_ASSERT(op, "failed to create proppatch operation 2"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1389 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1390 | ret = webdav_op_proppatch(op, "/", "/"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1391 | UCX_TEST_ASSERT(ret == 0, "webdav_op_proppatch failed (2)"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1392 | UCX_TEST_ASSERT(!backend1_proppatch_commit, "backend1 commit"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1393 | UCX_TEST_ASSERT(!backend2_proppatch_commit, "backend2 commit"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1394 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1395 | // TEST_PROPPATCH4 should abort |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1396 | reset_backends(); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1397 | op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH4); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1398 | UCX_TEST_ASSERT(op, "failed to create proppatch operation 3"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1399 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1400 | ret = webdav_op_proppatch(op, "/", "/"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1401 | UCX_TEST_ASSERT(ret != 0, "webdav_op_proppatch should fail"); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1402 | 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
|
1403 | 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
|
1404 | 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
|
1405 | 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
|
1406 | |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1407 | UCX_TEST_END; |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1408 | testutil_destroy_session(sn); |
4adad7faf452
add proppatch op
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
239
diff
changeset
|
1409 | } |
242
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1410 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1411 | #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
|
1412 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1413 | UCX_TEST(test_webdav_proppatch) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1414 | Session *sn; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1415 | Request *rq; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1416 | TestIOStream *st; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1417 | pblock *pb; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1418 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1419 | UCX_TEST_BEGIN; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1420 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1421 | int ret; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1422 | // Test 1 |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1423 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", TEST_PROPPATCH2); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1424 | rq->davCollection = &backend1; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1425 | ret = webdav_proppatch(pb, sn, rq); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1426 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1427 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_proppatch (1) failed"); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1428 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1429 | xmlDoc *doc = xmlReadMemory( |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1430 | st->buf->space, st->buf->size, NULL, NULL, 0); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1431 | UCX_TEST_ASSERT(doc, "proppatch1: response is not valid xml"); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1432 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1433 | //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
|
1434 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1435 | xmlNode *root = xmlDocGetRootElement(doc); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1436 | UCX_TEST_ASSERT(root, "proppatch1: no root"); |
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 *nodeC = NULL; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1439 | xmlNode *node = root->children; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1440 | int depth = 1; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1441 | while(node) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1442 | const xmlChar *name = node->name; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1443 | int nextNode = 1; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1444 | if(node->type != XML_ELEMENT_NODE) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1445 | // nothing |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1446 | } else if(depth == 1) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1447 | if(xstreq(name, "response")) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1448 | nextNode = 0; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1449 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1450 | } else if(depth == 2) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1451 | if(xstreq(name, "propstat")) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1452 | nextNode = 0; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1453 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1454 | } else if(depth == 3) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1455 | if(xstreq(name, "prop")) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1456 | nextNode = 0; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1457 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1458 | } else if(depth == 4) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1459 | if(xstreq(name, "c")) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1460 | nodeC = node; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1461 | break; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1462 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1463 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1464 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1465 | if(nextNode) { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1466 | node = node->next; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1467 | } else { |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1468 | node = node->children; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1469 | depth++; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1470 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1471 | } |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1472 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1473 | UCX_TEST_ASSERT(nodeC, "prop c not in response"); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1474 | 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
|
1475 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1476 | testutil_destroy_session(sn); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1477 | xmlFreeDoc(doc); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1478 | testutil_iostream_destroy(st); |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1479 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1480 | |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1481 | UCX_TEST_END; |
c337a7ac82a8
implement webdav_proppatch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
1482 | } |
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
|
1483 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1484 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1485 | /* ------------------------------------------------------------------------- |
a193c42fc809
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 | * 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
|
1488 | * |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1489 | * ------------------------------------------------------------------------ */ |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1490 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1491 | 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
|
1492 | 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
|
1493 | 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
|
1494 | 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
|
1495 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1496 | static int mkcol_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
|
1497 | 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
|
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_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
|
1500 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1501 | static int 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
|
1502 | |
a193c42fc809
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 | 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
|
1504 | 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
|
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 | 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
|
1507 | 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
|
1508 | 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
|
1509 | 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
|
1510 | } |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1511 | 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
|
1512 | 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
|
1513 | 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
|
1514 | } |
a193c42fc809
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 | 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
|
1516 | 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
|
1517 | 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
|
1518 | } |
a193c42fc809
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 | 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
|
1520 | 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
|
1521 | 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
|
1522 | } |
a193c42fc809
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 | 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
|
1524 | } |
a193c42fc809
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 | 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
|
1527 | *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
|
1528 | 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
|
1529 | } |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1530 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1531 | 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
|
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 | 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
|
1535 | 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
|
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 | 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
|
1538 | 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
|
1539 | 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
|
1540 | 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
|
1541 | } |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1542 | } 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
|
1543 | int *data = req->userdata; |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1544 | if(data != &mkcol_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
|
1545 | mkcol_err = 1; |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1546 | } |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1547 | } else { |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1548 | int *data = req->userdata; |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1549 | // 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
|
1550 | 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
|
1551 | 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
|
1552 | } |
a193c42fc809
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 | } |
a193c42fc809
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 | |
a193c42fc809
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 | 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
|
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 | 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
|
1559 | 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
|
1560 | 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
|
1561 | } |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1562 | |
249
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1563 | static int delete_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1564 | static int delete_finish_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1565 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1566 | 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
|
1567 | delete_count++; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1568 | return 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1569 | } |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1570 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1571 | static int test_backend_webdav_delete_finish(WebdavVFSRequest *req, WSBool success) { |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1572 | delete_finish_count++; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1573 | return 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1574 | } |
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
|
1575 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1576 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1577 | 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
|
1578 | 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
|
1579 | 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
|
1580 | 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
|
1581 | 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
|
1582 | |
249
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1583 | // 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
|
1584 | // behaves the same for both operations |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1585 | // the only difference are the callbacks |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1586 | |
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
|
1587 | 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
|
1588 | VFS *testvfs = testvfs_create(sn); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1589 | 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
|
1590 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1591 | 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
|
1592 | 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
|
1593 | 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
|
1594 | dav1.opt_mkcol_finish = test_webdav_mkcol_finish; |
249
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1595 | dav1.opt_delete = test_backend_webdav_delete; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1596 | 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
|
1597 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1598 | 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
|
1599 | 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
|
1600 | 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
|
1601 | |
a193c42fc809
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 | 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
|
1603 | 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
|
1604 | 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
|
1605 | |
a193c42fc809
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 | 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
|
1607 | 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
|
1608 | 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
|
1609 | 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
|
1610 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1611 | 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
|
1612 | 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
|
1613 | 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
|
1614 | |
a193c42fc809
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 | 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
|
1616 | |
a193c42fc809
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 | 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
|
1618 | |
a193c42fc809
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 | 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
|
1620 | |
a193c42fc809
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 | 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
|
1622 | |
a193c42fc809
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 | 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
|
1624 | 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
|
1625 | 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
|
1626 | 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
|
1627 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1628 | // 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
|
1629 | 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
|
1630 | 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
|
1631 | |
a193c42fc809
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 | 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
|
1633 | 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
|
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 | 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
|
1636 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1637 | // 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
|
1638 | 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
|
1639 | 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
|
1640 | 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
|
1641 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1642 | 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
|
1643 | 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
|
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 | 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
|
1646 | 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
|
1647 | 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
|
1648 | |
249
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1649 | // 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
|
1650 | pblock_replace("path", "/deltest", rq->vars); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1651 | rq->vfs = testvfs; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1652 | 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
|
1653 | vfs_open(op_del->vfs, "/deltest", O_CREAT); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1654 | 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
|
1655 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1656 | UCX_TEST_ASSERT(!ret, "op_del failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1657 | 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
|
1658 | 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
|
1659 | |
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
|
1660 | |
a193c42fc809
add mkcol and delete interface to webdav backend, move webdav vfs logic to operation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
244
diff
changeset
|
1661 | 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
|
1662 | } |
249
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1663 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1664 | UCX_TEST(test_webdav_delete){ |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1665 | Session *sn; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1666 | Request *rq; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1667 | TestIOStream *st; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1668 | pblock *pb; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1669 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1670 | init_test_webdav_method(&sn, &rq, &st, &pb, "DELETE", NULL); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1671 | rq->vfs = testvfs_create(sn); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1672 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1673 | WebdavBackend dav1; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1674 | ZERO(&dav1, sizeof(WebdavBackend)); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1675 | dav1.opt_delete = test_backend_webdav_delete; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1676 | dav1.opt_delete_finish = test_backend_webdav_delete_finish; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1677 | delete_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1678 | delete_finish_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1679 | rq->davCollection = &dav1; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1680 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1681 | UCX_TEST_BEGIN; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1682 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1683 | // prepare |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1684 | VFSContext *vfs = vfs_request_context(sn, rq); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1685 | int err; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1686 | err = vfs_mkdir(vfs, "/dir1"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1687 | UCX_TEST_ASSERT(err == 0, "mkdir dir1 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1688 | err = vfs_mkdir(vfs, "/dir2"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1689 | UCX_TEST_ASSERT(err == 0, "mkdir dir2 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1690 | err = vfs_mkdir(vfs, "/dir2/dir3"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1691 | UCX_TEST_ASSERT(err == 0, "mkdir dir3 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1692 | err = vfs_mkdir(vfs, "/dir2/dir4"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1693 | UCX_TEST_ASSERT(err == 0, "mkdir dir4 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1694 | err = vfs_mkdir(vfs, "/dir2/dir4/dir5"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1695 | UCX_TEST_ASSERT(err == 0, "mkdir dir5 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1696 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1697 | SYS_FILE f0 = vfs_open(vfs, "/file0", O_CREAT); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1698 | UCX_TEST_ASSERT(f0, "f0 create failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1699 | // no f1 |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1700 | 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
|
1701 | UCX_TEST_ASSERT(f2, "f2 create failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1702 | 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
|
1703 | UCX_TEST_ASSERT(f3, "f3 create failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1704 | 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
|
1705 | UCX_TEST_ASSERT(f4, "f4 create failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1706 | 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
|
1707 | UCX_TEST_ASSERT(f5, "f5 create failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1708 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1709 | // delete single file |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1710 | pblock_replace("path", "/file0", rq->vars); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1711 | err = webdav_delete(NULL, sn, rq); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1712 | UCX_TEST_ASSERT(err == 0, "DELETE /file0 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1713 | 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
|
1714 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1715 | delete_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1716 | pblock_replace("path", "/dir1", rq->vars); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1717 | err = webdav_delete(NULL, sn, rq); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1718 | UCX_TEST_ASSERT(err == 0, "DELETE /dir1 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1719 | 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
|
1720 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1721 | delete_count = 0; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1722 | pblock_replace("path", "/dir2", rq->vars); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1723 | err = webdav_delete(NULL, sn, rq); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1724 | UCX_TEST_ASSERT(err == 0, "DELETE /dir2 failed"); |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1725 | 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
|
1726 | |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1727 | UCX_TEST_END; |
3b302093945c
add webdav_delete tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
245
diff
changeset
|
1728 | } |
251
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1729 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1730 | UCX_TEST(test_webdav_put) { |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1731 | Session *sn; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1732 | Request *rq; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1733 | TestIOStream *st; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1734 | pblock *pb; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1735 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1736 | const char *content_const = "Hello World"; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1737 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1738 | init_test_webdav_method(&sn, &rq, &st, &pb, "PUT", content_const); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1739 | rq->vfs = testvfs_create(sn); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1740 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1741 | UCX_TEST_BEGIN; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1742 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1743 | int err; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1744 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1745 | pblock_replace("path", "/file0", rq->vars); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1746 | err = webdav_put(NULL, sn, rq); |
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 | 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
|
1749 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1750 | VFSContext *vfs = vfs_request_context(sn, rq); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1751 | 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
|
1752 | UCX_TEST_ASSERT(f0, "cannot open file0"); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1753 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1754 | char buf[1024]; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1755 | int r = system_fread(f0, buf, 1024); |
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 | 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
|
1758 | 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
|
1759 | |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1760 | testutil_destroy_session(sn); |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1761 | testutil_iostream_destroy(st); |
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 | UCX_TEST_END; |
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
249
diff
changeset
|
1764 | } |