Skip to content

Commit 042b0c1

Browse files
committed
Naming checks, exempt two checks for MacOS
1 parent ac49e2e commit 042b0c1

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

t/31_isJSON_valid.t

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ my $check2run ="--ip=one --ids-friendly -q --color 0";
1313
my $uri="";
1414
my $json="";
1515
my $out="";
16+
my $cmd_timeout="--openssl-timeout=10";
1617
# Blacklists we use to trigger an error:
1718
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
1819
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
20+
# that can be done better but I am a perl n00b ;-)
21+
my $os=`perl -e 'print "$^O";'`;
1922

2023
die "Unable to open $prg" unless -f $prg;
2124

@@ -33,6 +36,7 @@ my @errors=eval { decode_json($json) };
3336
is(@errors,0,"no errors");
3437
$tests++;
3538

39+
3640
#2
3741
printf "%s\n", ".. pretty JSON --> $uri ";
3842
$out = `./testssl.sh $check2run --jsonfile-pretty tmp.json $uri`;
@@ -44,27 +48,6 @@ $tests++;
4448

4549

4650
#3
47-
# This testssl.sh run deliberately does NOT work as travis-ci.org blocks port 25 egress.
48-
# but the output should be fine. The idea is to have a unit test for a failed connection.
49-
printf "%s\n", ".. plain JSON for a failed run: '--mx $uri' ...";
50-
$out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile tmp.json --mx $uri`;
51-
$json = json('tmp.json');
52-
unlink 'tmp.json';
53-
@errors=eval { decode_json($json) };
54-
is(@errors,0,"no errors");
55-
$tests++;
56-
57-
#4
58-
# Same as above but with pretty JSON
59-
printf "%s\n", ".. pretty JSON for a failed run '--mx $uri' ...";
60-
$out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile-pretty tmp.json --mx $uri`;
61-
$json = json('tmp.json');
62-
unlink 'tmp.json';
63-
@errors=eval { decode_json($json) };
64-
is(@errors,0,"no errors");
65-
$tests++;
66-
67-
#5
6851
my $uri = "smtp-relay.gmail.com:587";
6952
printf "%s\n", " .. plain JSON and STARTTLS --> $uri ...";
7053
$out = `./testssl.sh --jsonfile tmp.json $check2run -t smtp $uri`;
@@ -74,6 +57,35 @@ unlink 'tmp.json';
7457
is(@errors,0,"no errors");
7558
$tests++;
7659

60+
if ( $os eq "linux" ){
61+
# macos doesn't have a timout command, unless we install coreutils (gnu coreutils)
62+
# so we just silently skip this
63+
64+
#4
65+
# This testssl.sh run deliberately does NOT work as github actions block port 25 egress.
66+
# but the output should be fine. The idea is to have a unit test for a failed connection.
67+
printf "%s\n", ".. plain JSON for a failed run: '--mx $uri' ...";
68+
$out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile tmp.json --mx $uri`;
69+
$json = json('tmp.json');
70+
unlink 'tmp.json';
71+
@errors=eval { decode_json($json) };
72+
is(@errors,0,"no errors");
73+
$tests++;
74+
75+
#5
76+
# Same as above but with pretty JSON
77+
printf "%s\n", ".. pretty JSON for a failed run '--mx $uri' ...";
78+
$out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile-pretty tmp.json --mx $uri`;
79+
$json = json('tmp.json');
80+
unlink 'tmp.json';
81+
@errors=eval { decode_json($json) };
82+
is(@errors,0,"no errors");
83+
$tests++;
84+
85+
} elif ( $os eq "darwin" ){
86+
printf "skipped two checks on MacOS\n\n";
87+
}
88+
7789
printf "\n";
7890
done_testing($tests);
7991

0 commit comments

Comments
 (0)