The beginnings of a testing framework.

This commit is contained in:
Andrew McMillan 2006-10-05 00:38:23 +13:00
parent 487c53d838
commit 046e390380
26 changed files with 330 additions and 0 deletions

108
testing/dav_test Executable file
View File

@ -0,0 +1,108 @@
#!/usr/bin/perl -w
#
# Run a test
#
my $suite=$ARGV[0];
my $test=$ARGV[1];
usage() unless ( defined($suite) && defined($test) );
my @arguments = ( "--basic", "--user", "andrew:x", "--proxy", "", "--silent" );
push @arguments, "--verbose" if ( defined($ARGV[2]) );
my $url;
my $datafile = "tests/$suite/$test.data";
open( TEST, '<', "tests/$suite/$test.test" ) or die "Can't open 'tests/$suite/$test.test'";
while( <TEST> ) {
/^\s*(#|$)/ && next;
/^\s*HEAD\s*(#|$|=)/ && do {
push @arguments, "--include";
};
/^\s*DATA\s*=\s*(\S.*)$/ && do {
$datafile="tests/$suite/$1.data";
};
/^\s*VERBOSE\s*(#|$|=)/ && do {
push @arguments, "--verbose";
};
/^\s*TYPE\s*=\s*(\S.*)$/ && do {
push @arguments, "--request", $1;
};
/^\s*HEADER\s*=\s*(\S.*)$/ && do {
push @arguments, "--header", $1;
};
/^\s*URL\s*=\s*(\S.*)$/ && do {
$url=$1;
};
}
if ( !defined($url) ) {
print <<EOERROR ;
The .test file must contain a URL. It may also contain a TYPE line (to
specify the request type, such as PROPFIND, MKCOL, PUT etc) and it may
contain a number of HEADER lines to specify additional headers to send
along with the request.
EOERROR
exit (2);
}
if ( -f $datafile ) {
push @arguments, "--data-binary", "\@$datafile";
# print "Using datafile: ", $datafile,"\n";
}
else {
undef($datafile);
}
# print @arguments;
# print "\n";
push @arguments, $url;
open RESULTS, "-|", "curl", @arguments;
while( <RESULTS> ) {
print;
}
exit(0);
sub usage {
print <<EOERROR ;
Usage: dav_test <testsuite> <testname>
This program will read the file 'tests/<testsuite>/<testname>.test
and follow the instructions there. Those instructions will include
lines defining the test like:
=================================================
# This is an example
URL=http://mycaldav/caldav.php/andrew/
HEADER=Depth: 0
HEADER=Content-type: text/xml
TYPE=PROPFIND
VERBOSE
DATA=OTHERTEST
=================================================
URL The URL to request from.
HEADER An additional header for the request
TYPE The type of request (e.g. GET/PUT/POST/REPORT/...)
HEAD Whether to include the headers in the recorded response
VERBOSE Whether to provide the full request / response headers.
DATA The name of a different test in this suite to use data from.
Additionally, if a file 'tests/<testsuite>/<testname>.data' exists
the contents of that file will be sent in the body of the request.
EOERROR
exit(1);
}

View File

@ -0,0 +1,6 @@
#
# Test the initial OPTIONS for the root
#
TYPE=OPTIONS
URL=http://mycaldav/caldav.php/andrew/.chandler/
HEAD

View File

@ -0,0 +1,6 @@
#
# Test the initial OPTIONS for the root
#
TYPE=OPTIONS
URL=http://mycaldav/caldav.php/andrew/
HEAD

View File

@ -0,0 +1,8 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 0
URL=http://mycaldav/caldav.php/andrew/.chandler/
HEADER=Content-Type: text/xml; charset="utf-8"
DATA=PROPFIND

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<ns0:propfind xmlns:ns0="DAV:"><ns0:prop><ns0:getetag /><ns0:resourcetype /><ns0:displayname /></ns0:prop></ns0:propfind>

View File

@ -0,0 +1,7 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 0
URL=http://mycaldav/caldav.php/andrew/
HEADER=Content-Type: text/xml; charset="utf-8"

View File

@ -0,0 +1,9 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 0
HEADER=Content-Type: text/xml; charset="utf-8"
URL=http://mycaldav/caldav.php/andrew/
DATA=PROPFIND
HEAD

View File

@ -0,0 +1,9 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 1
HEADER=Content-Type: text/xml; charset="utf-8"
URL=http://mycaldav/caldav.php/
DATA=PROPFIND
HEAD

View File

@ -0,0 +1,7 @@
#
# Test the REPORT request from Mulberry
#
TYPE=REPORT
HEADER=Content-Type: text/xml; charset=utf-8
URL=http://mycaldav/caldav.php/andrew/mulberry/
HEAD

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<ns0:propfind xmlns:ns0="DAV:"><ns0:prop><ns0:current-user-privilege-set /><ns0:getetag /><ns0:resourcetype /><ns0:displayname /></ns0:prop></ns0:propfind>

View File

@ -0,0 +1,7 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 0
HEADER=Content-Type: text/xml; charset="utf-8"
URL=http://mycaldav/caldav.php/andrew/

View File

@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<ns0:propfind xmlns:ns0="DAV:"><ns0:prop><ns1:ticketdiscovery xmlns:ns1="http://www.xythos.com/namespaces/StorageServer" /><ns0:getetag /><ns0:resourcetype /><ns0:displayname /></ns0:prop></ns0:propfind>

View File

@ -0,0 +1,7 @@
#
# Test the initial PROPFIND for the root.
#
TYPE=PROPFIND
HEADER=Depth: 0
HEADER=Content-Type: text/xml; charset="utf-8"
URL=http://mycaldav/caldav.php/andrew/

View File

@ -0,0 +1,6 @@
#
# Test the initial OPTIONS for the root
#
TYPE=OPTIONS
URL=http://mycaldav/caldav.php/andrew/
HEAD

View File

@ -0,0 +1,12 @@
<C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
<D:prop>
<D:getetag/>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:is-defined/>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>

View File

@ -0,0 +1,7 @@
#
# Test the REPORT request
#
TYPE=REPORT
URL=http://mycaldav/caldav.php/andrew/
HEADER=Content-Type: text/xml
HEAD

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<D:propfind xmlns:D="DAV:">
<D:prop>
<D:getcontentlength/>
<D:getcontenttype/>
<D:resourcetype/>
</D:prop>
</D:propfind>

View File

@ -0,0 +1,7 @@
#
# After creating a calendar in Mulberry, we should be able
# to do a PROPFIND and discover it.
TYPE=PROPFIND
URL=http://mycaldav/caldav.php/andrew/
HEADER=Depth: 1
HEADER=Content-Type: text/xml; charset=utf-8

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<D:propfind xmlns:D="DAV:">
<D:prop>
<D:getcontentlength/>
<D:getcontenttype/>
<D:resourcetype/>
<D:getetag/>
</D:prop>
</D:propfind>

View File

@ -0,0 +1,7 @@
#
# After creating a calendar in Mulberry, we should be able
# to do a PROPFIND and discover it.
TYPE=PROPFIND
URL=http://mycaldav/caldav.php/andrew/mulberry/
HEADER=Depth: 1
HEADER=Content-Type: text/xml; charset=utf-8

View File

@ -0,0 +1,31 @@
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
VERSION:2.0
BEGIN:VTIMEZONE
LAST-MODIFIED:20040110T032845Z
TZID:New Zealand Standard Time
X-LIC-LOCATION:Pacific/Auckland
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:NZDT
TZOFFSETFROM:+1200
TZOFFSETTO:+1300
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=10
TZNAME:NZST
TZOFFSETFROM:+1300
TZOFFSETTO:+1200
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20061004T072647Z
DTSTART;TZID=New Zealand Standard Time:20061004T111500
DURATION:PT1H
SUMMARY:A new event
UID:73CEA660B2AB08BE90C9D6B5@D76FAF7B10D9E8D2D41F779C
END:VEVENT
END:VCALENDAR

View File

@ -0,0 +1,7 @@
#
# PUT a calendar entry into the Mulberry calendar
#
TYPE=PUT
URL=http://mycaldav/caldav.php/andrew/mulberry/30A56217E5719B1453D1942F83106C7A-0.ics
HEADER=Content-Type: text/calendar; charset=utf-8
HEAD

View File

@ -0,0 +1,33 @@
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
VERSION:2.0
BEGIN:VTIMEZONE
LAST-MODIFIED:20040110T032845Z
TZID:New Zealand Standard Time
X-LIC-LOCATION:Pacific/Auckland
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:NZDT
TZOFFSETFROM:+1200
TZOFFSETTO:+1300
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=10
TZNAME:NZST
TZOFFSETFROM:+1300
TZOFFSETTO:+1200
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:Weigh a pie
DTSTAMP:20061004T102416Z
DTSTART;TZID=New Zealand Standard Time:20061004T110000
DURATION:PT1H
LOCATION:Somewhere over the rainbow
SUMMARY:11am on Wednesday\, 4th
UID:A1E59F7D54EF85BE2A7E6900@CA1CBED546AAE36FF3BC722E
END:VEVENT
END:VCALENDAR

View File

@ -0,0 +1,7 @@
#
# PUT a calendar entry into the Mulberry calendar
#
TYPE=PUT
URL=http://mycaldav/caldav.php/andrew/mulberry/F91ACE37725E396C1A4BB87568CE36C0-0.ics
HEADER=Content-Type: text/calendar; charset=utf-8
HEAD

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-multiget xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<D:getetag/>
<C:calendar-data/>
</D:prop>
<D:href>/caldav.php/andrew/mulberry/30A56217E5719B1453D1942F83106C7A-0.ics</D:href>
<D:href>/caldav.php/andrew/mulberry/F91ACE37725E396C1A4BB87568CE36C0-0.ics</D:href>
</C:calendar-multiget>

View File

@ -0,0 +1,7 @@
#
# Test the REPORT request
#
TYPE=REPORT
URL=http://mycaldav/caldav.php/andrew/mulberry/
HEADER=Content-Type: text/xml; charset=utf-8
HEAD