Roxen.git / server / etc / test / tests / http / RoxenTest_webdav.pike

version» Context lines:

Roxen.git/server/etc/test/tests/http/RoxenTest_webdav.pike:1:   inherit "../pike_test_common";    + #include <testsuite.h> +    string webdav_mount_point = "webdav/testdir/";   string filesystem_dir = "$VARDIR/testsuite/webdav/testdir";      string basic_auth = "test:test";      /* Some globals to avoid having to pass this stuff around explicitly. */      // Expanded filesystem_dir.   string real_dir;   
Roxen.git/server/etc/test/tests/http/RoxenTest_webdav.pike:215:   <?xml version='1.0' encoding='utf-8'?>   <DAV:propfind xmlns:DAV='DAV:'>    <DAV:propname/>   </DAV:propfind>   ";    array(int|mapping(string:string)|string) res =    webdav_request("PROPFIND", path, UNDEFINED, propfind);       report_debug("Webdav: propfind result: %d\n%O\n", res[0], res[2]);    -  // FIXME: Parse the result. -  return (res[0] >= 200) && (res[0] < 300); +  TEST_TRUE(res[0] >= 200 && res[0] < 300); +  if (res[0] < 200 || res[0] > 300) { +  return 0;    }    -  +  Parser.XML.Tree.SimpleRootNode root_node = +  Parser.XML.Tree.simple_parse_input(res[2]); +  array(Parser.XML.Tree.AbstractNode) multistatus_nodes = +  root_node->get_elements("DAV:multistatus", true); +  TEST_TRUE(sizeof(multistatus_nodes) > 0); +  array(Parser.XML.Tree.AbstractNode) response_nodes = +  Array.flatten(multistatus_nodes->get_elements("DAV:response", true)); +  TEST_TRUE(sizeof(response_nodes) > 0); +  array(Parser.XML.Tree.AbstractNode) href_nodes = +  Array.flatten(response_nodes->get_elements("DAV:href", true)); +  TEST_TRUE(sizeof(href_nodes) > 0); +  array(string) hrefs = href_nodes->value_of_node(); +  array(string) actual = Array.flatten(map(hrefs, +  lambda(string href) { +  // Remove leading "http://*/webdav/testdir/" from each string. +  return array_sscanf(href, "%*s"+webdav_mount_point+"%s"); +  })); +  // Remove empty strings. +  actual = filter(actual, +  lambda(string str) { return sizeof(str) > 0; }); +  TEST_EQUAL(sort(expected), sort(actual)); +  return equal(sort(expected), sort(actual)); + }    -  +    void setup()   {    real_dir = roxen_path(filesystem_dir);       report_debug("Webdav real_dir: %O\n", real_dir);       Stdio.mkdirhier(real_dir);   }      void run_tests(Configuration conf)