From 33ece6858d75a5f6c234add9f225b512d5107676 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Mon, 6 May 2019 14:07:08 +0200 Subject: [PATCH] In line with the new scheme now --- t/25_baseline_starttls.t | 117 +++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/t/25_baseline_starttls.t b/t/25_baseline_starttls.t index 90ccda9..10930c5 100755 --- a/t/25_baseline_starttls.t +++ b/t/25_baseline_starttls.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl # Just a functional test, whether there are any problems on the client side -# Probably we could also inspect the JSON for any problems for +# Probably we could also inspect the JSON for any problems for # "id" : "scanProblem" # "finding" : "Scan interrupted" @@ -12,102 +12,111 @@ use strict; use Test::More; use Data::Dumper; -use JSON; +# use JSON; +# if we need JSON we need to comment this and the lines below in my $tests = 0; +my $prg="./testssl.sh"; my $check2run_smtp="--protocols --standard --pfs --server-preference --headers --vulnerable --each-cipher -q --ip=one --color 0"; my $check2run="-q --ip=one --color 0"; my $uri=""; -my $socketout=""; -my $opensslout=""; +my $socket_out=""; +my $openssl_out=""; +# Blacklists we use to trigger an error: +my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal'; +my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem'; +# my $socket_json=""; +# my $openssl_json=""; # $check2run_smtp="--jsonfile tmp.json $check2run_smtp"; # $check2run="--jsonfile tmp.json $check2run"; +die "Unable to open $prg" unless -f $prg; + $uri="smtp-relay.gmail.com:587"; # we will have client simulations later, so we don't need to run everything again: -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS SMTP unit test via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run_smtp -t smtp $uri`; -# my $socket = json('tmp.json'); -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out = `./testssl.sh $check2run_smtp -t smtp $uri 2>&1`; +# $socket_json = json('tmp.json'); +unlike($socket_out, qr/$socket_regex_bl/, ""); $tests++; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS SMTP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run_smtp -t smtp $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run_smtp -t smtp $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; $uri="pop.gmx.net:110"; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS POP3 unit tests via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run -t pop3 $uri`; -# my $socket = json('tmp.json'); -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out = `./testssl.sh $check2run -t pop3 $uri 2>&1`; +# $socket_json = json('tmp.json'); +unlike($socket_out, qr/$socket_regex_bl/, ""); $tests++; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS POP3 unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t pop3 $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run -t pop3 $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; $uri="imap.gmx.net:143"; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS IMAP unit tests via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run -t imap $uri`; -# my $socket = json('tmp.json'); -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out = `./testssl.sh $check2run -t imap $uri 2>&1`; +# $socket_json = json('tmp.json'); +unlike($socket_out, qr/$socket_regex_bl/, ""); $tests++; printf "\n%s\n", "STARTTLS IMAP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t imap $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run -t imap $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; $uri="jabber.org:5222"; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS XMPP unit tests via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run -t xmpp $uri`; -# my $socket = json('tmp.json'); -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out = `./testssl.sh $check2run -t xmpp $uri 2>&1`; +# $socket_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; printf "\n%s\n", "STARTTLS XMPP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t xmpp $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run -t xmpp $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; $uri="ldap.uni-rostock.de:21"; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS FTP unit tests via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run -t ftp $uri`; -# my $socket = json('tmp.json'); +$socket_out = `./testssl.sh $check2run -t ftp $uri 2>&1`; +# $socket_json = json('tmp.json'); # OCSP stapling fails sometimes with: 'offered, error querying OCSP responder (ERROR: No Status found)' -$socketout =~ s/ error querying OCSP responder .*\n//g; -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out =~ s/ error querying OCSP responder .*\n//g; +unlike($socket_out, qr/$socket_regex_bl/, ""); $tests++; printf "\n%s\n", "STARTTLS FTP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t ftp $uri`; -# my $openssl = json('tmp.json'); +$openssl_out = `./testssl.sh --ssl-native $check2run -t ftp $uri 2>&1`; +# $openssl_json = json('tmp.json'); # OCSP stapling fails sometimes with: 'offered, error querying OCSP responder (ERROR: No Status found)' -$opensslout =~ s/ error querying OCSP responder .*\n//g; -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out =~ s/ error querying OCSP responder .*\n//g; +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; @@ -115,25 +124,25 @@ $tests++; $uri="ldap.telesec.de:389"; printf "\n%s\n", "STARTTLS LDAP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t ldap $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run -t ldap $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; $uri="news.newsguy.com:119"; -unlink "tmp.json"; +# unlink "tmp.json"; printf "\n%s\n", "STARTTLS NNTP unit tests via sockets --> $uri ..."; -$socketout = `./testssl.sh $check2run -t nntp $uri`; -# my $socket = json('tmp.json'); -unlike($socketout, qr/(e|E)rror|(f|F)atal/, ""); +$socket_out = `./testssl.sh $check2run -t nntp $uri 2>&1`; +# $socket_json = json('tmp.json'); +unlike($socket_out, qr/$socket_regex_bl/, ""); $tests++; printf "\n%s\n", "STARTTLS NNTP unit tests via OpenSSL --> $uri ..."; -$opensslout = `./testssl.sh --ssl-native $check2run -t nntp $uri`; -# my $openssl = json('tmp.json'); -unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, ""); +$openssl_out = `./testssl.sh --ssl-native $check2run -t nntp $uri 2>&1`; +# $openssl_json = json('tmp.json'); +unlike($openssl_out, qr/$openssl_regex_bl/, ""); $tests++; @@ -143,7 +152,7 @@ $tests++; done_testing($tests); -unlink "tmp.json"; +# unlink "tmp.json"; sub json($) { my $file = shift;