Sat, 24 Sep 2022 16:19:24 +0200
remove debug code
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 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
39 | #include <ucx/string.h> |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
40 | #include <ucx/utils.h> |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
41 | #include <ucx/buffer.h> |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
42 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
43 | #include "pgtest.h" |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
44 | #include "vfs.h" |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
45 | #include "webdav.h" |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
46 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
47 | #include <libpq-fe.h> |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
48 | |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
49 | #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
|
50 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
51 | static char *pg_connstr = "postgresql://localhost/test1"; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
52 | static int abort_pg_tests = 0; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
53 | static PGconn *test_connection; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
54 | 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
|
55 | static PgRepository test_repo; |
287
a171da778817
prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
296
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
57 | void debug_print_resources(void) { |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
58 | PGresult *result = PQexec(test_connection, "select * from Resource;"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
59 | int n = PQntuples(result); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
60 | printf("\nntuples: %d\n-----------------------------------------------\n", n); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
61 | printf("%10s %10s %s\n", "resource_id", "parent_id", "nodename"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
62 | for(int i=0;i<n;i++) { |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
63 | char *res_id = PQgetvalue(result, i, 0); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
64 | char *parent_id = PQgetvalue(result, i, 1); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
65 | char *nodename = PQgetvalue(result, i, 2); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
66 | printf("%10s %10s %s\n", res_id, parent_id, nodename); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
67 | } |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
68 | printf("\n"); |
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 | |
374
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
71 | 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
|
72 | 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
|
73 | |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
78 | 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
|
79 | 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
|
80 | } |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
81 | } |
296
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
82 | |
287
a171da778817
prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | void register_pg_tests(int argc, char **argv, UcxTestSuite *suite) { |
a171da778817
prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
85 | test_connection = PQconnectdb(pg_connstr); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
86 | if(!test_connection) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
87 | abort_pg_tests = 1; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
88 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
89 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
90 | if(PQstatus(test_connection) != CONNECTION_OK) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
91 | abort_pg_tests = 1; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
92 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
93 | |
374
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
94 | 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
|
95 | test_root_lookup(); |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
96 | |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
97 | ucx_test_register(suite, test_pg_conn); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
98 | if(!abort_pg_tests) { |
374
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
99 | ucx_test_register(suite, test_pg_lookup_root); |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
100 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
101 | ucx_test_register(suite, test_pg_vfs_open); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
102 | ucx_test_register(suite, test_pg_vfs_io); |
293
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
103 | ucx_test_register(suite, test_pg_vfs_stat); |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
104 | ucx_test_register(suite, test_pg_vfs_mkdir); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
105 | ucx_test_register(suite, test_pg_vfs_unlink); |
296
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
106 | ucx_test_register(suite, test_pg_vfs_rmdir); |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
107 | |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
108 | ucx_test_register(suite, test_pg_webdav_create_from_resdata); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
109 | ucx_test_register(suite, test_pg_prepare_tests); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
110 | ucx_test_register(suite, test_pg_webdav_propfind); |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
111 | ucx_test_register(suite, test_pg_webdav_propfind_allprop); |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
112 | ucx_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
|
113 | |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
114 | PGresult *result = PQexec(test_connection, "BEGIN"); |
293
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
115 | PQclear(result); |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
116 | } |
287
a171da778817
prepare build system for postgresql plugin tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | } |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
118 | |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
119 | static void parse_response_tag(TestMultistatus *ms, xmlNode *node) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
120 | // thanks to dav for some of this code |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
121 | UcxAllocator *a = ms->mp->allocator; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
122 | node = node->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
123 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
124 | sstr_t href = {NULL, 0}; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
125 | UcxMap *properties = ucx_map_new_a(ms->mp->allocator, 16); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
126 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
127 | while(node) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
128 | if(node->type == XML_ELEMENT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
129 | if(xstreq(node->name, "href")) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
130 | xmlNode *href_node = node->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
131 | if(href_node->type != XML_TEXT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
132 | return; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
133 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
134 | href = sstrdup_a(ms->mp->allocator, scstr((const char*)href_node->content)); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
135 | } else if(xstreq(node->name, "propstat")) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
136 | xmlNode *n = node->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
137 | xmlNode *prop_node = NULL; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
138 | int status_code = 0; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
139 | while(n) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
140 | if(n->type == XML_ELEMENT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
141 | if(xstreq(n->name, "prop")) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
142 | prop_node = n; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
143 | } else if(xstreq(n->name, "status")) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
144 | xmlNode *status_node = n->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
145 | if(status_node->type != XML_TEXT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
146 | return; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
147 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
148 | sstr_t status_str = sstr((char*)status_node->content); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
149 | if(status_str.length < 13) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
150 | return; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
151 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
152 | status_str = sstrsubsl(status_str, 9, 3); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
153 | sstr_t status_s = sstrdup(status_str); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
154 | status_code = atoi(status_s.ptr); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
155 | free(status_s.ptr); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
156 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
157 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
158 | n = n->next; |
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 = prop_node->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
162 | while(n) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
163 | if(n->type == XML_ELEMENT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
164 | TestProperty *property = ucx_mempool_calloc(ms->mp, 1, sizeof(TestProperty)); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
165 | if(n->ns) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
166 | property->prefix = n->ns->prefix ? sstrdup_a(a, scstr((const char*)n->ns->prefix)).ptr : NULL; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
167 | property->namespace = n->ns->href ? sstrdup_a(a, scstr((const char*)n->ns->href)).ptr : NULL; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
168 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
169 | property->name = sstrdup_a(a, scstr((const char*)n->name)).ptr; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
170 | property->node = n; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
171 | property->status = status_code; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
172 | xmlNode *value = n->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
173 | if(value && value->type == XML_TEXT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
174 | property->value = sstrdup_a(a, scstr((const char*)value->content)).ptr; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
175 | } |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
176 | sstr_t pname = sstrcat(2, sstr(property->namespace), sstr(property->name)); |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
177 | ucx_map_sstr_put(properties, pname, property); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
178 | free(pname.ptr); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
179 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
180 | n = n->next; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
181 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
182 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
183 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
184 | node = node->next; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
185 | } |
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 | TestResponse *resp =almalloc(a, sizeof(TestResponse)); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
188 | resp->href = href.ptr; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
189 | resp->properties = properties; |
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 | ucx_map_sstr_put(ms->responses, href, resp); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
192 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
193 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
194 | 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
|
195 | xmlDoc *doc = xmlReadMemory(space, size, NULL, NULL, 0); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
196 | if(!doc) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
197 | return NULL; |
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 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
200 | UcxMempool *mp = ucx_mempool_new(64); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
201 | TestMultistatus *ms = ucx_mempool_malloc(mp, sizeof(TestMultistatus)); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
202 | ms->doc = doc; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
203 | ms->mp = mp; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
204 | ms->responses = ucx_map_new_a(mp->allocator, 8); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
205 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
206 | // parse response |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
207 | xmlNode *xml_root = xmlDocGetRootElement(doc); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
208 | xmlNode *node = xml_root->children; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
209 | while(node) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
210 | if(node->type == XML_ELEMENT_NODE) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
211 | if(xstreq(node->name, "response")) { |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
212 | parse_response_tag(ms, node); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
213 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
214 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
215 | node = node->next; |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
216 | } |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
217 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
218 | return ms; |
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 | |
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 | void test_multistatus_destroy(TestMultistatus *ms) { |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
223 | if(!ms) return; |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
224 | xmlFreeDoc(ms->doc); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
225 | ucx_mempool_destroy(ms->mp); |
313
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 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
228 | |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
229 | UCX_TEST(test_pg_conn) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
230 | 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
|
231 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
232 | UCX_TEST_BEGIN; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
233 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
234 | if(abort_pg_tests) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
235 | int msglen = strlen(msg); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
236 | if(msglen > 0 && msg[msglen-1] == '\n') { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
237 | msglen--; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
238 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
239 | fprintf(stdout, "%.*s: ", msglen, msg); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
240 | UCX_TEST_ASSERT(1 == 0, "skip pg tests"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
241 | } else { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
242 | UCX_TEST_ASSERT(1 == 1, "ok"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
243 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
244 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
245 | UCX_TEST_END; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
246 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
247 | |
374
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
248 | UCX_TEST(test_pg_lookup_root) { |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
249 | UCX_TEST_BEGIN; |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
250 | |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
251 | // test already done in test_root_lookup() |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
252 | UCX_TEST_ASSERT(!abort_pg_tests, "Lookup failed"); |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
253 | |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
254 | UCX_TEST_END; |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
255 | } |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
256 | |
374
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
257 | |
77506ec632a4
use configured root node from PgRepository in pg vfs/webdav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
350
diff
changeset
|
258 | 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
|
259 | 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
|
260 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
261 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
262 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
263 | UCX_TEST(test_pg_vfs_open) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
264 | Session *sn = testutil_session(); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
265 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
266 | rq->vfs = create_test_pgvfs(sn, rq); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
267 | VFSContext *vfs = vfs_request_context(sn, rq); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
268 | SYS_FILE file; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
269 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
270 | UCX_TEST_BEGIN; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
271 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
272 | file = vfs_open(vfs, "/test_notfound1", O_RDONLY); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
273 | UCX_TEST_ASSERT(!file, "/test_notfound should not exist"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
274 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
275 | file = vfs_open(vfs, "/test_file1", O_RDWR | O_CREAT); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
276 | UCX_TEST_ASSERT(file, "cannot create file 1"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
277 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
278 | vfs_close(file); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
279 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
280 | UCX_TEST_END; |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
281 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
282 | testutil_destroy_session(sn); |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
283 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
284 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
285 | UCX_TEST(test_pg_vfs_io) { |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
286 | Session *sn = testutil_session(); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
287 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
288 | rq->vfs = create_test_pgvfs(sn, rq); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
289 | VFSContext *vfs = vfs_request_context(sn, rq); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
290 | SYS_FILE file; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
291 | SYS_FILE file2; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
292 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
293 | UCX_TEST_BEGIN; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
294 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
295 | file = vfs_open(vfs, "/test_f1", O_WRONLY | O_CREAT); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
296 | UCX_TEST_ASSERT(file, "cannot open file1"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
297 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
298 | int w = system_fwrite(file, "test1\n", 6); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
299 | UCX_TEST_ASSERT(w == 6, "fwrite ret (1)"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
300 | w = system_fwrite(file, "2", 1); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
301 | UCX_TEST_ASSERT(w == 1, "fwrite ret (2)"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
302 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
303 | vfs_close(file); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
304 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
305 | file = vfs_open(vfs, "/test_f1", O_RDONLY); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
306 | file2 = vfs_open(vfs, "/test_f2", O_WRONLY | O_CREAT); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
307 | UCX_TEST_ASSERT(file, "cannot open file1"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
308 | UCX_TEST_ASSERT(file2, "cannot open file2"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
309 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
310 | char buf[128]; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
311 | int r = system_fread(file, buf, 128); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
312 | UCX_TEST_ASSERT(r == 7, "cannot read from file1"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
313 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
314 | w = system_fwrite(file2, buf, r); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
315 | UCX_TEST_ASSERT(w == 7, "cannot write to file2"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
316 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
317 | vfs_close(file); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
318 | vfs_close(file2); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
319 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
320 | file2 = vfs_open(vfs, "/test_f2", O_RDONLY); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
321 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
322 | r = system_fread(file, buf, 128); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
323 | UCX_TEST_ASSERT(r == 7, "fread ret"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
324 | UCX_TEST_ASSERT(!memcmp(buf, "test1\n2", 7), "wrong buffer content after read"); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
325 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
326 | vfs_close(file2); |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
327 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
328 | |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
329 | UCX_TEST_END; |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
330 | |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
331 | testutil_destroy_session(sn); |
289
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
332 | } |
285d483db2fb
add first pg vfs tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
287
diff
changeset
|
333 | |
290
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
334 | UCX_TEST(test_pg_vfs_stat) { |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
335 | Session *sn = testutil_session(); |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
336 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
337 | rq->vfs = create_test_pgvfs(sn, rq); |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
338 | VFSContext *vfs = vfs_request_context(sn, rq); |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
339 | |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
340 | UCX_TEST_BEGIN; |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
341 | |
293
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
342 | // testdata, content doesn't matter |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
343 | char test1[512]; |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
344 | memset(test1, 'x', 512); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
345 | const int test_len1 = 200; |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
346 | const int test_len2 = 432; |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
347 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
348 | SYS_FILE f1 = vfs_open(vfs, "/test_s1", O_WRONLY|O_CREAT); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
349 | UCX_TEST_ASSERT(f1, "cannot open test_s1"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
350 | system_fwrite(f1, test1, test_len1); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
351 | vfs_close(f1); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
352 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
353 | SYS_FILE f2 = vfs_open(vfs, "/test_s2", O_RDWR|O_CREAT); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
354 | UCX_TEST_ASSERT(f2, "cannot open test_s2"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
355 | system_fwrite(f2, test1, test_len2); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
356 | vfs_close(f2); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
357 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
358 | struct stat st1, st2; |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
359 | int r1 = vfs_stat(vfs, "/test_s1", &st1); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
360 | int r2 = vfs_stat(vfs, "/test_s2", &st2); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
361 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
362 | UCX_TEST_ASSERT(r1 == 0, "stat1 failed"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
363 | UCX_TEST_ASSERT(r2 == 0, "stat2 failed"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
364 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
365 | UCX_TEST_ASSERT(st1.st_size == test_len1, "s1 wrong length"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
366 | UCX_TEST_ASSERT(st2.st_size == test_len2, "s2 wrong length"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
367 | |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
368 | int testfail = vfs_stat(vfs, "/test_stat_fail", &st1); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
369 | UCX_TEST_ASSERT(testfail != 0, "stat 3 should fail"); |
d3899857a81d
add pg stat tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
290
diff
changeset
|
370 | |
290
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
371 | UCX_TEST_END; |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
372 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
373 | testutil_destroy_session(sn); |
290
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
374 | } |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
375 | |
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
376 | UCX_TEST(test_pg_vfs_mkdir) { |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
377 | Session *sn = testutil_session(); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
378 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
379 | rq->vfs = create_test_pgvfs(sn, rq); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
380 | VFSContext *vfs = vfs_request_context(sn, rq); |
290
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
381 | |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
382 | UCX_TEST_BEGIN; |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
383 | |
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
|
384 | struct stat s; |
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
|
385 | |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
386 | SYS_FILE f1 = vfs_open(vfs, "/test_mkdir/file", O_WRONLY|O_CREAT); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
387 | UCX_TEST_ASSERT(f1 == NULL, "open should fail"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
388 | |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
389 | int r = vfs_mkdir(vfs, "/test_mkdir"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
390 | UCX_TEST_ASSERT(r == 0, "mkdir failed"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
391 | |
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
|
392 | r = vfs_stat(vfs, "/test_mkdir", &s); |
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
|
393 | UCX_TEST_ASSERT(r == 0, "stat (1) failed"); |
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
|
394 | |
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
|
395 | UCX_TEST_ASSERT(S_ISDIR(s.st_mode), "/test_mkdir is not a directory"); |
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
|
396 | |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
397 | f1 = vfs_open(vfs, "/test_mkdir/file", O_WRONLY|O_CREAT); |
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
|
398 | vfs_close(f1); |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
399 | UCX_TEST_ASSERT(f1, "open failed"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
400 | |
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
|
401 | r = vfs_stat(vfs, "/test_mkdir/file", &s); |
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
|
402 | UCX_TEST_ASSERT(r == 0, "stat (2) failed"); |
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 | |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
404 | r = vfs_mkdir(vfs, "/test_mkdir/test_sub"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
405 | UCX_TEST_ASSERT(r == 0, "mkdir failed (2)"); |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
406 | |
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
|
407 | r = vfs_stat(vfs, "/test_mkdir/test_sub", &s); |
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
|
408 | UCX_TEST_ASSERT(r == 0, "stat (3) failed"); |
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
|
409 | UCX_TEST_ASSERT(S_ISDIR(s.st_mode), "/test_mkdir/test_sub is not a directory"); |
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
|
410 | |
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
|
411 | r = vfs_mkdir(vfs, "/test_mkdir/test_sub/test_sub2/"); |
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
|
412 | UCX_TEST_ASSERT(r == 0, "mkdir failed (4)"); |
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
|
413 | |
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
|
414 | r = vfs_stat(vfs, "/test_mkdir/test_sub/test_sub2/", &s); |
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
|
415 | UCX_TEST_ASSERT(r == 0, "stat (4) failed"); |
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
|
416 | UCX_TEST_ASSERT(S_ISDIR(s.st_mode), "/test_mkdir/test_sub/test_sub2/ is not a directory"); |
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
|
417 | |
295
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
418 | UCX_TEST_END; |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
419 | |
73a1243fce15
add pg mkdir tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
294
diff
changeset
|
420 | testutil_destroy_session(sn); |
290
efc10acf539f
implement pg vfs mkdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
289
diff
changeset
|
421 | } |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
422 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
423 | UCX_TEST(test_pg_vfs_unlink) { |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
424 | Session *sn = testutil_session(); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
425 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
426 | rq->vfs = create_test_pgvfs(sn, rq); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
427 | VFSContext *vfs = vfs_request_context(sn, rq); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
428 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
429 | UCX_TEST_BEGIN; |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
430 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
431 | SYS_FILE f1 = vfs_open(vfs, "/test_unlink1", O_WRONLY|O_CREAT); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
432 | UCX_TEST_ASSERT(f1, "cannot create test file"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
433 | system_fwrite(f1, "test", 4); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
434 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
435 | PgFile *pgfile = f1->data; |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
436 | Oid oid = pgfile->oid; |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
437 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
438 | vfs_close(f1); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
439 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
440 | int r = vfs_unlink(vfs, "/test_unlink1"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
441 | UCX_TEST_ASSERT(r == 0, "unlink failed"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
442 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
443 | f1 = vfs_open(vfs, "/test_unlink1", O_RDONLY); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
444 | UCX_TEST_ASSERT(f1 == NULL, "test file not deleted"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
445 | |
298
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
446 | PGresult *result = PQexec(test_connection, "savepoint sp;"); |
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
447 | PQclear(result); |
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
448 | int pgfd = lo_open(test_connection, oid, INV_READ); |
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
449 | UCX_TEST_ASSERT(pgfd < 0, "large object not deleted"); |
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
450 | result = PQexec(test_connection, "rollback to savepoint sp;"); |
8f5c556120a5
fix error handling in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
297
diff
changeset
|
451 | PQclear(result); |
294
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
452 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
453 | r = vfs_unlink(vfs, "/test_unlink1"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
454 | UCX_TEST_ASSERT(r, "unlink should fail"); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
455 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
456 | UCX_TEST_END; |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
457 | |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
458 | testutil_destroy_session(sn); |
277a5896a2ec
implement pg unlink
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
293
diff
changeset
|
459 | } |
296
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
460 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
461 | UCX_TEST(test_pg_vfs_rmdir) { |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
462 | Session *sn = testutil_session(); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
463 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
464 | rq->vfs = create_test_pgvfs(sn, rq); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
465 | VFSContext *vfs = vfs_request_context(sn, rq); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
466 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
467 | 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
|
468 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
469 | UCX_TEST_BEGIN; |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
470 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
471 | int r; |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
472 | SYS_FILE f1; |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
473 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
474 | // prepare some dirs/files |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
475 | r = vfs_mkdir(vfs, "/rmdir_test"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
476 | UCX_TEST_ASSERT(r == 0, "mkdir failed (1)"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
477 | r = vfs_mkdir(vfs, "/rmdir_test/subdir1"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
478 | UCX_TEST_ASSERT(r == 0, "mkdir failed (2)"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
479 | r = vfs_mkdir(vfs, "/rmdir_test/subdir2"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
480 | UCX_TEST_ASSERT(r == 0, "mkdir failed (3)"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
481 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
482 | f1 = vfs_open(vfs, "/rmdir_test/subdir2/file", O_CREAT|O_WRONLY); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
483 | UCX_TEST_ASSERT(f1, "open failed"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
484 | vfs_close(f1); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
485 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
486 | // test rmdir |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
487 | r = vfs_rmdir(vfs, "/rmdir_test/subdir1"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
488 | UCX_TEST_ASSERT(r == 0, "rmdir failed");; |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
489 | |
297
14cd7137a3a8
handle sql error in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
296
diff
changeset
|
490 | r = vfs_rmdir(vfs, "/rmdir_test/subdir2"); |
14cd7137a3a8
handle sql error in pg_remove_res
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
296
diff
changeset
|
491 | UCX_TEST_ASSERT(r != 0, "rmdir should fail if the dir is not empty"); |
296
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
492 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
493 | r = vfs_unlink(vfs, "/rmdir_test/subdir2/file"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
494 | UCX_TEST_ASSERT(r == 0, "unlink failed"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
495 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
496 | r = vfs_rmdir(vfs, "/rmdir_test/subdir2"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
497 | UCX_TEST_ASSERT(r == 0, "rmdir failed 2"); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
498 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
499 | UCX_TEST_END; |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
500 | |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
501 | testutil_destroy_session(sn); |
78e92337fa4e
implement pg rmdir
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
295
diff
changeset
|
502 | } |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
503 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
504 | /* ----------------------------- WebDAV tests ----------------------------- */ |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
505 | |
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 | 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
|
508 | 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
|
509 | } |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
510 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
511 | UCX_TEST(test_pg_webdav_create_from_resdata) { |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
512 | Session *sn = testutil_session(); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
513 | Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
514 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
515 | UCX_TEST_BEGIN; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
516 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
517 | WebdavBackend *dav = create_test_pgdav(sn, rq); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
518 | UCX_TEST_ASSERT(dav, "cannot create pg dav backend"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
519 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
520 | UCX_TEST_END; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
521 | } |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
522 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
523 | UCX_TEST(test_pg_prepare_tests) { |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
524 | Session *sn = testutil_session(); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
525 | Request *rq = testutil_request(sn->pool, "PUT", "/"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
526 | rq->vfs = create_test_pgvfs(sn, rq); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
527 | VFSContext *vfs = vfs_request_context(sn, rq); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
528 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
529 | UCX_TEST_BEGIN; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
530 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
531 | vfs_mkdir(vfs, "/propfind"); |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
532 | vfs_mkdir(vfs, "/proppatch"); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
533 | SYS_FILE f1; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
534 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
535 | int64_t res1_id, res2_id; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
536 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
537 | f1 = vfs_open(vfs, "/propfind/res1", O_WRONLY|O_CREAT); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
538 | UCX_TEST_ASSERT(f1, "res1 create failed"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
539 | res1_id = ((PgFile*)f1->data)->resource_id; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
540 | vfs_close(f1); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
541 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
542 | f1 = vfs_open(vfs, "/propfind/res2", O_WRONLY|O_CREAT); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
543 | UCX_TEST_ASSERT(f1, "res2 create failed"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
544 | res2_id = ((PgFile*)f1->data)->resource_id; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
545 | vfs_close(f1); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
546 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
547 | f1 = vfs_open(vfs, "/propfind/res3", O_WRONLY|O_CREAT); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
548 | UCX_TEST_ASSERT(f1, "res3 create failed"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
549 | vfs_close(f1); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
550 | |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
551 | int r = vfs_mkdir(vfs, "/propfind/sub"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
552 | UCX_TEST_ASSERT(r == 0, "sub create failed"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
553 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
554 | f1 = vfs_open(vfs, "/propfind/sub/res4", O_WRONLY|O_CREAT); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
555 | UCX_TEST_ASSERT(f1, "res4 create failed"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
556 | vfs_close(f1); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
557 | |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
558 | f1 = vfs_open(vfs, "/proppatch/pp1", O_WRONLY|O_CREAT); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
559 | UCX_TEST_ASSERT(f1, "pp1 create failed"); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
560 | vfs_close(f1); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
561 | |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
562 | // 2 properties for res1 |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
563 | char idstr[32]; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
564 | snprintf(idstr, 32, "%" PRId64, res1_id); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
565 | const char* params[1] = { idstr }; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
566 | PGresult *result = PQexecParams( |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
567 | test_connection, |
317
09676b559091
store property prefix in the database
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
316
diff
changeset
|
568 | "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'test', 'testvalue');", |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
569 | 1, // number of parameters |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
570 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
571 | params, // parameter value |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
572 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
573 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
574 | 0); // 0: result in text format |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
575 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
576 | UCX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK, "cannot create property 1"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
577 | PQclear(result); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
578 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
579 | result = PQexecParams( |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
580 | test_connection, |
317
09676b559091
store property prefix in the database
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
316
diff
changeset
|
581 | "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'prop2', 'value2');", |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
582 | 1, // number of parameters |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
583 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
584 | params, // parameter value |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
585 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
586 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
587 | 0); // 0: result in text format |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
588 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
589 | UCX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK, "cannot create property 1"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
590 | PQclear(result); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
591 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
592 | // 1 property for res2 |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
593 | snprintf(idstr, 32, "%" PRId64, res2_id); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
594 | result = PQexecParams( |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
595 | test_connection, |
317
09676b559091
store property prefix in the database
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
316
diff
changeset
|
596 | "insert into Property(resource_id, prefix, xmlns, pname, pvalue) values ($1, 'x', 'http://example.com/', 'test', 'res2test');", |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
597 | 1, // number of parameters |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
598 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
599 | params, // parameter value |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
600 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
601 | NULL, |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
602 | 0); // 0: result in text format |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
603 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
604 | UCX_TEST_ASSERT(PQresultStatus(result) == PGRES_COMMAND_OK, "cannot create property 1"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
605 | PQclear(result); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
606 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
607 | UCX_TEST_END; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
608 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
609 | testutil_destroy_session(sn); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
610 | } |
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 | UCX_TEST(test_pg_webdav_propfind) { |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
613 | Session *sn; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
614 | Request *rq; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
615 | TestIOStream *st; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
616 | pblock *pb; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
617 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
618 | UCX_TEST_BEGIN; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
619 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
620 | // test data: |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
621 | // |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
622 | // /propfind/ |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
623 | // /propfind/res1 (2 properties: test, prop2) |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
624 | // /propfind/res2 (1 property: test) |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
625 | // /propfind/res3 |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
626 | // /propfind/sub |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
627 | // /propfind/sub/res4 |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
628 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
629 | int ret; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
630 | // Test 1 |
307
8787cb5ebab3
fix href in pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
306
diff
changeset
|
631 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND1); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
632 | rq->davCollection = create_test_pgdav(sn, rq); |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
633 | pblock_nvinsert("depth", "0", rq->headers); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
634 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
635 | ret = webdav_propfind(pb, sn, rq); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
636 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
637 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
638 | |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
639 | TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
640 | UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml"); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
641 | |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
642 | TestResponse *r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
643 | UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
644 | |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
645 | UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
646 | |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
647 | TestProperty *p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
648 | UCX_TEST_ASSERT(p, "propfind1: missing property 'resourcetype'"); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
649 | UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'resourcetype'"); |
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
650 | |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
651 | p = ucx_map_cstr_get(r1->properties, "DAV:getlastmodified"); |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
652 | UCX_TEST_ASSERT(p, "propfind1: missing property 'getlastmodified'"); |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
653 | UCX_TEST_ASSERT(p->status == 200, "propfind1: wrong status code for property 'getlastmodified'"); |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
654 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
655 | testutil_destroy_session(sn); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
656 | test_multistatus_destroy(ms); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
657 | testutil_iostream_destroy(st); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
658 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
659 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
660 | // Test 2 |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
661 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
662 | rq->davCollection = create_test_pgdav(sn, rq); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
663 | pblock_nvinsert("depth", "1", rq->headers); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
664 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
665 | ret = webdav_propfind(pb, sn, rq); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
666 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
667 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
668 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
669 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
670 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
671 | ms = test_parse_multistatus(st->buf->space, st->buf->size); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
672 | UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
673 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
674 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
675 | UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
676 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
677 | UCX_TEST_ASSERT(ms->responses->count == 5, "propfind2: wrong response count"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
678 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
679 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/res2"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
680 | UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res2 response"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
681 | |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
682 | p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
683 | UCX_TEST_ASSERT(p, "propfind2: missing property 'test'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
684 | UCX_TEST_ASSERT(p->status == 200, "propfind2: wrong status code for property 'test'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
685 | UCX_TEST_ASSERT(!strcmp(p->value, "res2test"), "propfind2: wrong property value"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
686 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
687 | |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
688 | testutil_destroy_session(sn); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
689 | test_multistatus_destroy(ms); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
690 | testutil_iostream_destroy(st); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
691 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
692 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
693 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
694 | // Test 3 |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
695 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_PROPFIND2); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
696 | rq->davCollection = create_test_pgdav(sn, rq); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
697 | pblock_nvinsert("depth", "infinity", rq->headers); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
698 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
699 | ret = webdav_propfind(pb, sn, rq); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
700 | |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
701 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
702 | |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
703 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (3) failed"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
704 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
705 | ms = test_parse_multistatus(st->buf->space, st->buf->size); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
706 | UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
707 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
708 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
709 | UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
710 | |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
711 | UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
712 | |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
713 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
714 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
715 | UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res1 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
716 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
717 | p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
718 | UCX_TEST_ASSERT(p, "propfind3: missing property 'test'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
719 | UCX_TEST_ASSERT(p->status == 200, "propfind3: wrong status code for property 'test'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
720 | UCX_TEST_ASSERT(!strcmp(p->value, "testvalue"), "propfind3: wrong property value"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
721 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
722 | p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
723 | UCX_TEST_ASSERT(p, "propfind3: missing property 'prop2'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
724 | UCX_TEST_ASSERT(p->status == 200, "propfind3: wrong status code for property 'prop2'"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
725 | UCX_TEST_ASSERT(!strcmp(p->value, "value2"), "propfind3: wrong property value"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
726 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
727 | |
315
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
728 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"); |
b608b7aa43a6
fix sql query for selecting specific properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
729 | UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/sub/res4 response"); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
730 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
731 | testutil_destroy_session(sn); |
313
3ad0b65ec838
test pg propfind response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
307
diff
changeset
|
732 | test_multistatus_destroy(ms); |
306
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
733 | testutil_iostream_destroy(st); |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
734 | |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
735 | UCX_TEST_END; |
e03737cea6e2
add semi functional pg propfind handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
298
diff
changeset
|
736 | } |
316
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
737 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
738 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
739 | UCX_TEST(test_pg_webdav_propfind_allprop) { |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
740 | Session *sn; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
741 | Request *rq; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
742 | TestIOStream *st; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
743 | pblock *pb; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
744 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
745 | UCX_TEST_BEGIN; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
746 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
747 | // test data: |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
748 | // |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
749 | // /propfind/ |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
750 | // /propfind/res1 (2 properties: test, prop2) |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
751 | // /propfind/res2 (1 property: test) |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
752 | // /propfind/res3 |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
753 | // /propfind/sub |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
754 | // /propfind/sub/res4 |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
755 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
756 | int ret; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
757 | TestResponse *r1; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
758 | TestProperty *p; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
759 | // Test 1 |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
760 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
761 | rq->davCollection = create_test_pgdav(sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
762 | pblock_nvinsert("depth", "0", rq->headers); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
763 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
764 | ret = webdav_propfind(pb, sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
765 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
766 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (1) failed"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
767 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
768 | TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
769 | UCX_TEST_ASSERT(ms, "propfind1: response is not valid xml"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
770 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
771 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
772 | UCX_TEST_ASSERT(r1, "propfind1: missing /propfind/ response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
773 | UCX_TEST_ASSERT(ms->responses->count == 1, "propfind1: wrong response count"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
774 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
775 | p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
776 | UCX_TEST_ASSERT(r1, "propfind1: missing resourcetype property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
777 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
778 | testutil_destroy_session(sn); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
779 | test_multistatus_destroy(ms); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
780 | testutil_iostream_destroy(st); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
781 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
782 | // Test 2 |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
783 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
784 | rq->davCollection = create_test_pgdav(sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
785 | pblock_nvinsert("depth", "1", rq->headers); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
786 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
787 | ret = webdav_propfind(pb, sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
788 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
789 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
790 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
791 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
792 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
793 | ms = test_parse_multistatus(st->buf->space, st->buf->size); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
794 | UCX_TEST_ASSERT(ms, "propfind2: response is not valid xml"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
795 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
796 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
797 | UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/ response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
798 | UCX_TEST_ASSERT(ms->responses->count == 5, "propfind2: wrong response count"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
799 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
800 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
801 | UCX_TEST_ASSERT(r1, "propfind2: missing /propfind/res1 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
802 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
803 | p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
804 | UCX_TEST_ASSERT(r1, "propfind2: missing resourcetype property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
805 | p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
806 | UCX_TEST_ASSERT(r1, "propfind2: missing test property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
807 | p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
808 | UCX_TEST_ASSERT(r1, "propfind2: missing prop2 property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
809 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
810 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res2"), "propfind2: missing /propfind/res2 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
811 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res3"), "propfind2: missing /propfind/res3 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
812 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/"), "propfind2: missing /propfind/sub response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
813 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
814 | testutil_destroy_session(sn); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
815 | test_multistatus_destroy(ms); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
816 | testutil_iostream_destroy(st); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
817 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
818 | // Test 3 |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
819 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPFIND", "/propfind/", PG_TEST_ALLPROP); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
820 | rq->davCollection = create_test_pgdav(sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
821 | pblock_nvinsert("depth", "infinity", rq->headers); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
822 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
823 | ret = webdav_propfind(pb, sn, rq); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
824 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
825 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "webdav_propfind (2) failed"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
826 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
827 | ms = test_parse_multistatus(st->buf->space, st->buf->size); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
828 | UCX_TEST_ASSERT(ms, "propfind3: response is not valid xml"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
829 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
830 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
831 | UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/ response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
832 | UCX_TEST_ASSERT(ms->responses->count == 6, "propfind3: wrong response count"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
833 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
834 | r1 = ucx_map_cstr_get(ms->responses, "/propfind/res1"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
835 | UCX_TEST_ASSERT(r1, "propfind3: missing /propfind/res1 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
836 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
837 | p = ucx_map_cstr_get(r1->properties, "DAV:resourcetype"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
838 | UCX_TEST_ASSERT(r1, "propfind3: missing resourcetype property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
839 | p = ucx_map_cstr_get(r1->properties, "http://example.com/test"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
840 | UCX_TEST_ASSERT(r1, "propfind3: missing test property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
841 | p = ucx_map_cstr_get(r1->properties, "http://example.com/prop2"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
842 | UCX_TEST_ASSERT(r1, "propfind3: missing prop2 property"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
843 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
844 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res2"), "propfind3: missing /propfind/res2 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
845 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/res3"), "propfind3: missing /propfind/res3 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
846 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/"), "propfind3: missing /propfind/sub response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
847 | UCX_TEST_ASSERT(ucx_map_cstr_get(ms->responses, "/propfind/sub/res4"), "propfind3: missing /propfind/sub/res4 response"); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
848 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
849 | testutil_destroy_session(sn); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
850 | test_multistatus_destroy(ms); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
851 | testutil_iostream_destroy(st); |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
852 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
853 | |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
854 | UCX_TEST_END; |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
855 | } |
4090fc1b1c52
add tests for propfind allprop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
856 | |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
857 | UCX_TEST(test_pg_webdav_proppatch_set) { |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
858 | Session *sn; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
859 | Request *rq; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
860 | TestIOStream *st; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
861 | pblock *pb; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
862 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
863 | UCX_TEST_BEGIN; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
864 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
865 | // test data: |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
866 | // |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
867 | // /propfind/ |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
868 | // /propfind/res1 (2 properties: test, prop2) |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
869 | // /propfind/res2 (1 property: test) |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
870 | // /propfind/res3 |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
871 | // /propfind/sub |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
872 | // /propfind/sub/res4 |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
873 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
874 | int ret; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
875 | TestResponse *r1; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
876 | TestProperty *p; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
877 | // Test 1 |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
878 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/proppatch/pp1", PG_TEST_PROPPATCH1); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
879 | rq->davCollection = create_test_pgdav(sn, rq); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
880 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
881 | ret = webdav_proppatch(pb, sn, rq); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
882 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "proppatch1 failed"); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
883 | |
319
a9b9344875aa
add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
318
diff
changeset
|
884 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
885 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
886 | TestMultistatus *ms = test_parse_multistatus(st->buf->space, st->buf->size); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
887 | UCX_TEST_ASSERT(ms, "proppatch1 response is not valid xml"); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
888 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
889 | testutil_destroy_session(sn); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
890 | test_multistatus_destroy(ms); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
891 | testutil_iostream_destroy(st); |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
892 | |
324
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
893 | // Test 2: xml property value |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
894 | init_test_webdav_method(&sn, &rq, &st, &pb, "PROPPATCH", "/proppatch/pp1", PG_TEST_PROPPATCH2); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
895 | rq->davCollection = create_test_pgdav(sn, rq); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
896 | |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
897 | ret = webdav_proppatch(pb, sn, rq); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
898 | UCX_TEST_ASSERT(ret == REQ_PROCEED, "proppatch2 failed"); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
899 | |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
900 | //printf("\n\n%.*s\n", (int)st->buf->size, st->buf->space); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
901 | |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
902 | ms = test_parse_multistatus(st->buf->space, st->buf->size); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
903 | UCX_TEST_ASSERT(ms, "proppatch2 response is not valid xml"); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
904 | |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
905 | testutil_destroy_session(sn); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
906 | test_multistatus_destroy(ms); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
907 | testutil_iostream_destroy(st); |
44cf877b3d9f
add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
319
diff
changeset
|
908 | |
318
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
909 | |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
910 | UCX_TEST_END; |
60870dbac94f
add basic pg proppatch implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
317
diff
changeset
|
911 | } |