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