src/server/test/webdav.c

Tue, 31 Dec 2019 14:53:13 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 31 Dec 2019 14:53:13 +0100
branch
webdav
changeset 220
2915b6c11aec
parent 219
dd6c155c082a
child 221
ff5826fc6a6c
permissions
-rw-r--r--

add test for webdav_op_propfind_children

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
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
43 /* ----------------------------- Test Backends --------------------------*/
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
44
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
45 static int backend2_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
46 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
47 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
48
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
49 // backend2
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
50 static int backend2_propfind_init(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
51 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
52 const char *path,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
53 WebdavPList **outPList)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
54 {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
55 backend2_init_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
56 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
57 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
58
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
59 static int backend2_propfind_do(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
60 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
61 WebdavResponse *response,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
62 VFS_DIR parent,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
63 WebdavResource *resource,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
64 struct stat *s)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
65 {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
66 backend2_propfind_do_count++;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
67 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
68 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
69
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
70 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
71 backend2_propfind_finish_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
72 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
73 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
74
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
75 static WebdavBackend backend2 = {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
76 backend2_propfind_init,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
77 backend2_propfind_do,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
78 backend2_propfind_finish,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
79 0,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
80 NULL
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
81 };
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
82
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
83 // backend1
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
84
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
85 static int backend1_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
86 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
87 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
88
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
89
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
90 static int backend1_propfind_init(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
91 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
92 const char *path,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
93 WebdavPList **outPList)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
94 {
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
95 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
96
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
97 WebdavPList *plist = *outPList;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
98 WebdavProperty *p = plist->property;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
99 if(!strcmp(p->name, "displayname")) {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
100 plist->next->prev = NULL;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
101 *outPList = plist->next; // remove first item from plist
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
102 } else {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
103 return 1;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
104 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
105
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
106 return 0;
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
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
109 static int backend1_propfind_do(
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
110 WebdavPropfindRequest *propfind,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
111 WebdavResponse *response,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
112 VFS_DIR parent,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
113 WebdavResource *resource,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
114 struct stat *s)
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
115 {
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
116 backend1_propfind_do_count++;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
117 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
118 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
119
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
120 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
121 backend1_propfind_finish_called = 1;
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
122 return 0;
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
123 }
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
124
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
125 WebdavBackend backend1 = {
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
126 backend1_propfind_init,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
127 backend1_propfind_do,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
128 backend1_propfind_finish,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
129 0,
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
130 &backend2
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
131 };
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
132
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
133 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
134 backend1_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
135 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
136 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
137 backend2_init_called = 0;
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
138 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
139 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
140 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
141
217
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
142 /* ----------------------------------------------------------------------*/
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
143
8ed14d76db42 add backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 216
diff changeset
144
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
145 static int test_init(
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
146 Session **out_sn,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
147 Request **out_rq,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
148 WebdavPropfindRequest **out_propfind,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
149 const char *xml)
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
150 {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
151 Session *sn = testutil_session();
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
152 Request *rq = testutil_request(sn->pool, "PROPFIND", "/");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
153
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
154 int error = 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
155
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
156 WebdavPropfindRequest *propfind = propfind_parse(
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
157 sn,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
158 rq,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
159 xml,
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
160 strlen(xml),
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
161 &error);
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 if(error) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
164 return 1;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
165 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
166
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
167 if(!propfind || !propfind->properties) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
168 return 1;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
169 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
170
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
171 *out_sn = sn;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
172 *out_rq = rq;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
173 *out_propfind = propfind;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
174 return 0;
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
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
177 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
178 Session **out_sn,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
179 Request **out_rq,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
180 const char *xml)
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
181 {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
182 WebdavPropfindRequest *propfind;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
183 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
184 return NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
185 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
186
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
187 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
188 if(!ms) {
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
189 return NULL;
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 // 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
192 // 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
193 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
194
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
195 UcxList *requests = NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
196
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
197 // 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
198 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
199 return NULL;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
200 }
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
201
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
202 return webdav_operation_create(
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
203 (*out_sn)->pool,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
204 &backend1,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
205 requests,
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
206 response);
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
207 }
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
208
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 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
210 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
211 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
212
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 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
214
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 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
216
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 // ----------------- TEST_PROPFIND1 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 // 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
220 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
221 sn,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 rq,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 TEST_PROPFIND1,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 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
225 &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 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
228 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
229 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
230 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
231 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
232
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 // 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
234 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
235 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
236 !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
237 "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
238 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
239 !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
240 "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
241
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 // 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
243 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
244 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
245 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
246 !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
247 "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
248 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
249 !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
250 "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
251
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 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
253 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
254 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
255 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
256 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
257 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
258
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 // 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
260 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
261 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
262 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
263 !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
264 "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
265 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
266 !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
267 "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
268 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
269
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 // ----------------- TEST_PROPFIND2 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 // 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
273 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
274 sn,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 rq,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 TEST_PROPFIND2,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 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
278 &error);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 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
281 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
282 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
283 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
284
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 // 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
286 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
287 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
288 !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
289 "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
290 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
291 !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
292 "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
293
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 // 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
295 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
296 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
297 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
298 !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
299 "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
300 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
301 !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
302 "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
303
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 // 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
305 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
306 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
307 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
308 !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
309 "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
310 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
311 !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
312 "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
313
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 // property 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
315 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
316 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
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, "testprop"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 "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
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, "testns"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 "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
323
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 // ----------------- TEST_PROPFIND3 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 // test allprop
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 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
329
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(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
331 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
332 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
333 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
334 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
335
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 // ----------------- TEST_PROPFIND4 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 // test propname
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 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
341
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 UCX_TEST_ASSERT(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
343 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
344 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
345 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
346
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 // ----------------- TEST_PROPFIND5 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 // 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
351 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
352
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 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
354 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
355 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
356 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
357 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
358
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 // 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
360 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
361 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
362 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
363 !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
364 "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
365 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
366 !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
367 "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
368
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 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
370 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
371 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
372 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
373
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 // 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
375 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
376 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
377 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
378 !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
379 "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
380 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
381 !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
382 "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
383
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 // ----------------- TEST_PROPFIND6 -----------------
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 // 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
388 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
389
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 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
391 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
392 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
393 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
394 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
395
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 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
397
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 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
399 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 UCX_TEST(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
402 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
403 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
404
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 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
406 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 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
409
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 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
411 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
412 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
413 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
414 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
415 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
416 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
417 !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
418 "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
419
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 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
421
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 UCX_TEST_ASSERT(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
423 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
424 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
425 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
426
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(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 !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
429 "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
430 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
431 !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
432 "p2: set property 1: wrong name");
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
433 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
434 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
435 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
436 "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
437 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
438 p2set1->content,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 "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
440 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
441 !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
442 "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
443
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
444 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
445 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
446 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 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
448 "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
449 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
450 p2set3->next,
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 "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
452
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 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
455 "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
456
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 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
459 "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
460
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 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
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*) value1, "test1"),
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 "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
465 xmlFree(value1);
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 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
468 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
469 !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
470 "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
471 xmlFree(value2);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 UCX_TEST_ASSERT(
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 !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
475 "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
476
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 UCX_TEST_END
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 pool_destroy(sn->pool);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 UCX_TEST(test_lock_parse) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 Session *sn = testutil_session();
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 Request *rq = testutil_request(sn->pool, "LOCK", "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 UCX_TEST_BEGIN
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 int error = 0;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 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
490
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 UCX_TEST_ASSERT(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
492 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
493 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
494 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
495 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
496
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_END
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499 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
500 }
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 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
503 Session *sn;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 Request *rq;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505
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_BEGIN;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 // TEST 1
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 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
510 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
511 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
512
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 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
514 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
515 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
516
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 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
518 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
519
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 //
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 // TEST 2
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522 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
523 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
524 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
525 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
526 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 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
528 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
529 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
530
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 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
532 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
533 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
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_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
536 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
537
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 UCX_TEST_END;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539 }
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
541 UCX_TEST(test_webdav_plist_iterator) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
542 Session *sn;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
543 Request *rq;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
544 WebdavPropfindRequest *propfind;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
545
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
546 UCX_TEST_BEGIN;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
547 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
548
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
549 WebdavPList *properties = propfind->properties;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
550 size_t count = 0;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
551
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
552 WebdavPListIterator i = webdav_plist_iterator(&properties);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
553 WebdavPList *cur;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
554 while(webdav_plist_iterator_next(&i, &cur)) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
555 switch(i.index) {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
556 case 0: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
557 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
558 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
559 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
560 case 1: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
561 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
562 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
563 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
564 case 2: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
565 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
566 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
567 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
568 case 3: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
569 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
570 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
571 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
572 case 4: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
573 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
574 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
575 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
576 case 5: {
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
577 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
578 break;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
579 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
580 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
581 count++;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
582 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
583
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
584 UCX_TEST_ASSERT(count == propfind->propcount, "wrong count");
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
585
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
586
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
587 UCX_TEST_END;
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
588 testutil_destroy_session(sn);
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
589 }
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
590
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
591 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
592 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
593 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
594 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
595
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
596 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
597 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
598
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
599 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
600 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
601 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
602 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
603
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
604 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
605 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
606
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
607 // 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
608 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
609 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
610 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
611 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
612 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
613 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
614
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
615 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
616 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
617 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
618 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
619
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
620 // 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
621 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
622 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
623 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
624 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
625 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
626 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
627
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
628 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
629 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
630 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
631
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
632 // 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
633 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
634 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
635 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
636 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
637 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
638 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
639
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
640 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
641 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
642
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
643 // 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
644 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
645 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
646 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
647 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
648 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
649 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
650 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
651 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
652 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
653 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
654 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
655 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
656 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
657 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
658 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
659 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
660 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
661 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
662 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
663 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
664 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
665 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
666 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
667 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
668 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
669 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
670 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
671 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
672 }
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 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
674 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
675 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
676 }
ce2866ec97f6 add webdav_plist_iterator_remove_current tests and fix some plist related bugs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 215
diff changeset
677 }
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
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(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
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 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
682 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
683 }
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
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
685 UCX_TEST(test_msresponse_addproperty) {
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
686 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
687 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
688 Multistatus *ms = multistatus_response(sn, rq);
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
689 MSResponse *r;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
690
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
691 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
692
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
693 r = (MSResponse*)ms->response.addresource((WebdavResponse*)ms, "/");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
694
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
695 WebdavProperty p1;
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
696 WebdavProperty p[16];
212
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
697 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
698
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
699 // init test data
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
700 p1.namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
701 p1.lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
702 p1.name = "test1";
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
703 p1.value.data = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
704 p1.vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
705
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
706 for(int i=0;i<8;i++) {
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
707 p[i].namespace = webdav_dav_namespace();
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
708 p[i].name = names[i];
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
709 p[i].lang = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
710 p[i].value.node = NULL;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
711 p[1].vtype = 0;
d7e7ea9c6bc6 refactore webdav backend struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 211
diff changeset
712 }
211
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
713
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
714 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
715
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
716 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
717 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
718 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
719
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
720 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
721 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
722 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
723 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
724 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
725 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
726 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
727
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
728 UCX_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
729
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
730 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
731 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
732 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
733 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
734
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
735 UCX_TEST_ASSERT(ucx_list_size(r->errors->begin) == 2, "404 list size != 2");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
736 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->begin) == 4, "403 list size != 4");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
737 UCX_TEST_ASSERT(ucx_list_size(r->errors->next->next->begin) == 1, "500 list size != 1");
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
738
2160585200ac add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
739 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
740 }
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
741
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
742 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
743 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
744
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
745 Session *sn;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
746 Request *rq;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
747 WebdavPropfindRequest *propfind;
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
748 UCX_TEST_BEGIN;
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
749 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
750
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
751 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
752 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
753
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
754 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
755 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
756 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
757
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
758 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
759 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
760
215
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
761 // backend1 removes the first property from the plist
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
762 // backend2 should have one property less
68e824ba4a4f add plist iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 214
diff changeset
763
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
764 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
765 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
766 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
767 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
768
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
769 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
770 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
771
214
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
772 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
773
4d7ac67a1c14 add tests for webdav_propfind_init and fix wrong backend call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 212
diff changeset
774 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
775 }
218
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
776
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
777 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
778 reset_backends();
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
779
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
780 Session *sn;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
781 Request *rq;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
782
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
783 UCX_TEST_BEGIN;
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
784 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
785 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
786
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
787 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
788 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
789 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
790 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
791
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
792
2ba512b284b9 add webdav_op_propfind_begin test that checks backend chaining
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 217
diff changeset
793 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
794 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
795 }
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
796
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
797 UCX_TEST(test_webdav_op_propfind_children) {
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
798 reset_backends();
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
799
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
800 Session *sn;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
801 Request *rq;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
802
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
803 UCX_TEST_BEGIN;
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
804 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
805 UCX_TEST_ASSERT(op, "WebdavOperation not created");
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
806
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
807 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
808 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
809
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
810 // 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
811 rq->vfs = testvfs_create(sn);
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
812 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
813 UCX_TEST_ASSERT(vfs, "no vfs");
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
814
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
815 err = vfs_mkdir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
816 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
817
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
818 // add some test file to /dir
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
819 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
820 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
821 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
822 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
823
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
824 VFSDir *dir = vfs_opendir(vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
825 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
826
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
827 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
828 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
829
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
830 // propfind for all children
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
831 err = webdav_op_propfind_children(op, vfs, "/dir");
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
832 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
833
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
834 // 1 dir + 4 children
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
835 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
836 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
837
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
838 UCX_TEST_END;
220
2915b6c11aec add test for webdav_op_propfind_children
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 219
diff changeset
839 testutil_destroy_session(sn);
219
dd6c155c082a add simple vfs implementation for testing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 218
diff changeset
840 }

mercurial