aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.pl
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2007-03-08 02:38:49 +0000
committerDan Fandrich <dan@coneharvesters.com>2007-03-08 02:38:49 +0000
commit1bfa7dfe39ec74cbec28808969ba8320f0807ae4 (patch)
tree969d2808edbe0ae257a8e0eb12268e946e528354 /tests/runtests.pl
parent85daec253cf5a6e1eb3f023e76180f553c715de8 (diff)
Added test infrastructure to support basic FTPS tests. This currently
supports only ftps:// URLs with --ftp-ssl-control specified, which implicitly encrypts the control channel but not the data channels. That allows stunnel to be used with an unmodified ftp server in exactly the same way that the test https server is set up. Added test case 400 as a basic FTPS test.
Diffstat (limited to 'tests/runtests.pl')
-rwxr-xr-xtests/runtests.pl93
1 files changed, 88 insertions, 5 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index c2f561b43..aeff8b4fa 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -480,7 +480,11 @@ sub verifyftp {
my ($proto, $ip, $port) = @_;
my $pid;
my $time=time();
- my $cmd="$CURL -m$server_response_maxtime --silent -vg \"$proto://$ip:$port/verifiedserver\" 2>log/verifyftp";
+ my $extra;
+ if($proto eq "ftps") {
+ $extra = "-k --ftp-ssl-control ";
+ }
+ my $cmd="$CURL -m$server_response_maxtime --silent -vg $extra\"$proto://$ip:$port/verifiedserver\" 2>log/verifyftp";
# check if this is our server running on this port:
my @data=`$cmd`;
logmsg "RUN: $cmd\n" if($verbose);
@@ -518,6 +522,7 @@ sub verifyftp {
my %protofunc = ('http' => \&verifyhttp,
'https' => \&verifyhttp,
'ftp' => \&verifyftp,
+ 'ftps' => \&verifyftp,
'tftp' => \&verifyftp);
sub verifyserver {
@@ -628,7 +633,7 @@ sub runhttpsserver {
}
my $flag=$debugprotocol?"-v ":"";
- my $cmd="$perl $srcdir/httpsserver.pl $flag -s \"$stunnel\" -d $srcdir -r $HTTPPORT $HTTPSPORT";
+ my $cmd="$perl $srcdir/httpsserver.pl $flag -p https -s \"$stunnel\" -d $srcdir -r $HTTPPORT $HTTPSPORT";
my ($httpspid, $pid2) = startnew($cmd, $HTTPSPIDFILE);
@@ -722,6 +727,60 @@ sub runftpserver {
}
#######################################################################
+# start the ftps server (or rather, tunnel)
+#
+sub runftpsserver {
+ my ($verbose, $ipv6) = @_;
+ my $STATUS;
+ my $RUNNING;
+ my $ip = $HOSTIP;
+
+ if(!$stunnel) {
+ return 0;
+ }
+
+ if($ipv6) {
+ # not complete yet
+ $ip = $HOST6IP;
+ }
+
+ my $pid=checkserver($FTPSPIDFILE);
+
+ if($pid > 0) {
+ # kill previous stunnel!
+ stopserver($pid);
+ }
+
+ my $flag=$debugprotocol?"-v ":"";
+ my $cmd="$perl $srcdir/httpsserver.pl $flag -p ftps -s \"$stunnel\" -d $srcdir -r $FTPPORT $FTPSPORT";
+
+ my ($ftpspid, $pid2) = startnew($cmd, $FTPSPIDFILE);
+
+ if(!kill(0, $ftpspid)) {
+ # it is NOT alive
+ logmsg "RUN: failed to start the FTPS server!\n";
+ stopservers($verbose);
+ return(0,0);
+ }
+
+ # Server is up. Verify that we can speak to it.
+ if(!verifyserver("ftps", $ip, $FTPSPORT)) {
+ logmsg "RUN: FTPS server failed verification\n";
+ # failed to talk to it properly. Kill the server and return failure
+ stopserver("$ftpspid $pid2");
+ return (0,0);
+ }
+
+ if($verbose) {
+ logmsg "RUN: FTPS server is now running PID $ftpspid\n";
+ }
+
+ sleep(1);
+
+ return ($ftpspid, $pid2);
+}
+
+#######################################################################
# start the tftp server
#
sub runtftpserver {
@@ -1072,7 +1131,7 @@ sub checksystem {
logmsg sprintf("* FTP port: %d\n", $FTPPORT);
logmsg sprintf("* FTP port 2: %d\n", $FTP2PORT);
if($stunnel) {
- #logmsg sprintf("* FTPS port: %d\n", $FTPSPORT);
+ logmsg sprintf("* FTPS port: %d\n", $FTPSPORT);
logmsg sprintf("* HTTPS port: %d\n", $HTTPSPORT);
}
if($http_ipv6) {
@@ -1890,8 +1949,32 @@ sub startservers {
}
}
elsif($what eq "ftps") {
- # we can't run ftps tests at all for the moment
- return "test suite lacks FTPS support";
+ if(!$stunnel) {
+ # we can't run ftps tests without stunnel
+ return "no stunnel";
+ }
+ if(!$ssl_version) {
+ # we can't run ftps tests if libcurl is SSL-less
+ return "curl lacks SSL support";
+ }
+
+ if(!$run{'ftp'}) {
+ ($pid, $pid2) = runftpserver("", $verbose);
+ if($pid <= 0) {
+ return "failed starting FTP server";
+ }
+ printf ("* pid ftp => %d %d\n", $pid, $pid2) if($verbose);
+ $run{'ftp'}="$pid $pid2";
+ }
+ if(!$run{'ftps'}) {
+ ($pid, $pid2) = runftpsserver($verbose);
+ if($pid <= 0) {
+ return "failed starting FTPS server (stunnel)";
+ }
+ logmsg sprintf("* pid ftps => %d %d\n", $pid, $pid2)
+ if($verbose);
+ $run{'ftps'}="$pid $pid2";
+ }
}
elsif($what eq "file") {
# we support it but have no server!