Skip to content

Commit 04c98d9

Browse files
authored
Merge pull request #2628 from testssl/diffing_openssls
Add unittest for different openssl versions
2 parents d115b2e + ce89847 commit 04c98d9

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

t/12_diff_opensslversions.t

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env perl
2+
3+
# Baseline diff test against testssl.sh (csv output)
4+
#
5+
# This runs a basic test with the supplied openssl vs /usr/bin/openssl
6+
7+
use strict;
8+
use Test::More;
9+
use Data::Dumper;
10+
use Text::Diff;
11+
12+
my $tests = 0;
13+
my $prg="./testssl.sh";
14+
my $check2run="--protocols --std --server-preference --fs --header --renegotiation --crime --breach --poodle --tls-fallback --sweet32 --beast --lucky13 --freak --logjam --drown --rc4 --phone-out --client-simulation -q --ip=one --color 0 --csvfile";
15+
my $csvfile="tmp.csv";
16+
my $csvfile2="tmp2.csv";
17+
my $cat_csvfile="";
18+
my $cat_csvfile2="";
19+
my $uri="google.com";
20+
my $diff="";
21+
my $distro_openssl="/usr/bin/openssl";
22+
my @args="";
23+
24+
die "Unable to open $prg" unless -f $prg;
25+
die "Unable to open $distro_openssl" unless -f $distro_openssl;
26+
27+
# Provide proper start conditions
28+
unlink "tmp.csv";
29+
unlink "tmp2.csv";
30+
31+
#1 run
32+
printf "\n%s\n", "Diff test IPv4 with supplied openssl against \"$uri\"";
33+
@args="$prg $check2run $csvfile $uri 2>&1";
34+
system("@args") == 0
35+
or die ("FAILED: \"@args\"");
36+
37+
# 2
38+
printf "\n%s\n", "Diff test IPv4 with $distro_openssl against \"$uri\"";
39+
@args="$prg $check2run $csvfile2 --openssl=$distro_openssl $uri 2>&1";
40+
system("@args") == 0
41+
or die ("FAILED: \"@args\" ");
42+
43+
$cat_csvfile = `cat $csvfile`;
44+
$cat_csvfile2 = `cat $csvfile2`;
45+
46+
# Filter for changes that are allowed to occur
47+
$cat_csvfile =~ s/HTTP_clock_skew.*\n//g;
48+
$cat_csvfile2 =~ s/HTTP_clock_skew.*\n//g;
49+
50+
# HTTP time
51+
$cat_csvfile =~ s/HTTP_headerTime.*\n//g;
52+
$cat_csvfile2 =~ s/HTTP_headerTime.*\n//g;
53+
54+
#engine_problem
55+
$cat_csvfile =~ s/"engine_problem.*\n//g;
56+
$cat_csvfile2 =~ s/"engine_problem.*\n//g;
57+
58+
# PR #2628. TL:DR; make the kx between tls_sockets() and openssl the same for this CI run
59+
$cat_csvfile =~ s/ECDH 256/ECDH 253/g;
60+
$cat_csvfile =~ s/ECDH\/MLKEM/ECDH 253 /g;
61+
62+
# Nonce in CSP
63+
$cat_csvfile =~ s/.nonce-.* //g;
64+
$cat_csvfile2 =~ s/.nonce-.* //g;
65+
66+
$diff = diff \$cat_csvfile, \$cat_csvfile2;
67+
68+
# Compare the differences -- and print them if there were any
69+
ok( $cat_csvfile eq $cat_csvfile2, "Check whether CSV outputs match" ) or
70+
diag ("\n%s\n", "$diff");
71+
72+
unlink "tmp.csv";
73+
unlink "tmp2.csv";
74+
75+
$tests++;
76+
done_testing($tests);
77+
printf "\n";
78+
79+
80+
# vim:ts=5:sw=5:expandtab
81+

0 commit comments

Comments
 (0)