Skip to content

Commit

Permalink
Merge pull request #2583 from drwetter/minor_polish_unitTests
Browse files Browse the repository at this point in the history
Minor polish unit tests
  • Loading branch information
drwetter authored Oct 14, 2024
2 parents 656726e + e0e7423 commit b7a4d5c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions t/00_testssl_help.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no erro
my $info = stat($prg);
my $retMode = $info->mode;

is($retMode & 0400, 0400, "Checking \"./testssl.sh\" for read permission");
is($retMode & 0400, 0400, "Checking \"./testssl.sh\" for read permission");
$tests++;

is($retMode & 0100, 0100, "Checking \"./testssl.sh\" for execute permission");
is($retMode & 0100, 0100, "Checking \"./testssl.sh\" for execute permission");
$tests++;

$fileout = `timeout 10 bash $prg 2>&1`;
Expand Down Expand Up @@ -55,7 +55,7 @@ $out=`grep -E "$debug_regexp" $prg`;
unlike($out, qr/$debug_regexp/, "Debug RegEx");
$tests++;

printf "\n";
printf "\n\n";
done_testing($tests);


Expand Down
2 changes: 1 addition & 1 deletion t/05_ca_hashes_up_to_date.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Test::More;
printf "\n%s\n", "Testing whether CA certificates are newer their SPKI hashes \"~/etc/ca_hashes.txt\" ...";

my $newer_bundles=`find etc/*.pem -newer etc/ca_hashes.txt`;
is($newer_bundles,"","If there's an output with a *.pem file run \"~/utils/create_ca_hashes.sh\"");
is($newer_bundles,"","Checking if there's an output with a *.pem file run \"~/utils/create_ca_hashes.sh\"");

printf "\n";
done_testing;
Expand Down
20 changes: 10 additions & 10 deletions t/32_isHTML_valid.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ $edited_html =~ s/>/>/g;
$edited_html =~ s/"/"/g;
$edited_html =~ s/'/'/g;

cmp_ok($edited_html, "eq", $out, "HTML file matches terminal output");
$tests++;

$diff = diff \$edited_html, \$out;
printf "\n%s\n", "$diff";

cmp_ok($edited_html, "eq", $out, "Checking if HTML file matches terminal output") or
diag ("\n%s\n", "$diff");

$tests++;


#2
printf "\n%s\n", " .. running again $prg against \"$uri\", now with --debug 4 to create HTML output (may take another ~2 minutes)";
printf "%s\n", " .. running again $prg against \"$uri\", now with --debug 4 to create HTML output (may take another ~2 minutes)";
# Redirect stderr to /dev/null in order to avoid some unexplained "date: invalid date" error messages
$out = `TERM_WIDTH=120 $prg $check2run --debug 4 $uri 2> /dev/null`;
$debughtml = `cat $htmlfile`;
Expand All @@ -79,15 +80,14 @@ $debughtml =~ s/.*built: .*\n//g;
$debughtml =~ s/.*Using bash .*\n//g;
# is whole line: s/.*<pattern> .*\n//g;

cmp_ok($debughtml, "eq", $html, "HTML file created with --debug 4 matches HTML file created without --debug");
$tests++;

$diff = diff \$debughtml, \$html;
printf "\n%s\n", "$diff";

cmp_ok($debughtml, "eq", $html, "Checking if HTML file created with --debug 4 matches HTML file created without --debug") or
diag ("\n%s\n", "$diff");
$tests++;


printf "\n";
printf "\n\n";
done_testing($tests);


Expand Down
12 changes: 6 additions & 6 deletions t/51_badssl.com.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pass("Running testssl.sh against badssl.com to create a baseline (may take 2~3 m
my $okout = `./testssl.sh -S -e --freak --logjam --drown --rc4 --sweet32 --breach --winshock --crime --jsonfile tmp.json --color 0 badssl.com`;
my $okjson = json('tmp.json');
unlink 'tmp.json';
cmp_ok(@$okjson,'>',10,"We have more then 10 findings"); $tests++;
cmp_ok(@$okjson,'>',10,"We should have more then 10 findings"); $tests++;

# Expiration
pass("Running testssl against expired.badssl.com"); $tests++;
Expand All @@ -35,7 +35,7 @@ foreach my $f ( @$json ) {
last;
}
}
is($found,1,"We had a finding for this in the JSON output"); $tests++;
is($found,1,"We should have a finding for this in the JSON output"); $tests++;

# Self signed and not-expired
pass("Running testssl against self-signed.badssl.com"); $tests++;
Expand All @@ -52,7 +52,7 @@ foreach my $f ( @$json ) {
last;
}
}
is($found,1,"We had a finding for this in the JSON output"); $tests++;
is($found,1,"We should a finding for this in the JSON output"); $tests++;

like($out, qr/Chain of trust.*?NOT ok.*\(self signed\)/,"Chain of trust should fail because of self signed"); $tests++;
$found = 0;
Expand All @@ -64,7 +64,7 @@ foreach my $f ( @$json ) {
last;
}
}
is($found,1,"We had a finding for this in the JSON output"); $tests++;
is($found,1,"We should have a finding for this in the JSON output"); $tests++;

like($okout, qr/Chain of trust[^\n]*?Ok/,"Chain of trust should be ok"); $tests++;
$found = 0;
Expand All @@ -77,7 +77,7 @@ foreach my $f ( @$okjson ) {
last;
}
}
is($found,1,"We had a finding for this in the JSON output"); $tests++;
is($found,1,"We should have a finding for this in the JSON output"); $tests++;

# Wrong host
#pass("Running testssl against wrong.host.badssl.com"); $tests++;
Expand Down Expand Up @@ -111,7 +111,7 @@ foreach my $f ( @$json ) {
last;
}
}
is($found,1,"We had a finding for this in the JSON output"); $tests++;
is($found,1,"We should have a finding for this in the JSON output"); $tests++;

# TODO: RSA 8192

Expand Down

0 comments on commit b7a4d5c

Please sign in to comment.