Sat, 25 Jan 2020 15:34:30 +0100
add proppatch interface
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 | |
239
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
211 | return webdav_create_propfind_operation( |
222
5f05e56cb8e2
create namespace definition lists when properties are added to a multistatus response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
221
diff
changeset
|
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, |
237
ee1680ef1ef2
handle missing properties in multistatus.c
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
233
diff
changeset
|
215 | propfind->properties, |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
216 | requests, |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
217 | response); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
218 | } |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
219 | |
228
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
220 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
221 | 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
|
222 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
223 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
224 | UCX_TEST_BEGIN; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
225 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
226 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
227 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
228 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
229 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
230 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
231 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
232 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
233 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
234 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
235 | 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
|
236 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
237 | 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
|
238 | 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
|
239 | 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
|
240 | 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
|
241 | 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
|
242 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
243 | 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
|
244 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
253 | 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
|
254 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
259 | UCX_TEST_END; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
260 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
261 | testutil_destroy_session(sn); |
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 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
264 | 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
|
265 | Session *sn = testutil_session(); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
266 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
267 | UCX_TEST_BEGIN; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
268 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
269 | WebdavPList *begin = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
270 | WebdavPList *end = NULL; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
271 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
272 | WebdavProperty p1, p2, p3; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
273 | ZERO(&p1, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
274 | ZERO(&p2, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
275 | ZERO(&p3, sizeof(WebdavProperty)); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
276 | int r; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
277 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
278 | 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
|
279 | 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
|
280 | 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
|
281 | 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
286 | UCX_TEST_END; |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
287 | |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
288 | testutil_destroy_session(sn); |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
289 | } |
c0afce708b1d
add tests for some webdav plist util functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
290 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
291 | 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
|
292 | 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
|
293 | 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
|
294 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | 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
|
296 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
297 | 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
|
298 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
299 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
300 | // ----------------- TEST_PROPFIND1 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | // 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
|
302 | 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
|
303 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
304 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
305 | 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 | 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
|
307 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
308 | |
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, "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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | 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
|
314 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
315 | // 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
|
316 | 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
|
317 | 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
|
318 | !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
|
319 | "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
|
320 | 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
|
321 | !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
|
322 | "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
|
323 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | // 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
|
325 | 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
|
326 | 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
|
327 | 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
|
328 | !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
|
329 | "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
|
330 | 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
|
331 | !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
|
332 | "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
|
333 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
334 | 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
|
335 | 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
|
336 | 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
|
337 | 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
|
338 | 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
|
339 | 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
|
340 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | // 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
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | !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
|
346 | "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
|
347 | 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
|
348 | !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
|
349 | "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
|
350 | 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
|
351 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | // ----------------- TEST_PROPFIND2 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | // 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
|
355 | 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
|
356 | sn, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
357 | rq, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | 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 | 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
|
360 | &error); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | |
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, "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
|
363 | 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
|
364 | 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
|
365 | 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
|
366 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
367 | // 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
|
368 | 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
|
369 | 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
|
370 | !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
|
371 | "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
|
372 | 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
|
373 | !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
|
374 | "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
|
375 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
376 | // 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
|
377 | 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
|
378 | 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
|
379 | 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
|
380 | !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
|
381 | "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
|
382 | 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
|
383 | !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
|
384 | "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
|
385 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
386 | // 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | !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
|
391 | "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
|
392 | 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
|
393 | !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
|
394 | "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
|
395 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | // 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
|
397 | 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
|
398 | 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
|
399 | 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
|
400 | !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
|
401 | "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
|
402 | 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
|
403 | !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
|
404 | "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
|
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 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
408 | // ----------------- TEST_PROPFIND3 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
409 | // test allprop |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
410 | 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
|
411 | |
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, "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
|
413 | 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
|
414 | 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
|
415 | 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
|
416 | 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
|
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 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | // ----------------- TEST_PROPFIND4 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
421 | // test propname |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
422 | 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
|
423 | |
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, "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
|
425 | 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
|
426 | 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
|
427 | 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
|
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 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
431 | // ----------------- TEST_PROPFIND5 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
432 | // 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
|
433 | 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
|
434 | |
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, "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
|
436 | 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
|
437 | 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
|
438 | 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
|
439 | 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
|
440 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
441 | // 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | !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
|
446 | "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
|
447 | 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
|
448 | !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
|
449 | "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
|
450 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
451 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
452 | UCX_TEST_ASSERT(elm, "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
|
453 | elm = elm->next; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | UCX_TEST_ASSERT(elm, "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
|
455 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
456 | // 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
|
457 | 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
|
458 | 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
|
459 | 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
|
460 | !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
|
461 | "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
|
462 | 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
|
463 | !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
|
464 | "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
|
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 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
468 | // ----------------- TEST_PROPFIND6 ----------------- |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
469 | // 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
|
470 | 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
|
471 | |
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, "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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
478 | UCX_TEST_END |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
479 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
480 | 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
|
481 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
483 | UCX_TEST(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
|
484 | 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
|
485 | 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
|
486 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
487 | UCX_TEST_BEGIN |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
488 | 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
|
489 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
490 | 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
|
491 | |
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->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
|
493 | 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
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
499 | !strcmp(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
|
500 | "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
|
501 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
502 | 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
|
503 | |
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->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
|
505 | 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
|
506 | 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
|
507 | 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
|
508 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
509 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
510 | !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
|
511 | "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
|
512 | 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
|
513 | !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
|
514 | "p2: set property 1: wrong name"); |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
515 | 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
|
516 | 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
|
517 | 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
|
518 | "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
|
519 | 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
|
520 | p2set1->content, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
521 | "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
|
522 | 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
|
523 | !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
|
524 | "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
|
525 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
526 | 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
|
527 | 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
|
528 | 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
|
529 | 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
|
530 | "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
|
531 | 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
|
532 | p2set3->next, |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
533 | "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
|
534 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
535 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
536 | 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
|
537 | "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
|
538 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
539 | 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
|
540 | 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
|
541 | "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
|
542 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
543 | 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
|
544 | 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
|
545 | !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
|
546 | "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
|
547 | xmlFree(value1); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
548 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
549 | 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
|
550 | 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
|
551 | !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
|
552 | "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
|
553 | xmlFree(value2); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
554 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
555 | UCX_TEST_ASSERT( |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
556 | !strcmp(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
|
557 | "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
|
558 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
559 | 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
|
560 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
561 | 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
|
562 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
563 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
564 | 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
|
565 | 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
|
566 | 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
|
567 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
568 | UCX_TEST_BEGIN |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
569 | 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
|
570 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
571 | 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
|
572 | |
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, "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
|
574 | 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
|
575 | 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
|
576 | 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
|
577 | 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
|
578 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
579 | 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
|
580 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
581 | 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
|
582 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
583 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
584 | UCX_TEST(test_rqbody2buffer) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
585 | Session *sn; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
586 | Request *rq; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
587 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
588 | 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
|
589 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
590 | // TEST 1 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
591 | 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
|
592 | 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
|
593 | 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
|
594 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
595 | 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
|
596 | 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
|
597 | 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
|
598 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
599 | 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
|
600 | 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
|
601 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
602 | // |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
603 | // TEST 2 |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
604 | 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
|
605 | 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
|
606 | 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
|
607 | 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
|
608 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
609 | 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
|
610 | 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
|
611 | 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
|
612 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
613 | 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
|
614 | 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
|
615 | 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
|
616 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
617 | 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
|
618 | 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
|
619 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
620 | UCX_TEST_END; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
621 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
622 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
623 | UCX_TEST(test_webdav_plist_iterator) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
624 | Session *sn; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
625 | Request *rq; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
626 | WebdavPropfindRequest *propfind; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
627 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
628 | UCX_TEST_BEGIN; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
629 | 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
|
630 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
631 | WebdavPList *properties = propfind->properties; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
632 | size_t count = 0; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
633 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
634 | WebdavPListIterator i = webdav_plist_iterator(&properties); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
635 | WebdavPList *cur; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
636 | while(webdav_plist_iterator_next(&i, &cur)) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
637 | switch(i.index) { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
638 | case 0: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
639 | 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
|
640 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
641 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
642 | case 1: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
643 | 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
|
644 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
645 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
646 | case 2: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
647 | 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
|
648 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
649 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
650 | case 3: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
651 | 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
|
652 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
653 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
654 | case 4: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
655 | 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
|
656 | break; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
657 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
658 | case 5: { |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
659 | 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
|
660 | break; |
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 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
663 | count++; |
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 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
666 | UCX_TEST_ASSERT(count == propfind->propcount, "wrong count"); |
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 | |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
669 | UCX_TEST_END; |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
670 | testutil_destroy_session(sn); |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
671 | } |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
672 | |
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
|
673 | 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
|
674 | 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
|
675 | 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
|
676 | 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
|
677 | |
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_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
|
679 | 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
|
680 | |
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 *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
|
682 | 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
|
683 | 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
|
684 | 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
|
685 | |
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 | 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
|
687 | 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
|
688 | |
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 | // 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
|
690 | 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
|
691 | 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
|
692 | 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
|
693 | 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
|
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 | |
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(!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
|
698 | 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
|
699 | 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
|
700 | 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
|
701 | |
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 | // 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
|
703 | 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
|
704 | 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
|
705 | 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
|
706 | 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
|
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 | |
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(!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
|
711 | 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
|
712 | 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
|
713 | |
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 | // 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
|
715 | 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
|
716 | 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
|
717 | 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
|
718 | 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
|
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 | |
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(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
|
723 | 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
|
724 | |
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 | // 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
|
726 | 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
|
727 | 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
|
728 | 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
|
729 | 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
|
730 | 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
|
731 | 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
|
732 | 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
|
733 | 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
|
734 | } |
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 | 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
|
736 | 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
|
737 | 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
|
738 | 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
|
739 | } |
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 | 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
|
741 | 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
|
742 | 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
|
743 | 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
|
744 | } |
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 | 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
|
746 | 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
|
747 | 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
|
748 | 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
|
749 | } |
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 | 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
|
751 | 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
|
752 | 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
|
753 | 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
|
754 | } |
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 | 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
|
756 | 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
|
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 | |
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 | 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
|
762 | |
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 | 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
|
764 | 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
|
765 | } |
ce2866ec97f6
add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
766 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
767 | UCX_TEST(test_msresponse_addproperty) { |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
768 | Session *sn; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
769 | 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
|
770 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
771 | 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
|
772 | |
223
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
773 | WebdavOperation *op = test_propfind_op(&sn, &rq, TEST_PROPFIND1); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
774 | UCX_TEST_ASSERT(op, "init failed"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
775 | UCX_TEST_ASSERT(op->response, "no response"); |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
776 | |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
777 | Multistatus *ms = (Multistatus*)op->response; |
bbaec8415c10
add xml tree iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
222
diff
changeset
|
778 | 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
|
779 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
780 | WebdavProperty p1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
781 | WebdavProperty p[16]; |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
782 | 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
|
783 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
784 | WSNamespace ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
785 | ZERO(&ns1, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
786 | WSNamespace ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
787 | ZERO(&ns2, sizeof(WSNamespace)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
788 | ns1.prefix = (xmlChar*)"x1"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
789 | ns1.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
790 | ns2.prefix = (xmlChar*)"x2"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
791 | ns2.href = (xmlChar*)"http://example.com/test/"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
792 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
793 | WebdavProperty dp1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
794 | ZERO(&dp1, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
795 | dp1.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
796 | dp1.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
797 | dp1.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
798 | dp1.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
799 | dp1.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
800 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
801 | WebdavProperty dp2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
802 | ZERO(&dp2, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
803 | dp2.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
804 | dp2.namespace = &ns1; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
805 | dp2.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
806 | dp2.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
807 | dp2.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
808 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
809 | WebdavProperty dp3; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
810 | ZERO(&dp3, sizeof(WebdavProperty)); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
811 | dp3.name = "dup"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
812 | dp3.namespace = &ns2; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
813 | dp3.value.text.str = "Hello"; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
814 | dp3.value.text.length = 5; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
815 | dp3.vtype = WS_VALUE_TEXT; |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
816 | |
212
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
817 | // init test data |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
818 | p1.namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
819 | p1.lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
820 | p1.name = "test1"; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
821 | p1.value.data = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
822 | p1.vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
823 | |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
824 | for(int i=0;i<8;i++) { |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
825 | p[i].namespace = webdav_dav_namespace(); |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
826 | p[i].name = names[i]; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
827 | p[i].lang = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
828 | p[i].value.node = NULL; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
829 | p[1].vtype = 0; |
d7e7ea9c6bc6
refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
830 | } |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
831 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
832 | 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
|
833 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
834 | 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
|
835 | 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
|
836 | 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
|
837 | |
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[0], 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[1], 404); |
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[2], 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[3], 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[4], 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[5], 403); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
844 | 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
|
845 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
846 | 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
|
847 | |
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, "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
|
849 | 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
|
850 | 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
|
851 | 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
|
852 | |
229
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->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
|
854 | 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
|
855 | 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
|
856 | |
227
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
857 | // new resource for prop duplication tests |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
858 | r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/test"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
859 | UCX_TEST_ASSERT(r, "cannot create second response"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
860 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
861 | r->resource.addproperty((WebdavResource*)r, &dp1, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
862 | UCX_TEST_ASSERT(r->plist_begin, "adding dp1 failed"); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
863 | 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
|
864 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
865 | r->resource.addproperty((WebdavResource*)r, &dp2, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
866 | 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
|
867 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
868 | r->resource.addproperty((WebdavResource*)r, &dp2, 404); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
869 | 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
|
870 | if(r->errors) { |
229
73cb1c98ef7d
replace UcxList with WebdavPList in the multistatus object
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
228
diff
changeset
|
871 | 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
|
872 | } |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
873 | |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
874 | r->resource.addproperty((WebdavResource*)r, &dp3, 200); |
3c23855f7b46
remove nsdef from WebdavProperty
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
875 | 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
|
876 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
877 | 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
|
878 | } |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
879 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
880 | 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
|
881 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
882 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
883 | Session *sn; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
884 | Request *rq; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
885 | WebdavPropfindRequest *propfind; |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
886 | UCX_TEST_BEGIN; |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
887 | 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
|
888 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
889 | 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
|
890 | 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
|
891 | |
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(!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
|
893 | 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
|
894 | 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
|
895 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
896 | 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
|
897 | 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
|
898 | |
215
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
899 | // backend1 removes the first property from the plist |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
900 | // backend2 should have one property less |
68e824ba4a4f
add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
214
diff
changeset
|
901 | |
214
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, "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
|
903 | 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
|
904 | 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
|
905 | 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
|
906 | |
218
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(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
|
908 | 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
|
909 | |
214
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
910 | 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
|
911 | |
4d7ac67a1c14
add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
212
diff
changeset
|
912 | 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
|
913 | } |
218
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
914 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
915 | 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
|
916 | reset_backends(); |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
917 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
918 | Session *sn; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
919 | Request *rq; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
920 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
921 | UCX_TEST_BEGIN; |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
922 | 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
|
923 | 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
|
924 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
925 | 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
|
926 | 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
|
927 | 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
|
928 | 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
|
929 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
930 | |
2ba512b284b9
add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
217
diff
changeset
|
931 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
932 | 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
|
933 | } |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
934 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
935 | UCX_TEST(test_webdav_op_propfind_children) { |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
936 | reset_backends(); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
937 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
938 | Session *sn; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
939 | Request *rq; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
940 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
941 | UCX_TEST_BEGIN; |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
942 | 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
|
943 | UCX_TEST_ASSERT(op, "WebdavOperation not created"); |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
944 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
945 | 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
|
946 | 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
|
947 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
948 | // 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
|
949 | rq->vfs = testvfs_create(sn); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
950 | 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
|
951 | UCX_TEST_ASSERT(vfs, "no vfs"); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
952 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
953 | err = vfs_mkdir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
954 | 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
|
955 | |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
956 | // add some test file to /dir |
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/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
|
958 | 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
|
959 | 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
|
960 | 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
|
961 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
962 | VFSDir *dir = vfs_opendir(vfs, "/dir"); |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
963 | 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
|
964 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
965 | 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
|
966 | 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
|
967 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
968 | // propfind for all children |
221
ff5826fc6a6c
add href parameter to webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
220
diff
changeset
|
969 | 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
|
970 | 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
|
971 | |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
972 | // 1 dir + 4 children |
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
973 | 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
|
974 | 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
|
975 | |
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
976 | UCX_TEST_END; |
220
2915b6c11aec
add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
219
diff
changeset
|
977 | testutil_destroy_session(sn); |
219
dd6c155c082a
add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
218
diff
changeset
|
978 | } |
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
|
979 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
980 | static void init_test_webdav_propfind( |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
981 | Session **out_sn, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
982 | Request **out_rq, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
983 | TestIOStream **out_st, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
984 | pblock **out_pb, |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
985 | const char *request_body) |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
986 | { |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
987 | Session *sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
988 | Request *rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
989 | TestIOStream *st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
990 | pblock *pb; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
991 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
992 | sn = testutil_session(); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
993 | rq = testutil_request(sn->pool, "PROPFIND", "/"); |
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
|
994 | |
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 | 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
|
996 | 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
|
997 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
998 | st = testutil_iostream(2048, TRUE); |
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
|
999 | 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
|
1000 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1001 | testutil_request_body(sn, rq, request_body, strlen(request_body)); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1002 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1003 | pb = pblock_create_pool(sn->pool, 4); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1004 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1005 | *out_sn = sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1006 | *out_rq = rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1007 | *out_st = st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1008 | *out_pb = pb; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1009 | } |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1010 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1011 | UCX_TEST(test_webdav_propfind) { |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1012 | Session *sn; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1013 | Request *rq; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1014 | TestIOStream *st; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1015 | pblock *pb; |
233
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1016 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1017 | 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
|
1018 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1019 | int ret; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1020 | // Test 1 |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1021 | init_test_webdav_propfind(&sn, &rq, &st, &pb, TEST_PROPFIND1); |
233
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1022 | |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1023 | ret = webdav_propfind(pb, sn, rq); |
233
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1024 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1025 | 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
|
1026 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1027 | 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
|
1028 | st->buf->space, st->buf->size, NULL, NULL, 0); |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1029 | UCX_TEST_ASSERT(doc, "propfind1: response is not valid xml"); |
233
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1030 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1031 | //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
|
1032 | |
c5985d2fc19a
add test for webdav_propfind() that checks if the response is valid xml
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
229
diff
changeset
|
1033 | testutil_destroy_session(sn); |
238
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1034 | xmlFreeDoc(doc); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1035 | testutil_iostream_destroy(st); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1036 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1037 | // Test2 |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1038 | init_test_webdav_propfind(&sn, &rq, &st, &pb, TEST_PROPFIND2); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1039 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1040 | ret = webdav_propfind(pb, sn, rq); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1041 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1042 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1043 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1044 | xmlDoc *doc2 = xmlReadMemory( |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1045 | st->buf->space, st->buf->size, NULL, NULL, 0); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1046 | UCX_TEST_ASSERT(doc, "propfind2: response is not valid xml"); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1047 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1048 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1049 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1050 | testutil_destroy_session(sn); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1051 | xmlFreeDoc(doc2); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1052 | testutil_iostream_destroy(st); |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1053 | |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1054 | UCX_TEST_END; |
e820d433f405
fix multistatus response and add propfind tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
237
diff
changeset
|
1055 | |
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
|
1056 | } |
239
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1057 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1058 | /* ------------------------------------------------------------------------- |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1059 | * |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1060 | * PROPPATCH TESTS |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1061 | * |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1062 | * ------------------------------------------------------------------------ */ |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1063 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1064 | static int test_proppatch_init( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1065 | Session **out_sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1066 | Request **out_rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1067 | WebdavProppatchRequest **out_proppatch, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1068 | const char *xml) |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1069 | { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1070 | if(!webdav_is_initialized) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1071 | if(webdav_init(NULL, NULL, NULL) != REQ_PROCEED) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1072 | return 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1073 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1074 | webdav_is_initialized = 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1075 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1076 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1077 | Session *sn = testutil_session(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1078 | Request *rq = testutil_request(sn->pool, "PROPPATCH", "/"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1079 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1080 | int error = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1081 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1082 | WebdavProppatchRequest *proppatch = proppatch_parse( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1083 | sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1084 | rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1085 | xml, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1086 | strlen(xml), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1087 | &error); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1088 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1089 | if(error) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1090 | return 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1091 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1092 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1093 | if(!proppatch || !(proppatch->set || proppatch->remove)) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1094 | return 1; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1095 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1096 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1097 | *out_sn = sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1098 | *out_rq = rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1099 | *out_proppatch = proppatch; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1100 | return 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1101 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1102 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1103 | static WebdavOperation* test_proppatch_op1( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1104 | Session **out_sn, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1105 | Request **out_rq, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1106 | const char *xml) |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1107 | { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1108 | WebdavProppatchRequest *proppatch; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1109 | if(test_proppatch_init(out_sn, out_rq, &proppatch, xml)) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1110 | return NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1111 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1112 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1113 | Multistatus *ms = multistatus_response(*out_sn, *out_rq); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1114 | if(!ms) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1115 | return NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1116 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1117 | // WebdavResponse is the public interface used by Backends |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1118 | // for adding resources to the response |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1119 | WebdavResponse *response = (WebdavResponse*)ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1120 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1121 | return webdav_create_proppatch_operation( |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1122 | (*out_sn), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1123 | (*out_rq), |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1124 | &backend1, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1125 | proppatch, |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1126 | response); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1127 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1128 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1129 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1130 | UCX_TEST(test_proppatch_msresponse) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1131 | Session *sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1132 | Request *rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1133 | WebdavOperation *op; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1134 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1135 | Multistatus *ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1136 | WebdavResource *res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1137 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1138 | WebdavProperty p[16]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1139 | const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1140 | for(int i=0;i<8;i++) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1141 | p[i].namespace = webdav_dav_namespace(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1142 | p[i].name = names[i]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1143 | p[i].lang = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1144 | p[i].value.node = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1145 | p[1].vtype = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1146 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1147 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1148 | UCX_TEST_BEGIN; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1149 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1150 | op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1151 | UCX_TEST_ASSERT(op, "failed to create proppatch operation"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1152 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1153 | ms = (Multistatus*)op->response; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1154 | ms->proppatch = TRUE; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1155 | res = ms->response.addresource(&ms->response, "/"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1156 | UCX_TEST_ASSERT(res, "cannot create resource 1"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1157 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1158 | UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1159 | UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1160 | UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 200), "addproperty 3 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1161 | UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1162 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1163 | UCX_TEST_ASSERT(!res->close(res), "close failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1164 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1165 | MSResponse *msres = (MSResponse*)res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1166 | UCX_TEST_ASSERT(!msres->errors, "error list not NULL"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1167 | UCX_TEST_ASSERT(msres->plist_begin, "elm1 missing"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1168 | UCX_TEST_ASSERT(msres->plist_begin->next, "elm2 missing"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1169 | UCX_TEST_ASSERT(msres->plist_begin->next->next, "elm3 missing"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1170 | UCX_TEST_ASSERT(msres->plist_begin->next->next->next, "elm4 missing"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1171 | UCX_TEST_ASSERT(!msres->plist_begin->next->next->next->next, "count != 4"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1172 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1173 | UCX_TEST_END; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1174 | testutil_destroy_session(sn); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1175 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1176 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1177 | UCX_TEST(test_msresponse_addproperty_with_errors) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1178 | Session *sn; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1179 | Request *rq; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1180 | WebdavOperation *op; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1181 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1182 | Multistatus *ms; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1183 | WebdavResource *res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1184 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1185 | WebdavProperty p[16]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1186 | const char *names[] = {"a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9"}; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1187 | for(int i=0;i<8;i++) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1188 | p[i].namespace = webdav_dav_namespace(); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1189 | p[i].name = names[i]; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1190 | p[i].lang = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1191 | p[i].value.node = NULL; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1192 | p[1].vtype = 0; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1193 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1194 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1195 | UCX_TEST_BEGIN; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1196 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1197 | op = test_proppatch_op1(&sn, &rq, TEST_PROPPATCH2); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1198 | UCX_TEST_ASSERT(op, "failed to create proppatch operation"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1199 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1200 | ms = (Multistatus*)op->response; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1201 | ms->proppatch = TRUE; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1202 | res = ms->response.addresource(&ms->response, "/"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1203 | UCX_TEST_ASSERT(res, "cannot create resource 1"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1204 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1205 | UCX_TEST_ASSERT(!res->addproperty(res, &p[0], 200), "addproperty 1 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1206 | UCX_TEST_ASSERT(!res->addproperty(res, &p[1], 200), "addproperty 2 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1207 | UCX_TEST_ASSERT(!res->addproperty(res, &p[2], 409), "addproperty 3 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1208 | UCX_TEST_ASSERT(!res->addproperty(res, &p[3], 200), "addproperty 4 failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1209 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1210 | UCX_TEST_ASSERT(!res->close(res), "close failed"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1211 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1212 | // all properties should have an error status code now |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1213 | // 1 x 409, 3 x 424 |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1214 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1215 | MSResponse *msres = (MSResponse*)res; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1216 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1217 | UCX_TEST_ASSERT(!msres->plist_begin, "plist not NULL"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1218 | UCX_TEST_ASSERT(msres->errors, "error list is NULL"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1219 | UCX_TEST_ASSERT(msres->errors->next, "second error list is missing"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1220 | UCX_TEST_ASSERT(!msres->errors->next->next, "wrong error list size"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1221 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1222 | // We know that we have 2 error lists, one with status code 409 and |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1223 | // the other must have 409. However we don't enforce the order of the |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1224 | // error lists, therefore check both variants |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1225 | if(msres->errors->status == 409) { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1226 | UCX_TEST_ASSERT(msres->errors->next->status == 424, "wrong status code in second err elm"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1227 | UCX_TEST_ASSERT(msres->errors->begin, "missing 409 property"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1228 | UCX_TEST_ASSERT(msres->errors->next->begin, "missing 424 properties"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1229 | } else { |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1230 | UCX_TEST_ASSERT(msres->errors->next->status == 409, "wrong status code in second err elm"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1231 | UCX_TEST_ASSERT(msres->errors->begin, "missing 424 properties"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1232 | UCX_TEST_ASSERT(msres->errors->next->begin, "missing 409 property"); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1233 | } |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1234 | |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1235 | UCX_TEST_END; |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1236 | testutil_destroy_session(sn); |
d5031c30022c
make multistatus response ready for proppatch requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
238
diff
changeset
|
1237 | } |