Skip to content

Commit

Permalink
Split up secure protocol tests to their own unit test file
Browse files Browse the repository at this point in the history
  • Loading branch information
SineSwiper authored and oalders committed Oct 8, 2024
1 parent 1a3808e commit 72aa5e1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 40 deletions.
33 changes: 1 addition & 32 deletions t/ftp.t
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
use strict;
use warnings;

use Test::More tests => 23;
use Test::More tests => 15;

use URI ();
my $uri;

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

is($uri->scheme, "ftp");

is($uri->host, "ftp.example.com");

is($uri->port, 21);

is($uri->secure, 0);

is($uri->encrypt_mode, undef);

is($uri->user, "anonymous");

is($uri->password, 'anonymous@');

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

is($uri, "ftp://gisle%40aas.no\@ftp.example.com/path");

is($uri->user, "gisle\@aas.no");

is($uri->password, undef);

$uri->password("secret");
Expand All @@ -37,29 +29,6 @@ is($uri, "ftp://gisle%40aas.no:secret\@ftp.example.com/path");
$uri = URI->new("ftp://gisle\@aas.no:secret\@ftp.example.com/path");

is($uri, "ftp://gisle\@aas.no:secret\@ftp.example.com/path");

is($uri->userinfo, "gisle\@aas.no:secret");

is($uri->user, "gisle\@aas.no");

is($uri->password, "secret");

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

is($uri->scheme, "ftps");

is($uri->port, 990);

is($uri->secure, 1);

is($uri->encrypt_mode, 'implicit');

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

is($uri->scheme, "ftpes");

is($uri->port, 21);

is($uri->secure, 1);

is($uri->encrypt_mode, 'explicit');
14 changes: 14 additions & 0 deletions t/ftpes.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use strict;
use warnings;

use Test::More tests => 4;

use URI ();
my $uri;

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

is($uri->scheme, 'ftpes');
is($uri->port, 21);
is($uri->secure, 1);
is($uri->encrypt_mode, 'explicit');
14 changes: 14 additions & 0 deletions t/ftps.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use strict;
use warnings;

use Test::More tests => 4;

use URI ();
my $uri;

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

is($uri->scheme, 'ftps');
is($uri->port, 990);
is($uri->secure, 1);
is($uri->encrypt_mode, 'implicit');
11 changes: 3 additions & 8 deletions t/irc.t
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
use strict;
use warnings;

use Test::More tests => 12;
use Test::More tests => 10;

use URI ();
my $uri;

$uri = URI->new("irc://PerlUser\@irc.perl.org:6669/#libwww-perl,ischannel,isnetwork?key=bazqux");

is($uri, "irc://PerlUser\@irc.perl.org:6669/#libwww-perl,ischannel,isnetwork?key=bazqux");

is($uri->port, 6669);

# add a password
$uri->password('foobar');

is($uri->userinfo, "PerlUser:foobar");

my @opts = $uri->options;
is_deeply(\@opts, [qw< key bazqux >]);

$uri->options(foo => "bar", bar => "baz");
is($uri->query, "foo=bar&bar=baz");

is($uri->query, "foo=bar&bar=baz");
is($uri->host, "irc.perl.org");

is($uri->path, "/#libwww-perl,ischannel,isnetwork");

# add a bunch of flags to clean up
Expand All @@ -37,7 +36,3 @@ is($uri->secure, 0);

$uri->port(undef);
is($uri->port, 6667);

$uri->scheme("ircs");
is($uri->port, 994);
is($uri->secure, 1);
14 changes: 14 additions & 0 deletions t/ircs.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use strict;
use warnings;

use Test::More tests => 4;

use URI ();
my $uri;

$uri = URI->new("ircs://PerlUser\@irc.perl.org");

is($uri, "ircs://PerlUser\@irc.perl.org");
is($uri->scheme, 'ircs');
is($uri->port, 994);
is($uri->secure, 1);

0 comments on commit 72aa5e1

Please sign in to comment.