Roxen.git
/
server
/
etc
/
test
/
tests
/
http
/
RoxenTest_webdav.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/etc/test/tests/http/RoxenTest_webdav.pike:1:
-
inherit "
etc/test/tests/http/WebdavTestBase
.pike";
+
inherit "
..
/
pike_
test
_common
";
-
private
string
testdir = "/testdir/"
;
+
#include
<testsuite.h>
+
+
import
TEST.http.WebDAV
;
+
+
private string filesystem_dir = "$VARDIR/testsuite/webdav"; // Expanded filesystem_dir.
-
private string
real
_
dir
;
+
private string
webdav
_
mount_point = "webdav/"
;
+
private string username = "test";
+
private string password = "test";
-
string
get_
testdir
() {
-
return
testdir;
+
void
run_tests(Configuration conf)
+
{
+
array(Standards.URI) base_uris = TestUtils.
get_
test_urls
(
conf,
+
webdav_mount_point,
+
username,
+
password
)
;
+
int count = 0;
+
foreach (base_uris, Standards.URI base_uri)
{
+
report_debug("Webdav testsuite: Base URI: %s\n", (string)base_uri);
+
mapping(string:string) base_headers = ([
+
"host": base_uri->host,
+
"user-agent": "Roxen WebDAV Tester",
+
]);
+
WebdavTest testsuite =
+
WebdavTest(webdav_mount_point, base_uri, base_headers, "
testdir
"+count++)
;
+
testsuite->run();
+
// Hack for counting number of tests.
+
::current_test += testsuite->current_test;
+
::tests_failed += testsuite->tests_failed;
}
-
+
}
-
int
filesystem_
check
_
exists
(string
path
)
+
+
private
class WebdavTest {
+
+
inherit TestBase;
+
+
private string real_dir = roxen_path(
filesystem_
dir);
+
+
protected void create(string webdav
_
mount_point,
+
Standards.URI base_uri,
+
mapping
(string
:string)
base_headers,
+
string testdir
)
{
-
+
::create(webdav_mount_point, base_uri, base_headers, testdir);
+
report_debug("Webdav real_dir: %O\n", real_dir);
+
Stdio.mkdirhier(real_dir);
+
}
+
+
protected int filesystem_check_exists(string path)
+
{
+
path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
string real_path = Stdio.append_path(real_dir, path);
-
return Stdio.
is_file
(real_path);
+
return Stdio.
exist
(real_path);
}
-
string filesystem_read_file(string path)
+
protected
string filesystem_read_file(string path)
{
-
+
path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
string real_path = Stdio.append_path(real_dir, path); return Stdio.read_bytes(real_path); }
-
void
setup
()
+
protected array
(
string
)
filesystem_get_dir(string path)
{
-
webdav_mount_point
=
"webdav/";
-
basic
_
auth
=
"
test:test
";
-
real_
dir
=
roxen
_path(
filesystem
_dir);
-
report_debug("Webdav
real_dir:
%O\n",
real
_dir
);
-
Stdio.mkdirhier
(real_
dir
);
+
path = string
_
to
_
utf8(Unicode.normalize(utf8_to_string(path),
"
NFC
"
))
;
+
string
real_
path
=
Stdio.append
_path(
real
_dir
, path
);
+
return
get
_dir(real_
path
);
}
-
+
+
protected int filesystem_is_dir(string path)
+
{
+
path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
+
string real_path = Stdio.append_path(real_dir, path);
+
return Stdio.is_dir(real_path);
+
}
+
+
protected int filesystem_is_file(string path)
+
{
+
path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
+
string real_path = Stdio.append_path(real_dir, path);
+
return Stdio.is_file(real_path);
+
}
+
+
// protected int filesystem_recursive_rm(string path)
+
// {
+
// path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
+
// string real_path = Stdio.append_path(real_dir, path);
+
// return Stdio.recursive_rm(real_path);
+
// }
+
+
}
+