src/server/plugins/postgresql/pgtest.c

Fri, 06 Feb 2026 15:57:37 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 06 Feb 2026 15:57:37 +0100
changeset 664
9b1066313c17
parent 660
f00d03835dd9
permissions
-rw-r--r--

fix pgtest connection string

287
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2022 Olaf Wintermann. All rights reserved.
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
a171da778817 prepare build system for postgresql plugin tests
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
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
30 #include <inttypes.h>
287
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
32 #include "../../util/util.h"
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
33 #include "../../test/testutils.h"
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
34 #include "../../test/webdav.h"
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
35 #include "../../public/nsapi.h"
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
36 #include "../../public/webdav.h"
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
37 #include "../../webdav/webdav.h"
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
38
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
39 #include <cx/string.h>
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
40 #include <cx/buffer.h>
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
41
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
42 #include "pgtest.h"
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
43 #include "vfs.h"
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
44 #include "webdav.h"
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
45
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
46 #include <libpq-fe.h>
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
47
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
48 #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b)
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
49
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
50 #define MAP_GET(map, key) cxMapGet(map, cx_hash_key_str(key))
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
51 #define MAP_PUT(map, key, value) cxMapPut(map, cx_hash_key_str(key), value)
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
52
664
9b1066313c17 fix pgtest connection string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 660
diff changeset
53 static char *pg_connstr = "dbname=test1";
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
54 static int abort_pg_tests = 0;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
55 static PGconn *test_connection;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
56 static ResourceData resdata;
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
57 static PgRepository test_repo;
287
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
59 void debug_print_resources(void) {
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
60 PGresult *result = PQexec(test_connection, "select * from Resource;");
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
61 int n = PQntuples(result);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
62 printf("\nntuples: %d\n-----------------------------------------------\n", n);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
63 printf("%10s %10s %s\n", "resource_id", "parent_id", "nodename");
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
64 for(int i=0;i<n;i++) {
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
65 char *res_id = PQgetvalue(result, i, 0);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
66 char *parent_id = PQgetvalue(result, i, 1);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
67 char *nodename = PQgetvalue(result, i, 2);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
68 printf("%10s %10s %s\n", res_id, parent_id, nodename);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
69 }
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
70 printf("\n");
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
71 }
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
72
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
73 static void test_root_lookup(void) {
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
74 memset(&test_repo, 0, sizeof(PgRepository));
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
75
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
76 int64_t root_id = -1;
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
77 int err = pg_lookup_root(&resdata, "root", &root_id);
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
78 test_repo.root_resource_id = root_id;
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
79
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
80 if(err || root_id < 0) {
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
81 abort_pg_tests = 1;
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
82 }
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
83 }
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
84
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
85 void register_pg_tests(int argc, char **argv, CxTestSuite *suite) {
287
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
87 test_connection = PQconnectdb(pg_connstr);
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
88 if(!test_connection) {
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
89 abort_pg_tests = 1;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
90 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
91
664
9b1066313c17 fix pgtest connection string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 660
diff changeset
92 ConnStatusType status = PQstatus(test_connection);
9b1066313c17 fix pgtest connection string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 660
diff changeset
93 if(status != CONNECTION_OK) {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
94 abort_pg_tests = 1;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
95 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
96
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
97 resdata.data = test_connection;
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
98 test_root_lookup();
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
99
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
100 cx_test_register(suite, test_pg_conn);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
101 if(!abort_pg_tests) {
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
102 cx_test_register(suite, test_pg_lookup_root);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
103
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
104 cx_test_register(suite, test_pg_vfs_open);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
105 cx_test_register(suite, test_pg_vfs_io);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
106 cx_test_register(suite, test_pg_vfs_stat);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
107 cx_test_register(suite, test_pg_vfs_mkdir);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
108 cx_test_register(suite, test_pg_vfs_unlink);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
109 cx_test_register(suite, test_pg_vfs_rmdir);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
110
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
111 cx_test_register(suite, test_pg_webdav_create_from_resdata);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
112 cx_test_register(suite, test_pg_prepare_tests);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
113 cx_test_register(suite, test_pg_webdav_propfind);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
114 cx_test_register(suite, test_pg_webdav_propfind_allprop);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
115 cx_test_register(suite, test_pg_webdav_proppatch_set);
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
116
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
117 PGresult *result = PQexec(test_connection, "BEGIN");
293
d3899857a81d add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 290
diff changeset
118 PQclear(result);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
119 }
287
a171da778817 prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 }
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
121
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
122 static void parse_response_tag(TestMultistatus *ms, xmlNode *node) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
123 // thanks to dav for some of this code
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
124 CxAllocator *a = (CxAllocator*)ms->mp->allocator;
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
125 node = node->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
126
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
127 cxmutstr href = {NULL, 0};
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 415
diff changeset
128 CxMap *properties = cxHashMapCreate(a, CX_STORE_POINTERS, 16);
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
129
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
130 while(node) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
131 if(node->type == XML_ELEMENT_NODE) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
132 if(xstreq(node->name, "href")) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
133 xmlNode *href_node = node->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
134 if(href_node->type != XML_TEXT_NODE) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
135 return;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
136 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
137 href = cx_strdup_a(a, cx_str((const char*)href_node->content));
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
138 } else if(xstreq(node->name, "propstat")) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
139 xmlNode *n = node->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
140 xmlNode *prop_node = NULL;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
141 int status_code = 0;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
142 while(n) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
143 if(n->type == XML_ELEMENT_NODE) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
144 if(xstreq(n->name, "prop")) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
145 prop_node = n;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
146 } else if(xstreq(n->name, "status")) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
147 xmlNode *status_node = n->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
148 if(status_node->type != XML_TEXT_NODE) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
149 return;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
150 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
151 cxmutstr status_str = cx_mutstr((char*)status_node->content);
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
152 if(status_str.length < 13) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
153 return;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
154 }
660
f00d03835dd9 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 633
diff changeset
155 status_str = cx_strsubsl(status_str, 9, 3);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
156 cxmutstr status_s = cx_strdup(cx_strcast(status_str));
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
157 status_code = atoi(status_s.ptr);
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
158 free(status_s.ptr);
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
159 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
160 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
161 n = n->next;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
162 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
163
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
164 n = prop_node->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
165 while(n) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
166 if(n->type == XML_ELEMENT_NODE) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
167 TestProperty *property = cxCalloc(ms->mp->allocator, 1, sizeof(TestProperty));
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
168 if(n->ns) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
169 property->prefix = n->ns->prefix ? cx_strdup_a(a, cx_str((const char*)n->ns->prefix)).ptr : NULL;
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
170 property->namespace = n->ns->href ? cx_strdup_a(a, cx_str((const char*)n->ns->href)).ptr : NULL;
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
171 }
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
172 property->name = cx_strdup_a(a, cx_str((const char*)n->name)).ptr;
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
173 property->node = n;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
174 property->status = status_code;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
175 xmlNode *value = n->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
176 if(value && value->type == XML_TEXT_NODE) {
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
177 property->value = cx_strdup_a(a, cx_str((const char*)value->content)).ptr;
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
178 }
403
0f678595d497 fix multistatus response creating namespace definitions twice in some cases
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
179 if(property->namespace && property->name) {
660
f00d03835dd9 update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 633
diff changeset
180 cxmutstr pname = cx_strcat(CX_NULLSTR, 2, cx_str(property->namespace), cx_str(property->name));
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
181 cxMapPut(properties, cx_hash_key(pname.ptr, pname.length), property);
403
0f678595d497 fix multistatus response creating namespace definitions twice in some cases
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
182 free(pname.ptr);
0f678595d497 fix multistatus response creating namespace definitions twice in some cases
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 374
diff changeset
183 }
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
184 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
185 n = n->next;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
186 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
187 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
188 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
189 node = node->next;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
190 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
191
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
192 TestResponse *resp = cxMalloc(a, sizeof(TestResponse));
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
193 resp->href = href.ptr;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
194 resp->properties = properties;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
195
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
196 cxMapPut(ms->responses, cx_hash_key(href.ptr, href.length), resp);
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
197 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
198
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
199 TestMultistatus* test_parse_multistatus(const char *space, size_t size) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
200 xmlDoc *doc = xmlReadMemory(space, size, NULL, NULL, 0);
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
201 if(!doc) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
202 return NULL;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
203 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
204
579
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 490
diff changeset
205 CxMempool *mp = cxMempoolCreateSimple(64);
415
d938228c382e switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 403
diff changeset
206 TestMultistatus *ms = cxMalloc(mp->allocator, sizeof(TestMultistatus));
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
207 ms->doc = doc;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
208 ms->mp = mp;
490
d218607f5a7e update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 415
diff changeset
209 ms->responses = cxHashMapCreate((CxAllocator*)mp->allocator, CX_STORE_POINTERS, 8);
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
210
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
211 // parse response
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
212 xmlNode *xml_root = xmlDocGetRootElement(doc);
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
213 xmlNode *node = xml_root->children;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
214 while(node) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
215 if(node->type == XML_ELEMENT_NODE) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
216 if(xstreq(node->name, "response")) {
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
217 parse_response_tag(ms, node);
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
218 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
219 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
220 node = node->next;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
221 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
222
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
223 return ms;
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
224 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
225
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
226
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
227 void test_multistatus_destroy(TestMultistatus *ms) {
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
228 if(!ms) return;
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
229 xmlFreeDoc(ms->doc);
579
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 490
diff changeset
230 cxMempoolFree(ms->mp);
313
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
231 }
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
232
3ad0b65ec838 test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 307
diff changeset
233
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
234 CX_TEST(test_pg_conn) {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
235 char *msg = test_connection ? PQerrorMessage(test_connection) : "no connection";
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
236
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
237 CX_TEST_DO {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
238
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
239 if(abort_pg_tests) {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
240 int msglen = strlen(msg);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
241 if(msglen > 0 && msg[msglen-1] == '\n') {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
242 msglen--;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
243 }
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
244 fprintf(stdout, "%.*s: ", msglen, msg);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
245 CX_TEST_ASSERT(1 == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
246 } else {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
247 CX_TEST_ASSERT(1 == 1);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
248 }
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
249
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
250 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
251 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
252
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
253 CX_TEST(test_pg_lookup_root) {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
254 CX_TEST_DO {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
255 // test already done in test_root_lookup()
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
256 CX_TEST_ASSERT(!abort_pg_tests);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
257 }
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
258 }
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
259
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
260
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
261 static VFS* create_test_pgvfs(Session *sn, Request *rq) {
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
262 return pg_vfs_create_from_resourcedata(sn, rq, &test_repo, &resdata);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
263 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
264
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
265
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
266 CX_TEST(test_pg_vfs_open) {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
267 Session *sn = testutil_session();
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
268 Request *rq = testutil_request(sn->pool, "PUT", "/");
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
269 rq->vfs = create_test_pgvfs(sn, rq);
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
270 VFSContext *vfs = vfs_request_context(sn, rq);
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
271 SYS_FILE file;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
272
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
273 CX_TEST_DO {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
274
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
275 file = vfs_open(vfs, "/test_notfound1", O_RDONLY);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
276 CX_TEST_ASSERT(!file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
277
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
278 file = vfs_open(vfs, "/test_file1", O_RDWR | O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
279 CX_TEST_ASSERT(file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
280
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
281 vfs_close(file);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
282
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
283 }
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
284
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
285 testutil_destroy_session(sn);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
286 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
287
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
288 CX_TEST(test_pg_vfs_io) {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
289 Session *sn = testutil_session();
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
290 Request *rq = testutil_request(sn->pool, "PUT", "/");
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
291 rq->vfs = create_test_pgvfs(sn, rq);
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
292 VFSContext *vfs = vfs_request_context(sn, rq);
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
293 SYS_FILE file;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
294 SYS_FILE file2;
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
295
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
296 CX_TEST_DO {
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
297
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
298 file = vfs_open(vfs, "/test_f1", O_WRONLY | O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
299 CX_TEST_ASSERT(file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
300
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
301 int w = system_fwrite(file, "test1\n", 6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
302 CX_TEST_ASSERT(w == 6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
303 w = system_fwrite(file, "2", 1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
304 CX_TEST_ASSERT(w == 1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
305
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
306 vfs_close(file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
307
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
308 file = vfs_open(vfs, "/test_f1", O_RDONLY);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
309 file2 = vfs_open(vfs, "/test_f2", O_WRONLY | O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
310 CX_TEST_ASSERT(file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
311 CX_TEST_ASSERT(file2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
312
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
313 char buf[128];
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
314 int r = system_fread(file, buf, 128);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
315 CX_TEST_ASSERT(r == 7);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
316
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
317 w = system_fwrite(file2, buf, r);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
318 CX_TEST_ASSERT(w == 7);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
319
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
320 vfs_close(file);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
321 vfs_close(file2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
322
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
323 file2 = vfs_open(vfs, "/test_f2", O_RDONLY);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
324
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
325 r = system_fread(file, buf, 128);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
326 CX_TEST_ASSERT(r == 7);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
327 CX_TEST_ASSERT(!memcmp(buf, "test1\n2", 7));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
328
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
329 vfs_close(file2);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
330
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
331
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
332 }
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
333
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
334 testutil_destroy_session(sn);
289
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
335 }
285d483db2fb add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 287
diff changeset
336
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
337 CX_TEST(test_pg_vfs_stat) {
290
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
338 Session *sn = testutil_session();
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
339 Request *rq = testutil_request(sn->pool, "PUT", "/");
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
340 rq->vfs = create_test_pgvfs(sn, rq);
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
341 VFSContext *vfs = vfs_request_context(sn, rq);
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
342
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
343 CX_TEST_DO {
293
d3899857a81d add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 290
diff changeset
344
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
345 // testdata, content doesn't matter
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
346 char test1[512];
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
347 memset(test1, 'x', 512);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
348 const int test_len1 = 200;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
349 const int test_len2 = 432;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
350
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
351 SYS_FILE f1 = vfs_open(vfs, "/test_s1", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
352 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
353 system_fwrite(f1, test1, test_len1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
354 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
355
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
356 SYS_FILE f2 = vfs_open(vfs, "/test_s2", O_RDWR|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
357 CX_TEST_ASSERT(f2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
358 system_fwrite(f2, test1, test_len2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
359 vfs_close(f2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
360
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
361 struct stat st1, st2;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
362 int r1 = vfs_stat(vfs, "/test_s1", &st1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
363 int r2 = vfs_stat(vfs, "/test_s2", &st2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
364
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
365 CX_TEST_ASSERT(r1 == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
366 CX_TEST_ASSERT(r2 == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
367
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
368 CX_TEST_ASSERT(st1.st_size == test_len1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
369 CX_TEST_ASSERT(st2.st_size == test_len2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
370
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
371 int testfail = vfs_stat(vfs, "/test_stat_fail", &st1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
372 CX_TEST_ASSERT(testfail != 0);
293
d3899857a81d add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 290
diff changeset
373
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
374 }
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
375
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
376 testutil_destroy_session(sn);
290
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
377 }
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
378
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
379 CX_TEST(test_pg_vfs_mkdir) {
295
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
380 Session *sn = testutil_session();
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
381 Request *rq = testutil_request(sn->pool, "PUT", "/");
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
382 rq->vfs = create_test_pgvfs(sn, rq);
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
383 VFSContext *vfs = vfs_request_context(sn, rq);
290
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
384
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
385 CX_TEST_DO {
295
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
386
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
387 struct stat s;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
388
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
389 SYS_FILE f1 = vfs_open(vfs, "/test_mkdir/file", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
390 CX_TEST_ASSERT(f1 == NULL);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
391
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
392 int r = vfs_mkdir(vfs, "/test_mkdir");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
393 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
394
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
395 r = vfs_stat(vfs, "/test_mkdir", &s);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
396 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
397
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
398 CX_TEST_ASSERT(S_ISDIR(s.st_mode));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
399
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
400 f1 = vfs_open(vfs, "/test_mkdir/file", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
401 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
402 CX_TEST_ASSERT(f1);
350
abba342112c2 fix that pg mkdir can create directories with trailing path separators in the nodename
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
403
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
404 r = vfs_stat(vfs, "/test_mkdir/file", &s);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
405 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
406
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
407 r = vfs_mkdir(vfs, "/test_mkdir/test_sub");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
408 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
409
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
410 r = vfs_stat(vfs, "/test_mkdir/test_sub", &s);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
411 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
412 CX_TEST_ASSERT(S_ISDIR(s.st_mode));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
413
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
414 r = vfs_mkdir(vfs, "/test_mkdir/test_sub/test_sub2/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
415 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
416
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
417 r = vfs_stat(vfs, "/test_mkdir/test_sub/test_sub2/", &s);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
418 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
419 CX_TEST_ASSERT(S_ISDIR(s.st_mode));
295
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
420
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
421 }
295
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
422
73a1243fce15 add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 294
diff changeset
423 testutil_destroy_session(sn);
290
efc10acf539f implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 289
diff changeset
424 }
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
425
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
426 CX_TEST(test_pg_vfs_unlink) {
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
427 Session *sn = testutil_session();
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
428 Request *rq = testutil_request(sn->pool, "PUT", "/");
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
429 rq->vfs = create_test_pgvfs(sn, rq);
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
430 VFSContext *vfs = vfs_request_context(sn, rq);
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
431
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
432 CX_TEST_DO {
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
433
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
434 SYS_FILE f1 = vfs_open(vfs, "/test_unlink1", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
435 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
436 system_fwrite(f1, "test", 4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
437
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
438 PgFile *pgfile = f1->data;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
439 Oid oid = pgfile->oid;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
440
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
441 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
442
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
443 int r = vfs_unlink(vfs, "/test_unlink1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
444 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
445
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
446 f1 = vfs_open(vfs, "/test_unlink1", O_RDONLY);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
447 CX_TEST_ASSERT(f1 == NULL);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
448
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
449 PGresult *result = PQexec(test_connection, "savepoint sp;");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
450 PQclear(result);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
451 int pgfd = lo_open(test_connection, oid, INV_READ);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
452 CX_TEST_ASSERT(pgfd < 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
453 result = PQexec(test_connection, "rollback to savepoint sp;");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
454 PQclear(result);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
455
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
456 r = vfs_unlink(vfs, "/test_unlink1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
457 CX_TEST_ASSERT(r);
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
458
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
459 }
294
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
460
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
461 testutil_destroy_session(sn);
277a5896a2ec implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 293
diff changeset
462 }
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
463
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
464 CX_TEST(test_pg_vfs_rmdir) {
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
465 Session *sn = testutil_session();
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
466 Request *rq = testutil_request(sn->pool, "PUT", "/");
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
467 rq->vfs = create_test_pgvfs(sn, rq);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
468 VFSContext *vfs = vfs_request_context(sn, rq);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
469
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
470 PQexec(test_connection, "delete from Resource where parent_id is not null;");
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
471
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
472 CX_TEST_DO {
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
473
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
474 int r;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
475 SYS_FILE f1;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
476
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
477 // prepare some dirs/files
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
478 r = vfs_mkdir(vfs, "/rmdir_test");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
479 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
480 r = vfs_mkdir(vfs, "/rmdir_test/subdir1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
481 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
482 r = vfs_mkdir(vfs, "/rmdir_test/subdir2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
483 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
484
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
485 f1 = vfs_open(vfs, "/rmdir_test/subdir2/file", O_CREAT|O_WRONLY);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
486 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
487 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
488
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
489 // test rmdir
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
490 r = vfs_rmdir(vfs, "/rmdir_test/subdir1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
491 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
492
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
493 r = vfs_rmdir(vfs, "/rmdir_test/subdir2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
494 CX_TEST_ASSERT(r != 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
495
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
496 r = vfs_unlink(vfs, "/rmdir_test/subdir2/file");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
497 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
498
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
499 r = vfs_rmdir(vfs, "/rmdir_test/subdir2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
500 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
501
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
502 }
296
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
503
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
504 testutil_destroy_session(sn);
78e92337fa4e implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 295
diff changeset
505 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
506
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
507 /* ----------------------------- WebDAV tests ----------------------------- */
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
508
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
509
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
510 static WebdavBackend* create_test_pgdav(Session *sn, Request *rq) {
374
77506ec632a4 use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
511 return pg_webdav_create_from_resdata(sn, rq, &test_repo, &resdata);
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
512 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
513
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
514 CX_TEST(test_pg_webdav_create_from_resdata) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
515 Session *sn = testutil_session();
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
516 Request *rq = testutil_request(sn->pool, "PROPFIND", "/");
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
517
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
518 CX_TEST_DO {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
519
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
520 WebdavBackend *dav = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
521 CX_TEST_ASSERT(dav);
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
522
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
523 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
524 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
525
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
526 CX_TEST(test_pg_prepare_tests) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
527 Session *sn = testutil_session();
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
528 Request *rq = testutil_request(sn->pool, "PUT", "/");
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
529 rq->vfs = create_test_pgvfs(sn, rq);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
530 VFSContext *vfs = vfs_request_context(sn, rq);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
531
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
532 CX_TEST_DO {
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
533
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
534 vfs_mkdir(vfs, "/propfind");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
535 vfs_mkdir(vfs, "/proppatch");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
536 SYS_FILE f1;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
537
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
538 int64_t res1_id, res2_id;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
539
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
540 f1 = vfs_open(vfs, "/propfind/res1", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
541 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
542 res1_id = ((PgFile*)f1->data)->resource_id;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
543 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
544
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
545 f1 = vfs_open(vfs, "/propfind/res2", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
546 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
547 res2_id = ((PgFile*)f1->data)->resource_id;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
548 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
549
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
550 f1 = vfs_open(vfs, "/propfind/res3", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
551 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
552 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
553
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
554 int r = vfs_mkdir(vfs, "/propfind/sub");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
555 CX_TEST_ASSERT(r == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
556
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
557 f1 = vfs_open(vfs, "/propfind/sub/res4", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
558 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
559 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
560
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
561 f1 = vfs_open(vfs, "/proppatch/pp1", O_WRONLY|O_CREAT);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
562 CX_TEST_ASSERT(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
563 vfs_close(f1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
564
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
565 // 2 properties for res1
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
566 char idstr[32];
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
567 snprintf(idstr, 32, "%" PRId64, res1_id);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
568 const char* params[1] = { idstr };
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
569 PGresult *result = PQexecParams(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
570 test_connection,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
571 "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'test', 'testvalue');",
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
572 1, // number of parameters
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
573 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
574 params, // parameter value
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
575 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
576 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
577 0); // 0: result in text format
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
578
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
579 CX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
580 PQclear(result);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
581
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
582 result = PQexecParams(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
583 test_connection,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
584 "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'prop2', 'value2');",
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
585 1, // number of parameters
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
586 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
587 params, // parameter value
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
588 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
589 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
590 0); // 0: result in text format
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
591
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
592 CX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
593 PQclear(result);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
594
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
595 // 1 property for res2
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
596 snprintf(idstr, 32, "%" PRId64, res2_id);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
597 result = PQexecParams(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
598 test_connection,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
599 "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'test', 'res2test');",
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
600 1, // number of parameters
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
601 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
602 params, // parameter value
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
603 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
604 NULL,
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
605 0); // 0: result in text format
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
606
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
607 CX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
608 PQclear(result);
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
609
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
610 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
611
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
612 testutil_destroy_session(sn);
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
613 }
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
614
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
615 CX_TEST(test_pg_webdav_propfind) {
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
616 Session *sn;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
617 Request *rq;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
618 TestIOStream *st;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
619 pblock *pb;
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
620
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
621 CX_TEST_DO {
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
622
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
623 // test data:
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
624 //
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
625 // /propfind/
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
626 // /propfind/res1 (2 properties: test, prop2)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
627 // /propfind/res2 (1 property: test)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
628 // /propfind/res3
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
629 // /propfind/sub
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
630 // /propfind/sub/res4
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
631
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
632 int ret;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
633 // Test 1
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
634 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
635 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
636 pblock_nvinsert("depth", "0", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
637
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
638 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
639
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
640 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
641
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
642 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
643 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
644
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
645 TestResponse *r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
646 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
647
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
648 CX_TEST_ASSERT(cxMapSize(ms->responses) == 1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
649
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
650 TestProperty *p = MAP_GET(r1->properties, "DAV:resourcetype");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
651 CX_TEST_ASSERT(p);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
652 CX_TEST_ASSERT(p->status == 200);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
653
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
654 p = MAP_GET(r1->properties, "DAV:getlastmodified");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
655 CX_TEST_ASSERT(p);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
656 CX_TEST_ASSERT(p->status == 200);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
657
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
658 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
659 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
660 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
661
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
662
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
663 // Test 2
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
664 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
665 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
666 pblock_nvinsert("depth", "1", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
667
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
668 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
669
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
670 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
671
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
672 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
673
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
674 ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
675 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
676
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
677 r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
678 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
679
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
680 CX_TEST_ASSERT(cxMapSize(ms->responses) == 5);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
681
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
682 r1 = MAP_GET(ms->responses, "/propfind/res2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
683 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
684
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
685 p = MAP_GET(r1->properties, "http://example.com/test");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
686 CX_TEST_ASSERT(p);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
687 CX_TEST_ASSERT(p->status == 200);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
688 CX_TEST_ASSERT(!strcmp(p->value, "res2test"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
689
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
690
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
691 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
692 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
693 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
694
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
695
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
696
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
697 // Test 3
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
698 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
699 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
700 pblock_nvinsert("depth", "infinity", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
701
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
702 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
703
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
704 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
705
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
706 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
707
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
708 ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
709 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
710
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
711 r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
712 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
713
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
714 CX_TEST_ASSERT(cxMapSize(ms->responses) == 6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
715
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
716
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
717 r1 = MAP_GET(ms->responses, "/propfind/res1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
718 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
719
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
720 p = MAP_GET(r1->properties, "http://example.com/test");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
721 CX_TEST_ASSERT(p);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
722 CX_TEST_ASSERT(p->status == 200);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
723 CX_TEST_ASSERT(!strcmp(p->value, "testvalue"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
724
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
725 p = MAP_GET(r1->properties, "http://example.com/prop2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
726 CX_TEST_ASSERT(p);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
727 CX_TEST_ASSERT(p->status == 200);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
728 CX_TEST_ASSERT(!strcmp(p->value, "value2"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
729
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
730
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
731 r1 = MAP_GET(ms->responses, "/propfind/sub/res4");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
732 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
733
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
734 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
735 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
736 testutil_iostream_destroy(st);
315
b608b7aa43a6 fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
737
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
738 }
306
e03737cea6e2 add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 298
diff changeset
739 }
316
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
740
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
741
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
742 CX_TEST(test_pg_webdav_propfind_allprop) {
316
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
743 Session *sn;
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
744 Request *rq;
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
745 TestIOStream *st;
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
746 pblock *pb;
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
747
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
748 CX_TEST_DO {
316
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
749
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
750 // test data:
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
751 //
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
752 // /propfind/
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
753 // /propfind/res1 (2 properties: test, prop2)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
754 // /propfind/res2 (1 property: test)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
755 // /propfind/res3
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
756 // /propfind/sub
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
757 // /propfind/sub/res4
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
758
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
759 int ret;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
760 TestResponse *r1;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
761 TestProperty *p;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
762 // Test 1
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
763 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
764 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
765 pblock_nvinsert("depth", "0", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
766
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
767 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
768
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
769 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
770
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
771 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
772 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
773
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
774 r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
775 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
776 CX_TEST_ASSERT(cxMapSize(ms->responses) == 1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
777
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
778 p = MAP_GET(r1->properties, "DAV:resourcetype");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
779 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
780
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
781 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
782 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
783 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
784
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
785 // Test 2
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
786 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
787 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
788 pblock_nvinsert("depth", "1", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
789
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
790 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
791
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
792 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
793
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
794 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
795
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
796 ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
797 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
798
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
799 r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
800 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
801 CX_TEST_ASSERT(cxMapSize(ms->responses) == 5);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
802
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
803 r1 = MAP_GET(ms->responses, "/propfind/res1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
804 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
805
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
806 p = MAP_GET(r1->properties, "DAV:resourcetype");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
807 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
808 p = MAP_GET(r1->properties, "http://example.com/test");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
809 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
810 p = MAP_GET(r1->properties, "http://example.com/prop2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
811 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
812
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
813 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/res2"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
814 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/res3"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
815 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/sub/"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
816
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
817 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
818 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
819 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
820
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
821 // Test 3
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
822 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
823 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
824 pblock_nvinsert("depth", "infinity", rq->headers);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
825
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
826 ret = webdav_propfind(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
827
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
828 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
829
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
830 ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
831 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
832
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
833 r1 = MAP_GET(ms->responses, "/propfind/");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
834 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
835 CX_TEST_ASSERT(cxMapSize(ms->responses) == 6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
836
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
837 r1 = MAP_GET(ms->responses, "/propfind/res1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
838 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
839
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
840 p = MAP_GET(r1->properties, "DAV:resourcetype");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
841 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
842 p = MAP_GET(r1->properties, "http://example.com/test");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
843 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
844 p = MAP_GET(r1->properties, "http://example.com/prop2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
845 CX_TEST_ASSERT(r1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
846
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
847 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/res2"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
848 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/res3"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
849 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/sub/"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
850 CX_TEST_ASSERT(MAP_GET(ms->responses, "/propfind/sub/res4"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
851
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
852 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
853 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
854 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
855 }
316
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
856 }
4090fc1b1c52 add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
857
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
858 CX_TEST(test_pg_webdav_proppatch_set) {
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
859 Session *sn;
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
860 Request *rq;
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
861 TestIOStream *st;
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
862 pblock *pb;
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
863
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
864 CX_TEST_DO {
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
865
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
866 // test data:
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
867 //
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
868 // /propfind/
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
869 // /propfind/res1 (2 properties: test, prop2)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
870 // /propfind/res2 (1 property: test)
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
871 // /propfind/res3
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
872 // /propfind/sub
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
873 // /propfind/sub/res4
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
874
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
875 int ret;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
876 TestResponse *r1;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
877 TestProperty *p;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
878 // Test 1
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
879 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/proppatch/pp1", PG_TEST_PROPPATCH1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
880 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
881
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
882 ret = webdav_proppatch(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
883 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
884
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
885 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
886
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
887 TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
888 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
889
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
890 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
891 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
892 testutil_iostream_destroy(st);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
893
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
894 // Test 2: xml property value
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
895 init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/proppatch/pp1", PG_TEST_PROPPATCH2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
896 rq->davCollection = create_test_pgdav(sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
897
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
898 ret = webdav_proppatch(pb, sn, rq);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
899 CX_TEST_ASSERT(ret == REQ_PROCEED);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
900
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
901 //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
902
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
903 ms = test_parse_multistatus(st->buf->space, st->buf->size);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
904 CX_TEST_ASSERT(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
905
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
906 testutil_destroy_session(sn);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
907 test_multistatus_destroy(ms);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
908 testutil_iostream_destroy(st);
324
44cf877b3d9f add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 319
diff changeset
909
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 584
diff changeset
910 }
318
60870dbac94f add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
911 }

mercurial