wget/tests/SSLTest.pm
Vijo Cherian 2a96249469 Added new tests for SSL
* tests/Test-https-badcerts.px : New file
* tests/Test-https-clientcert.px : New file
* tests/Test-https-crl.px : New file
* tests/Test-https-weboftrust.px : New file
* tests/certs/interca.conf : New file
* tests/certs/rootca.conf : New file
* tests/certs/test-ca-key.pem : New file

Added all new SSL / HTTPS tests to make check
Added Test for SSL Web of Trust, accept only if CA chain of trust is intact.
Added a test script for client certificate
Added Test for crlfile option of wget
Added test to make sure that wget doesn't accept expired or invalid certs

Some clean up : 1, Removed cause of warnings from perl & other cosmetic changes
                2, Fix  make -j 4 check such that it passes all tests
2017-05-04 16:51:49 +02:00

67 lines
1.4 KiB
Perl

package SSLTest;
use strict;
use warnings;
use SSLServer;
use WgetTests;
use HTTPTest;
our @ISA = qw(WgetTest HTTPTest);
my $VERSION = 0.01;
my %ssl_defaults = (
_certfile => "certs/server.crt",
_keyfile => "certs/server.key",
_cafile => "certs/test-ca-cert.pem",
_ciphers => 'ALL',
_lhostname => 'wgettestingserver',
_sslport => 55443,
);
{
my %_attr_data = %ssl_defaults;
sub _default_for
{
my ($self, $attr) = @_;
return $_attr_data{$attr} if exists $_attr_data{$attr};
return $self->SUPER::_default_for($attr);
}
sub _standard_keys
{
my ($self) = @_;
($self->SUPER::_standard_keys(), keys %_attr_data);
}
}
sub _setup_server
{
my $self = shift;
my %ssl_config = %ssl_defaults;
$self->{_server} = SSLServer->new()
or die "Cannot create SSL server!!!";
for my $attrname ($self->_standard_keys())
{
my ($argname) = ($attrname =~ m/^_(.*)/msx);
$ssl_config{$argname} = $self->{$attrname};
}
for my $attrname (keys %ssl_config)
{
if ($attrname =~ m/file$/)
{
my $cwd = $self->SUPER::_default_for('_workdir');
my $cfile = $ssl_config{$attrname};
$ssl_config{$attrname} = "$cwd/$cfile";
}
}
$self->{_server}->init(%ssl_config);
}
1;
# vim: et ts=4 sw=4