From 91f8f33a6cfd24122bbf2d032af2c85c98ef4658 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Mon, 13 Jan 2020 17:36:40 +0100 Subject: [PATCH] add new basic checks, rename ca_hashes_up_to_date --- t/00_testssl_help.t | 41 ++++++++++++++++ t/01_testssl_banner.t | 47 +++++++++++++++++++ ...up_to_date.t => 05_ca_hashes_up_to_date.t} | 0 3 files changed, 88 insertions(+) create mode 100755 t/00_testssl_help.t create mode 100755 t/01_testssl_banner.t rename t/{01_ca_hashes_up_to_date.t => 05_ca_hashes_up_to_date.t} (100%) diff --git a/t/00_testssl_help.t b/t/00_testssl_help.t new file mode 100755 index 00000000..d8dc7852 --- /dev/null +++ b/t/00_testssl_help.t @@ -0,0 +1,41 @@ +#!/usr/bin/env perl + +# Basics: is there a synatx error where alerady bash hiccups on? + +use strict; +use Test::More; + +my $tests = 0; +my $fileout=""; +# Blacklists we use to trigger an error: +my $error_regexp1='(syntax|parse) (e|E)rror'; +my $error_regexp2='testssl.sh: line'; +my $error_regexp3='bash: warning'; +my $error_regexp4='command not found'; +my $error_regexp5='(syntax error|unexpected token)'; + +printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no error ..."; +$fileout = `timeout 10 bash ./testssl.sh 2>&1`; +my $retval=$?; + +unlike($fileout, qr/$error_regexp1/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp2/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp3/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp4/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp5/, ""); +$tests++; + +is($retval, 0, "return value should be equal zero: \"$retval\""); +$tests++; + +done_testing($tests); + + diff --git a/t/01_testssl_banner.t b/t/01_testssl_banner.t new file mode 100755 index 00000000..7a3cceae --- /dev/null +++ b/t/01_testssl_banner.t @@ -0,0 +1,47 @@ +#!/usr/bin/env perl + +# Basics: is there a synatx error where already bash hiccups on? +# --banner is equal to --version + +use strict; +use Test::More; + +my $tests = 0; +my $fileout=""; +# Blacklists we use to trigger an error: +my $error_regexp1='(syntax|parse) (e|E)rror'; +my $error_regexp2='testssl.sh: line'; +my $error_regexp3='bash: warning'; +my $error_regexp4='command not found'; +my $error_regexp5='(syntax error|unexpected token)'; +# my $good_regexp='free software.*USAGE w/o ANY WARRANTY.*OWN RISK.*Using.*ciphers.*built(.*)platform'; +my $good_regexp='free software([\s\S]*)USAGE w/o ANY WARRANTY([\s\S]*)OWN RISK([\s\S]*)Using([\s\S]*)ciphers([\s\S]*)built([\s\S]*)platform'; + +printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no error ..."; +$fileout = `timeout 10 bash ./testssl.sh --banner 2>&1`; +my $retval=$?; + +unlike($fileout, qr/$error_regexp1/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp2/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp3/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp4/, ""); +$tests++; + +unlike($fileout, qr/$error_regexp5/, ""); +$tests++; + +like($fileout, qr/$good_regexp/, ""); +$tests++; + +is($retval, 0, "return value should be equal zero: \"$retval\""); +$tests++; + +done_testing($tests); + + diff --git a/t/01_ca_hashes_up_to_date.t b/t/05_ca_hashes_up_to_date.t similarity index 100% rename from t/01_ca_hashes_up_to_date.t rename to t/05_ca_hashes_up_to_date.t