Skip to content

Commit ece7bce

Browse files
committed
Merge branch '3.3dev' into fix_early_data_empty
2 parents d648a08 + 2b73544 commit ece7bce

14 files changed

Lines changed: 182 additions & 177 deletions

t/00_testssl_help.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ my $out="";
1313

1414
# Try to detect remainders from debugging:
1515
my $debug_regexp='^(\s)*set (-|\+)x';
16-
# Blacklists we use to trigger an error:
16+
# Patterns used to trigger an error:
1717
my $error_regexp1='(syntax|parse) (e|E)rror';
1818
my $error_regexp2='testssl.sh: line';
1919
my $error_regexp3='bash: warning';

t/01_testssl_banner.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Test::More;
88

99
my $tests = 0;
1010
my $fileout="";
11-
# Blacklists we use to trigger an error:
11+
# Patterns used to trigger an error:
1212
my $error_regexp1='(syntax|parse) (e|E)rror';
1313
my $error_regexp2='testssl.sh: line';
1414
my $error_regexp3='bash: warning';

t/02_clientsim_txt_parsable.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Test::More;
88

99
my $tests = 0;
1010
my $fileout="";
11-
# Blacklists we use to trigger an error:
11+
# Patterns used to trigger an error:
1212
my $error_regexp1='(syntax|parse) (e|E)rror';
1313
my $error_regexp2='client-simulation.txt:';
1414

t/10_baseline_ipv4_http.t

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env perl
22

3-
# baseline test for testssl, screen and JSON output
4-
5-
# This is referred by the documentation.
3+
# Baseline test for testssl, screen and JSON output
64

75
# We could also inspect the JSON for any problems for
86
# "id" : "scanProblem"
@@ -15,58 +13,89 @@ use JSON;
1513

1614
my $tests = 0;
1715
my $prg="./testssl.sh";
18-
my $tmp_json="tmp.json";
19-
my $check2run="-p -s -P --fs -S -h -U -q --ip=one --color 0 --jsonfile $tmp_json";
16+
my $json_file="";
17+
my $check2run="-p -s -P --fs -S -h -U -q --ip=one --color 0 --jsonfile";
2018
my $uri="google.com";
21-
my $socket_out="";
22-
my $openssl_out="";
23-
my $socket_json="";
24-
my $openssl_json="";
19+
my $terminal_out="";
20+
my $json_string="";
2521
#FIXME: Pattern we use to trigger an error, but likely we can skip that and instead we should?/could use the following??
2622
# @args="$prg $check2run $uri >/dev/null";
2723
# system("@args") == 0
2824
# or die ("FAILED: \"@args\" ");
2925
my $socket_errors='(e|E)rror|FIXME|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
3026
my $openssl_errors='(e|E)rror|FIXME|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
3127
my $json_errors='(id".*:\s"scanProblem"|severity".*:\s"FATAL"|"Scan interrupted")';
28+
my $os="$^O";
3229

3330
# useful against "failed to flush stdout" messages
3431
STDOUT->autoflush(1);
3532

3633
die "Unable to open $prg" unless -f $prg;
3734

3835
# Provide proper start conditions
39-
unlink $tmp_json;
36+
$json_file="tmp.json";
37+
unlink $json_file;
4038

4139
# Title
4240
printf "\n%s\n", "Baseline unit test IPv4 against \"$uri\"";
43-
$socket_out = `$prg $check2run $uri 2>&1`;
44-
$socket_json = json($tmp_json);
41+
42+
43+
# run the check
44+
$terminal_out = `$prg $check2run $json_file $uri 2>&1`;
45+
$json_string = json($json_file);
46+
4547

4648
#1
47-
unlike($socket_out, qr/$socket_errors/, "via sockets, checking terminal output");
49+
unlike($terminal_out, qr/$socket_errors/, "via sockets, checking terminal output");
4850
$tests++;
4951

5052
#2
51-
unlike($socket_json, qr/$json_errors/, "via sockets checking JSON output");
53+
unlike($json_string, qr/$json_errors/, "via sockets checking JSON output");
5254
$tests++;
5355

54-
unlink $tmp_json;
55-
5656
#3
57-
$openssl_out = `$prg --ssl-native $check2run $uri 2>&1`;
58-
$openssl_json = json($tmp_json);
59-
unlike($openssl_out, qr/$openssl_errors/, "via (builtin) OpenSSL, checking terminal output");
57+
unlink $json_file;
58+
$terminal_out = `$prg --ssl-native $check2run $json_file $uri 2>&1`;
59+
$json_string = json($json_file);
60+
unlike($terminal_out, qr/$openssl_errors/, "via (builtin) OpenSSL, checking terminal output");
6061
$tests++;
6162

6263
#4
63-
unlike($openssl_json, qr/$json_errors/, "via OpenSSL (builtin) checking JSON output");
64+
unlike($json_string, qr/$json_errors/, "via OpenSSL (builtin) checking JSON output");
6465
$tests++;
6566

66-
unlink $tmp_json;
67+
if ( $os eq "linux" ){
68+
#5 -- early data test. We just take the last check
69+
my $found=0;
70+
open my $fh, '<', $json_file or die "Can't open '$json_file': $!";
71+
local $/; # undef slurp mode
72+
my $data = decode_json(<$fh>);
73+
close $fh;
74+
75+
# Check if the decoded data is an array
76+
if (ref $data eq 'ARRAY') {
77+
# Iterate through the array of JSON objects
78+
foreach my $obj (@$data) {
79+
# Check if the 'id' is "early_data" and 'severity' is "HIGH"
80+
if ($obj->{id} eq 'early_data' && $obj->{severity} eq 'HIGH') {
81+
$found=1;
82+
last; # we can leave the loop
83+
}
84+
}
85+
}
86+
87+
if ($found) {
88+
ok(1, "0‑RTT found in JSON from $uri");
89+
} else {
90+
fail("0‑RTT test for $uri failed");
91+
}
92+
$tests++;
93+
} elsif ( $os eq "darwin" ){
94+
printf "%s\n", "Skipping test. The result of the check under MacOS is not understood" ;
95+
}
6796

6897
done_testing($tests);
69-
printf "\n";
98+
printf "\n\n";
7099

71100

72101
sub json($) {
@@ -76,6 +105,5 @@ sub json($) {
76105
return from_json($file);
77106
}
78107

79-
80108
# vim:ts=5:sw=5:expandtab
81109

t/11_baseline_ipv6_http.t.DISABLED

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env perl
22

3-
# disabled as IPv6 wasn't supported by Travis CI and isn't by GH action, see https://github.com/testssl/testssl.sh/issues/1177
3+
# disabled as IPv6 wasn't supported by Travis CI and isn't also supported by GH action, see https://github.com/testssl/testssl.sh/issues/1177
44

55
# Just a functional test, whether there are any problems on the client side
66
# Probably we could also inspect the JSON for any problems for
@@ -10,16 +10,16 @@
1010
use strict;
1111
use Test::More;
1212
use Data::Dumper;
13+
# if JSON it'll be needed to uncommented this and the lines below
1314
# use JSON;
14-
# if we need JSON we need to comment this and the lines below in
1515

1616
my $tests = 0;
1717
my $prg="./testssl.sh";
1818
my $check2run ="-p -s -P --fs -S -h -U -q --ip=one --color 0";
1919
my $uri="";
2020
my $socket_out="";
2121
my $openssl_out="";
22-
# Blacklists we use to trigger an error:
22+
# Patterns used to trigger an error:
2323
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
2424
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
2525

t/12_diff_opensslversions.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ my $diff="";
2121
my $distro_openssl="/usr/bin/openssl";
2222
my @args="";
2323
# that can be done better but I am a perl n00b ;-)
24-
my $os=`perl -e 'print "$^O";'`;
24+
my $os="$^O";
2525

2626
# useful against "failed to flush stdout" messages
2727
STDOUT->autoflush(1);

t/21_baseline_starttls.t

Lines changed: 26 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ my $check2run="-q --ip=one --color 0";
2222
my $uri="";
2323
my $socket_out="";
2424
my $openssl_out="";
25-
# Blacklists we use to trigger an error:
25+
# Patterns used to trigger an error:
2626
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
2727
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
28+
my $openssl_fallback_cmd=""; # empty for Linux
29+
my $os="$^O";
2830

2931
# useful against "failed to flush stdout" messages
3032
STDOUT->autoflush(1);
@@ -36,10 +38,26 @@ STDOUT->autoflush(1);
3638

3739
die "Unable to open $prg" unless -f $prg;
3840

39-
$uri="smtp-relay.gmail.com:587";
41+
if ( $os eq "darwin" ){
42+
# MacOS silicon doesn't have ~/bin/openssl.Darwin.arm64 binary so we use the
43+
# homebrew version which was moved to /opt/homebrew/bin/openssl.NOPE in
44+
# .github/workflows/unit_tests_macos.yml . The LibreSSL version from MacOS
45+
# sometimes have problems to finish the run, thus we use homebrew's version
46+
# as fallback.
47+
# If this will be run outside GH actions, i.e. locally, we provide a fallback to
48+
# /opt/homebrew/bin/openssl or just leave this thing
49+
if ( -x "/opt/homebrew/bin/openssl.NOPE" ) {
50+
$openssl_fallback_cmd="--openssl /opt/homebrew/bin/openssl.NOPE";
51+
}
52+
elsif ( -x "/opt/homebrew/bin/openssl" ) {
53+
$openssl_fallback_cmd="--openssl /opt/homebrew/bin/openssl";
54+
}
55+
}
4056

57+
$check2run_smtp="$check2run_smtp $openssl_fallback_cmd" ;
4158

4259
#1
60+
$uri="smtp-relay.gmail.com:587";
4361
# unlink "tmp.json";
4462
# we will have client simulations later, so we don't need to run everything again:
4563
printf "\n%s\n", "STARTTLS SMTP unit test via sockets --> $uri ...";
@@ -49,60 +67,34 @@ unlike($socket_out, qr/$socket_regex_bl/, "");
4967
$tests++;
5068

5169
#2
52-
# unlink "tmp.json";
53-
printf "\n%s\n", "STARTTLS SMTP unit tests via OpenSSL --> $uri ...";
54-
$openssl_out = `$prg --ssl-native $check2run_smtp -t smtp $uri 2>&1`;
55-
# $openssl_json = json('tmp.json');
56-
unlike($openssl_out, qr/$openssl_regex_bl/, "");
57-
$tests++;
58-
5970
$uri="pop.gmx.net:110";
60-
61-
#3
6271
# unlink "tmp.json";
6372
printf "\n%s\n", "STARTTLS POP3 unit tests via sockets --> $uri ...";
6473
$socket_out = `$prg $check2run -t pop3 $uri 2>&1`;
6574
# $socket_json = json('tmp.json');
6675
unlike($socket_out, qr/$socket_regex_bl/, "");
6776
$tests++;
6877

69-
#4
70-
printf "\n%s\n", "STARTTLS POP3 unit tests via OpenSSL --> $uri ...";
71-
$openssl_out = `$prg --ssl-native $check2run -t pop3 $uri 2>&1`;
72-
# $openssl_json = json('tmp.json');
73-
unlike($openssl_out, qr/$openssl_regex_bl/, "");
74-
$tests++;
75-
78+
#3
7679
$uri="imap.gmx.net:143";
77-
78-
#5
7980
# unlink "tmp.json";
8081
printf "\n%s\n", "STARTTLS IMAP unit tests via sockets --> $uri ...";
8182
$socket_out = `$prg $check2run -t imap $uri 2>&1`;
8283
# $socket_json = json('tmp.json');
8384
unlike($socket_out, qr/$socket_regex_bl/, "");
8485
$tests++;
8586

86-
#6
87-
printf "\n%s\n", "STARTTLS IMAP unit tests via OpenSSL --> $uri ...";
88-
$openssl_out = `$prg --ssl-native $check2run -t imap $uri 2>&1`;
89-
# $openssl_json = json('tmp.json');
90-
unlike($openssl_out, qr/$openssl_regex_bl/, "");
91-
$tests++;
92-
87+
#4
9388
$uri="mail.tigertech.net:4190";
94-
95-
#7
9689
# unlink "tmp.json";
9790
printf "\n%s\n", "STARTTLS MANAGE(SIEVE) unit tests via sockets --> $uri ...";
9891
$socket_out = `$prg $check2run -t sieve $uri 2>&1`;
9992
# $socket_json = json('tmp.json');
10093
unlike($openssl_out, qr/$openssl_regex_bl/, "");
10194
$tests++;
10295

96+
#5
10397
$uri="jabber.org:5222";
104-
105-
#8
10698
# unlink "tmp.json";
10799
printf "\n%s\n", "STARTTLS XMPP unit tests via sockets --> $uri ...";
108100
$socket_out = `$prg $check2run -t xmpp $uri 2>&1`;
@@ -112,23 +104,15 @@ $tests++;
112104

113105
# commented out, bc of travis' limits
114106
#
115-
#printf "\n%s\n", "STARTTLS XMPP unit tests via OpenSSL --> $uri ...";
116-
#$openssl_out = `$prg --ssl-native $check2run -t xmpp $uri 2>&1`;
117-
# $openssl_json = json('tmp.json');
118-
#unlike($openssl_out, qr/$openssl_regex_bl/, "");
119-
#$tests++;
120-
121107
# $uri="jabber.ccc.de:5269";
122108
# printf "\n%s\n", "Quick STARTTLS XMPP S2S unit tests via sockets --> $uri ...";
123109
# $openssl_out = `$prg --openssl=/usr/bin/openssl -p $check2run -t xmpp-server $uri 2>&1`;
124110
# # $openssl_json = json('tmp.json');
125111
# unlike($openssl_out, qr/$openssl_regex_bl/, "");
126112
# $tests++;
127113

128-
114+
#6
129115
$uri="ldap.uni-rostock.de:21";
130-
131-
#9
132116
# unlink "tmp.json";
133117
printf "\n%s\n", "STARTTLS FTP unit tests via sockets --> $uri ...";
134118
$socket_out = `$prg $check2run -t ftp $uri 2>&1`;
@@ -138,50 +122,23 @@ $socket_out =~ s/ error querying OCSP responder .*\n//g;
138122
unlike($socket_out, qr/$socket_regex_bl/, "");
139123
$tests++;
140124

141-
# commented out, bc of travis' limits
142-
#
143-
# printf "\n%s\n", "STARTTLS FTP unit tests via OpenSSL --> $uri ...";
144-
# $openssl_out = `$prg --ssl-native $check2run -t ftp $uri 2>&1`;
145-
# $openssl_json = json('tmp.json');
146-
# OCSP stapling fails sometimes with: 'offered, error querying OCSP responder (ERROR: No Status found)'
147-
# $openssl_out =~ s/ error querying OCSP responder .*\n//g;
148-
# unlike($openssl_out, qr/$openssl_regex_bl/, "");
149-
# $tests++;
150-
151-
125+
#7
152126
# https://ldapwiki.com/wiki/Public%20LDAP%20Servers
153127
$uri="db.debian.org:389";
154-
155-
#10
156128
printf "\n%s\n", "STARTTLS LDAP unit tests via sockets --> $uri ...";
157129
$socket_out = `$prg $check2run -t ldap $uri 2>&1`;
158130
# $socket_json = json('tmp.json');
159131
unlike($socket_out, qr/$socket_regex_bl/, "");
160132
$tests++;
161133

162-
#11
163-
printf "\n%s\n", "STARTTLS LDAP unit tests via OpenSSL --> $uri ...";
164-
$openssl_out = `$prg --ssl-native $check2run -t ldap $uri 2>&1`;
165-
# $openssl_json = json('tmp.json');
166-
unlike($openssl_out, qr/$openssl_regex_bl/, "");
167-
$tests++;
168-
169-
170134
# For NNTP there doesn't seem to be reliable host out there
171135
#$uri="144.76.182.167:119";
172136

173137
#printf "\n%s\n", "STARTTLS NNTP unit tests via sockets --> $uri ...";
174138
#$socket_out = `$prg $check2run -t nntp $uri 2>&1`;
175139
#unlike($socket_out, qr/$socket_regex_bl/, "");
176140
#$tests++;
177-
178-
# commented out, bc of travis' limits
179-
#
180-
#printf "\n%s\n", "STARTTLS NNTP unit tests via OpenSSL --> $uri ...";
181-
#$openssl_out = `$prg --ssl-native $check2run -t nntp $uri 2>&1`;
182-
# $openssl_json = json('tmp.json');
183-
#unlike($openssl_out, qr/$openssl_regex_bl/, "");
184-
#$tests++;
141+
# also: commented out, bc of travis' limits
185142

186143
# IRC: missing
187144
# LTMP, mysql, postgres

0 commit comments

Comments
 (0)