summaryrefslogtreecommitdiffstats
path: root/tests/SSLTest.pm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:38:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:38:31 +0000
commit252601302d45036817546c533743e5918b6b86e8 (patch)
treebfad3f5be123f000fdb03e26400050dece33d72f /tests/SSLTest.pm
parentInitial commit. (diff)
downloadwget-252601302d45036817546c533743e5918b6b86e8.tar.xz
wget-252601302d45036817546c533743e5918b6b86e8.zip
Adding upstream version 1.21.3.upstream/1.21.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/SSLTest.pm')
-rw-r--r--tests/SSLTest.pm73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/SSLTest.pm b/tests/SSLTest.pm
new file mode 100644
index 0000000..60f8188
--- /dev/null
+++ b/tests/SSLTest.pm
@@ -0,0 +1,73 @@
+package SSLTest;
+
+use strict;
+use warnings;
+
+use SSLServer;
+use WgetTests;
+use HTTPTest;
+
+our @ISA = qw(WgetTest HTTPTest);
+my $VERSION = 0.01;
+
+my $srcdir;
+if (defined $ENV{srcdir}) {
+ $srcdir = Cwd::abs_path($ENV{srcdir});
+} else {
+ $srcdir = ".";
+}
+
+my %ssl_defaults = (
+ _certfile => "$srcdir/certs/server-cert.pem",
+ _keyfile => "$srcdir/certs/server-key.pem",
+ _cafile => "$srcdir/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$/ && !$attrname =~ m/^\//)
+# {
+# 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