Sun, 19 Jan 2020 09:31:45 +0100
fix response href
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; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
50 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
51 | // backend2 |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
52 | static int backend2_propfind_init( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
53 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
54 | const char *path, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
55 | WebdavPList **outPList) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
56 | { |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
57 | backend2_init_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
58 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
59 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
60 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
61 | static int backend2_propfind_do( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
62 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
63 | WebdavResponse *response, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
64 | VFS_DIR parent, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
65 | WebdavResource *resource, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
66 | struct stat *s) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
67 | { |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
68 | backend2_propfind_do_count++; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
69 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
70 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
71 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
72 | 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
|
73 | backend2_propfind_finish_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
74 | return 0; |
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 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
77 | static WebdavBackend backend2 = { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
78 | backend2_propfind_init, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
79 | backend2_propfind_do, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
80 | backend2_propfind_finish, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
81 | 0, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
82 | NULL |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
83 | }; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
84 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
85 | // backend1 |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
86 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
87 | static int backend1_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
88 | 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
|
89 | static int backend1_propfind_finish_called = 0; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
90 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
91 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
92 | static int backend1_propfind_init( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
93 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
94 | const char *path, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
95 | WebdavPList **outPList) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
96 | { |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
97 | 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
|
98 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
99 | WebdavPList *plist = *outPList; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
100 | WebdavProperty *p = plist->property; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
101 | if(!strcmp(p->name, "displayname")) { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
102 | plist->next->prev = NULL; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
103 | *outPList = plist->next; // remove first item from plist |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
104 | } else { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
105 | return 1; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
106 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
107 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
108 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
109 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
110 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
111 | static int backend1_propfind_do( |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
112 | WebdavPropfindRequest *propfind, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
113 | WebdavResponse *response, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
114 | VFS_DIR parent, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
115 | WebdavResource *resource, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
116 | struct stat *s) |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
117 | { |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
118 | backend1_propfind_do_count++; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
119 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
120 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
121 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
122 | 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
|
123 | backend1_propfind_finish_called = 1; |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
124 | return 0; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
125 | } |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
126 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
127 | WebdavBackend backend1 = { |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
128 | backend1_propfind_init, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
129 | backend1_propfind_do, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
130 | backend1_propfind_finish, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
131 | 0, |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
132 | &backend2 |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
133 | }; |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
134 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
135 | 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
|
136 | backend1_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
137 | 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
|
138 | backend1_propfind_finish_called = 0; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
139 | backend2_init_called = 0; |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
140 | 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
|
141 | backend2_propfind_finish_called = 0; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
142 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
143 | |
217
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
144 | /* ----------------------------------------------------------------------*/ |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
145 | |
8ed14d76db42
add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
216
diff
changeset
|
146 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
147 | static int test_init( |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
148 | Session **out_sn, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
149 | Request **out_rq, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
150 | WebdavPropfindRequest **out_propfind, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
151 | const char *xml) |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
152 | { |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
153 | if(!webdav_is_initialized) { |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
154 | if(webdav_init(NULL, NULL, NULL) != REQ_PROCEED) { |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
155 | return 1; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
156 | } |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
157 | webdav_is_initialized = 1; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
158 | } |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
159 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
160 | Session *sn = testutil_session(); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
161 | Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
162 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
163 | int error = 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
164 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
165 | WebdavPropfindRequest *propfind = propfind_parse( |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
166 | sn, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
167 | rq, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
168 | xml, |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
169 | strlen(xml), |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
170 | &error); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
171 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
172 | if(error) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
173 | return 1; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
174 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
175 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
176 | if(!propfind || !propfind->properties) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
177 | return 1; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
178 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
179 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
180 | *out_sn = sn; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
181 | *out_rq = rq; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
182 | *out_propfind = propfind; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
183 | return 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
184 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
185 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
186 | 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
|
187 | Session **out_sn, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
188 | Request **out_rq, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
189 | const char *xml) |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
190 | { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
191 | WebdavPropfindRequest *propfind; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
192 | 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
|
193 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
194 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
195 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
196 | 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
|
197 | if(!ms) { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
198 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
199 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
200 | // 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
|
201 | // 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
|
202 | 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
|
203 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
204 | UcxList *requests = NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
205 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
206 | // Initialize all Webdav Backends |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
207 | if(webdav_propfind_init(&backend1, propfind, "/", &requests)) { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
208 | return NULL; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
209 | } |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
210 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
211 | return webdav_operation_create( |
222
5f05e56cb8e2
create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
212 | (*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
|
213 | (*out_rq), |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
214 | &backend1, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
215 | requests, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
216 | response); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
217 | } |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
218 | |
228
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
219 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
220 | UCX_TEST(test_webdav_plist_add) { |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
221 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
222 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
223 | UCX_TEST_BEGIN; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
224 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
225 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
226 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
227 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
228 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
229 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
230 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
231 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
232 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
233 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
234 | 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
|
235 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
236 | UCX_TEST_ASSERT(r == 0, "add 1 failed"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
237 | UCX_TEST_ASSERT(begin && end, "ptrs are NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
238 | UCX_TEST_ASSERT(begin == end, "begin != end"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
239 | UCX_TEST_ASSERT(begin->prev == NULL, "begin->prev not NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
240 | UCX_TEST_ASSERT(begin->next == NULL, "begin->next not NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
241 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
242 | 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
|
243 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
244 | UCX_TEST_ASSERT(r == 0, "add 2 failed"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
245 | UCX_TEST_ASSERT(begin && end, "add2: ptrs are NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
246 | UCX_TEST_ASSERT(begin->next, "begin->next is NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
247 | UCX_TEST_ASSERT(begin->next == end, "begin->next != end"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
248 | UCX_TEST_ASSERT(end->prev = begin, "end->prev != begin"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
249 | UCX_TEST_ASSERT(begin->prev == NULL, "add2: begin->prev not NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
250 | UCX_TEST_ASSERT(end->next == NULL, "add2: end->next not NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
251 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
252 | 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
|
253 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
254 | UCX_TEST_ASSERT(r == 0, "add 3 failed"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
255 | UCX_TEST_ASSERT(begin && end, "add3: ptrs are NULL"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
256 | UCX_TEST_ASSERT(begin->next == end->prev, "begin->next != end->prev"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
257 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
258 | UCX_TEST_END; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
259 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
260 | testutil_destroy_session(sn); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
261 | } |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
262 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
263 | UCX_TEST(test_webdav_plist_size) { |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
264 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
265 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
266 | UCX_TEST_BEGIN; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
267 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
268 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
269 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
270 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
271 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
272 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
273 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
274 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
275 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
276 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
277 | UCX_TEST_ASSERT(webdav_plist_size(begin) == 0, "size != 0"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
278 | 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
|
279 | UCX_TEST_ASSERT(webdav_plist_size(begin) == 1, "size != 1"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
280 | 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
|
281 | UCX_TEST_ASSERT(webdav_plist_size(begin) == 2, "size != 2"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
282 | 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
|
283 | UCX_TEST_ASSERT(webdav_plist_size(begin) == 3, "size != 3"); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
284 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
285 | UCX_TEST_END; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
286 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
287 | testutil_destroy_session(sn); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
288 | } |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
289 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
290 | UCX_TEST(test_propfind_parse) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
291 | 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
|
292 | 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
|
293 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
294 | UCX_TEST_BEGIN |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | int error = 0; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
297 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
298 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
299 | // ----------------- TEST_PROPFIND1 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
300 | // test basic propfind request |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | WebdavPropfindRequest *p1 = propfind_parse( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
302 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
303 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
304 | TEST_PROPFIND1, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
305 | strlen(TEST_PROPFIND1), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
306 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
307 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
308 | UCX_TEST_ASSERT(p1, "p1 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
309 | UCX_TEST_ASSERT(p1->properties, "p1: no props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
310 | UCX_TEST_ASSERT(!p1->allprop, "p1: allprop is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
311 | UCX_TEST_ASSERT(!p1->propname, "p1: propname is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
312 | UCX_TEST_ASSERT(p1->propcount == 6, "p1: wrong propcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
313 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
314 | // property 1: DAV:displayname |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
315 | WebdavPList *elm = p1->properties; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
316 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
317 | !strcmp(elm->property->name, "displayname"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
318 | "p1: property 1 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
319 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
321 | "p1: property 1 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
322 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
323 | // property 2: DAV:getcontentlength |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
325 | UCX_TEST_ASSERT(elm, "p1: property 2 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
326 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
327 | !strcmp(elm->property->name, "getcontentlength"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
328 | "p1: property 2 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
329 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
330 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
331 | "p1: property 2 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
332 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
333 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
334 | UCX_TEST_ASSERT(elm, "p1: property 3 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
335 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
336 | UCX_TEST_ASSERT(elm, "p1: property 4 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
337 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
338 | UCX_TEST_ASSERT(elm, "p1: property 5 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
339 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
340 | // property 6: DAV:getetag |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
342 | UCX_TEST_ASSERT(elm, "p1: property 6 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
343 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
344 | !strcmp(elm->property->name, "getetag"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | "p1: property 6 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | "p1: property 6 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | UCX_TEST_ASSERT(!elm->next, "p1: should not have property 7"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
351 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | // ----------------- TEST_PROPFIND2 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | // test with multiple namespaces |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | WebdavPropfindRequest *p2 = propfind_parse( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
356 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
357 | TEST_PROPFIND2, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | strlen(TEST_PROPFIND2), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
359 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | UCX_TEST_ASSERT(p2, "p2 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
362 | UCX_TEST_ASSERT(p2->properties, "p2: no props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
363 | UCX_TEST_ASSERT(!p2->allprop, "p2: allprop is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
364 | UCX_TEST_ASSERT(!p2->propname, "p2: propname is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
365 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
366 | // property 1: DAV:resourcetype |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
367 | elm = p2->properties; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
368 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
369 | !strcmp(elm->property->name, "resourcetype"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
370 | "p2: property 1 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
371 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
372 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
373 | "p2: property 1 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
374 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
375 | // property 2: X:testprop |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
376 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
377 | UCX_TEST_ASSERT(elm, "p2: property 2 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
378 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
379 | !strcmp(elm->property->name, "testprop"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
380 | "p2: property 2 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
381 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
382 | !strcmp((char*)elm->property->namespace->href, "http://example.com/"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
383 | "p2: property 2 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
384 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
385 | // property 3: X:name |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
386 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
387 | UCX_TEST_ASSERT(elm, "p2: property 3 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
388 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
389 | !strcmp(elm->property->name, "name"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
390 | "p2: property 3 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
391 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
392 | !strcmp((char*)elm->property->namespace->href, "http://example.com/"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
393 | "p2: property 3 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
394 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
395 | // property 4: Z:testprop |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
397 | UCX_TEST_ASSERT(elm, "p2: property 4 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
398 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
399 | !strcmp(elm->property->name, "testprop"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
400 | "p2: property 4 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
401 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
402 | !strcmp((char*)elm->property->namespace->href, "testns"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
403 | "p2: property 4 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
404 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
405 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
406 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
407 | // ----------------- TEST_PROPFIND3 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
408 | // test allprop |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
409 | WebdavPropfindRequest *p3 = propfind_parse(sn, rq, TEST_PROPFIND3, strlen(TEST_PROPFIND3), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
410 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
411 | UCX_TEST_ASSERT(p3, "p3 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
412 | UCX_TEST_ASSERT(!p3->properties, "p2: has props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
413 | UCX_TEST_ASSERT(p3->allprop, "p2: allprop is FALSE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
414 | UCX_TEST_ASSERT(!p3->propname, "p2: propname is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
415 | UCX_TEST_ASSERT(p3->propcount == 0, "p2: wrong propcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
416 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
417 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
418 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
419 | // ----------------- TEST_PROPFIND4 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | // test propname |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
421 | WebdavPropfindRequest *p4 = propfind_parse(sn, rq, TEST_PROPFIND4, strlen(TEST_PROPFIND4), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
422 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
423 | UCX_TEST_ASSERT(p4, "p4 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
424 | UCX_TEST_ASSERT(!p4->properties, "p2: has props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
425 | UCX_TEST_ASSERT(!p4->allprop, "p2: allprop is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
426 | UCX_TEST_ASSERT(p4->propname, "p2: propname is FALSE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
427 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
428 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
429 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
430 | // ----------------- TEST_PROPFIND5 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
431 | // test duplicate check |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
432 | WebdavPropfindRequest *p5 = propfind_parse(sn, rq, TEST_PROPFIND5, strlen(TEST_PROPFIND5), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
433 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
434 | UCX_TEST_ASSERT(p5, "p5 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
435 | UCX_TEST_ASSERT(p5->properties, "p5: no props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
436 | UCX_TEST_ASSERT(!p5->allprop, "p5: allprop is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
437 | UCX_TEST_ASSERT(!p5->propname, "p5: propname is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
438 | UCX_TEST_ASSERT(p5->propcount == 4, "p5: wrong propcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
439 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
440 | // property 1: DAV:displayname |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
441 | elm = p5->properties; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
442 | UCX_TEST_ASSERT(elm, "p5: property 1 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
443 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
444 | !strcmp(elm->property->name, "displayname"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
445 | "p5: property 1 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
446 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
447 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
448 | "p5: property 1 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
449 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
450 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
451 | UCX_TEST_ASSERT(elm, "p5: property 2 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
452 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
453 | UCX_TEST_ASSERT(elm, "p5: property 3 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
455 | // property 4: DAV:resourcetype |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
456 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
457 | UCX_TEST_ASSERT(elm, "p5: property 4 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
458 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
459 | !strcmp(elm->property->name, "resourcetype"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
460 | "p5: property 4 has wrong name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
461 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
462 | !strcmp((char*)elm->property->namespace->href, "DAV:"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | "p5: property 4 has wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
464 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
465 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
466 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
467 | // ----------------- TEST_PROPFIND6 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
468 | // test prop/allprop mix |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
469 | WebdavPropfindRequest *p6 = propfind_parse(sn, rq, TEST_PROPFIND6, strlen(TEST_PROPFIND6), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
470 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
471 | UCX_TEST_ASSERT(p6, "p5 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
472 | UCX_TEST_ASSERT(!p6->properties, "p5: has props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
473 | UCX_TEST_ASSERT(p6->allprop, "p5: allprop is FALSE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
474 | UCX_TEST_ASSERT(!p6->propname, "p5: propname is TRUE"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
475 | UCX_TEST_ASSERT(p6->propcount == 0, "p5: wrong propcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
476 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
477 | UCX_TEST_END |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
478 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
479 | 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
|
480 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
481 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | UCX_TEST(test_proppatch_parse) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
483 | 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
|
484 | Request *rq = testutil_request(sn->pool, "PROPPATCH", "/"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
485 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
486 | UCX_TEST_BEGIN |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
487 | int error = 0; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
488 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
489 | WebdavProppatchRequest *p1 = proppatch_parse(sn, rq, TEST_PROPPATCH1, strlen(TEST_PROPPATCH1), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
490 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
491 | UCX_TEST_ASSERT(p1->set, "p1: missing set props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
492 | UCX_TEST_ASSERT(!p1->remove, "p1: has remove props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
493 | UCX_TEST_ASSERT(p1->setcount == 2, "p1: wrong setcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
494 | UCX_TEST_ASSERT(p1->set->next, "p1: set plist broken"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
495 | UCX_TEST_ASSERT(!p1->set->next->next, "p1: set plist has no end"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
496 | UCX_TEST_ASSERT(p1->set->property, "p1: missing property ptr in plist"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
497 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
498 | !strcmp(p1->set->property->name, "test"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
499 | "p1: wrong property 1 name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
500 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
501 | WebdavProppatchRequest *p2 = proppatch_parse(sn, rq, TEST_PROPPATCH2, strlen(TEST_PROPPATCH2), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
502 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
503 | UCX_TEST_ASSERT(p2->set, "p2: missing set props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
504 | UCX_TEST_ASSERT(p2->remove, "p2: missing remove props"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
505 | UCX_TEST_ASSERT(p2->setcount == 4, "p2: wrong setcount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
506 | UCX_TEST_ASSERT(p2->removecount == 1, "p2: wrong removecount"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
507 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
508 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
509 | !strcmp((char*)p2->set->property->namespace->href, "http://example.com/"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
510 | "p2: set property 1: wrong namespace"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
511 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
512 | !strcmp(p2->set->property->name, "a"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
513 | "p2: set property 1: wrong name"); |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
514 | WSXmlNode *p2set1 = p2->set->property->value.node; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
515 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
516 | p2set1->type == WS_NODE_TEXT, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
517 | "p2: set property 1: wrong type"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
518 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
519 | p2set1->content, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
520 | "p2: set property 1: no text"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
521 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
522 | !strcmp((char*)p2set1->content, "test"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
523 | "p2: set property 1: wrong value"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
524 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
525 | WSXmlNode *p2set3 = p2->set->next->next->property->value.node; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
526 | UCX_TEST_ASSERT(p2set3, "p2: set property 3 missing"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
527 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
528 | p2set3->type == WS_NODE_TEXT, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
529 | "p2: set property 3: wrong type"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
530 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
531 | p2set3->next, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
532 | "p2: set property 3: missing element X:name"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
533 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
534 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
535 | xmlHasProp(p2set3->next, BAD_CAST"test"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
536 | "p2: set property 3: missing attribute 'test'"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
537 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
538 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
539 | xmlHasProp(p2set3->next, BAD_CAST"abc"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
540 | "p2: set property 3: missing attribute 'abc"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
541 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
542 | xmlChar *value1 = xmlGetProp(p2set3->next, BAD_CAST"test"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
543 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
544 | !strcmp((char*) value1, "test1"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
545 | "p2: set property 3: wrong attribute value 1"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
546 | xmlFree(value1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
547 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
548 | xmlChar *value2 = xmlGetProp(p2set3->next, BAD_CAST"abc"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
549 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
550 | !strcmp((char*) value2, "def"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
551 | "p2: set property 3: wrong attribute value 2"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
552 | xmlFree(value2); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
553 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
554 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
555 | !strcmp(p2->remove->property->name, "e"), |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
556 | "p2: wrong remove property"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
557 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
558 | UCX_TEST_END |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
559 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
560 | 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
|
561 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
562 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
563 | UCX_TEST(test_lock_parse) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
564 | 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
|
565 | 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
|
566 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
567 | UCX_TEST_BEGIN |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
568 | int error = 0; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
569 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
570 | WebdavLockRequest *l1 = lock_parse(sn, rq, TEST_LOCK1, strlen(TEST_LOCK1), &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
571 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
572 | UCX_TEST_ASSERT(l1, "l1 is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
573 | UCX_TEST_ASSERT(l1->type == WEBDAV_LOCK_WRITE, "l1: wrong type"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
574 | UCX_TEST_ASSERT(l1->scope == WEBDAV_LOCK_SHARED, "l1: wrong scope"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
575 | UCX_TEST_ASSERT(l1->owner, "l1: owner is NULL"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
576 | UCX_TEST_ASSERT(!strcmp((char*)l1->owner->content, "User"), "l1: wrong owner"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
577 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
578 | UCX_TEST_END |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
579 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
580 | 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
|
581 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
582 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
583 | UCX_TEST(test_rqbody2buffer) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
584 | Session *sn; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
585 | Request *rq; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
586 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
587 | UCX_TEST_BEGIN; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
588 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
589 | // TEST 1 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
590 | 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
|
591 | rq = testutil_request(sn->pool, "PUT", "/"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
592 | testutil_request_body(sn, rq, "Hello World!", 12); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
593 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
594 | UcxBuffer *b1 = rqbody2buffer(sn, rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
595 | UCX_TEST_ASSERT(b1->size == 12, "b1: wrong size"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
596 | UCX_TEST_ASSERT(!memcmp(b1->space,"Hello World!",12), "b1: wrong content"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
597 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
598 | ucx_buffer_free(b1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
599 | testutil_destroy_session(sn); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
600 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
601 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
602 | // TEST 2 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
603 | size_t len1 = 25000; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
604 | unsigned char *body1 = malloc(len1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
605 | for(int i=0;i<len1;i++) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
606 | body1[i] = i; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
607 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
608 | 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
|
609 | rq = testutil_request(sn->pool, "PUT", "/"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
610 | testutil_request_body(sn, rq, (char*)body1, len1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
611 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
612 | UcxBuffer *b2 = rqbody2buffer(sn, rq); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
613 | UCX_TEST_ASSERT(b2->size == len1, "b2: wrong size"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
614 | UCX_TEST_ASSERT(!memcmp(b2->space, body1, len1), "b2: wrong content"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
615 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
616 | ucx_buffer_free(b2); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
617 | testutil_destroy_session(sn); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
618 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
619 | UCX_TEST_END; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
620 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
621 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
622 | UCX_TEST(test_webdav_plist_iterator) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
623 | Session *sn; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
624 | Request *rq; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
625 | WebdavPropfindRequest *propfind; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
626 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
627 | UCX_TEST_BEGIN; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
628 | UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
629 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
630 | WebdavPList *properties = propfind->properties; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
631 | size_t count = 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
632 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
633 | WebdavPListIterator i = webdav_plist_iterator(&properties); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
634 | WebdavPList *cur; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
635 | while(webdav_plist_iterator_next(&i, &cur)) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
636 | switch(i.index) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
637 | case 0: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
638 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "displayname"), "wrong property 1"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
639 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
640 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
641 | case 1: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
642 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontentlength"), "wrong property 2"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
643 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
644 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
645 | case 2: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
646 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "getcontenttype"), "wrong property 3"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
647 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
648 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
649 | case 3: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
650 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "getlastmodified"), "wrong property 4"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
651 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
652 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
653 | case 4: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
654 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "resourcetype"), "wrong property 5"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
655 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
656 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
657 | case 5: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
658 | UCX_TEST_ASSERT(!strcmp(cur->property->name, "getetag"), "wrong property 6"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
659 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
660 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
661 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
662 | count++; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
663 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
664 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
665 | UCX_TEST_ASSERT(count == propfind->propcount, "wrong count"); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
666 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
667 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
668 | UCX_TEST_END; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
669 | testutil_destroy_session(sn); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
670 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
671 | |
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
|
672 | UCX_TEST(test_webdav_plist_iterator_remove_current) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
673 | 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
|
674 | 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
|
675 | 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
|
676 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
677 | UCX_TEST_BEGIN; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
678 | UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
679 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
680 | WebdavPList *properties1 = webdav_plist_clone(sn->pool, propfind->properties); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
681 | WebdavPList *properties2 = webdav_plist_clone(sn->pool, propfind->properties); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
682 | WebdavPList *properties3 = webdav_plist_clone(sn->pool, propfind->properties); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
683 | WebdavPList *properties4 = webdav_plist_clone(sn->pool, propfind->properties); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
684 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
685 | WebdavPListIterator i; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
686 | WebdavPList *cur; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
687 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
688 | // test removal of first element |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
689 | i = webdav_plist_iterator(&properties1); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
690 | while(webdav_plist_iterator_next(&i, &cur)) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
691 | if(i.index == 0) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
692 | webdav_plist_iterator_remove_current(&i); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
693 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
694 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
695 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
696 | UCX_TEST_ASSERT(!properties1->prev, "test1: prev not cleared"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
697 | UCX_TEST_ASSERT(!strcmp(properties1->property->name, "getcontentlength"), "test1: wrong property"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
698 | UCX_TEST_ASSERT(!strcmp(properties1->next->property->name, "getcontenttype"), "test1: wrong property 2"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
699 | UCX_TEST_ASSERT(properties1->next->prev == properties1, "test1: wrong link"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
700 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
701 | // test removal of second element |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
702 | i = webdav_plist_iterator(&properties2); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
703 | while(webdav_plist_iterator_next(&i, &cur)) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
704 | if(i.index == 1) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
705 | webdav_plist_iterator_remove_current(&i); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
706 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
707 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
708 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
709 | UCX_TEST_ASSERT(!strcmp(properties2->next->property->name, "getcontenttype"), "test2: wrong property"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
710 | UCX_TEST_ASSERT(properties2->next->prev == properties2, "test2: wrong link"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
711 | UCX_TEST_ASSERT(webdav_plist_size(properties2) == 5, "test2: wrong size"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
712 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
713 | // remove last element |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
714 | i = webdav_plist_iterator(&properties3); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
715 | while(webdav_plist_iterator_next(&i, &cur)) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
716 | if(i.index == 5) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
717 | webdav_plist_iterator_remove_current(&i); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
718 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
719 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
720 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
721 | UCX_TEST_ASSERT(webdav_plist_size(properties3) == 5, "test3: wrong size"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
722 | UCX_TEST_ASSERT(!strcmp(properties3->next->next->next->next->property->name, "resourcetype"), "test2: wrong property"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
723 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
724 | // remove all elements |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
725 | i = webdav_plist_iterator(&properties4); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
726 | while(webdav_plist_iterator_next(&i, &cur)) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
727 | webdav_plist_iterator_remove_current(&i); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
728 | switch(i.index) { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
729 | case 0: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
730 | UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontentlength"), "test4: wrong property 2"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
731 | UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (0)"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
732 | break; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
733 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
734 | case 1: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
735 | UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontenttype"), "test4: wrong property 3"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
736 | UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (1)"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
737 | break; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
738 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
739 | case 2: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
740 | UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getlastmodified"), "test4: wrong property 4"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
741 | UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (2)"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
742 | break; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
743 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
744 | case 3: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
745 | UCX_TEST_ASSERT(!strcmp(properties4->property->name, "resourcetype"), "test4: wrong property 5"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
746 | UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (3)"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
747 | break; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
748 | } |
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 | case 4: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
750 | UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getetag"), "test4: wrong property 6"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
751 | UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (4)"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
752 | break; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
753 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
754 | default: { |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
755 | UCX_TEST_ASSERT(i.index <= 5, "fail"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
756 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
757 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
758 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
759 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
760 | UCX_TEST_ASSERT(properties4 == NULL, "test4: list not NULL"); |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
761 | |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
762 | UCX_TEST_END; |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
763 | 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
|
764 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
765 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
766 | UCX_TEST(test_msresponse_addproperty) { |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
767 | Session *sn; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
768 | 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
|
769 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
770 | UCX_TEST_BEGIN; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
771 | |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
772 | WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
773 | UCX_TEST_ASSERT(op, "init failed"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
774 | UCX_TEST_ASSERT(op->response, "no response"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
775 | |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
776 | Multistatus *ms = (Multistatus*)op->response; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
777 | MSResponse *r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/"); |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
778 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
779 | WebdavProperty p1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
780 | WebdavProperty p[16]; |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
781 | const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
782 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
783 | WSNamespace ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
784 | ZERO(&ns1, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
785 | WSNamespace ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
786 | ZERO(&ns2, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
787 | ns1.prefix = (xmlChar*)"x1"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
788 | ns1.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
789 | ns2.prefix = (xmlChar*)"x2"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
790 | ns2.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
791 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
792 | WebdavProperty dp1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
793 | ZERO(&dp1, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
794 | dp1.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
795 | dp1.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
796 | dp1.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
797 | dp1.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
798 | dp1.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
799 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
800 | WebdavProperty dp2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
801 | ZERO(&dp2, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
802 | dp2.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
803 | dp2.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
804 | dp2.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
805 | dp2.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
806 | dp2.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
807 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
808 | WebdavProperty dp3; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
809 | ZERO(&dp3, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
810 | dp3.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
811 | dp3.namespace = &ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
812 | dp3.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
813 | dp3.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
814 | dp3.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
815 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
816 | // init test data |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
817 | p1.namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
818 | p1.lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
819 | p1.name = "test1"; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
820 | p1.value.data = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
821 | p1.vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
822 | |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
823 | for(int i=0;i<8;i++) { |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
824 | p[i].namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
825 | p[i].name = names[i]; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
826 | p[i].lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
827 | p[i].value.node = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
828 | p[1].vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
829 | } |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
830 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
831 | UCX_TEST_ASSERT(!r->plist_begin && !r->plist_end, "plist not empty"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
832 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
833 | r->resource.addproperty((WebdavResource*)r, &p1, 200); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
834 | UCX_TEST_ASSERT(r->plist_begin, "!plist_begin"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
835 | UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
836 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
837 | r->resource.addproperty((WebdavResource*)r, &p[0], 404); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
838 | r->resource.addproperty((WebdavResource*)r, &p[1], 404); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
839 | r->resource.addproperty((WebdavResource*)r, &p[2], 403); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
840 | r->resource.addproperty((WebdavResource*)r, &p[3], 403); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
841 | r->resource.addproperty((WebdavResource*)r, &p[4], 403); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
842 | r->resource.addproperty((WebdavResource*)r, &p[5], 403); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
843 | r->resource.addproperty((WebdavResource*)r, &p[6], 500); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
844 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
845 | UCX_TEST_ASSERT(r->plist_begin == r->plist_end, "plist begin != end"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
846 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
847 | UCX_TEST_ASSERT(r->errors, "no prop errors"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
848 | UCX_TEST_ASSERT(r->errors->next, "no second error code"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
849 | UCX_TEST_ASSERT(r->errors->next->next, "no third error code"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
850 | UCX_TEST_ASSERT(!r->errors->next->next->next, "too many error codes"); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
851 | |
229
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
852 | UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 2, "404 list size != 2"); |
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
853 | UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->begin) == 4, "403 list size != 4"); |
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
854 | UCX_TEST_ASSERT(webdav_plist_size(r->errors->next->next->begin) == 1, "500 list size != 1"); |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
855 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
856 | // new resource for prop duplication tests |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
857 | r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
858 | UCX_TEST_ASSERT(r, "cannot create second response"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
859 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
860 | r->resource.addproperty((WebdavResource*)r, &dp1, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
861 | UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
862 | UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: list size not 1"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
863 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
864 | r->resource.addproperty((WebdavResource*)r, &dp2, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
865 | UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 should not work"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
866 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
867 | r->resource.addproperty((WebdavResource*)r, &dp2, 404); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
868 | UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp2 with different status should not work (1)"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
869 | if(r->errors) { |
229
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
870 | UCX_TEST_ASSERT(webdav_plist_size(r->errors->begin) == 0, "dp1: error list not empty"); |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
871 | } |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
872 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
873 | r->resource.addproperty((WebdavResource*)r, &dp3, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
874 | UCX_TEST_ASSERT(!r->plist_begin->next, "dp1: adding dp3 should not work"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
875 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
876 | UCX_TEST_END; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
877 | } |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
878 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
879 | UCX_TEST(test_webdav_propfind_init) { |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
880 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
881 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
882 | Session *sn; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
883 | Request *rq; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
884 | WebdavPropfindRequest *propfind; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
885 | UCX_TEST_BEGIN; |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
886 | UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
887 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
888 | UcxList *requests = NULL; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
889 | int err = webdav_propfind_init(&backend1, propfind, "/", &requests); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
890 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
891 | UCX_TEST_ASSERT(!err, "webdav_propfind_init failed"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
892 | UCX_TEST_ASSERT(requests, "request list is empty"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
893 | UCX_TEST_ASSERT(ucx_list_size(requests), "request list has wrong size"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
894 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
895 | WebdavPropfindRequest *p1 = requests->data; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
896 | WebdavPropfindRequest *p2 = requests->next->data; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
897 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
898 | // backend1 removes the first property from the plist |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
899 | // backend2 should have one property less |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
900 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
901 | UCX_TEST_ASSERT(p1 && p2, "missing requests objects"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
902 | UCX_TEST_ASSERT(p1 != p2, "request objects equal"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
903 | UCX_TEST_ASSERT(p1->properties != p2->properties, "plists equal"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
904 | UCX_TEST_ASSERT(p1->propcount == p2->propcount + 1, "first property not removed"); |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
905 | |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
906 | UCX_TEST_ASSERT(backend1_init_called == 1, "backend1 init not called"); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
907 | UCX_TEST_ASSERT(backend2_init_called == 1, "backend2 init not called"); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
908 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
909 | UCX_TEST_END; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
910 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
911 | 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
|
912 | } |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
913 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
914 | UCX_TEST(test_webdav_op_propfind_begin) { |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
915 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
916 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
917 | Session *sn; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
918 | Request *rq; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
919 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
920 | UCX_TEST_BEGIN; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
921 | WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
922 | UCX_TEST_ASSERT(op, "WebdavOperation not created"); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
923 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
924 | int err = webdav_op_propfind_begin(op, "/", NULL, NULL); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
925 | UCX_TEST_ASSERT(err == 0, "err not 0"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
926 | UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
927 | UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend2 propfind_do not called"); |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
928 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
929 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
930 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
931 | 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
|
932 | } |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
933 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
934 | UCX_TEST(test_webdav_op_propfind_children) { |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
935 | reset_backends(); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
936 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
937 | Session *sn; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
938 | Request *rq; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
939 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
940 | UCX_TEST_BEGIN; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
941 | WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
942 | UCX_TEST_ASSERT(op, "WebdavOperation not created"); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
943 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
944 | int err = webdav_op_propfind_begin(op, "/", NULL, NULL); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
945 | UCX_TEST_ASSERT(err == 0, "propfind_begin error"); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
946 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
947 | // create test vfs with some files (code from test_vfs_readdir) |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
948 | rq->vfs = testvfs_create(sn); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
949 | VFSContext *vfs = vfs_request_context(sn, rq); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
950 | UCX_TEST_ASSERT(vfs, "no vfs"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
951 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
952 | err = vfs_mkdir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
953 | UCX_TEST_ASSERT(err == 0, "error not 0"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
954 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
955 | // add some test file to /dir |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
956 | UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file1", O_CREAT), "creation of file1 failed"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
957 | UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file2", O_CREAT), "creation of file2 failed"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
958 | UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file3", O_CREAT), "creation of file3 failed"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
959 | UCX_TEST_ASSERT(vfs_open(vfs, "/dir/file4", O_CREAT), "creation of file4 failed"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
960 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
961 | VFSDir *dir = vfs_opendir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
962 | UCX_TEST_ASSERT(dir, "dir not opened"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
963 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
964 | UCX_TEST_ASSERT(backend1_propfind_do_count == 1, "backend1 propfind_do not called"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
965 | UCX_TEST_ASSERT(backend2_propfind_do_count == 1, "backend1 propfind_do not called") |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
966 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
967 | // propfind for all children |
221
ff5826fc6a6c
add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
220
diff
changeset
|
968 | err = webdav_op_propfind_children(op, vfs, "/", "/dir"); |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
969 | UCX_TEST_ASSERT(err == 0, "webdav_op_propfind_children failed"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
970 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
971 | // 1 dir + 4 children |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
972 | UCX_TEST_ASSERT(backend1_propfind_do_count == 5, "backend1 propfind_do wrong count"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
973 | UCX_TEST_ASSERT(backend2_propfind_do_count == 5, "backend2 propfind_do wrong count"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
974 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
975 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
976 | testutil_destroy_session(sn); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
977 | } |
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
|
978 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
979 | UCX_TEST(test_webdav_propfind) { |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
980 | Session *sn = testutil_session(); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
981 | Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
982 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
983 | pblock_nvinsert("path", "/", rq->vars); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
984 | pblock_nvinsert("uri", "/", rq->reqpb); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
985 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
986 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
987 | TestIOStream *st = testutil_iostream(2048, TRUE); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
988 | sn->csd = st; |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
989 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
990 | testutil_request_body(sn, rq, TEST_PROPFIND1, strlen(TEST_PROPFIND1)); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
991 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
992 | UCX_TEST_BEGIN; |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
993 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
994 | pblock *pb = pblock_create_pool(sn->pool, 4); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
995 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
996 | int ret = webdav_propfind(pb, sn, rq); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
997 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
998 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
999 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1000 | xmlDoc *doc = xmlReadMemory( |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1001 | st->buf->space, st->buf->size, NULL, NULL, 0); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1002 | UCX_TEST_ASSERT(doc, "response is not valid xml"); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1003 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1004 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1005 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1006 | UCX_TEST_END; |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1007 | testutil_destroy_session(sn); |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1008 | } |