1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
# -*- mode: cperl; -*-
use Test::Base;
use Net::SSL::ExpireDate;
if ($ENV{TEST_HTTPS}) {
plan tests => 7 * blocks;
} else {
plan skip_all => 'set TEST_HTTPS=1 if you want to test https access';
}
filters {
expire_date => [qw(eval)],
begin_date => [qw(eval)],
not_after => [qw(eval)],
not_before => [qw(eval)],
is_expired => [qw(eval)],
};
our %NOT_BEFORE = (
year => 2024,
month => 8,
day => 9,
hour => 15,
minute => 5,
second => 44,
time_zone => 'UTC'
);
our %NOT_AFTER = (
year => 2024,
month => 11,
day => 7,
hour => 15,
minute => 5,
second => 43,
time_zone => 'UTC'
);
run {
my $block = shift;
my $ed = Net::SSL::ExpireDate->new(
https => $block->input,
($block->name eq 'SNI' ? (sni => $block->sni ) : ()),
);
my $expire_date = $ed->expire_date;
is $expire_date->iso8601, $block->expire_date->iso8601, 'expire_date';
my $begin_date = $ed->begin_date;
is $begin_date->iso8601, $block->begin_date->iso8601, 'begin_date';
my $not_after = $ed->not_after;
is $not_after->iso8601, $block->not_after->iso8601, 'not_after';
my $not_before = $ed->not_before;
is $not_before->iso8601, $block->not_before->iso8601, 'not_before';
my $is_expired = $ed->is_expired;
is $is_expired, $block->is_expired, 'is_expired';
my $will_expired;
$will_expired = $ed->is_expired('10 years');
is $will_expired, $block->will_expired, 'will_expired string';
$will_expired = $ed->is_expired(DateTime::Duration->new(years=>10));
is $will_expired, $block->will_expired, 'will_expired DateTime::Duration';
}
__END__
=== badssl.com
--- input: badssl.com
--- expire_date
DateTime->new(%main::NOT_AFTER);
--- begin_date
DateTime->new(%main::NOT_BEFORE);
--- not_after
DateTime->new(%main::NOT_AFTER);
--- not_before
DateTime->new(%main::NOT_BEFORE);
--- is_expired: undef
--- will_expired: 1
=== SNI
--- input: blah-blah-blah.badssl.com
--- sni: badssl.com
--- expire_date
DateTime->new(%main::NOT_AFTER);
--- begin_date
DateTime->new(%main::NOT_BEFORE);
--- not_after
DateTime->new(%main::NOT_AFTER);
--- not_before
DateTime->new(%main::NOT_BEFORE);
--- is_expired: undef
--- will_expired: 1
|