33 exit 1 |
33 exit 1 |
34 fi |
34 fi |
35 |
35 |
36 BASE_URL=`dav repo-url dav-test-repo` |
36 BASE_URL=`dav repo-url dav-test-repo` |
37 |
37 |
38 # test |
38 # |
|
39 # test simple file upload |
|
40 # |
39 echo "hello world" > hello |
41 echo "hello world" > hello |
40 dav put dav-test-repo/tests/ hello |
42 dav put dav-test-repo/tests/ hello |
41 DAV_RES=$? |
43 DAV_RES=$? |
42 rm hello |
44 rm -f hello |
43 |
45 |
44 if [ $DAV_RES -ne 0 ]; then |
46 if [ $DAV_RES -ne 0 ]; then |
45 echo "dav put returned" $DAV_RES |
47 echo "dav put returned" $DAV_RES |
46 exit 2 |
48 exit 2 |
47 fi |
49 fi |
57 then |
59 then |
58 echo "wrong resource type" |
60 echo "wrong resource type" |
59 exit 2 |
61 exit 2 |
60 fi |
62 fi |
61 |
63 |
|
64 echo "hello world" > hello |
|
65 curl --silent -o cmphello $BASE_URL/tests/hello |
|
66 diff hello cmphello > /dev/null |
|
67 RES=$? |
|
68 rm -f hello |
|
69 rm -f cmphello |
|
70 if [ $RES -ne 0 ]; then |
|
71 echo "wrong content" |
|
72 exit 2 |
|
73 fi |
62 |
74 |
|
75 # |
|
76 # test dir upload |
|
77 # |
|
78 dav put -R dav-test-repo/tests/ testdir > /dev/null |
|
79 if [ $? -ne 0 ]; then |
|
80 echo "dir upload failed" |
|
81 exit 2 |
|
82 fi |
|
83 |
|
84 # check file1 |
|
85 curl --silent -o tmp_file1 $BASE_URL/tests/file1 |
|
86 if [ $? -ne 0 ]; then |
|
87 echo "cannot download file1" |
|
88 rm -f tmp_file1 |
|
89 exit 2 |
|
90 fi |
|
91 |
|
92 diff testdir/file1 tmp_file1 > /dev/null |
|
93 if [ $? -ne 0 ]; then |
|
94 echo "file1 has wrong content" |
|
95 rm -f tmp_file1 |
|
96 exit 2 |
|
97 fi |
|
98 rm tmp_file1 |
|
99 |
|
100 # check subdir file |
|
101 curl --silent -o tmp_sub1 $BASE_URL/tests/subdir/sub1 |
|
102 if [ $? -ne 0 ]; then |
|
103 echo "cannot download subdir/sub1" |
|
104 rm tmp_sub1 |
|
105 exit 2 |
|
106 fi |
|
107 |
|
108 diff testdir/subdir/sub1 tmp_sub1 > /dev/null |
|
109 if [ $? -ne 0 ]; then |
|
110 echo "subdir/sub1 has wrong content" |
|
111 rm -f tmp_sub1 |
|
112 exit 2 |
|
113 fi |
|
114 rm -f tmp_sub1 |
|
115 |
|
116 # check subdir |
|
117 OUT=`dav info dav-test-repo/tests/subdir` |
|
118 if [ $? -ne 0 ]; then |
|
119 echo "cannot get subdir infos" |
|
120 exit 2 |
|
121 fi |
|
122 |
|
123 echo $OUT | grep "type: collection" > /dev/null |
|
124 if [ $? -ne 0 ]; |
|
125 then |
|
126 echo "subdir has wrong type" |
|
127 exit 2 |
|
128 fi |
|
129 |
|
130 # |
|
131 # test upload to specific url |
|
132 # |
|
133 dav put dav-test-repo/tests/uploaded_file testdir/file1 |
|
134 if [ $? -ne 0 ]; then |
|
135 echo "upload to /tests/uploaded_file failed" |
|
136 exit 2 |
|
137 fi |
|
138 curl --silent -o /dev/null $BASE_URL/tests/uploaded_file |
|
139 if [ $? -ne 0 ]; then |
|
140 echo "uploaded_file has wrong content" |
|
141 exit 2 |
|
142 fi |
|
143 |
|
144 # |
|
145 # test upload with automatic collection creation |
|
146 # |
|
147 dav put dav-test-repo/tests/newdir/newsubdir/newfile testdir/file2 |
|
148 if [ $? -ne 0 ]; then |
|
149 echo "upload to /tests/newdir/newsubdir/newfile failed" |
|
150 exit 2 |
|
151 fi |
|
152 curl --silent -o /dev/null $BASE_URL/tests/newdir/newsubdir/newfile |
|
153 if [ $? -ne 0 ]; then |
|
154 echo "newfile has wrong content" |
|
155 exit 2 |
|
156 fi |
|
157 |
|
158 # |
|
159 # test dir upload to specific url |
|
160 # |
|
161 dav put -R dav-test-repo/tests/testdir testdir > /dev/null |
|
162 if [ $? -ne 0 ]; then |
|
163 echo "dir upload to /tests/testdir failed" |
|
164 exit 2 |
|
165 fi |
|
166 |
|
167 OUT=`dav info dav-test-repo/tests/testdir` |
|
168 if [ $? -ne 0 ]; then |
|
169 echo "cannot get /tests/testdir infos" |
|
170 exit 2 |
|
171 fi |
|
172 |
|
173 echo $OUT | grep "type: collection" > /dev/null |
|
174 if [ $? -ne 0 ]; |
|
175 then |
|
176 echo "/tests/testdir has wrong type" |
|
177 exit 2 |
|
178 fi |
|
179 |
|
180 curl --silent -o tmp_file3 $BASE_URL/tests/testdir/file3 |
|
181 CURL_RES=$? |
|
182 diff tmp_file3 testdir/file3 > /dev/null |
|
183 DIFF_RES=$? |
|
184 rm -f tmp_file3 |
|
185 |
|
186 if [ $CURL_RES -ne 0 ]; then |
|
187 echo "cannot download /tests/testdir/file3" |
|
188 exit 2 |
|
189 fi |
|
190 if [ $DIFF_RES -ne 0 ]; then |
|
191 echo "/tests/testdir/file3 has wrong content" |
|
192 exit 2 |
|
193 fi |