Author: wrowe
Date: Wed Feb 15 22:40:34 2006
New Revision: 378185
URL: http://svn.apache.org/viewcvs?rev=378185&view=rev
Log:
Import the perl-framework suite for mod_ftp.
I removed two a.out files from the tarball that Zubin indiciated over
IM were redundant (generated by aa_setup) and believe most of the
eol-style tags are correct, but this needs to be verified on Win32.
I also have changed the covalent and hexaware company names, using the
name 'common' instead so as not to offend anyone's sensibilities.
Authored by: Zubin Kika <zubin_qc@yahoo.com>
Added:
incubator/mod_ftp/trunk/tests/perl-framework/Ssl/
incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/
incubator/mod_ftp/trunk/tests/perl-framework/t/conf/
incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/aa_setup.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/accesstransfer.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_limitlogin.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_login.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/append.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/dele.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/help.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/homeDir.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/limitlogin.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/list.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/maxloginattempt.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/mdtm.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/mkd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/nlst.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/noop.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/pasvRange.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/pwd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/rename.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/rest.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/retr.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/rmd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/size.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/stor.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/syst.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/timeouts.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/type.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/aa_setup.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/accesstransfer.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/anon_limitlogin.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/anon_login.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/append.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/dele.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/help.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/homeDir.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/limitlogin.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/list.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/maxloginattempt.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/mdtm.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/mkd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/nlst.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/noop.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/pasvRange.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/pwd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/rename.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/rest.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/retr.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/rmd.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/size.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/stor.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/syst.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/timeouts.t
incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_imp_ssl/type.t
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/anonftpdocs/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/.libs/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/abor/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/app1
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/app2
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/app3
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/app4
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir/zerobytes
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir_backup/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir_backup/appzero
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir_backup/remoteapp1
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/appenddir_backup/remoteapp3
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/deledir_backup/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/deledir_backup/dele_dir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/deledir_backup/dele_file
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/deledir_backup/dele_nonemptydir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/deledir_backup/dele_nonemptydir/file.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/hello.c (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/mkddir_backup/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/mkddir_backup/mkd_existingdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/renamedir_backup/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/renamedir_backup/rename_oldfilename
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/retrdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/rmddir_backup/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/rmddir_backup/rmd_dir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/rmddir_backup/rmd_file
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/rmddir_backup/rmd_nonemptydir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/rmddir_backup/rmd_nonemptydir/file.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/stordir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/stordir/a.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/stordir/err
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/stordir/smallfile
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/data/stordir/zerobytes
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftp_userfile
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/anonymous/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/abor/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/abor/text.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/app2
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/app4
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/app2
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/appzero
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/remoteapp1
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/remoteapp3
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/appenddir/zerobytes
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/cwdtestdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/deledir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/deledir/dele_nonemptydir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/deledir/dele_nonemptydir/file.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/getlist/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/getlist/a.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/getlist/retrtestdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/getlist/smallfile
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/getlist/zerobytes
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/123456
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/23452345
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/344
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/543
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/980
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/a/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/a.html (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/a/1.txt/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/a/2.txt/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/abcde
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/acdefb
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/aoJjugb
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/b
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/b.html (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/bcdef
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/faqs
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/list.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/q
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/list_dir/quick
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mdtmlist/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mdtmlist/smallfile
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mdtmlist/test.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mkddir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mkddir/mkd_existingdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/mkddir/mkd_newdir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/123456
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/23452345
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/344
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/543
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/980
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/a/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/a.html (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/a/1.txt/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/a/2.txt/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/abcde
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/acdefb
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/aoJjugb
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/b
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/b.html (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/bcdef
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/faqs
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/list.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/q
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/nlst_dir/quick
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/putlist/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/renamedir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/renamedir/rename_newfilename
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/restlist/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/restlist/smallfile
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/rmddir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/rmddir/rmd_file
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/rmddir/rmd_nonemptydir/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/rmddir/rmd_nonemptydir/file.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/common/zerobytes
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/user1/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/user1/user1.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/user2/
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/user2/user2.txt (with props)
incubator/mod_ftp/trunk/tests/perl-framework/t/htdocs/ftp/ftpdocs/home/user3/
Added: incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm Wed Feb 15 22:40:34 2006
@@ -0,0 +1,1218 @@
+# File : Net::FTPSSL
+# Author : kral <kral at paranici dot org>
+# Created : 01 March 2005
+# Version : 0.04
+# Revision: $Id: FTPSSL.pm,v 1.24 2005/10/23 14:37:12 kral Exp $
+
+package Ssl::FTPSSL;
+
+use strict;
+use warnings;
+use vars qw( $VERSION @EXPORT );
+use base ( 'Exporter', 'IO::Socket::SSL' );
+use Time::Local;
+use IO::Socket::INET;
+use Net::SSLeay::Handle;
+use Fcntl qw(O_WRONLY O_RDONLY O_APPEND O_CREAT O_TRUNC);
+use Carp qw( carp croak );
+use Errno qw/ EINTR /;
+
+$VERSION = "0.04";
+@EXPORT = qw( IMP_CRYPT EXP_CRYPT );
+
+use constant IMP_CRYPT => "I";
+use constant EXP_CRYPT => "E";
+
+use constant CMD_INFO => 1;
+use constant CMD_OK => 2;
+use constant CMD_MORE => 3;
+use constant CMD_REJECT => 4;
+use constant CMD_ERROR => 5;
+use constant CMD_PENDING => 0;
+use constant MODE_BINARY => "I";
+use constant MODE_ASCII => "A";
+
+sub new {
+ my $self = shift;
+ my $type = ref($self) || $self;
+ my $host = shift;
+ my %arg = @_;
+ my $port = $arg{Port} || 'ftp(21)';
+ my $debug = $arg{Debug} || 0;
+ my $timeout = $arg{Timeout} || 120;
+ my $buf_size = $arg{Buffer} || 10240;
+ my $encrypt_mode = $arg{Encryption} || EXP_CRYPT;
+ my $clear_sock;
+ croak "Host undefined" unless $host;
+
+ croak "Encryption mode unknow!"
+ if ( $encrypt_mode ne IMP_CRYPT && $encrypt_mode ne EXP_CRYPT );
+
+ # We start with a clear connection, 'cause I don't know if the
+ # connection will be implicit or explicit.
+
+
+ my $socket = IO::Socket::INET->new(
+ PeerAddr => $host,
+ PeerPort => $port,
+ Proto => 'tcp',
+ Timeout => $timeout
+ )
+ or return undef;
+
+ $socket->autoflush(1);
+
+
+ # In explicit mode, FTPSSL send an AUTH SSL command, catch the messages
+ # and then transform the clear connection in a crypted one.
+ # TODO: Let the user select the encryption type. (SSL, TLS)
+
+ if ( $encrypt_mode eq EXP_CRYPT ) {
+ return undef unless ( response($socket) == CMD_OK );
+ command( $socket, "AUTH", "TLS" );
+ response($socket);
+ }
+
+ my $obj = $type->start_SSL( $socket, SSL_version => "TLSv1" )
+ or croak IO::Socket::SSL::errstr();
+
+
+ # This is made for catch the banner when the connection
+ # is implicitly crypted.
+
+if ( $encrypt_mode eq IMP_CRYPT ) {
+ return undef unless ( response($socket) == CMD_OK );
+ }
+ ${*$obj}{'debug'} = $debug;
+ ${*$obj}{'timeout'} = $timeout;
+ ${*$obj}{'buf_size'} = $buf_size;
+ ${*$obj}{'type'} = 'A';
+
+ return $obj;
+
+}
+
+#-----------------------------------------------------------------------
+# TODO:
+# - Adding ACCT (Account) support (response 332 on password)
+sub login {
+ my $self = shift;
+ my ( $user, $pass ) = @_;
+
+ return 0 unless $self->user($user);
+
+ return 0 unless $self->password($pass);
+ return 1;
+}
+
+#-----------------------------------------------------------------------
+
+sub user {
+ my ( $self, $user ) = @_;
+ my $resp = $self->_user($user);
+ if ( !defined $resp ) {
+ return 0;
+ }
+ unless ( $resp == CMD_OK || $resp == CMD_MORE ) { return 0; }
+ return 1;
+}
+
+sub password {
+ my ( $self, $pass ) = @_;
+ my $resp = $self->_passwd($pass);
+ if ( !defined $resp) {
+ return 0;
+ }
+ unless ( $resp == CMD_OK || $resp == CMD_MORE ) { return 0; }
+ return 1;
+}
+
+sub quit {
+ my $self = shift;
+ $self->_quit() or return 0;
+ $self->close();
+ return 1;
+}
+
+sub port
+{
+ my $self =shift;
+ my $ok;
+ $self->_protp();
+ $self->_PORT("127,0,0,1,35,40");
+
+my $port = "9000";
+
+
+${*$self}{'flag'} = 1;
+
+my $listen;
+#my $cntx = ${*$self}{'_SSL_ctx'};
+ if(!($listen = IO::Socket::SSL->new( Listen => 5,
+ LocalAddr => 'localhost',
+ LocalPort => 9000,
+ Proto => 'tcp',
+ SSL_version => "TLSv1",
+ # SSL_verify_mode => 0x00,
+ # SSL_key_file => '/home/joydeep/ers-3.0.2-20051107/servers/default20/ssl/sushil.key',
+ # SSL_passwd_cb => sub {return "password"},
+ # SSL_cert_file =>'/home/joydeep/ers-3.0.2-20051107/servers/default20/ssl/sushil.cert',
+ # SSL_reuse_ctx => $cntx
+ )) ) {
+
+
+ warn "unable to create socket: ", &IO::Socket::SSL::errstr, "\n";
+ exit(0);
+}
+
+${*$self}{'data_ch'} = \*$listen;
+return 1;
+
+#}
+#
+# ${*$self}{'net_ftp_listen'} = $listen;
+# print "$listen\n";
+#
+# my($myport, @myaddr) = ($listen->sockport, split(/\./,$listen->sockhost));
+#
+# my $port = join(',', @myaddr, $myport >> 8, $myport & 0xff);
+# print "$port\n";
+# ${*$self}{'net_ftp_intern_port'} = 1;
+# ${*$self}{'flag'}= 1;
+# $ok = $self->_PORT($port);
+# ${*$self}{'net_ftp_port'} = $port;
+# print $ok;
+ #$ok;
+}
+sub pasv {
+ my $self = shift;
+
+ #$self->_pbsz();
+ $self->_protp();
+
+ $self->command("PASV");
+ my $msg = $self->getline();
+ print "<<< " . $msg if ${*$self}{'debug'};
+
+ unless ( substr( $msg, 0, 1 ) == CMD_OK ) { return 0; }
+
+ $msg =~ m/(\d+)\s(.*)\(((\d+,?)+)\)\.?/
+ ; # [227] [Entering Passive Mode] ([h1,h2,h3,h4,p1,p2]).
+ my @address = split( /,/, $3 );
+
+ my $host = join( '.', @address[ 0 .. 3 ] );
+ my $port = $address[4] * 256 + $address[5];
+ my $host1 = join(',',@address[0 .. 5]);
+
+ my $socket = Net::SSLeay::Handle->make_socket( $host, $port )
+ or croak "Can't open $host:$port";
+
+ unless ($socket) { croak "Can't open $host:$port"; }
+
+ ${*$self}{'data_ch'} = \*$socket;
+
+ return 1;
+}
+sub pasv_xfer {
+ my $self = shift;
+ $self->_protp();
+
+ $self->command("PASV");
+ my $msg = $self->getline();
+ print "<<< " . $msg if ${*$self}{'debug'};
+
+ unless ( substr( $msg, 0, 1 ) == CMD_OK ) { return 0; }
+
+ $msg =~ m/(\d+)\s(.*)\(((\d+,?)+)\)\.?/
+ ; # [227] [Entering Passive Mode] ([h1,h2,h3,h4,p1,p2]).
+ my @address = split( /,/, $3 );
+ my $host_ip_port = join(',',@address[0 .. 5]);
+
+ return $host_ip_port;
+
+}
+
+
+sub list {
+ my $self = shift;
+ my $path = shift;
+ my ( $tmp, $dati, $io, $size );
+ $dati ='';
+##For the PORT Command
+# if(${*$self}{'flag'} == 1) {
+# $self->_list($path);
+# my $pkg = ${*$self}{'data_ch'};
+# my $socket = $pkg->accept();
+# print "after accept";
+# while ( $tmp = $socket->getline() )
+# {
+# $dati .= $tmp;
+# }
+# $socket->close();
+#
+# }
+##For the PASV Command
+# else
+ if ($self->_list($path)){
+# $self->_list($path);
+ $size = ${*$self}{'buf_size'};
+ $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+ $io->autoflush(1);
+ while ( $tmp = $io->getline() )
+ {
+ $dati .= $tmp;
+ }
+ $io->close();
+
+}
+
+ #$io->close();
+ $self->response; # For catch "226 Closing data connection."
+
+ return $dati ? split( /\n/, $dati ) : ();
+}
+
+sub nlst {
+ my $self = shift;
+ my $path = shift;
+ my ( $tmp, $dati, $io, $size );
+
+ unless ( $self->pasv() ) {
+ croak "Can't set passive mode!: " . ${*$self}{'last_ftp_msg'};
+ }
+
+ if ( $self->_nlst($path) ) {
+
+ $size = ${*$self}{'buf_size'};
+
+ $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+
+ $io->autoflush(1);
+
+ while ( $tmp = $io->getline()) {
+ #unless ( defined $len ) {
+ # next if $! == EINTR;
+ # croak "System read error on read while nlst(): $!\n";
+ #}
+ $dati .= $tmp;
+ }
+ }
+
+ $io->close();
+ $self->response; # For catch "226 Closing data connection."
+
+ return $dati ? split( /\n/, $dati ) : ();
+}
+sub restart
+{
+ @_ == 2 || croak 'usage: $self->restart( BYTE_OFFSET )';
+
+ my($self,$where) = @_;
+ ${*$self}{'net_ftp_rest'} = $where;
+
+ return undef;
+}
+
+sub get {
+ my $self = shift;
+ my $file_rem = shift;
+ my $file_loc = shift;
+ my $where = shift ;
+ my ( $size, $localfd );
+ $size = ${*$self}{'buf_size'} || 2048;
+
+ unless ( $self->pasv() ) {
+ croak "Can't set passive mode!";
+ }
+ #############New-Code for REST Command#####
+ ${*$self}{'net_ftp_rest'} = $where if defined $where;
+ my $rest = ${*$self}{'net_ftp_rest'};
+ ###########################################
+ if ( ref($file_loc) && ref($file_loc) eq "GLOB" ) {
+ $localfd = \*$file_loc;
+ }
+ else {
+ #$localfd = \*FD;
+ unless(sysopen($localfd, $file_loc, O_CREAT | O_WRONLY | ($rest ? O_APPEND : O_TRUNC) )) {
+ #unless ( open( $localfd, "> $file_loc" ) ) {
+ $self->_abort();
+ croak "Can't create local file!";
+ }
+ }
+
+ if ( ${*$self}{'type'} eq MODE_BINARY ) {
+ unless ( binmode $localfd ) {
+ $self->_abort();
+ croak "Can't set binary mode to local file!";
+ }
+ }
+
+ if($rest) {
+ $self->_rest($rest);
+ }
+
+ if ( $self->_retr($file_rem) ){
+ my ( $data, $written );
+ my $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+ $io->autoflush(1);
+ while ( my $len = $io->read($data,$size ) ) {
+ unless ( defined $len ) {
+ next if $! == EINTR;
+ croak "System read error on get(): $!\n";
+ }
+ $written = syswrite $localfd, $data, $len;
+ croak "System write error on get(): $!\n" unless defined $written;
+ }
+
+ $io->close();
+ my $return_code;
+ $return_code=$self->response;
+ if ($return_code == 5) {
+ return undef;
+ }
+ return 1;
+ }
+ return undef;
+}
+
+sub put {
+ my $self = shift;
+ my $file_loc = shift;
+ my $file_rem = shift;
+ my ( $size, $localfd );
+
+ $size = ${*$self}{'buf_size'} || 2048;
+
+ unless ( $self->pasv() ) {
+ croak "Can't set passive mode!: " . ${*$self}{'last_ftp_msg'};
+ }
+
+ if ( ref($file_loc) && ref($file_loc) eq "GLOB" ) {
+ $localfd = \*$file_loc;
+ croak "If you had passed a stream, you must specify the remote filename."
+ unless $file_rem;
+ }
+ else {
+ unless ( open( $localfd, "< $file_loc" ) ) {
+ #print "Test";
+ #$self->_abort();
+ #croak "Can't open local file!";
+ print "Local File does not exits\n";
+ return undef;
+ }
+ }
+
+ unless ($file_rem) {
+ require File::Basename;
+ $file_rem = File::Basename::basename($file_loc);
+ }
+
+ if ( ${*$self}{'type'} eq MODE_BINARY ) {
+ unless ( binmode $localfd ) {
+ # $self->_abort();
+ # croak "Can't set binary mode to local file!";
+ print "Local File does not exits\n";
+ return undef;
+ }
+ }
+
+ # If alloc_size is already set, I skip this part
+ # unless ( defined ${*$self}{'alloc_size'} ) {
+ # if ( -f $file_loc ) {
+ # my $size = -s $file_loc;
+ # $self->alloc($size);
+ # }
+ # }
+
+ # delete ${*$self}{'alloc_size'};
+
+ if ( $self->_stor($file_rem) ) {
+
+ my ( $data, $written );
+ my $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+
+ $io->autoflush(1);
+
+ while ( ( my $len = sysread $localfd, $data, $size ) ) {
+ unless ( defined $len ) {
+ next if $! == EINTR;
+ croak "System read error on put(): $!\n";
+ }
+ $written = $io->write($data, $len);
+ croak "System write error on put(): $!\n" unless defined $written;
+ }
+
+ $io->close();
+ $self->response; # For catch "226 Closing data connection."
+ return 1;
+
+ }
+
+ return undef;
+}
+
+sub uput { # Unique put (STOU command)
+ my $self = shift;
+ my $file_loc = shift;
+ my $file_rem = shift;
+ my ( $size, $localfd );
+
+ $size = ${*$self}{'buf_size'} || 2048;
+
+ unless ( $self->pasv() ) {
+ $self->_abort();
+ croak "Can't set passive mode!: " . ${*$self}{'last_ftp_msg'};
+ }
+
+ if ( ref($file_loc) && ref($file_loc) eq "GLOB" ) {
+ $localfd = \*$file_loc;
+ }
+ else {
+ unless ( open( $localfd, "< $file_loc" ) ) {
+ $self->_abort();
+ croak "Can't open local file!";
+ }
+ }
+
+ if ( ${*$self}{'type'} eq 'I' ) {
+ unless ( binmode $localfd ) {
+ $self->_abort();
+ croak "Can't set binary mode to local file!";
+ }
+ }
+
+ unless ( defined ${*$self}{'alloc_size'} ) {
+ if ( -f $file_loc ) {
+ my $size = -s $file_loc;
+ $self->alloc($size);
+ }
+ }
+
+ delete ${*$self}{'alloc_size'};
+
+ if ( $self->_stou($file_rem) ) {
+
+ my ( $data, $written );
+ my $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+
+ $io->autoflush(1);
+
+ while ( ( my $len = sysread $localfd, $data, $size ) ) {
+ unless ( defined $len ) {
+ next if $! == EINTR;
+ croak "System read error on put(): $!\n";
+ }
+ $written = syswrite $io, $data, $len;
+ croak "System write error on put(): $!\n" unless defined $written;
+ }
+
+ $io->close();
+ $self->response; # For catch "226 Closing data connection."
+ return 1;
+
+ }
+
+ return undef;
+}
+
+sub alloc {
+ my $self = shift;
+ my $size = shift;
+
+ if ( $self->_alloc($size) ) {
+ ${*$self}{'alloc_size'} = $size;
+ }
+ else {
+ return 0;
+ }
+
+ return 1;
+
+}
+
+sub delete {
+ my $self = shift;
+ $self->command( "DELE", @_ );
+ return ( $self->response == CMD_OK );
+}
+
+sub auth {
+ my $self = shift;
+ $self->command( "AUTH", "TLS" );
+ return ( $self->response == CMD_OK );
+}
+
+sub pwd {
+ my $self = shift;
+ my $path;
+
+ $self->command("PWD");
+ $self->response();
+ if ( ${*$self}{'last_ftp_msg'} =~ /\"(.*)\".*/ )
+ { # 257 "/<PATH>/" is current directory.
+ ( $path = $1 ) =~
+ s/\"\"/\"/g; # "Quote-doubling" convention - RFC 959, Appendix II
+ return $path;
+ }
+ else {
+ return undef;
+ }
+}
+
+sub cwd {
+ my $self = shift;
+ $self->command( "CWD", @_ );
+ return ( $self->response == CMD_OK );
+}
+
+sub noop {
+ my $self = shift;
+ $self->command("NOOP");
+ return ( $self->response == CMD_OK );
+}
+
+sub rename {
+ my $self = shift;
+ my $old_name = shift;
+ my $new_name = shift;
+
+ return 0 unless $self->_rnfr($old_name);
+ return 0 unless $self->_rnto($new_name);
+ return 1;
+
+}
+
+sub cdup {
+ my $self = shift;
+ $self->command("CDUP");
+ return ( $self->response == CMD_OK );
+}
+
+
+# TODO: Make mkdir() working with recursion.
+sub mkdir {
+ my $self = shift;
+ my $dir = shift;
+ $self->command("MKD", $dir);
+ return ( $self->response == CMD_OK );
+}
+
+# TODO: Make rmdir() working with recursion.
+sub rmdir {
+ my $self = shift;
+ my $dir = shift;
+ $self->command("RMD", $dir);
+ return ( $self->response == CMD_OK );
+}
+
+sub site {
+ my $self = shift;
+ my $args = shift;
+
+ $self->command("SITE", $args);
+ return ( $self->response == CMD_OK );
+}
+
+sub mdtm
+{
+ my $self = shift;
+ my $file = shift;
+
+ # Server Y2K bug workaround
+ #
+ # sigh; some idiotic FTP servers use ("19%d",tm.tm_year) instead of
+ # ("%d",tm.tm_year+1900). This results in an extra digit in the
+ # string returned. To account for this we allow an optional extra
+ # digit in the year. Then if the first two digits are 19 we use the
+ # remainder, otherwise we subtract 1900 from the whole year.
+
+ $self->_MDTM($file) && $self->message =~ /((\d\d)(\d\d\d?))(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/
+ ? timegm($8,$7,$6,$5,$4-1,$2 eq '19' ? $3 : ($1-1900))
+ : undef;
+}
+
+sub size {
+ my $self = shift;
+ my $file = shift;
+ my $io;
+ if($self->supported("SIZE")) {
+ return $self->_SIZE($file)
+ ? ($self->message =~ /(\d+)\s*(bytes?\s*)?$/)[0]
+ : undef;
+ }
+ elsif($self->supported("STAT")) {
+ my @msg;
+ return undef
+ unless $self->_STAT($file) && (@msg = $self->message) == 3;
+ my $line;
+ foreach $line (@msg) {
+ return (split(/\s+/,$line))[4]
+ if $line =~ /^[-rwxSsTt]{10}/
+ }
+ }
+ else {
+ my @files = $self->list($file);
+ if(@files) {
+ return (split(/\s+/,$1))[4]
+ if $files[0] =~ /^([-rwxSsTt]{10}.*)$/;
+ }
+ }
+ undef;
+
+}
+
+sub supported {
+ @_ == 2 or croak 'usage: $ftp->supported( CMD )';
+ my $self = shift;
+ my $cmd = uc shift;
+ my $hash = ${*$self}{'net_ftp_supported'} ||= {};
+
+ return $hash->{$cmd}
+ if exists $hash->{$cmd};
+
+ return $hash->{$cmd} = 0
+ unless $self->_HELP($cmd);
+
+ my $text = $self->message;
+ if($text =~ /following\s+commands/i) {
+ $text =~ s/^.*\n//;
+ while($text =~ /(\*?)(\w+)(\*?)/sg) {
+ $hash->{"\U$2"} = !length("$1$3");
+ }
+ }
+ else {
+ $hash->{$cmd} = $text !~ /unimplemented/i;
+ }
+
+ $hash->{$cmd} ||= 0;
+
+}
+
+sub message
+{
+ @_ == 1 or croak 'usage: $obj->message()';
+
+ my $self = shift;
+
+ wantarray ? @{${*$self}{'net_cmd_resp'}}
+ : join("", @{${*$self}{'net_cmd_resp'}});
+}
+sub append {
+ my $self = shift;
+ my $file_loc = shift;
+ my $file_rem = shift;
+ my ( $size, $localfd );
+
+ $size = ${*$self}{'buf_size'} || 2048;
+
+ unless ( $self->pasv() ) {
+ croak "Can't set passive mode!: " . ${*$self}{'last_ftp_msg'};
+ }
+
+ if ( ref($file_loc) && ref($file_loc) eq "GLOB" ) {
+ $localfd = \*$file_loc;
+ croak "If you had passed a stream, you must specify the remote filename."
+ unless $file_rem;
+ }
+ else {
+ unless ( open( $localfd, "< $file_loc" ) ) {
+ #print "Test";
+ #$self->_abort();
+ #croak "Can't open local file!";
+ print "Local File does not exits\n";
+ return undef;
+ }
+ }
+
+ unless ($file_rem) {
+ require File::Basename;
+ $file_rem = File::Basename::basename($file_loc);
+ }
+
+ if ( ${*$self}{'type'} eq MODE_BINARY ) {
+ unless ( binmode $localfd ) {
+ # $self->_abort();
+ # croak "Can't set binary mode to local file!";
+ print "Local File does not exits\n";
+ return undef;
+ }
+ }
+ if ( $self->_append($file_rem) ) {
+ my ( $data, $written );
+ my $io = new IO::Handle;
+ tie( *$io, "Net::SSLeay::Handle", ${*$self}{'data_ch'} );
+
+ $io->autoflush(1);
+ while ( ( my $len = sysread $localfd, $data, $size ) ) {
+ unless ( defined $len ) {
+ next if $! == EINTR;
+ croak "System read error on put(): $!\n";
+ }
+ $written = $io->write($data, $len);
+ croak "System write error on put(): $!\n" unless defined $written;
+ }
+
+ $io->close();
+ $self->response; # For catch "226 Closing data connection."
+ return 1;
+
+ }
+
+ return undef;
+
+}
+
+sub help {
+ my $self = shift;
+ $self->command( "HELP" );
+ return ( $self->response == CMD_OK );
+}
+
+sub syst {
+ my $self = shift;
+ $self->command( "SYST" );
+ return ( $self->response == CMD_OK );
+}
+sub A {
+ my $self = shift;
+ $self->command("TYPE A");
+ return ( $self->response() == CMD_OK);
+}
+
+sub B {
+ my $self = shift;
+ $self->command("TYPE B");
+ return ( $self->response() == CMD_ERROR);
+}
+
+sub E {
+ my $self = shift;
+ $self->command("TYPE E");
+ return ( $self->response() == CMD_ERROR);
+}
+
+sub I {
+ my $self = shift;
+ $self->command("TYPE I");
+ return ( $self->response() == CMD_OK);
+}
+
+sub foo {
+ my $self = shift;
+ $self->command("TYPE FOO");
+ return ( $self->response() == CMD_ERROR);
+}
+
+
+#-----------------------------------------------------------------------
+# Type setting function
+#-----------------------------------------------------------------------
+
+sub ascii {
+ my $self = shift;
+ ${*$self}{'type'} = MODE_ASCII;
+ return $self->_type('A');
+}
+
+sub binary {
+ my $self = shift;
+ ${*$self}{'type'} = MODE_BINARY;
+ return $self->_type('I');
+}
+
+#-----------------------------------------------------------------------
+# Internal functions
+#-----------------------------------------------------------------------
+
+sub _user {
+ my $self = shift;
+ $self->command( "USER", @_ );
+ return $self->response;
+}
+
+sub _passwd {
+ my $self = shift;
+ $self->command( "PASS", @_ );
+ return $self->response;
+}
+
+sub _quit {
+ my $self = shift;
+ $self->command("QUIT");
+ return ( $self->response );
+}
+
+sub _protp {
+ my $self = shift;
+ $self->command( "PROT", "P" );
+ return ( $self->response == CMD_OK );
+}
+
+sub _pbsz {
+ my $self = shift;
+ $self->command( "PBSZ", "0" );
+ return ( $self->response == CMD_OK );
+}
+
+sub _nlst {
+ my $self = shift;
+ $self->command( "NLST", @_ );
+ return ( $self->response == CMD_INFO );
+}
+
+sub _list {
+ my $self = shift;
+ $self->command( "LIST", @_ );
+ return ( $self->response == CMD_INFO );
+}
+
+sub _type {
+ my $self = shift;
+ $self->command( "TYPE", @_ );
+ return ( $self->response == CMD_OK );
+}
+
+sub _retr {
+ my $self = shift;
+ $self->command( "RETR", @_ );
+ return ( $self->response == CMD_INFO );
+}
+
+sub _rest {
+ my $self = shift;
+ $self->command( "REST", @_ );
+ return ( $self->response == CMD_INFO );
+}
+sub _stor {
+ my $self = shift;
+ $self->command( "STOR", @_ );
+ return ( $self->response == CMD_INFO );
+}
+
+sub _stou {
+ my $self = shift;
+ $self->command( "STOU", @_ );
+ return ( $self->response == CMD_INFO );
+}
+
+sub _abort {
+ my $self = shift;
+ $self->command("ABOR");
+ return ( $self->response == CMD_OK );
+}
+
+sub _alloc {
+ my $self = shift;
+ $self->command( "ALLO", @_ );
+ return ( $self->response == CMD_OK );
+}
+
+sub _rnfr {
+ my $self = shift;
+ $self->command( "RNFR", @_ );
+ return ( $self->response == CMD_MORE );
+}
+
+sub _rnto {
+ my $self = shift;
+ $self->command( "RNTO", @_ );
+ return ( $self->response == CMD_OK );
+}
+sub _PORT {
+ my $self = shift;
+ $self->command("PORT", @_);
+ return ( $self->response == CMD_INFO);
+}
+sub _SIZE {
+ my $self = shift;
+ $self->command("SIZE",@_);
+ return ( $self->response() == CMD_OK );
+}
+sub _STAT {
+ my $self = shift;
+ $self->command("STAT",@_);
+ return ( $self->response() == CMD_OK );
+}
+sub _HELP {
+ my $self = shift;
+ $self->command("HELP",@_);
+ return ( $self->response() == CMD_OK );
+}
+sub _MDTM {
+ my $self = shift;
+ $self->command("MDTM",@_);
+ return ( $self->response() == CMD_OK );
+ }
+sub _append {
+ my $self = shift;
+ $self->command("APPE",@_);
+ return ( $self->response() == CMD_INFO);
+}
+
+#-----------------------------------------------------------------------
+# Messages handler
+#-----------------------------------------------------------------------
+
+sub command {
+ my $self = shift;
+ my @args;
+ my $data;
+ @args = grep defined($_), @_;
+ # remove undef values from the list. Maybe I have to find out why those undef were passed.
+ $data = join(
+ " ",
+ map {
+ /\n/
+ ? do { my $n = $_; $n =~ tr/\n/ /; $n }
+ : $_;
+ } @args
+ );
+ $data .= "\015\012";
+
+ print STDERR ">>> +++ " . $data
+ if ref($self) eq "Ssl::FTPSSL" && ${*$self}{'debug'};
+ my $written;
+ my $len = length $data;
+
+ $written = $self->print($data);
+ unless ( defined $written ) {
+ carp "Can't write on socket: $!";
+ $self->close;
+ return undef;
+ }
+ ${*$self}{'net_cmd_resp'} = []; # the response
+ return 1;
+
+}
+
+sub response {
+ my $self = shift;
+ my ( $data, $code );
+ ${*$self}{'net_cmd_resp'} ||= [];
+ my $SELF = substr($self, 0, 16);
+ if($SELF eq 'IO::Socket::INET') {
+ $self->recv($data,1024);
+ }
+ else {
+ $data =$self->readline();
+ }
+# unless( defined $data ) {
+# croak "Can't read on socket: $!";
+# }
+ if ( !defined $data ) {
+ return undef;
+ }
+ my @lines = split( "\015\012", $data );
+ push(@{${*$self}{'net_cmd_resp'}},$data);
+ foreach my $line ( @lines ) {
+
+ $line =~ m/^(\d+)(\-?)(.*)$/s;
+ $code = $1;
+ print STDERR "<<< *** " . $line ."\n"
+ if ref($self) eq "Ssl::FTPSSL" && ${*$self}{'debug'};
+
+ if ( ref($self) eq "Ssl::FTPSSL" ) {
+ ${*$self}{'last_ftp_msg'} = $line;
+ }
+
+ last if $2 ne '-';
+
+ }
+ return substr( $code, 0, 1 );
+
+}
+
+sub last_message {
+ my $self = shift;
+ return ${*$self}{'last_ftp_msg'};
+}
+
+
+
+__END__
+
+=head1 NAME
+
+Net::FTPSSL - A FTP over SSL/TLS class
+
+=head1 VERSION 0.04
+
+=head1 SYNOPSIS
+
+ use Net::FTPSSL;
+
+ my $ftps = Net::FTPSSL->new('ftp.yoursecureserver.com',
+ Port => 21,
+ Encryption => 'E',
+ Debug => 1)
+ or die "Can't open ftp.yoursecureserver.com";
+
+ $ftps->login('anonymous', 'user@localhost')
+ or die "Can't login: ", $ftps->$last_message();
+
+ $ftps->cwd("/pub") or die "Can't change directory: ", $ftps->last_message;
+
+ $ftps->get("file") or die "Can't get file: ", $ftps->last_message;
+
+ $ftps->quit();
+
+=head1 DESCRIPTION
+
+C<Net::FTPSSL> is a class implementing a simple FTP client over a Secure
+Shell Layer (SSL) connection written in Perl as described in RFC959 and
+RFC2228.
+
+=head1 CONSTRUCTOR
+
+=over 4
+
+=item new ( HOST [, OPTIONS ])
+
+Creates a new B<Net::FTPSSL> object and opens a connection with the
+C<HOST>. C<HOST> is the address of the FTP server and it's a required
+argument. OPTIONS are passed in a hash like fashion, using key and value
+pairs.
+
+C<OPTIONS> are:
+
+B<Port> - The port number to connect to on the remote FTP server.
+Default value is 21.
+
+B<Encryption> - The connection can be implicitly (B<IMP_CRYPT>) or
+explicitly (B<EXP_CRYPT>) encrypted.
+In explicit cases the connection begins clear and became encrypted after an
+"AUTH" command is sent. Default value is EXP_CRYPT.
+
+B<Timeout> - Set a connection timeout value. Default value is 120.
+
+B<Buffer> - This is the block size that Net::FTPSSL will use when a transfer is
+made. Default value is 10240.
+
+B<Debug> - This set the debug informations option on/off. Default is off.
+
+=back
+
+=head1 METHODS
+
+All the methods return I<true> or I<false>, true when the operation was
+a succes and false when failed. Methods like B<list> or B<nlst> return an
+empty array when fail.
+
+=over 4
+
+=item login(USER, PASSWORD)
+
+Use the given informations to log into the FTP server.
+
+=item list([DIRECTORY])
+
+This method returns a list of files in this format:
+
+ total 5
+ drwxrwx--- 1 owner group 512 May 31 11:16 .
+ drwxrwx--- 1 owner group 512 May 31 11:16 ..
+ drwxrwx--- 1 owner group 512 Oct 27 2004 foo
+ drwxrwx--- 1 owner group 512 Oct 27 2004 pub
+ drwxrwx--- 1 owner group 512 Mar 29 12:09 bar
+
+If DIRECTORY is omitted, the method will return the list of the current
+directory.
+
+=item nlst([DIRECTORY])
+
+Same as C<list> but returns the list in this format:
+
+ foo
+ pub
+ bar
+
+Personally, I suggest to use list instead of nlst.
+
+=item ascii
+
+Sets the transfer file in ASCII mode.
+
+=item binary
+
+Sets the transfer file in binary mode. No transformation will be done.
+
+=item get(REMOTE_FILE, LOCAL_FILE)
+
+Retrives the REMOTE_FILE from the ftp server. LOCAL_FILE may be a filename or a
+filehandle. Return undef if it fails.
+
+=item put(LOCAL_FILE, [REMOTE_FILE])
+
+Stores the LOCAL_FILE into the remote ftp server. LOCAL_FILE may be filehandle,
+but in this case REMOTE_FILE is required. Return undef if it fails.
+
+=item delete(REMOTE_FILE)
+
+Deletes the indicated REMOTE_FILE.
+
+=item cwd(DIR)
+
+Attempts to change directory to the directory given in DIR.
+
+=item pwd
+
+Returns the full pathname of the current directory.
+
+=item cdup
+
+Changs directory to the parent of the current directory.
+
+=item mkdir(DIR)
+
+Creates the indicated directory. No recursion at the moment.
+
+=item rmdir(DIR)
+
+Removes the empty indicated directory. No recursion at the moment.
+
+=item noop
+
+It specifies no action other than the server send an OK reply.
+
+=back
+
+=head1 AUTHOR
+
+Marco Dalla Stella - <kral at paranoici dot org>
+
+=head1 SEE ALSO
+
+L<Net::Cmd>
+
+L<Net::FTP>
+
+L<Net::SSLeay::Handle>
+
+L<IO::Socket::SSL>
+
+RFC 2228 - L<ftp://ftp.rfc-editor.org/in-notes/rfc2228.txt>
+
+=head1 CREDITS
+
+Graham Barr <gbarr at pobox dot com> - for have written such a great
+collection of modules (libnet).
+
+=head1 BUGS
+
+I'm currently testing the module with proftpd and Titan FTP. I'm having a lot
+of trouble with the second at the moment. Put or get phases seem to work ok
+(sysread and syswrite don't return any errors) but the server doesn't receive
+all the sent data. I'm working on it.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2005 Marco Dalla Stella. All rights reserved. This
+program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
Propchange: incubator/mod_ftp/trunk/tests/perl-framework/Ssl/FTPSSL.pm
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in Wed Feb 15 22:40:34 2006
@@ -0,0 +1,152 @@
+#t/TEST -ftp
+
+<IfModule mod_ftp.c>
+
+ FTPLimitLoginServer 2
+ FTPLimitLoginUser 2
+ FTPLimitDBFile "@SERVERROOT@/htdocs/ftp/ftpdocs/dbfile"
+
+ <VirtualHost _default_:mod_ftp>
+ FTP On
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/ftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/ftpdocs">
+ AuthType Basic
+ AuthName ftp_authorization
+ AuthUserFile "@SERVERROOT@/htdocs/ftp/ftp_userfile"
+ Require valid-user
+ </Directory>
+ FTPHomeDir /home
+ FTPJailUser On
+ FTPOptions CreateHomeDirs
+ FTPTimeoutLogin 20
+ FTPTimeoutIdle 20
+ FTPTimeoutData 20
+ FTPMaxLoginAttempts 3
+ FTPPasvRange 10000 12000
+ </VirtualHost>
+
+ <VirtualHost ftp_anon_host>
+ FTP On
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/anonftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/anonftpdocs">
+ AuthType Basic
+ AuthName anon_authorization
+ Require valid-user
+ Anonymous_NoUserID off
+ Anonymous_MustGiveEmail on
+ Anonymous_VerifyEmail on
+ Anonymous anonymous ftp ftp1
+ </Directory>
+ FTPMaxLoginAttempts 3
+ </VirtualHost>
+
+
+ <IfModule mod_ssl.c>
+#######################################FTP-SSL-IMPLICIT SETTINGS####################################
+
+ <VirtualHost ftp_ssl_implicit>
+
+ FTP On
+ FTPImplicitSSL on
+ SSLEngine On
+
+ SSLCertificateFile @SSLCA@/asf/certs/server.crt
+ SSLCertificateKeyFile @SSLCA@/asf/keys/server.pem
+
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/ftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/ftpdocs">
+ AuthType Basic
+ AuthName ftp_authorization
+ AuthUserFile "@SERVERROOT@/htdocs/ftp/ftp_userfile"
+ Require valid-user
+ </Directory>
+ FTPHomeDir /home
+ FTPJailUser On
+ FTPOptions CreateHomeDirs
+ FTPTimeoutLogin 20
+ FTPTimeoutIdle 20
+ FTPTimeoutData 20
+ FTPMaxLoginAttempts 3
+ FTPPasvRange 10000 12000
+ </VirtualHost>
+
+
+ <VirtualHost ftp_ssl_anon_host>
+ FTP On
+ FTPImplicitSSL on
+ SSLEngine On
+
+ SSLCertificateFile @SSLCA@/asf/certs/server.crt
+ SSLCertificateKeyFile @SSLCA@/asf/keys/server.pem
+
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/anonftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/anonftpdocs">
+ AuthType Basic
+ AuthName anon_authorization
+ Require valid-user
+ Anonymous_NoUserID off
+ Anonymous_MustGiveEmail on
+ Anonymous_VerifyEmail on
+ Anonymous anonymous ftp ftp1
+ </Directory>
+ FTPMaxLoginAttempts 3
+ </VirtualHost>
+
+####################################################################################################
+
+#######################################FTP-SSL-EXPLICIT SETTINGS####################################
+
+ <VirtualHost ftp_ssl_explicit>
+
+ FTP On
+ FTPOptions RequireSSL
+ SSLEngine On
+
+ SSLCertificateFile @SSLCA@/asf/certs/server.crt
+ SSLCertificateKeyFile @SSLCA@/asf/keys/server.pem
+
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/ftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/ftpdocs">
+ AuthType Basic
+ AuthName ftp_authorization
+ AuthUserFile "@SERVERROOT@/htdocs/ftp/ftp_userfile"
+ Require valid-user
+ </Directory>
+ FTPHomeDir /home
+ FTPJailUser On
+ FTPOptions CreateHomeDirs
+ FTPTimeoutLogin 20
+ FTPTimeoutIdle 20
+ FTPTimeoutData 20
+ FTPMaxLoginAttempts 3
+ FTPPasvRange 10000 12000
+ </VirtualHost>
+
+
+ <VirtualHost ftp_ssl_anon_host_expl>
+ FTP On
+ FTPOptions RequireSSL
+ SSLEngine On
+
+ SSLCertificateFile @SSLCA@/asf/certs/server.crt
+ SSLCertificateKeyFile @SSLCA@/asf/keys/server.pem
+
+ DocumentRoot "@SERVERROOT@/htdocs/ftp/anonftpdocs"
+ <Directory "@SERVERROOT@/htdocs/ftp/anonftpdocs">
+ AuthType Basic
+ AuthName anon_authorization
+ Require valid-user
+ Anonymous_NoUserID off
+ Anonymous_MustGiveEmail on
+ Anonymous_VerifyEmail on
+ Anonymous anonymous ftp ftp1
+ </Directory>
+ FTPMaxLoginAttempts 3
+ </VirtualHost>
+
+####################################################################################################
+
+
+ </IfModule>
+
+</IfModule>
Propchange: incubator/mod_ftp/trunk/tests/perl-framework/t/conf/ftp.conf.in
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/aa_setup.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/aa_setup.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/aa_setup.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/aa_setup.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,74 @@
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+plan tests => 4, need_module 'mod_ftp';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+my $vars = Apache::Test::vars();
+$document_root=Apache::Test::vars('documentroot');
+$install_root="$document_root/ftp";
+
+my $config = Apache::Test::config();
+my $basedir = $config->{httpd_basedir};
+my $libtool = "$basedir/build/libtool";
+
+#This script will auto-generate a file of 61 MB.
+open (BIG_FILE, "> $install_root/data/stordir/bigstor");
+for(my $i=0; $i <5585432; $i++) {
+ print BIG_FILE "abcdefghijkl";
+}
+close (BIG_FILE);
+
+if (!(-e "$install_root/ftpdocs/home/common/getlist/bigretr"))
+{
+ @command=("ln","-s", "$install_root/data/stordir/bigstor", "$install_root/ftpdocs/home/common/getlist/bigretr");
+ system ( @command);
+}
+
+if (!(-e "$install_root/ftpdocs/home/common/abor/bigretr"))
+{
+ @command=("ln","-s", "$install_root/data/stordir/bigstor", "$install_root/ftpdocs/home/common/abor/bigretr");
+ system ( @command);
+}
+
+#This script will compile a c program and create a file a.out, which will be used for testing using binary files.It also copies the a.out file created into the appropriate directories, which will be used for testing by other scripts.
+my $datadir="$document_root/ftp/data/";
+
+if($^O eq "hpux"){
+ @command=( "cc", "-c","$datadir/hello.c", "-o", "$datadir/a.o" );
+ system ( @command );
+
+ @command=( "/usr/ccs/bin/ld", "/usr/ccs/lib/crt0.o", "-u", "main", "-o", "$datadir/a.out", "$datadir/a.o", "-lc");
+ system ( @command );
+ print "...$command[0] $command[1] $command[2]\n";
+}
+else {
+ @command=("cc","$datadir/hello.c" , "-o", "$datadir/a.out");
+ system ( @command );
+}
+
+@command=( "chmod","777", "$datadir/a.out");
+system ( @command );
+
+sub makeprog {
+ $dir=$_[0];
+
+ @command=( "cp","$datadir/a.out", "$dir");
+ system ( @command );
+
+ $expected = "File Exists";
+ $actual="";
+ $actual="File Exists" if -e "$dir/a.out";
+ ok t_cmp($actual,$expected,"Check if the a.out file exists");
+
+ $expected = "File is executable";
+ $actual="";
+ $actual="File is executable" if -x "$dir/a.out";
+ ok t_cmp($actual,$expected,"Check if the a.out file is executable");
+}
+
+#setup an executable file in "getlist" dir.
+makeprog("$install_root/ftpdocs/home/common/getlist");
+
+#setup an executable file in "stordir" dir.
+makeprog("$install_root/data/stordir");
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/accesstransfer.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/accesstransfer.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/accesstransfer.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/accesstransfer.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,180 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 11, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my $i=0;
+
+
+my @username=(
+"common",
+'incorrect',
+);
+
+my @password=(
+"password",
+"password",
+'incorrect',
+);
+
+my @expected=(
+'Login Successful',
+'Login Failed',
+'Login Failed',
+'CWD Successful',
+'CWD Failed',
+'CDUP Successful',
+'CDUP Successful',
+#'PORT Successful',
+'PASV Successful',
+'TYPE A Successful',
+'TYPE I Successful',
+'Quit Successful',
+
+);
+
+my @isarray=(
+'Login as normal user',
+'Attempting to Login with incorrect username',
+'Attempting to login as normal user and incorrect password',
+'Change working directory to existing directory',
+'Change working directory to a non-existing directory',
+'Giving CDUP command from a sub-directory',
+'Giving CDUP command from root directory',
+#'PORT Command',
+'PASV Command',
+'Type set to ASCII',
+'Type set to Binary',
+'Quit',
+);
+
+
+my $actual;
+
+for ($r=0;$r<2;$r++)
+{
+ my $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption => 'E',Debug => 0) or die "Couldn't connect to $host\n";
+ if ($ftp->login($username[$r],$password[$r]))
+ {
+ $actual="Login Successful";
+ }
+ else
+ {
+ $actual="Login Failed";
+ }
+ ok t_cmp( $actual,$expected[$i], $isarray[$i]);
+
+ $i=$i+1;
+ $ftp->quit() or die "Unable to quit";
+}
+
+
+#Opening a new session as default MaxLoginAttempts (3) is reached in previous session
+
+my $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption => 'E',Debug => 0) or die "Couldn't connect to $host\n";
+
+$ftp->login("common","password") or die "Login failed";
+
+my @subdir=(
+'cwdtestdir',
+'nonexisting',
+);
+
+
+for ($r=0;$r<2;$r++)
+{
+ if ($ftp->cwd($subdir[$r]))
+ {
+ $actual="CWD Successful";
+ }
+ else
+ {
+ $actual="CWD Failed";
+ }
+ ok t_cmp( $actual,$expected[$i] , $isarray[$i]);
+ $i=$i+1;
+}
+
+for ($r=0;$r<2;$r++)
+{
+ if ($ftp->cdup())
+ {
+ $actual="CDUP Successful";
+ }
+ else
+ {
+ $actual="CDUP Failed";
+ }
+ ok t_cmp( $actual,$expected[$i], $isarray[$i]);
+ $i=$i+1;
+
+}
+
+#if ($ftp->port())
+#{
+# $actual="PORT Successful";
+#}
+#else
+#{
+# $actual="PORT Failed";
+#}
+#ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
+
+#$i=$i+1;
+
+
+if ($ftp->pasv())
+{
+ $actual="PASV Successful";
+}
+else
+{
+ $actual="PASV Failed";
+}
+ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
+
+$i=$i+1;
+
+if ($ftp->ascii())
+{
+ $actual="TYPE A Successful";
+}
+else
+{
+ $actual="TYPE A Failed";
+}
+ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
+
+$i=$i+1;
+
+
+if ($ftp->binary())
+{
+ $actual="TYPE I Successful";
+}
+else
+{
+ $actual="TYPE I Failed";
+}
+ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
+
+$i=$i+1;
+
+
+if ($ftp->quit())
+{
+ $actual="Quit Successful";
+}
+else
+{
+ $actual="Quit Failed";
+}
+
+ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_limitlogin.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_limitlogin.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_limitlogin.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_limitlogin.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,141 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 6, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_anon_host_expl');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my @expected=(
+ 'Test Successful',
+ 'Test Failed',
+ 'Test Successful',
+);
+my $actual='Test Successful';
+
+my @username=(
+ "anonymous",
+ "ftp",
+ "ftp1",
+);
+
+my $password="@.";
+
+
+my $j=0;
+
+#LimitLoginServer 2
+#LimitLoginUser 2
+
+my @isarray=(
+ "\nUser:Anonymous\nLogging in twice using same username",
+ "\nUser:Anonymous\nLogging in third time using same username",
+ "\nUser:Anonymous\nLogout once and Login again using same username",
+ "\nUser:Anonymous\nLogging in twice using different usernames",
+ "\nUser:Anonymous\nLogging in third time using different username",
+ "\nUser:Anonymous\nLogout once and Login again using different username",
+);
+
+$actual="Test Successful";
+my $ftp1;
+my $ftp2;
+my $ftp3;
+
+
+########### Test with same username ###########
+
+
+$ftp1 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp1->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+sleep(3);
+
+$ftp2 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp2->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[0],$isarray[$j]);
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[0],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[1],$isarray[$j+1]);
+
+$ftp3->quit();
+$ftp1->quit();
+
+sleep(3);
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+
+if($ftp3->login($username[0],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[2],$isarray[$j+2]);
+
+$ftp2->quit();
+$ftp3->quit();
+
+########### Test with different usernames ###########
+
+$actual="Test Successful";
+
+$ftp1 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp1->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+sleep(3);
+
+$ftp2 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp2->login($username[1],$password))){
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[0],$isarray[$j]);
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[2],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[1],$isarray[$j+1]);
+
+$ftp3->quit();
+$ftp1->quit();
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[2],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[2],$isarray[$j+2]);
+$ftp2->quit();
+$ftp3->quit();
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_login.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_login.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_login.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/anon_login.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,53 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 2, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_anon_host_expl');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my $i=0;
+
+
+my @username=(
+ "anonymous",
+ "anonymous",
+);
+
+my @password=(
+ "@.",
+ 'xx',
+);
+
+my @expected=(
+ 'Login Successful',
+ 'Login Failed',
+);
+
+my @isarray=(
+ 'Login as anonymous user',
+ 'Attempting to login as anonymous user and incorrect e-mail id',
+);
+
+
+
+my $actual;
+
+for ($r=0;$r<2;$r++){
+ my $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+ print"***$ftp***";
+ if ($ftp->login($username[$r],$password[$r])){
+ $actual="Login Successful";
+ }
+ else{
+ $actual="Login Failed";
+ }
+ ok t_cmp ( $actual,$expected[$i], $isarray[$i]);
+
+ $i=$i+1;
+ $ftp->quit() or die "Unable to quit";
+}
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/append.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/append.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/append.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/append.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,146 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 10, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+use File::Path;
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+my $vars = Apache::Test::vars();
+$document_root=Apache::Test::vars('documentroot');
+$install_root="$document_root/ftp";
+
+my $mydir="$install_root/ftpdocs/home/common/appenddir";
+my $mydir1="$install_root/data/appenddir_backup";
+rmtree($mydir);
+mkdir $mydir;
+`cp -r $mydir1/\* $mydir`;
+my $ftp;
+
+
+
+my @expected=(
+ 'APPE Successful',
+ 'APPE Successful',
+ 'APPE Failed',
+ 'APPE Successful',
+ 'APPE Successful',
+ 'APPE Successful',
+ 'APPE Successful',
+ 'APPE Failed',
+ 'APPE Successful',
+ 'APPE Successful',
+# 'APPE Successful',
+# 'APPE Successful',
+# 'APPE Failed',
+# 'APPE Successful',
+# 'APPE Successful',
+# 'APPE Successful',
+# 'APPE Successful',
+# 'APPE Failed',
+# 'APPE Successful',
+# 'APPE Successful',
+);
+
+my $actual;
+
+my @isarray=(
+ 'PASV:Append local file to existing remote file in ASCII mode',
+ 'PASV:Append local file to non-existing remote file in ASCII mode',
+ 'PASV:Attempting to append a non-existing file',
+ 'PASV:Append zero bytes file to existing remote file in ASCII mode',
+ 'PASV:Append zero bytes file to non-existing remote file in ASCII mode',
+ 'PASV:Append local file to existing remote file in Binary mode',
+ 'PASV:Append local file to non-existing remote file in Binary mode',
+ 'PASV:Attempting to append a non-existing file',
+ 'PASV:Append zero bytes file to existing remote file in Binary mode',
+ 'PASV:Append zero bytes file to non-existing remote file in Binary mode',
+ # 'PORT:Append local file to existing remote file in ASCII mode',
+ # 'PORT:Append local file to non-existing remote file in ASCII mode',
+ # 'PORT:Attempting to append a non-existing file',
+ # 'PORT:Append zero bytes file to existing remote file in ASCII mode',
+ # 'PORT:Append zero bytes file to non-existing remote file in ASCII mode',
+ # 'PORT:Append local file to existing remote file in Binary mode',
+ # 'PORT:Append local file to non-existing remote file in Binary mode',
+ # 'PORT:Attempting to append a non-existing file',
+ # 'PORT:Append zero bytes file to existing remote file in Binary mode',
+ # 'PORT:Append zero bytes file to non-existing remote file in Binary mode',
+);
+
+my @locallisting=(
+ 'app1',
+ 'app2',
+ 'nonexisting',
+ 'zerobytes',
+ 'zerobytes',
+ 'app3',
+ 'app4',
+ 'nonexisting',
+ 'zerobytes',
+ 'zerobytes',
+);
+
+my @remotelisting=(
+ 'remoteapp1',
+ '',
+ 'remoteapp1',
+ 'appzero',
+ '',
+ 'remoteapp3',
+ '',
+ 'remoteapp3',
+ 'appzero',
+ '',
+);
+
+
+
+for ($x=0;$x<1;$x++){
+ if ($x==0){
+ #Using Passive mode of data transfer
+ $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+ }
+# else{
+# #Using Port mode of data transfer
+# $ftp = Net::FTP->new($host,Port =>$port,Passive =>0) or die "Couldn't connect to $host\n";
+# }
+
+ $ftp->login("common","password") or die "Login failed";
+
+ for($r=0;$r<10;$r++){
+ $ftp->pasv();
+ if ($r>4){
+ $ftp->binary();
+ }
+ else{
+ $ftp->ascii();
+ }
+
+
+ if (($r==0) ||($r==2) ||($r==3) ||($r==5) ||($r==7)||($r==8)){
+ $status=$ftp->append("$install_root/data/appenddir/$locallisting[$r]","appenddir/$remotelisting[$r]");
+ }
+ else{
+ $ftp->cwd("appenddir");
+ $status=$ftp->append("$install_root/data/appenddir/$locallisting[$r]");
+ $ftp->cdup();
+ }
+ if (defined($status)){
+ $actual="APPE Successful";
+ }
+ else{
+ $actual="APPE Failed";
+ }
+
+ ok t_cmp ($actual , $expected[$r+10*$x], $isarray[$r+10*$x]);
+
+
+ }
+
+}
+$ftp->quit() or die "Unable to quit";
+
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/dele.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/dele.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/dele.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/dele.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,78 @@
+use Ssl::FTPSSL;
+use File::Path;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 4, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my $vars = Apache::Test::vars();
+$document_root=Apache::Test::vars('documentroot');
+$install_root="$document_root/ftp";
+
+my $mydir="$install_root/ftpdocs/home/common/deledir";
+my $mydir1="$install_root/data/deledir_backup";
+rmtree($mydir);
+mkdir $mydir;
+`cp -r $mydir1/\* $mydir`;
+
+$username = "common";
+$password = "password";
+
+my @deletelist=(
+'dele_file',
+'dele_nonexistfile',
+'dele_dir',
+'dele_nonemptydir',
+);
+
+$r=0;
+
+my @expected =(
+"DELE Successful",
+"DELE Failed",
+"DELE Successful",
+"DELE Failed",
+);
+
+my $actual;
+
+my @isarray=(
+"Delete an existing file",
+"Delete a non-existing file",
+"Delete an empty directory",
+"Attempting to delete a non-empty directory",
+);
+
+my $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption => 'E',Debug => 0) or die "Couldn't connect to $host\n";
+
+$ftp->login($username, $password) or die "Login failed \n";
+
+if($ftp->cwd("deledir"))
+{
+}
+else
+{
+ die "Couldn't change to directoty deledir";
+}
+
+for($r=0;$r<4;$r++)
+{
+ if( $ftp->delete($deletelist[$r]))
+ {
+ $actual="DELE Successful";
+ }
+ else
+ {
+ $actual="DELE Failed";
+ }
+ ok t_cmp ( $actual,$expected[$r],$isarray[$r]);
+}
+
+$ftp->quit() or die "Unable to quit\n";
+
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/help.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/help.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/help.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/help.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,33 @@
+use Ssl::FTPSSL;
+use Carp qw( carp croak );
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 1, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my $username = "common";
+my $password = "password";
+
+my $actual;
+my $expected='Success';
+my $isarray= 'HELP command successful';
+
+my $ftp = Ssl::FTPSSL->new($host, Port =>$port,Encryption => 'E',Debug => 0) or die "Couldn't connect to $host\n";
+
+$ftp->login($username, $password) or die "Login failed \n";
+
+if ($ftp->help()) {
+ $actual="Success";
+}
+else{
+ $actual="Failure";
+}
+ok t_cmp ($actual,$expected,$isarray);
+
+$ftp->close();
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/homeDir.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/homeDir.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/homeDir.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/homeDir.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,110 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+plan tests => 3, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my $vars = Apache::Test::vars();
+$document_root=Apache::Test::vars('documentroot');
+$install_root="$document_root/ftp";
+
+my @username=(
+ "user1",
+ "user2",
+ "user3",
+);
+my $password = "password";
+
+#$dirName;
+
+my $r=0;
+
+my @directivestring=(
+ "FTPHomeDir",
+ "FTPJailUser",
+ "FTPOptions CreateHomeDirs"
+);
+
+my @expected =(
+ "FTPHomeDir Successful",
+ "FTPJailUser Successful",
+ "FTPOptions CreateHomeDirs Successful",
+);
+
+my $actual;
+my @isarray=(
+ "FTPHomeDir:Log into user's home directory",
+ "FTPJailUser: Attempting to change to a root directory",
+ "FTPOptions CreateHomeDirs:User whose home directory is not present, is logged in after the home directory is created",
+);
+
+rmdir("$install_root/ftpdocs/home/user3");
+my $ftp = Ssl::FTPSSL->new($host,Port=>$port,Encryption =>'E',Debug => 0 ) or die "Couldn't connect to $host\n";
+
+for($r=0;$r<3;$r++){
+ $ftp->login("$username[$r]", $password) or die "Login Failed. \n";
+
+ if($r==0){
+ my @filelist=$ftp->nlst();
+ if(@filelist!=0){
+ my $fileLine = $filelist[0];
+ chomp $fileLine;
+ my ($name,$other)=split(/\s+/,$fileLine);
+ if($name eq "user1.txt"){
+ $actual ="$directivestring[$r] Successful";
+ }
+ else{
+ $actual ="$directivestring[$r] Failed";
+ }
+ }
+ else{
+ die "NLST Failed \n";
+ }
+
+ }
+
+
+ if($r==1){
+ #$dirname1= $ftp->pwd();
+ $ftp->cdup();
+ #$dirname2= $ftp->pwd();
+ my @filelist=$ftp->nlst();
+ if(@filelist!=0){
+ my $fileLine = $filelist[0];
+ chomp $fileLine;
+ my ($name,$other)=split(/\s+/,$fileLine);
+ if($name eq "user2.txt"){
+ $actual ="$directivestring[$r] Successful";
+ }
+ else{
+ $actual ="$directivestring[$r] Failed";
+ }
+ }
+ else{
+ die "NLST Failed \n";
+ }
+ }
+
+
+ if($r==2){
+ my @filelist=$ftp->nlst();
+ if(@filelist==0){
+ $actual ="$directivestring[$r] Successful";
+ }
+ else{
+ $actual ="$directivestring[$r] Failed";
+ }
+
+
+ }
+
+
+ ok t_cmp ( $actual,$expected[$r], $isarray[$r]);
+
+}
+$ftp->quit() or die "Unable to quit\n";
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/limitlogin.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/limitlogin.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/limitlogin.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/limitlogin.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,141 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+plan tests => 6, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+my @expected=(
+ 'Test Successful',
+ 'Test Failed',
+ 'Test Successful',
+);
+my $actual;
+
+my @username=(
+ "user1",
+ "user2",
+ "user3",
+);
+
+my $password="password";
+
+
+my $j=0;
+
+#LimitLoginServer 2
+#LimitLoginUser 2
+
+my @isarray=(
+ "\nUser:Normal\nLogging in twice using same username",
+ "\nUser:Normal\nLogging in third time using same username",
+ "\nUser:Normal\nLogout once and Login again using same username",
+ "\nUser:Normal\nLogging in twice using different usernames",
+ "\nUser:Normal\nLogging in third time using different username",
+ "\nUser:Normal\nLogout once and Login again using different username",
+);
+
+$actual="Test Successful";
+my $ftp1;
+my $ftp2;
+my $ftp3;
+
+
+########### Test with same username ###########
+
+
+$ftp1 = Ssl::FTPSSL->new($host,Port =>$port, Encryption => 'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp1->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+sleep(3);
+
+$ftp2 = Ssl::FTPSSL->new($host,Port =>$port, Encryption => 'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp2->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[0],$isarray[$j]);
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port, Encryption => 'E',Debug =>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[0],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[1],$isarray[$j+1]);
+
+$ftp3->quit();
+$ftp1->quit();
+
+sleep(3);
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port, Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+
+if($ftp3->login($username[0],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[2],$isarray[$j+2]);
+
+$ftp2->quit();
+$ftp3->quit();
+
+########### Test with different usernames ###########
+
+$actual="Test Successful";
+
+$ftp1 = Ssl::FTPSSL->new($host,Port =>$port, Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp1->login($username[0],$password))){
+ $actual="Test Failed";
+}
+
+sleep(3);
+
+$ftp2 = Ssl::FTPSSL->new($host,Port =>$port, Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if(!($ftp2->login($username[1],$password))){
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[0],$isarray[$j]);
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E', Debug=>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[2],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[1],$isarray[$j+1]);
+
+$ftp3->quit();
+$ftp1->quit();
+
+sleep(3);
+
+$ftp3 = Ssl::FTPSSL->new($host,Port =>$port, Encryption =>'E',Debug =>0) or die "Couldn't connect to $host\n";
+if($ftp3->login($username[2],$password)){
+ $actual="Test Successful";
+}
+else {
+ $actual="Test Failed";
+}
+
+ok t_cmp ( $actual,$expected[2],$isarray[$j+2]);
+$ftp2->quit();
+$ftp3->quit();
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/list.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/list.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/list.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/list.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,239 @@
+use Ssl::FTPSSL;
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+plan tests => 19, need_module 'mod_ftp', need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+$username = ("common");
+$password = ("password");
+
+#$listFileName = "listFile";
+my @filelist;
+
+my @expected =(
+"LIST * Successful",
+"LIST *.html Successful",
+"LIST a*b Successful",
+"LIST 3* Successful",
+"LIST *3 Successful",
+"LIST *i* Successful",
+"LIST a* b* Successful",
+"LIST *.* Successful",
+"LIST q Successful",
+"LIST a/* Successful",
+"LIST 2*2* Successful",
+"LIST a* Successful",
+"LIST 9* Successful",
+"LIST b Successful",
+"LIST a*b Successful",
+"LIST b* Successful",
+"LIST q* Successful",
+"LIST *q Successful",
+"LIST 12* Successful",
+);
+
+my $actual;
+my $l;
+my @isarray_pasv=(
+'PASV:Issue LIST * Command',
+'PASV:Issue LIST *.html Command',
+'PASV:Issue LIST a*b Command',
+'PASV:Issue LIST 3* Command',
+'PASV:Issue LIST *3 Command',
+'PASV:Issue LIST *i* Command',
+'PASV:Issue LIST a* b* Command',
+'PASV:Issue LIST *.* Command',
+'PASV:Issue LIST q Command',
+'PASV:Issue LIST a/* Command',
+'PASV:Issue LIST 2*2* Command',
+'PASV:Issue LIST a* Command',
+'PASV:Issue LIST 9* Command',
+'PASV:Issue LIST b Command',
+'PASV:Issue LIST a*b Command',
+'PASV:Issue LIST b* Command',
+'PASV:Issue LIST q* Command',
+'PASV:Issue LIST *q Command',
+'PASV:Issue LIST 12* Command',
+);
+my @isarray_port=(
+'PORT:Issue LIST * Command',
+'PORT:Issue LIST *.html Command',
+'PORT:Issue LIST a*b Command',
+'PORT:Issue LIST 3* Command',
+'PORT:Issue LIST *3 Command',
+'PORT:Issue LIST *i* Command',
+'PORT:Issue LIST a*b* Command',
+'PORT:Issue LIST *.* Command',
+'PORT:Issue LIST q Command',
+'PORT:Issue LIST a/* Command',
+'PORT:Issue LIST 2*2* Command',
+'PORT:Issue LIST a* Command',
+'PORT:Issue LIST 9* Command',
+'PORT:Issue LIST b Command',
+'PORT:Issue LIST a*b Command',
+'PORT:Issue LIST b* Command',
+'PORT:Issue LIST q* Command',
+'PORT:Issue LIST *q Command',
+'PORT:Issue LIST 12* Command',
+);
+
+#########################################################################################
+my @commandlist = ("*","*.html","a*b","3*","*3","*i*","a* b*","*.*","q","a/*","2*2*","a*","9*","b","a*b","b*","q*","*q","12*");
+my @expectedlist = (
+["123456","23452345","344","543","980","a","a.html","abcde","acdefb","aoJjugb","b","b.html","bcdef","faqs","list.txt","q","quick"],
+["a.html","b.html"],
+["acdefb","aoJjugb"],
+["344"],
+["543"],
+["list.txt","quick"],
+["a.html","abcde","acdefb"],
+["a.html","b.html","list.txt"],
+["q"],
+["1.txt","2.txt"],
+["23452345"],
+["a.html","abcde","acdefb","aoJjugb"],
+["980"],
+["b"],
+["acdefb","aoJjugb"],
+["b","b.html","bcdef"],
+["q","quick"],
+["q"],
+["123456"],
+);
+my $flag_value = "true";
+my $i = 0;
+my @filelist_one=("true");
+##########################################################################################
+###########################################################################################
+#Using Passive mode of data transfer
+my $ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption =>'E',Debug => 0) or die "Couldn't connect to $host\n";
+
+$ftp->login($username, $password) or die "Login failed\n";
+
+
+if($ftp->cwd("list_dir"))
+{
+}
+else
+{
+ die "Couldn't change to directoty list_dir";
+}
+########################################################
+for ($i = 0; $i < 19; $i += 1)
+{
+ $ftp->pasv();
+ @filelist=$ftp->list($commandlist[$i]);
+ if(@filelist!=0)
+ {
+ my $k = 0;
+ while($filelist[$k] && $expectedlist[$i][$k])
+ {
+ my $fileLine = $filelist[$k];
+ chomp $fileLine;
+ my ($perm,$unkn,$user,$group,$size,$mo,$day,$time,$name)=split(/\s+/,$fileLine);
+ $filelist_one[$k]=$name;
+ print $name;
+ $l++;
+
+ if($filelist_one[$k] eq $expectedlist[$i][$k])
+ {
+ $k++;
+ }
+ else
+ {
+ $flag_value = "false";
+ $k++;
+ }
+
+ }
+ if ($flag_value eq "false")
+ {
+ $actual = "LIST $commandlist[$i] Failed";
+
+ }
+ else
+ {
+ $actual = "LIST $commandlist[$i] Successful";
+ }
+
+ ok t_cmp ($actual,$expected[$i],$isarray_pasv[$i]);
+ }
+ else
+ {
+ die "LIST * Failed \n";
+ }
+
+}
+
+#####################################################
+$ftp->quit() or die "Unable to quit\n";
+##############################################################################################
+##############################################################################################
+#Using Passive mode of data transfer
+#$ftp = Ssl::FTPSSL->new($host,Port =>$port,Encryption => 'E',Debug => 1) or die "Couldn't connect to $host\n";
+#
+#$ftp->login($username, $password) or die "Login failed\n";
+#
+#if($ftp->cwd("list_dir"))
+#{
+#}
+#else
+#{
+# die "Couldn't change to directoty list_dir";
+#}
+#######################################################
+#for ($i = 0; $i < 19; $i += 1)
+#{
+# $ftp->pasv();
+# @filelist=$ftp->list($commandlist[$i]);
+# if(@filelist!=0)
+# {
+# my $k = 0;
+# while($filelist[$k] && $expectedlist[$i][$k])
+# {
+# my $fileLine = $filelist[$k];
+# chomp $fileLine;
+# my ($perm,$unkn,$user,$group,$size,$mo,$day,$time,$name)=split(/\s+/,$fileLine);
+# $filelist_one[$k]=$name;
+# $l++;
+#
+# if($filelist_one[$k] eq $expectedlist[$i][$k])
+# {
+# $k++;
+# }
+# else
+# {
+# $flag_value = "false";
+# $k++;
+# }
+#
+# }
+# if ($flag_value eq "false")
+# {
+# $actual = "LIST $commandlist[$i] Failed";
+#
+# }
+# else
+# {
+# $actual = "LIST $commandlist[$i] Successful";
+# }
+#
+# ok t_cmp ($actual,$expected[$i],$isarray_port[$i]);
+# }
+# else
+# {
+# die "LIST * Failed \n";
+# }
+#
+#}
+#
+#####################################################
+#$ftp->quit() or die "Unable to quit\n";
+##############################################################################################
+
Added: incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/maxloginattempt.t
URL: http://svn.apache.org/viewcvs/incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/maxloginattempt.t?rev=378185&view=auto
==============================================================================
--- incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/maxloginattempt.t (added)
+++ incubator/mod_ftp/trunk/tests/perl-framework/t/ftp/ftp_exp_ssl/maxloginattempt.t Wed Feb 15 22:40:34 2006
@@ -0,0 +1,63 @@
+use Ssl::FTPSSL;
+use Apache::TestRequest;
+use Apache::Test;
+use Apache::TestUtil;
+plan tests => 2, need_module 'mod_ftp' , need_module 'mod_ssl';
+
+Apache::TestRequest::module('ftp_ssl_explicit');
+
+my $hostport = Apache::TestRequest::hostport();
+my ($host,$port)= split(/:/,$hostport);
+
+$username = "common";
+$correct_password = "password";
+
+
+$wrong_password = "wrong_password";
+
+my $r=0;
+
+my @expected =(
+ "MaxLoginAttempts Successful",
+ "MaxLoginAttempts Failed",
+);
+
+my $actual;
+
+my @isarray=(
+ "MaxLoginAttempts 3: Login twice using incorrect logon credentials.Login third time successfully using correct logon credentials.",
+ "MaxLoginAttempts 3: Login thrice using incorrect logon credentials.Attempting to login fourth timeusing correct logon credentials(unsuccessful).",
+);
+
+my $ftp = Ssl::FTPSSL->new($host,Port=>$port,Encryption =>'E', Debug =>0) or die "Couldn't connect to $host\n";
+
+
+if($ftp->login($username, $wrong_password)==0
+ && $ftp->login($username, $wrong_password)==0
+ && $ftp->login($username, $correct_password) ){
+ $actual="MaxLoginAttempts Successful";
+}
+else{
+ $actual="MaxLoginAttempts Failed";
+}
+
+ok t_cmp ( $actual,$expected[$r], $isarray[$r]);
+
+$ftp->quit() or die "Unable to quit\n";
+
+$ftp = Ssl::FTPSSL->new($host,Port=>$port, Encryption =>'E', Debug =>0 ) or die "Couldn't connect to $host\n";
+if($ftp->login($username, $wrong_password)==0
+ && $ftp->login($username, $wrong_password)==0
+ && $ftp->login($username, $wrong_password)==0
+ && $ftp->login($username, $correct_password)==0 ){
+ $actual="MaxLoginAttempts Successful";
+}
+else{
+ $actual= "MaxLoginAttempts Failed";
+}
+
+
+ok t_cmp ( $actual,$expected[$r], $isarray[$r]);
+
+$ftp->quit();
+
|