2019-05-04 13:51:20 +02:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
2019-05-05 12:53:07 +02:00
|
|
|
# disabled as IPv6 is not supported by Travis, see https://github.com/drwetter/testssl.sh/issues/1177
|
|
|
|
|
2019-05-04 13:51:20 +02:00
|
|
|
# Just a functional test, whether there are any problems on the client side
|
|
|
|
# Probably we could also inspect the JSON for any problems for
|
|
|
|
# "id" : "scanProblem"
|
|
|
|
# "finding" : "Scan interrupted"
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Test::More;
|
|
|
|
use Data::Dumper;
|
|
|
|
# use JSON;
|
2019-05-06 11:14:51 +02:00
|
|
|
# if we need JSON we need to comment this and the lines below in
|
2019-05-04 13:51:20 +02:00
|
|
|
|
|
|
|
my $tests = 0;
|
2019-05-06 11:14:51 +02:00
|
|
|
my $prg="./testssl.sh";
|
2020-04-14 15:53:05 +02:00
|
|
|
my $check2run ="-p -s -P --fs -S -h -U -q --ip=one --color 0";
|
2019-05-04 13:51:20 +02:00
|
|
|
my $uri="";
|
2019-05-06 11:14:51 +02:00
|
|
|
my $socket_out="";
|
|
|
|
my $openssl_out="";
|
|
|
|
# Blacklists we use to trigger an error:
|
2020-11-26 13:41:44 +01:00
|
|
|
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
|
|
|
|
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
|
2019-05-06 11:14:51 +02:00
|
|
|
|
|
|
|
# my $socket_json="";
|
|
|
|
# my $openssl_json="";
|
2019-05-04 13:51:20 +02:00
|
|
|
# $check2run="--jsonfile tmp.json $check2run";
|
|
|
|
|
2019-05-06 11:14:51 +02:00
|
|
|
die "Unable to open $prg" unless -f $prg;
|
2019-05-04 13:51:20 +02:00
|
|
|
|
2019-05-05 12:08:13 +02:00
|
|
|
$uri="testssl.net";
|
2019-05-04 13:51:20 +02:00
|
|
|
|
2019-05-06 11:14:51 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-04 13:51:20 +02:00
|
|
|
printf "\n%s\n", "Baseline unit test IPv6 via sockets --> $uri ...";
|
2019-05-06 11:14:51 +02:00
|
|
|
$socket_out = `./testssl.sh $check2run -6 $uri 2>&1`;
|
|
|
|
# $socket_json = json('tmp.json');
|
|
|
|
unlike($socket_out, qr/$socket_regex_bl/, "");
|
2019-05-04 13:51:20 +02:00
|
|
|
$tests++;
|
|
|
|
|
2019-05-06 11:14:51 +02:00
|
|
|
# unlink "tmp.json";
|
2019-05-04 13:51:20 +02:00
|
|
|
printf "\n%s\n", "Baseline unit test IPv6 via OpenSSL --> $uri ...";
|
2019-05-06 11:14:51 +02:00
|
|
|
$openssl_out = `./testssl.sh --ssl-native $check2run -6 $uri 2>&1`;
|
|
|
|
# $openssl_json = json('tmp.json');
|
|
|
|
# With Google only we encounter an error as they return a 0 char with openssl, so we white list this pattern here:
|
|
|
|
$openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g;
|
|
|
|
unlike($openssl_out, qr/$openssl_regex_bl/, "");
|
2019-05-04 13:51:20 +02:00
|
|
|
$tests++;
|
|
|
|
|
2019-05-06 11:14:51 +02:00
|
|
|
|
2019-05-04 13:51:20 +02:00
|
|
|
done_testing($tests);
|
|
|
|
unlink "tmp.json";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub json($) {
|
|
|
|
my $file = shift;
|
|
|
|
$file = `cat $file`;
|
|
|
|
unlink $file;
|
|
|
|
return from_json($file);
|
|
|
|
}
|