Roxen.git / server / etc / test / modules / TEST.pmod / http.pmod / WebDAV.pmod / TestBase.pike

version» Context lines:

Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:355:    }    return res;   }      protected WebDAVResponse webdav_move(string src_path,    string dst_path,    mapping(string:string) locks,    int expected_status_code)   {    bool src_equals_dst = false; -  if (non_normalizing_filesystem()) { +  if (case_sensitive_filesystem()) {    src_equals_dst = Unicode.normalize(utf8_to_string(src_path), "NFC") ==    Unicode.normalize(utf8_to_string(dst_path), "NFC");    } else {    src_equals_dst = lower_case(Unicode.normalize(utf8_to_string(src_path), "NFC")) ==    lower_case(Unicode.normalize(utf8_to_string(dst_path), "NFC"));    }    string expected_content;    bool is_regular_file = filesystem_is_file(src_path);    if (is_regular_file) {    expected_content = filesystem_read_file(src_path);
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:490:   }      protected WebDAVResponse webdav_ls(string path,    array(string) expected,    int|void expected_status_code)   {    return [object(WebDAVResponse)]    do_webdav_ls(path, expected, true, expected_status_code);   }    - protected bool non_normalizing_filesystem() + enum FSBehavior { +  FS_RAW = 0, +  FS_CASE_INSENSITIVE = 1, +  FS_UNICODE_NORMALIZING = 2, +  FS_BOTH = 3, + }; +  + protected FSBehavior filesystem_behavior()   {    string sysname = System.uname()->sysname;    if (sysname == "Darwin") { // OS X -  return false; +  return FS_BOTH;    }    if (has_value(sysname, "Win32")) { // Windows -  return false; +  return FS_CASE_INSENSITIVE;    } -  return true; +  return FS_RAW;   }    -  + protected bool case_sensitive_filesystem() + { +  return !(filesystem_behavior() & FS_CASE_INSENSITIVE); + } +  + protected bool non_normalizing_filesystem() + { +  return !(filesystem_behavior() & FS_UNICODE_NORMALIZING); + } +    protected void prepare_testdir(string testdir)   {    testdir = has_suffix(testdir, "/") ? testdir[..<1] : testdir;    DAV_WERROR("Webdav: Test dir is: %O\n", testdir);       // Consider working directly with the filesystem instead.    // filesystem_recursive_rm(testdir);       // webdav_mkcol may return true even it the dir already existed. Therefor    // we always clean.
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2111:    });   #endif      // Create directory and file using one encoding and mixed, lower or upper case.   // Then do ls for all combinations of (same encoding, other encoding) x   // (mixed case, lower case, upper case).   public void test_x_ls()   {    int count = 0;    bool normalizing = !non_normalizing_filesystem(); +  bool casesensitive = case_sensitive_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?    foreach (({"NFC", "NFD"}), string unicode_method_create) {    foreach (({"mc", "lc", "uc"}), string case_create) {    foreach (({"NFC", "NFD"}), string unicode_method_ls) {    foreach (({"mc", "lc", "uc"}), string case_ls) {    string filename = sprintf("%0"+w+"d_%s", count++, str);    string new_dir =    make_filenames(this::testcase_dir, filename,
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2136:    unicode_method_ls, true)[case_ls];    string file_ls = make_filenames("", filename, unicode_method_ls,    true)[case_ls];    mapping(string:string) exp_dir =    make_filenames(this::testcase_dir, filename, "NFC", false);    mapping(string:string) exp_file = make_filenames("", filename,    "NFC", false);    ASSERT_EQUAL(filesystem_mkdir_recursive(new_dir), 1);    string exp_path = exp_dir[case_ls] + "/" + exp_file[case_ls];    + #if 0 +  werror("normalizing: %d\n" +  "casesensitive: %d\n" +  "str: %O\n" +  "umc: %O\n" +  "cc: %O\n" +  "uml: %O\n" +  "cls: %O\n" +  "fn: %O\n" +  "nd: %O\n" +  "nf: %O\n" +  "dls: %O\n" +  "fls: %O\n" +  "ed: %O\n" +  "ef: %O\n" +  "ep: %O\n" +  "--------\n" +  "utf8(ep): %O\n" +  "ap(nd, nf): %O\n", +  normalizing, casesensitive, +  str, unicode_method_create, case_create, +  unicode_method_ls, case_ls, +  filename, +  new_dir, new_file, +  dir_ls, file_ls, +  exp_dir, exp_file, exp_path, +  string_to_utf8(exp_path), +  Stdio.append_path(new_dir, new_file)); + #endif +     if (string_to_utf8 (exp_path) ==    Stdio.append_path (new_dir, new_file)) {    webdav_ls(dir_ls, ({ exp_dir[case_ls] }) );    } else {    webdav_ls(dir_ls, ({ exp_dir[case_ls] }),    !normalizing && STATUS_NOT_FOUND);    }    string testdata = "FILE " + count;    ASSERT_EQUAL(filesystem_direct_write(new_dir + "/" + new_file,    testdata),
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2162:    exp_dir[case_ls] + "/" + exp_file[case_create] }) );       // When listing a file directly, it will have equivalent case    // in the returned list.    webdav_ls(dir_ls + "/" + file_ls,    ({ exp_dir[case_ls] + "/" + exp_file[case_ls] }) );    } else {    // In this case the result depends on whether the WebDAV backend    // is normalizing or not. For our WebServer tests it depends on    // the OS but other WebDAV modules may implement normalization -  // themselves (then normalizing_filesystem() is typically +  // themselves (then filesystem_behavior() is typically    // overridden by the test subclass.)    webdav_ls(dir_ls,    normalizing ?    ({ exp_dir[case_ls],    exp_dir[case_ls] + "/" + exp_file[case_create] })    : ({}),    normalizing ? STATUS_MULTI_STATUS : STATUS_NOT_FOUND);       // When listing a file directly, it will have equivalent case    // in the returned list.
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2222:    webdav_ls(dir_path, ({ dir_path }) );    webdav_put(file_path, "FILE\n", STATUS_CREATED);    webdav_ls(dir_path, ({ dir_path, file_path }) );    };    }   }      public void test_x_put()   {    int count = 0; -  bool caseSensitive = non_normalizing_filesystem(); +  bool caseSensitive = case_sensitive_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?    foreach (({"NFC", "NFD"}), string unicode_method_put1) {    foreach (({"mc", "lc", "uc"}), string case_put1) {    foreach (({"NFC", "NFD"}), string unicode_method_put2) {    foreach (({"mc", "lc", "uc"}), string case_put2) {    string filename = sprintf("%0"+w+"d_%s", count++, str);    string dir = make_filenames(this::testcase_dir, filename,    unicode_method_put1, true)[case_put1];
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2283:    }    }    }    }   }      // Test copy where src and target is the same except for case.   public void test_x_copy_file()   {    int count = 0; -  bool caseSensitive = non_normalizing_filesystem(); +  bool caseSensitive = case_sensitive_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?    foreach (({"NFC", "NFD"}), string unicode_method_src) {    foreach (({"mc", "lc", "uc"}), string case_src) {    foreach (({"NFC", "NFD"}), string unicode_method_target) {    foreach (({"mc", "lc", "uc"}), string case_target) {    string filename = sprintf("%0"+w+"d_%s", count++, str);    string src_file =    make_filenames(this::testcase_dir, filename, unicode_method_src,
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2319:    }    }    }    }   }      // This testcase tests creating a directory that already exists.   public void test_x_mkcol()   {    int count = 0; -  bool caseSensitive = non_normalizing_filesystem(); +  bool caseSensitive = case_sensitive_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?    foreach (({"NFC", "NFD"}), string unicode_method_dir1) {    foreach (({"mc", "lc", "uc"}), string case_dir1) {    foreach (({"NFC", "NFD"}), string unicode_method_dir2) {    foreach (({"mc", "lc", "uc"}), string case_dir2) {    string filename = sprintf("%0"+w+"d_%s", count++, str);    string dir1 = make_filenames(this::testcase_dir, filename,    unicode_method_dir1, true)[case_dir1];
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2354:    }    }    }    }   }      // Test move where src and target is the same except for case.   public void test_x_move_file()   {    int count = 0; -  bool caseSensitive = non_normalizing_filesystem(); +  bool caseSensitive = case_sensitive_filesystem();    int w = sizeof("" + (sizeof(FILENAMES)*2*3) );    foreach (FILENAMES, string str) {    // TODO: Skip the following 2 loops and just pick an encoding and a case for the src, or?    foreach (({"NFC", "NFD"}), string unicode_method_src) {    foreach (({"mc", "lc", "uc"}), string case_src) {    foreach (({"NFC", "NFD"}), string unicode_method_target) {    foreach (({"mc", "lc", "uc"}), string case_target) {    string filename = sprintf("%0"+w+"d_%s", count++, str);    string src_file = make_filenames(this::testcase_dir, filename,    unicode_method_src, true)[case_src];
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2393:    }    }    }    }    }   }      // Runs only on case insensitive systems.   public void test_x_put_copy_move_delete()   { -  if (non_normalizing_filesystem()) { +  if (case_sensitive_filesystem()) {    return;    }    string mv_dst = Stdio.append_path(this::testcase_dir, "mv_dst");    string cp_dst = Stdio.append_path(this::testcase_dir, "cp_dst");    foreach (FILENAMES, string filename) {    foreach (({"NFC", "NFD"}), string unicode_method_put) {    string put_path = make_filenames(this::testcase_dir,    filename,    unicode_method_put,    true)->mc;
Roxen.git/server/etc/test/modules/TEST.pmod/http.pmod/WebDAV.pmod/TestBase.pike:2455:   // Test cannot put on a locked non existing resource without lock.   // Test cannot put on locked existing resource without lock.   // Test cannot delete locked existing resource without lock.   // Test can put on locked existing resource if we have the lock.   // Test can delete locked existing resource if we have the lock.   // Test lock handling is case insensitive on case insensitive systems.   //   // We satisfy with taking a lock on a resource with mixed case and later   // creating a file with the same case.   { -  bool caseSensitive = non_normalizing_filesystem(); +  bool caseSensitive = case_sensitive_filesystem();    array(string) cases = ({"mc", "lc", "uc"});    if (caseSensitive) {    cases = ({ "mc" });    }    foreach (FILENAMES, string filename) {    foreach (({"NFC", "NFD"}), string unicode_method) {    mapping(string:string) resources = make_filenames(this::testcase_dir,    filename,    unicode_method,    true);