1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
inherit "etc/test/tests/pike_test_common.pike"; // Necessary for stuff in testsuite.h to work... 
 
#include <testsuite.h> 
 
array(Standards.URI) get_test_urls(Configuration conf, 
                                   string webdav_mount_point, 
                                   string|void username, 
                                   string|void password) 
{ 
  array(Standards.URI) uris = ({}); 
  // Run the suite once with every http protocol modules in the conf. 
  // This allows for testing such things as sub-path mounted sites etc. 
  foreach(conf->registered_urls, string full_url) { 
    mapping(string:string|Configuration|array(Protocol)) port_info = 
      roxen.urls[full_url]; 
    DAV_WERROR("full url: %O\n" 
               "port_info: %O\n", 
               full_url, port_info); 
    if (!test_true(mappingp, port_info)) continue; 
    array(Protocol) ports = port_info->ports; 
    if (!test_true(arrayp, ports)) continue; 
    foreach(ports, Protocol prot) { 
      if (!test_true(stringp, prot->prot_name)) continue; 
      if (prot->prot_name != "http") continue; 
 
      if (prot->bound != 1) continue; 
 
      if (!test_true(mappingp, prot->urls)) continue; 
 
      DAV_WERROR("prot: %O\n" 
                 "prot->urls: %O\n", prot, prot->urls); 
 
      // Strip the fragment from the full_url. 
      string url = (full_url/"#")[0]; 
      mapping(string:mixed) url_data = prot->urls[url]; 
      if (!test_true(mappingp, url_data)) continue; 
 
      // NB: url_data is typically the same mapping as port_info. 
      DAV_WERROR("url data: %O\n", url_data); 
      test_true(`==, url_data->conf, conf); 
      test_true(stringp, url_data->hostname); 
      test_true(stringp, url_data->path || "/"); 
 
      Standards.URI url_uri = Standards.URI(url, "http://*/"); 
      Standards.URI base_uri = Standards.URI( 
        Stdio.append_path(url_data->path || "/", 
                          webdav_mount_point), 
                          url_uri); 
      base_uri->port = prot->port; 
      base_uri->host = prot->ip; 
 
      if (username) { 
        base_uri->user = username; 
        base_uri->password = password; 
      } 
      uris += ({base_uri}); 
    } 
  } 
  return uris; 
}