Skip to content

Commit

Permalink
Add ftpes scheme, and encrypt_mode to ftp/ftps/ftpes
Browse files Browse the repository at this point in the history
  • Loading branch information
SineSwiper committed Feb 9, 2015
1 parent dacae2c commit 041f018
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
2 changes: 2 additions & 0 deletions URI/ftp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use parent qw(URI::_server URI::_userpass);

sub default_port { 21 }

sub encrypt_mode { undef }

sub path { shift->path_query(@_) } # XXX

sub _user { shift->SUPER::user(@_); }
Expand Down
10 changes: 10 additions & 0 deletions URI/ftpes.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package URI::ftpes;

require URI::ftp;
@ISA=qw(URI::ftp);

sub secure { 1 }

sub encrypt_mode { 'explicit' }

1;
2 changes: 2 additions & 0 deletions URI/ftps.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ sub default_port { 990 }

sub secure { 1 }

sub encrypt_mode { 'implicit' }

1;
58 changes: 46 additions & 12 deletions t/ftp.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;

print "1..13\n";
print "1..23\n";

use URI;
my $uri;
Expand All @@ -16,40 +16,74 @@ print "ok 1\n";
print "not " unless $uri->host eq "ftp.example.com";
print "ok 2\n";

print "not " unless $uri->port eq 21;
print "not " unless $uri->port == 21;
print "ok 3\n";

print "not " unless $uri->user eq "anonymous";
print "not " unless $uri->secure == 0;
print "ok 4\n";

print "not " unless $uri->password eq 'anonymous@';
print "not " if $uri->encrypt_mode;
print "ok 5\n";

print "not " unless $uri->user eq "anonymous";
print "ok 6\n";

print "not " unless $uri->password eq 'anonymous@';
print "ok 7\n";

$uri->userinfo("gisle\@aas.no");

print "not " unless $uri eq "ftp://gisle%40aas.no\@ftp.example.com/path";
print "ok 6\n";
print "ok 8\n";

print "not " unless $uri->user eq "gisle\@aas.no";
print "ok 7\n";
print "ok 9\n";

print "not " if defined($uri->password);
print "ok 8\n";
print "ok 10\n";

$uri->password("secret");

print "not " unless $uri eq "ftp://gisle%40aas.no:secret\@ftp.example.com/path";
print "ok 9\n";
print "ok 11\n";

$uri = URI->new("ftp://gisle\@aas.no:secret\@ftp.example.com/path");
print "not " unless $uri eq "ftp://gisle\@aas.no:secret\@ftp.example.com/path";
print "ok 10\n";
print "ok 12\n";

print "not " unless $uri->userinfo eq "gisle\@aas.no:secret";
print "ok 11\n";
print "ok 13\n";

print "not " unless $uri->user eq "gisle\@aas.no";
print "ok 12\n";
print "ok 14\n";

print "not " unless $uri->password eq "secret";
print "ok 13\n";
print "ok 15\n";

$uri = URI->new("ftps://ftp.example.com/path");

print "not " unless $uri->scheme eq "ftps";
print "ok 16\n";

print "not " unless $uri->port == 990;
print "ok 17\n";

print "not " unless $uri->secure == 1;
print "ok 18\n";

print "not " unless $uri->encrypt_mode eq 'implicit';
print "ok 19\n";

$uri = URI->new("ftpes://ftp.example.com/path");

print "not " unless $uri->scheme eq "ftpes";
print "ok 20\n";

print "not " unless $uri->port == 21;
print "ok 21\n";

print "not " unless $uri->secure == 1;
print "ok 22\n";

print "not " unless $uri->encrypt_mode eq 'explicit';
print "ok 23\n";

0 comments on commit 041f018

Please sign in to comment.