Unit test for baseline sanity check of the ClientHello

This commit is contained in:
Dirk Wetter 2020-03-08 16:41:41 +01:00
parent 8dbaab3656
commit 16be686adc

34
t/03_socketsend_OK.t Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env perl
use strict;
use Test::More;
my $tests = 0;
my $prg="./testssl.sh";
my $check2run ="--ip=one --debug=1 -q --color 0";
my $uri="dev.testssl.sh";
my $out="";
# Blacklists we use to trigger an error:
my $socket_regex_error1='length of byte .* called from .* is not ok';
my $socket_regex_error2='char .* called from .* doesn\'t start with a ';
my $socket_regex_error3='char .* called from .* doesn\'t have an x in second position';
my $socket_regex_error4='byte .* called from .* is not hex';
die "Unable to open $prg" unless -f $prg;
printf "\n%s\n", "Unit test to verify socket byte stream is properly formatted --> $uri ...";
$out = `$prg $check2run $uri 2>&1`;
unlike($out, qr/$socket_regex_error1/, "check: \"$socket_regex_error1\"");
$tests++;
unlike($out, qr/$socket_regex_error2/, "check: \"$socket_regex_error2\"");
$tests++;
unlike($out, qr/$socket_regex_error3/, "check: \"$socket_regex_error3\"");
$tests++;
unlike($out, qr/$socket_regex_error4/, "check: \"$socket_regex_error4\"");
$tests++;
printf "\n";
done_testing($tests);