Skip to content

Commit b7a4d5c

Browse files
authored
Merge pull request #2583 from drwetter/minor_polish_unitTests
Minor polish unit tests
2 parents 656726e + e0e7423 commit b7a4d5c

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

t/00_testssl_help.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no erro
2424
my $info = stat($prg);
2525
my $retMode = $info->mode;
2626

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

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

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

58-
printf "\n";
58+
printf "\n\n";
5959
done_testing($tests);
6060

6161

t/05_ca_hashes_up_to_date.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use Test::More;
66
printf "\n%s\n", "Testing whether CA certificates are newer their SPKI hashes \"~/etc/ca_hashes.txt\" ...";
77

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

1111
printf "\n";
1212
done_testing;

t/32_isHTML_valid.t

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ $edited_html =~ s/>/>/g;
4646
$edited_html =~ s/"/"/g;
4747
$edited_html =~ s/'/'/g;
4848

49-
cmp_ok($edited_html, "eq", $out, "HTML file matches terminal output");
50-
$tests++;
51-
5249
$diff = diff \$edited_html, \$out;
53-
printf "\n%s\n", "$diff";
50+
51+
cmp_ok($edited_html, "eq", $out, "Checking if HTML file matches terminal output") or
52+
diag ("\n%s\n", "$diff");
53+
54+
$tests++;
5455

5556

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

82-
cmp_ok($debughtml, "eq", $html, "HTML file created with --debug 4 matches HTML file created without --debug");
83-
$tests++;
84-
8583
$diff = diff \$debughtml, \$html;
86-
printf "\n%s\n", "$diff";
8784

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

8989

90-
printf "\n";
90+
printf "\n\n";
9191
done_testing($tests);
9292

9393

t/51_badssl.com.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pass("Running testssl.sh against badssl.com to create a baseline (may take 2~3 m
1717
my $okout = `./testssl.sh -S -e --freak --logjam --drown --rc4 --sweet32 --breach --winshock --crime --jsonfile tmp.json --color 0 badssl.com`;
1818
my $okjson = json('tmp.json');
1919
unlink 'tmp.json';
20-
cmp_ok(@$okjson,'>',10,"We have more then 10 findings"); $tests++;
20+
cmp_ok(@$okjson,'>',10,"We should have more then 10 findings"); $tests++;
2121

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

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

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

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

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

116116
# TODO: RSA 8192
117117

0 commit comments

Comments
 (0)