Skip to content

Commit e068c52

Browse files
authored
Merge pull request #2639 from testssl/fix_ci_runs
Fix ci runs
2 parents 04c98d9 + d93549e commit e068c52

4 files changed

Lines changed: 36 additions & 29 deletions

File tree

t/10_baseline_ipv4_http.t

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,51 @@ use JSON;
1515

1616
my $tests = 0;
1717
my $prg="./testssl.sh";
18-
my $check2run="-p -s -P --fs -S -h -U -q --ip=one --color 0";
18+
my $tmp_json="tmp.json";
19+
my $check2run="-p -s -P --fs -S -h -U -q --ip=one --color 0 --jsonfile $tmp_json";
1920
my $uri="google.com";
2021
my $socket_out="";
2122
my $openssl_out="";
22-
# Blacklists we use to trigger an error:
23-
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
24-
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
25-
my $json_regex_bl='(id".*:\s"scanProblem"|severity".*:\s"FATAL"|"Scan interrupted")';
26-
2723
my $socket_json="";
2824
my $openssl_json="";
29-
$check2run="--jsonfile tmp.json $check2run";
25+
#FIXME: Blacklists we use to trigger an error, but likely we can skip that and instead we should?/could use
26+
# @args="$prg $check2run $uri >/dev/null";
27+
# system("@args") == 0
28+
# or die ("FAILED: \"@args\" ");
29+
my $socket_errors='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
30+
my $openssl_errors='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
31+
my $json_errors='(id".*:\s"scanProblem"|severity".*:\s"FATAL"|"Scan interrupted")';
32+
3033

3134
die "Unable to open $prg" unless -f $prg;
3235

3336
# Provide proper start conditions
34-
unlink "tmp.json";
37+
unlink $tmp_json;
3538

3639
# Title
3740
printf "\n%s\n", "Baseline unit test IPv4 against \"$uri\"";
3841

3942
#1
4043
$socket_out = `$prg $check2run $uri 2>&1`;
41-
$socket_json = json('tmp.json');
42-
unlink "tmp.json";
43-
unlike($socket_out, qr/$socket_regex_bl/, "via sockets, terminal output");
44+
$socket_json = json($tmp_json);
45+
unlike($socket_out, qr/$socket_errors/, "via sockets, checking terminal output");
4446
$tests++;
45-
unlike($socket_json, qr/$json_regex_bl/, "via sockets JSON output");
47+
unlike($socket_json, qr/$json_errors/, "via sockets checking JSON output");
4648
$tests++;
4749

50+
unlink $tmp_json;
51+
52+
4853
#2
4954
$openssl_out = `$prg --ssl-native $check2run $uri 2>&1`;
50-
$openssl_json = json('tmp.json');
51-
unlink "tmp.json";
52-
# With Google only we sometimes encounter an error as they return a 0 char with openssl, so we white list this pattern here:
53-
# It should be fixed in the code though so we comment this out
54-
# $openssl_out =~ s/testssl.*warning: command substitution: ignored null byte in input\n//g;
55-
unlike($openssl_out, qr/$openssl_regex_bl/, "via OpenSSL");
55+
$openssl_json = json($tmp_json);
56+
unlike($openssl_out, qr/$openssl_errors/, "via (builtin) OpenSSL, checking terminal output");
5657
$tests++;
57-
unlike($openssl_json, qr/$json_regex_bl/, "via OpenSSL JSON output");
58+
unlike($openssl_json, qr/$json_errors/, "via OpenSSL (builtin) checking JSON output");
5859
$tests++;
5960

61+
unlink $tmp_json;
62+
6063
done_testing($tests);
6164
printf "\n";
6265

@@ -69,5 +72,5 @@ sub json($) {
6972
}
7073

7174

72-
# vim:ts=5:sw=5:expandtab
75+
# vim:ts=5:sw=5:expandtab
7376

t/12_diff_opensslversions.t

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ die "Unable to open $prg" unless -f $prg;
2525
die "Unable to open $distro_openssl" unless -f $distro_openssl;
2626

2727
# Provide proper start conditions
28-
unlink "tmp.csv";
29-
unlink "tmp2.csv";
28+
unlink $csvfile;
29+
unlink $csvfile2;
3030

3131
#1 run
3232
printf "\n%s\n", "Diff test IPv4 with supplied openssl against \"$uri\"";
33-
@args="$prg $check2run $csvfile $uri 2>&1";
33+
@args="$prg $check2run $csvfile $uri >/dev/null";
3434
system("@args") == 0
3535
or die ("FAILED: \"@args\"");
3636

3737
# 2
3838
printf "\n%s\n", "Diff test IPv4 with $distro_openssl against \"$uri\"";
39-
@args="$prg $check2run $csvfile2 --openssl=$distro_openssl $uri 2>&1";
39+
@args="$prg $check2run $csvfile2 --openssl=$distro_openssl $uri >/dev/null";
4040
system("@args") == 0
4141
or die ("FAILED: \"@args\" ");
4242

@@ -63,6 +63,10 @@ $cat_csvfile =~ s/ECDH\/MLKEM/ECDH 253 /g;
6363
$cat_csvfile =~ s/.nonce-.* //g;
6464
$cat_csvfile2 =~ s/.nonce-.* //g;
6565

66+
# Fix IP addresses. Needed when we don't hit the same IP address. We just remove them
67+
$cat_csvfile =~ s/","google.com\/.*","443/","google.com","443/g;
68+
$cat_csvfile2 =~ s/","google.com\/.*","443/","google.com","443/g;
69+
6670
$diff = diff \$cat_csvfile, \$cat_csvfile2;
6771

6872
# Compare the differences -- and print them if there were any

t/61_diff_testsslsh.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ my $cat_csv="tmp.csv";
2020
my $check2run="-p -s -P --fs -h -U -c -q --ip=one --color 0 --csvfile $cat_csv";
2121
my $uri="testssl.sh";
2222
my $diff="";
23+
my @args="";
2324

2425
die "Unable to open $prg" unless -f $prg;
2526
die "Unable to open $baseline_csv" unless -f $baseline_csv;
2627

2728
# Provide proper start conditions
2829
unlink $cat_csv;
2930

30-
my @args=("$prg", "$check2run", "$uri", "2>&1");
3131

3232
#1 run
3333
printf "\n%s\n", "Diff unit test (IPv4) against \"$uri\"";
34-
printf "@args\n";
34+
@args="$prg $check2run $uri >/dev/null";
3535
system("@args") == 0
3636
or die ("FAILED: \"@args\" ");
3737

t/Readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* 30-39: Does reporting work?
66
* 50-69: Are the results what I expect (server side)?
77

8-
Please help to write Travis/CI tests! Documentation can be found [here](https://perldoc.perl.org/Test/More.html).
9-
You can consult the existing code here. Feel free to use `10_baseline_ipv4_http.t` or `23_client_simulation.t` as a
10-
template.
8+
Please help to write CI tests! Documentation can be found [here](https://perldoc.perl.org/Test/More.html).
9+
You can consult the existing code here. Feel free to use `10_baseline_ipv4_http.t` or `12_diff_opensslversions.t` as a
10+
template. The latter is newer and code is cleaner.

0 commit comments

Comments
 (0)