7792d12018-02-27Karl Gustav Sterneberg inherit "../pike_test_common"; #include <testsuite.h> import TEST.http.WebDAV;
45f40f2018-04-13Martin Karlgren #ifdef DAV_DEBUG #define DAV_WERROR(X...) werror(X) #else /* !DAV_DEBUG */ #define DAV_WERROR(X...) #endif /* DAV_DEBUG */
ad307f2018-02-16Henrik Grubbström (Grubba) 
c5d9212018-02-21Karl Gustav Sterneberg private string filesystem_dir = "$VARDIR/testsuite/webdav";
ad307f2018-02-16Henrik Grubbström (Grubba) // Expanded filesystem_dir.
7792d12018-02-27Karl Gustav Sterneberg private string webdav_mount_point = "webdav/"; private string username = "test"; private string password = "test";
c5d9212018-02-21Karl Gustav Sterneberg 
7792d12018-02-27Karl Gustav Sterneberg void run_tests(Configuration conf)
30c5062018-02-16Henrik Grubbström (Grubba) {
7792d12018-02-27Karl Gustav Sterneberg  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) {
45f40f2018-04-13Martin Karlgren  DAV_WERROR("Webdav testsuite: Base URI: %s\n", (string)base_uri);
7792d12018-02-27Karl Gustav Sterneberg  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; }
e25b0f2018-10-26Henrik Grubbström (Grubba)  // Some low-level tests. RequestID fake_id = RequestID(0, 0, 0); fake_id->request_headers = ([ "if":"<path(>([W/\"etag)\"] <key(> not <no)key>)", ]); test_equal(([ "path(": ({ ({ ({ "etag", "W/\"etag)\"" }), ({ "key", "key(" }), ({ "not", 0 }), ({ "key", "no)key" }), }), }), 0: ({ ({ ({ "key", "key(" }), }), }), ]), fake_id->get_if_data);
30c5062018-02-16Henrik Grubbström (Grubba) }
ad307f2018-02-16Henrik Grubbström (Grubba) 
30c5062018-02-16Henrik Grubbström (Grubba) 
7792d12018-02-27Karl Gustav Sterneberg 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);
45f40f2018-04-13Martin Karlgren  DAV_WERROR("Webdav real_dir: %O\n", real_dir);
7792d12018-02-27Karl Gustav Sterneberg  Stdio.mkdirhier(real_dir); } protected int filesystem_check_exists(string path) {
3ee5f12018-03-20Henrik Grubbström (Grubba)  path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
7792d12018-02-27Karl Gustav Sterneberg  string real_path = Stdio.append_path(real_dir, path);
90c34b2018-03-20Henrik Grubbström (Grubba)  return Stdio.exist(real_path);
7792d12018-02-27Karl Gustav Sterneberg  } protected string filesystem_read_file(string path) {
3ee5f12018-03-20Henrik Grubbström (Grubba)  path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
7792d12018-02-27Karl Gustav Sterneberg  string real_path = Stdio.append_path(real_dir, path); return Stdio.read_bytes(real_path); } protected array(string) filesystem_get_dir(string path) {
3ee5f12018-03-20Henrik Grubbström (Grubba)  path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
7792d12018-02-27Karl Gustav Sterneberg  string real_path = Stdio.append_path(real_dir, path); return get_dir(real_path); } protected int filesystem_is_dir(string path) {
3ee5f12018-03-20Henrik Grubbström (Grubba)  path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
7792d12018-02-27Karl Gustav Sterneberg  string real_path = Stdio.append_path(real_dir, path); return Stdio.is_dir(real_path); } protected int filesystem_is_file(string path) {
3ee5f12018-03-20Henrik Grubbström (Grubba)  path = string_to_utf8(Unicode.normalize(utf8_to_string(path), "NFC"));
7792d12018-02-27Karl Gustav Sterneberg  string real_path = Stdio.append_path(real_dir, path); return Stdio.is_file(real_path); }
c002e12018-06-11Martin Karlgren  protected int(0..1) filesystem_mkdir_recursive(string(8bit) path) { string real_path = Stdio.append_path (real_dir, path); return Stdio.mkdirhier(real_path); } //! Writes a file to @[path], which is used verbatim without any normalization. protected int(0..) filesystem_direct_write(string(8bit) path, string(8bit) data) { string real_path = Stdio.append_path (real_dir, path); return Stdio.write_file(real_path, data); }
7a71a42018-03-29Karl Gustav Sterneberg  // 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); // }
7792d12018-02-27Karl Gustav Sterneberg 
ad307f2018-02-16Henrik Grubbström (Grubba) }
7792d12018-02-27Karl Gustav Sterneberg